GFX task for the FreeRTOS Web/DSP Demo.
Copyright (c) 2013-2018 Microchip Technology Inc. and its subsidiaries.
#include "task_demo.h"
#include "arm_math.h"
#include "logo_atmel.h"
#include <FreeRTOS.h>
#include <StackMacros.h>
#include <croutine.h>
#include <list.h>
#include <mpu_wrappers.h>
#include <portable.h>
#include <projdefs.h>
#include <queue.h>
#include <semphr.h>
#include <task.h>
#include <timers.h>
#include <pmc.h>
#include <sysclk.h>
#include "ili93xx.h"
#include "ili9325_regs.h"
#include "ili9341_regs.h"
#include "aat31xx.h"
#include "pio_handler.h"
#include "smc.h"
#include "ethernet_sam.h"
#include "timer_mgt_sam.h"
#include "rtouch.h"
Data Structures | |
struct | bmpfile_header |
BMP (Windows) Header Format. More... | |
Macros | |
#define | BUTTON_DETECT_Y 160 |
The Y value to determine which button is pressed. More... | |
#define | COLOR_CUSTOM_GREY 0xE4E4E4u |
#define | ILI93XX_LCD_CS 1 |
Chip select number to be set. More... | |
#define | IRQ_PRIOR_PIO 9 |
IRQ priority for PIO (The lower the value, the greater the priority) More... | |
Functions | |
void | create_gfx_task (uint16_t stack_depth_words, unsigned portBASE_TYPE task_priority) |
Create the GFX task. More... | |
static void | event_handler (rtouch_event_t const *event) |
Callback called when the pen is pressed on the touchscreen. More... | |
static void | gfx_draw_bmpfile (const uint8_t *bmpImage) |
Draw a bitmap image. More... | |
static void | gfx_init (void) |
Initialize the LCD. More... | |
static void | gfx_refresh_mag (void) |
Refresh magnitude rendering on the LCD. More... | |
static void | gfx_refresh_wav (void) |
Refresh wave rendering on the LCD. More... | |
static void | gfx_task (void *pvParameters) |
GFX task core function. More... | |
Variables | |
uint32_t | app_hold = 1 |
Hold the instructions screen and prevent other task from running. More... | |
static uint32_t | button1_filter_cnt = 0 |
static uint32_t | button2_filter_cnt = 0 |
int8_t | g_c_ipconfig [25] |
uint32_t | g_ip_mode = 0 |
IP mode: 0 unselected, 1 static, 2 dhcp. More... | |
xSemaphoreHandle | gfx_notification_semaphore |
GFX notification semaphore. More... | |
const portTickType | instructions_delay = 50UL / portTICK_RATE_MS |
Small delay to hold tasks, during instruction screen. More... | |
float32_t | mag_in_buffer [] |
Magnitude input buffer defined in DSP task. More... | |
uint32_t | mag_in_buffer_int [] |
Magnitude buffer converted in float. More... | |
static const portTickType | max_block_time_ticks = 1UL / portTICK_RATE_MS |
static const portTickType | presentation_delay = 2000UL / portTICK_RATE_MS |
static const portTickType | touch_delay = 10UL / portTICK_RATE_MS |
static uint32_t | touch_sel = 0 |
float32_t | wav_in_buffer [] |
Wave input buffer defined in DSP task. More... | |
#define BUTTON_DETECT_Y 160 |
The Y value to determine which button is pressed.
Referenced by event_handler().
#define COLOR_CUSTOM_GREY 0xE4E4E4u |
Referenced by event_handler(), and gfx_task().
#define ILI93XX_LCD_CS 1 |
Chip select number to be set.
#define IRQ_PRIOR_PIO 9 |
IRQ priority for PIO (The lower the value, the greater the priority)
Referenced by gfx_task().
void create_gfx_task | ( | uint16_t | stack_depth_words, |
unsigned portBASE_TYPE | task_priority | ||
) |
Create the GFX task.
stack_depth_words | Task stack size in 32 bits word. |
task_priority | Task priority. |
Initialize display.
Create the task as described above.
Referenced by main().
|
static |
Callback called when the pen is pressed on the touchscreen.
x | horizontal position (in pixel if ts calibrated). |
y | vertical position (in pixel if ts calibrated). |
If released, freeze buttons and perform IP settings.
References BUTTON_DETECT_Y, COLOR_BLACK, COLOR_CUSTOM_GREY, COLOR_GRAY, COLOR_LIGHTGREY, g_ip_mode, ili93xx_draw_filled_rectangle(), ili93xx_draw_rectangle(), ili93xx_draw_string(), ili93xx_set_foreground_color(), RTOUCH_MOVE, RTOUCH_PRESS, and RTOUCH_RELEASE.
Referenced by gfx_task().
|
static |
Draw a bitmap image.
Expected file format is 320x240, 24 bits, RGB888.
bmpImage | Pointer to the bmp file image. |
References DEVICE_TYPE_ILI9325, DEVICE_TYPE_ILI9341, bmpfile_header::height, ILI9325_GRAM_DATA_REG, ILI9341_CMD_MEMORY_WRITE, ILI9341_CMD_WRITE_MEMORY_CONTINUE, ili93xx_device_type(), ili93xx_set_cursor_position(), ili93xx_set_window(), offset, and bmpfile_header::width.
Referenced by gfx_task().
|
static |
Initialize the LCD.
Enable peripheral clock
Configure SMC interface for Lcd
Initialize display parameter
Initialize LCD
Referenced by create_gfx_task().
|
static |
Refresh magnitude rendering on the LCD.
Clear previous magnitude drawing.
Refresh FFT MAG display.
Limit to 99, even if we got 128 magnitudes to display. Bins are printed using col, incremented by mean of 2 to keep a clean rendering. Hence we cannot render all the magnitudes, because of the screen width. It would require a 128*2 space.
References COLOR_RED, COLOR_WHITE, ili93xx_draw_filled_rectangle(), ili93xx_draw_line(), ili93xx_set_foreground_color(), and mag_in_buffer_int.
Referenced by gfx_task().
|
static |
Refresh wave rendering on the LCD.
Clear previous wave drawing.
Draw wave with available data.
Limit to 398, ie. ~200 to fit the rendering frame.
References COLOR_BLACK, COLOR_BLUE, COLOR_WHITE, ili93xx_draw_filled_rectangle(), ili93xx_draw_line(), ili93xx_draw_pixel(), ili93xx_set_foreground_color(), and wav_in_buffer.
Referenced by gfx_task().
|
static |
GFX task core function.
pvParameters | Junk parameter. |
Initialize touchscreen with default calibration
Draw IP config menu.
Button 1.
Button 2.
Bring up the ethernet interface & initializes timer0, channel0
Wait for IP to be configured. Done in LwIP.
Show configured IP and unlock all other waiting tasks.
Draw application context.
GFX task Loop.
Wait for DSP task processing to complete.
Display sampled signal
Refresh magnitude
References AAT31XX_MAX_BACKLIGHT_LEVEL, AAT31XX_MIN_BACKLIGHT_LEVEL, aat31xx_set_backlight(), app_hold, COLOR_BLACK, COLOR_CUSTOM_GREY, COLOR_LIGHTGREY, COLOR_WHITE, event_handler(), g_c_ipconfig, g_ip_mode, gfx_draw_bmpfile(), gfx_refresh_mag(), gfx_refresh_wav(), ili93xx_display_on(), ili93xx_draw_filled_rectangle(), ili93xx_draw_line(), ili93xx_draw_rectangle(), ili93xx_draw_string(), ILI93XX_LCD_HEIGHT, ILI93XX_LCD_WIDTH, ili93xx_set_cursor_position(), ili93xx_set_foreground_color(), init_ethernet(), IRQ_PRIOR_PIO, logo_atmel_bmp, max_block_time_ticks, pmc_enable_periph_clk(), presentation_delay, rtouch_enable(), rtouch_init(), rtouch_is_pressed, rtouch_process(), rtouch_set_calibration_parameter(), rtouch_set_event_handler(), touch_delay, UNUSED, vTaskDelay(), and xSemaphoreTake.
Referenced by create_gfx_task().
uint32_t app_hold = 1 |
Hold the instructions screen and prevent other task from running.
Used to block the application on instruction screen.
Referenced by gfx_task().
|
static |
|
static |
int8_t g_c_ipconfig[25] |
uint32_t g_ip_mode = 0 |
IP mode: 0 unselected, 1 static, 2 dhcp.
xSemaphoreHandle gfx_notification_semaphore |
GFX notification semaphore.
Triggered from DSP task.
const portTickType instructions_delay = 50UL / portTICK_RATE_MS |
Small delay to hold tasks, during instruction screen.
float32_t mag_in_buffer[] |
Magnitude input buffer defined in DSP task.
Magnitude input buffer defined in DSP task.
Referenced by dsp_task().
uint32_t mag_in_buffer_int[] |
Magnitude buffer converted in float.
|
static |
Referenced by gfx_task().
|
static |
Referenced by gfx_task().
|
static |
Referenced by gfx_task().
|
static |
float32_t wav_in_buffer[] |
Wave input buffer defined in DSP task.
Referenced by dsp_sin_input(), dsp_task(), and gfx_refresh_wav().