75 lines
2.1 KiB
C
75 lines
2.1 KiB
C
/*
|
|
* MTG RFID Companion - UI task (Core 1)
|
|
*/
|
|
|
|
#include <string.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_log.h"
|
|
#include "display_manager.h"
|
|
#include "ui_task.h"
|
|
|
|
static const char *TAG = "ui";
|
|
|
|
#define UI_TASK_STACK (8 * 1024)
|
|
#define UI_TASK_PRIO (5)
|
|
#define UI_CORE (1)
|
|
|
|
static TaskHandle_t s_ui_task = NULL;
|
|
|
|
static void draw_color_bars(void)
|
|
{
|
|
static const uint16_t bars[] = {
|
|
COLOR_WHITE, COLOR_YELLOW, COLOR_CYAN, COLOR_GREEN,
|
|
COLOR_MAGENTA, COLOR_RED, COLOR_BLUE, COLOR_BLACK
|
|
};
|
|
const int band = DISP_W / 8;
|
|
for (int i = 0; i < 8; i++) {
|
|
display_fill_rect(i * band, 0, (i + 1) * band, 64, bars[i]);
|
|
}
|
|
}
|
|
|
|
static void ui_boot_demo(void)
|
|
{
|
|
ESP_LOGI(TAG, "UI demo: color bars");
|
|
draw_color_bars();
|
|
vTaskDelay(pdMS_TO_TICKS(1500));
|
|
|
|
ESP_LOGI(TAG, "UI demo: text rendering");
|
|
display_fill(COLOR_BLACK);
|
|
display_put_text_center(8, "MTG RFID COMPANION", COLOR_YELLOW, COLOR_BLACK);
|
|
display_put_text(16, 40, "UID: 04A2B3C4", COLOR_GREEN, COLOR_BLACK);
|
|
display_put_text(16, 56, "SOL RING", COLOR_WHITE, COLOR_BLACK);
|
|
display_put_text(16, 72, "MANA {1}", COLOR_CYAN, COLOR_BLACK);
|
|
display_put_text(16, 88, "PRICE $1.25", COLOR_MAGENTA, COLOR_BLACK);
|
|
vTaskDelay(pdMS_TO_TICKS(2000));
|
|
|
|
ESP_LOGI(TAG, "UI demo: JPEG decode from LittleFS");
|
|
display_show_jpeg_file("/spiffs/cards/sample.jpg");
|
|
vTaskDelay(pdMS_TO_TICKS(3000));
|
|
|
|
ESP_LOGI(TAG, "UI demo complete");
|
|
}
|
|
|
|
static void ui_task(void *arg)
|
|
{
|
|
(void)arg;
|
|
ESP_LOGI(TAG, "UI task on core %d", xPortGetCoreID());
|
|
ui_boot_demo();
|
|
ESP_LOGI(TAG, "UI task entering idle render loop");
|
|
while (1) {
|
|
/* Placeholder idle loop; state-driven rendering lands in Phase 7. */
|
|
vTaskDelay(pdMS_TO_TICKS(100));
|
|
}
|
|
}
|
|
|
|
esp_err_t ui_task_start(void)
|
|
{
|
|
xTaskCreatePinnedToCore(ui_task, "ui_task", UI_TASK_STACK, NULL, UI_TASK_PRIO, &s_ui_task, UI_CORE);
|
|
return ESP_OK;
|
|
}
|
|
|
|
void ui_task_wait_boot(void)
|
|
{
|
|
/* Expose for later phases; currently no-op before state machine lands. */
|
|
} |