Theming and animation

This commit is contained in:
Renze Nicolai 2022-06-03 04:23:00 +02:00
parent cf5f513f10
commit 0ed007e3f0
44 changed files with 427 additions and 50 deletions

View file

@ -22,6 +22,7 @@ idf_component_register(
"file_browser.c"
"test_common.c"
"factory_test.c"
"animation.c"
INCLUDE_DIRS "."
"include"
"menus"
@ -32,4 +33,36 @@ idf_component_register(
${project_dir}/resources/boot.snd
${project_dir}/resources/mch2022_logo.png
${project_dir}/resources/logo_screen.png
${project_dir}/resources/icons/dev.png
${project_dir}/resources/icons/home.png
${project_dir}/resources/icons/settings.png
${project_dir}/resources/icons/apps.png
${project_dir}/resources/animation/animation_frame_1.png
${project_dir}/resources/animation/animation_frame_2.png
${project_dir}/resources/animation/animation_frame_3.png
${project_dir}/resources/animation/animation_frame_4.png
${project_dir}/resources/animation/animation_frame_5.png
${project_dir}/resources/animation/animation_frame_6.png
${project_dir}/resources/animation/animation_frame_7.png
${project_dir}/resources/animation/animation_frame_8.png
${project_dir}/resources/animation/animation_frame_9.png
${project_dir}/resources/animation/animation_frame_10.png
${project_dir}/resources/animation/animation_frame_11.png
${project_dir}/resources/animation/animation_frame_12.png
${project_dir}/resources/animation/animation_frame_13.png
${project_dir}/resources/animation/animation_frame_14.png
${project_dir}/resources/animation/animation_frame_15.png
${project_dir}/resources/animation/animation_frame_16.png
${project_dir}/resources/animation/animation_frame_17.png
${project_dir}/resources/animation/animation_frame_18.png
${project_dir}/resources/animation/animation_frame_19.png
${project_dir}/resources/animation/animation_frame_20.png
${project_dir}/resources/animation/animation_frame_21.png
${project_dir}/resources/animation/animation_frame_22.png
${project_dir}/resources/animation/animation_frame_23.png
${project_dir}/resources/animation/animation_frame_24.png
${project_dir}/resources/animation/animation_frame_25.png
${project_dir}/resources/animation/animation_frame_26.png
${project_dir}/resources/animation/animation_frame_27.png
${project_dir}/resources/animation/animation_frame_28.png
)

167
main/animation.c Normal file
View file

@ -0,0 +1,167 @@
#include <stdio.h>
#include <string.h>
#include <sdkconfig.h>
#include <driver/gpio.h>
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "ili9341.h"
#include "ws2812.h"
#include "hardware.h"
extern const uint8_t animation_frame_1_start[] asm("_binary_animation_frame_1_png_start");
extern const uint8_t animation_frame_1_end[] asm("_binary_animation_frame_1_png_end");
extern const uint8_t animation_frame_2_start[] asm("_binary_animation_frame_2_png_start");
extern const uint8_t animation_frame_2_end[] asm("_binary_animation_frame_2_png_end");
extern const uint8_t animation_frame_3_start[] asm("_binary_animation_frame_3_png_start");
extern const uint8_t animation_frame_3_end[] asm("_binary_animation_frame_3_png_end");
extern const uint8_t animation_frame_4_start[] asm("_binary_animation_frame_4_png_start");
extern const uint8_t animation_frame_4_end[] asm("_binary_animation_frame_4_png_end");
extern const uint8_t animation_frame_5_start[] asm("_binary_animation_frame_5_png_start");
extern const uint8_t animation_frame_5_end[] asm("_binary_animation_frame_5_png_end");
extern const uint8_t animation_frame_6_start[] asm("_binary_animation_frame_6_png_start");
extern const uint8_t animation_frame_6_end[] asm("_binary_animation_frame_6_png_end");
extern const uint8_t animation_frame_7_start[] asm("_binary_animation_frame_7_png_start");
extern const uint8_t animation_frame_7_end[] asm("_binary_animation_frame_7_png_end");
extern const uint8_t animation_frame_8_start[] asm("_binary_animation_frame_8_png_start");
extern const uint8_t animation_frame_8_end[] asm("_binary_animation_frame_8_png_end");
extern const uint8_t animation_frame_9_start[] asm("_binary_animation_frame_9_png_start");
extern const uint8_t animation_frame_9_end[] asm("_binary_animation_frame_9_png_end");
extern const uint8_t animation_frame_10_start[] asm("_binary_animation_frame_10_png_start");
extern const uint8_t animation_frame_10_end[] asm("_binary_animation_frame_10_png_end");
extern const uint8_t animation_frame_11_start[] asm("_binary_animation_frame_11_png_start");
extern const uint8_t animation_frame_11_end[] asm("_binary_animation_frame_11_png_end");
extern const uint8_t animation_frame_12_start[] asm("_binary_animation_frame_12_png_start");
extern const uint8_t animation_frame_12_end[] asm("_binary_animation_frame_12_png_end");
extern const uint8_t animation_frame_13_start[] asm("_binary_animation_frame_13_png_start");
extern const uint8_t animation_frame_13_end[] asm("_binary_animation_frame_13_png_end");
extern const uint8_t animation_frame_14_start[] asm("_binary_animation_frame_14_png_start");
extern const uint8_t animation_frame_14_end[] asm("_binary_animation_frame_14_png_end");
extern const uint8_t animation_frame_15_start[] asm("_binary_animation_frame_15_png_start");
extern const uint8_t animation_frame_15_end[] asm("_binary_animation_frame_15_png_end");
extern const uint8_t animation_frame_16_start[] asm("_binary_animation_frame_16_png_start");
extern const uint8_t animation_frame_16_end[] asm("_binary_animation_frame_16_png_end");
extern const uint8_t animation_frame_17_start[] asm("_binary_animation_frame_17_png_start");
extern const uint8_t animation_frame_17_end[] asm("_binary_animation_frame_17_png_end");
extern const uint8_t animation_frame_18_start[] asm("_binary_animation_frame_18_png_start");
extern const uint8_t animation_frame_18_end[] asm("_binary_animation_frame_18_png_end");
extern const uint8_t animation_frame_19_start[] asm("_binary_animation_frame_19_png_start");
extern const uint8_t animation_frame_19_end[] asm("_binary_animation_frame_19_png_end");
extern const uint8_t animation_frame_20_start[] asm("_binary_animation_frame_20_png_start");
extern const uint8_t animation_frame_20_end[] asm("_binary_animation_frame_20_png_end");
extern const uint8_t animation_frame_21_start[] asm("_binary_animation_frame_21_png_start");
extern const uint8_t animation_frame_21_end[] asm("_binary_animation_frame_21_png_end");
extern const uint8_t animation_frame_22_start[] asm("_binary_animation_frame_22_png_start");
extern const uint8_t animation_frame_22_end[] asm("_binary_animation_frame_22_png_end");
extern const uint8_t animation_frame_23_start[] asm("_binary_animation_frame_23_png_start");
extern const uint8_t animation_frame_23_end[] asm("_binary_animation_frame_23_png_end");
extern const uint8_t animation_frame_24_start[] asm("_binary_animation_frame_24_png_start");
extern const uint8_t animation_frame_24_end[] asm("_binary_animation_frame_24_png_end");
extern const uint8_t animation_frame_25_start[] asm("_binary_animation_frame_25_png_start");
extern const uint8_t animation_frame_25_end[] asm("_binary_animation_frame_25_png_end");
extern const uint8_t animation_frame_26_start[] asm("_binary_animation_frame_26_png_start");
extern const uint8_t animation_frame_26_end[] asm("_binary_animation_frame_26_png_end");
extern const uint8_t animation_frame_27_start[] asm("_binary_animation_frame_27_png_start");
extern const uint8_t animation_frame_27_end[] asm("_binary_animation_frame_27_png_end");
extern const uint8_t animation_frame_28_start[] asm("_binary_animation_frame_28_png_start");
extern const uint8_t animation_frame_28_end[] asm("_binary_animation_frame_28_png_end");
const uint8_t* animation_frames[] = {
animation_frame_1_start,
animation_frame_2_start,
animation_frame_3_start,
animation_frame_4_start,
animation_frame_5_start,
animation_frame_6_start,
animation_frame_7_start,
animation_frame_8_start,
animation_frame_9_start,
animation_frame_10_start,
animation_frame_11_start,
animation_frame_12_start,
animation_frame_13_start,
animation_frame_14_start,
animation_frame_15_start,
animation_frame_16_start,
animation_frame_17_start,
animation_frame_18_start,
animation_frame_19_start,
animation_frame_20_start,
animation_frame_21_start,
animation_frame_22_start,
animation_frame_23_start,
animation_frame_24_start,
animation_frame_25_start,
animation_frame_26_start,
animation_frame_27_start,
animation_frame_28_start
};
const uint8_t* animation_frames_end[] = {
animation_frame_1_end,
animation_frame_2_end,
animation_frame_3_end,
animation_frame_4_end,
animation_frame_5_end,
animation_frame_6_end,
animation_frame_7_end,
animation_frame_8_end,
animation_frame_9_end,
animation_frame_10_end,
animation_frame_11_end,
animation_frame_12_end,
animation_frame_13_end,
animation_frame_14_end,
animation_frame_15_end,
animation_frame_16_end,
animation_frame_17_end,
animation_frame_18_end,
animation_frame_19_end,
animation_frame_20_end,
animation_frame_21_end,
animation_frame_22_end,
animation_frame_23_end,
animation_frame_24_end,
animation_frame_25_end,
animation_frame_26_end,
animation_frame_27_end,
animation_frame_28_end
};
void display_animation(pax_buf_t* pax_buffer, ILI9341* ili9341) {
gpio_set_direction(GPIO_SD_PWR, GPIO_MODE_OUTPUT);
gpio_set_level(GPIO_SD_PWR, 1);
ws2812_init(GPIO_LED_DATA);
uint8_t led_data[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
ws2812_send_data(led_data, sizeof(led_data));
pax_noclip(pax_buffer);
pax_background(pax_buffer, 0xFFFFFF);
for (uint8_t frame = 0; frame < 28; frame++) {
pax_buf_t image;
pax_decode_png_buf(&image, (void*) animation_frames[frame], animation_frames_end[frame] - animation_frames[frame], PAX_BUF_16_565RGB, 0);
pax_draw_image(pax_buffer, &image, 0, 0);
pax_buf_destroy(&image);
ili9341_write(ili9341, pax_buffer->buf);
uint8_t brightness = (frame > 14) ? (frame - 14) : (0);
led_data[1] = brightness;
led_data[3] = brightness;
led_data[8] = brightness;
led_data[9] = brightness / 2;
led_data[10] = brightness / 2;
led_data[14] = brightness;
ws2812_send_data(led_data, sizeof(led_data));
}
for (uint8_t brightness = 14; brightness < 50; brightness++) {
led_data[1] = brightness;
led_data[3] = brightness;
led_data[8] = brightness;
led_data[9] = brightness / 2;
led_data[10] = brightness / 2;
led_data[14] = brightness;
ws2812_send_data(led_data, sizeof(led_data));
vTaskDelay(50 / portTICK_PERIOD_MS);
}
}

View file

@ -109,7 +109,7 @@ void file_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9
char path[512] = {0};
strncpy(path, initial_path, sizeof(path));
while (true) {
menu_t* menu = menu_alloc(path);
menu_t* menu = menu_alloc(path, 20, 18);
DIR* dir = opendir(path);
if (dir == NULL) {
if (path[0] != 0) {

4
main/include/animation.h Normal file
View file

@ -0,0 +1,4 @@
#include "pax_gfx.h"
#include "ili9341.h"
void display_animation(pax_buf_t* pax_buffer, ILI9341* ili9341);

View file

@ -16,6 +16,8 @@ typedef struct _menu_item {
char* label;
menu_callback_t callback;
void* callbackArgs;
pax_buf_t* icon;
// Linked list
struct _menu_item* previousItem;
@ -27,11 +29,27 @@ typedef struct menu {
menu_item_t* firstItem;
size_t length;
size_t position;
float entry_height;
float text_height;
pax_buf_t* icon;
pax_col_t fgColor;
pax_col_t bgColor;
pax_col_t selectedItemColor;
pax_col_t bgTextColor;
pax_col_t borderColor;
pax_col_t titleColor;
pax_col_t titleBgColor;
pax_col_t scrollbarBgColor;
pax_col_t scrollbarFgColor;
} menu_t;
menu_t* menu_alloc(const char* aTitle);
menu_t* menu_alloc(const char* aTitle, float arg_entry_height, float arg_text_height);
void menu_free(menu_t* aMenu);
void menu_set_icon(menu_t* aMenu, pax_buf_t* icon);
bool menu_insert_item(menu_t* aMenu, const char* aLabel, menu_callback_t aCallback, void* aCallbackArgs, size_t aPosition);
bool menu_insert_item_icon(menu_t* aMenu, const char* aLabel, menu_callback_t aCallback, void* aCallbackArgs, size_t aPosition, pax_buf_t* icon);
bool menu_remove_item(menu_t* aMenu, size_t aPosition);
bool menu_navigate_to(menu_t* aMenu, size_t aPosition);
void menu_navigate_previous(menu_t* aMenu);

View file

@ -1,9 +1,10 @@
#include <stdio.h>
#include <string.h>
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "menu.h"
menu_t* menu_alloc(const char* aTitle) {
menu_t* menu_alloc(const char* aTitle, float arg_entry_height, float arg_text_height) {
if (aTitle == NULL) return NULL;
menu_t* menu = malloc(sizeof(menu_t));
if (menu == NULL) return NULL;
@ -17,6 +18,20 @@ menu_t* menu_alloc(const char* aTitle) {
menu->firstItem = NULL;
menu->length = 0;
menu->position = 0;
menu->entry_height = (arg_entry_height > 0) ? arg_entry_height : 20;
menu->text_height = (arg_text_height > 0) ? arg_text_height : (arg_entry_height - 2);
menu->icon = NULL;
menu->fgColor = 0xFF000000;
menu->bgColor = 0xFFFFFFFF;
menu->bgTextColor = 0xFFFFFFFF;
menu->selectedItemColor = 0xFF000000;
menu->borderColor = 0x88000000;
menu->titleColor = 0xFFFFFFFF;
menu->titleBgColor = 0xFF000000;
menu->scrollbarBgColor = 0xFFCCCCCC;
menu->scrollbarFgColor = 0xFF555555;
return menu;
}
@ -37,6 +52,10 @@ void menu_free(menu_t* aMenu) {
free(aMenu);
}
void menu_set_icon(menu_t* aMenu, pax_buf_t* icon) {
aMenu->icon = icon;
}
menu_item_t* _menu_find_item(menu_t* aMenu, size_t aPosition) {
menu_item_t* currentItem = aMenu->firstItem;
if (currentItem == NULL) return NULL;
@ -66,11 +85,12 @@ bool menu_insert_item(menu_t* aMenu, const char* aLabel, menu_callback_t aCallba
newItem->label = malloc(labelSize);
if (newItem->label == NULL) {
free(newItem);
return NULL;
return false;
}
memcpy(newItem->label, aLabel, labelSize);
newItem->callback = aCallback;
newItem->callbackArgs = aCallbackArgs;
newItem->icon = NULL;
if (aMenu->firstItem == NULL) {
newItem->nextItem = NULL;
newItem->previousItem = NULL;
@ -91,6 +111,21 @@ bool menu_insert_item(menu_t* aMenu, const char* aLabel, menu_callback_t aCallba
return true;
}
bool menu_insert_item_icon(menu_t* aMenu, const char* aLabel, menu_callback_t aCallback, void* aCallbackArgs, size_t aPosition, pax_buf_t* icon) {
if (!menu_insert_item(aMenu, aLabel, aCallback, aCallbackArgs, aPosition)) {
return false;
}
menu_item_t* item;
if (aPosition >= aMenu->length - 1) {
item = _menu_find_last_item(aMenu);
} else {
item = _menu_find_item(aMenu, aPosition);
}
item->icon = icon;
return true;
}
bool menu_remove_item(menu_t* aMenu, size_t aPosition) {
if (aMenu == NULL) return false; // Can't delete an item from a menu that doesn't exist
if (aMenu->length <= aPosition) return false; // Can't delete an item that doesn't exist
@ -175,17 +210,11 @@ void menu_debug(menu_t* aMenu) {
}
void menu_render(pax_buf_t *aBuffer, menu_t* aMenu, float aPosX, float aPosY, float aWidth, float aHeight, pax_col_t aColor) {
pax_col_t fgColor = aColor;
pax_col_t bgColor = 0xFFFFFFFF;
pax_col_t bgTextColor = 0xFFFFFFFF;
pax_col_t borderColor = 0x88000000;
pax_col_t titleColor = 0xFFFFFFFF;
pax_col_t titleBgColor = aColor;
pax_col_t scrollbarBgColor = 0xFFCCCCCC;
pax_col_t scrollbarFgColor = 0xFF555555;
const pax_font_t *font = pax_get_font("saira regular");
float entry_height = 18 + 2;
float entry_height = aMenu->entry_height;//18 + 2;
float text_height = aMenu->text_height;
float text_offset = ((entry_height - text_height) / 2) + 1;
size_t maxItems = aHeight / entry_height;
float posY = aPosY;
@ -193,12 +222,20 @@ void menu_render(pax_buf_t *aBuffer, menu_t* aMenu, float aPosX, float aPosY, fl
pax_noclip(aBuffer);
if (maxItems > 1) {
float offsetX = 0;
if (aMenu->icon != NULL) {
offsetX = aMenu->icon->width;
}
maxItems--;
pax_simple_rect(aBuffer, titleBgColor, aPosX, posY, aWidth, entry_height);
pax_simple_line(aBuffer, titleColor, aPosX + 1, aPosY + entry_height, aPosX + aWidth - 2, aPosY + entry_height - 1);
pax_clip(aBuffer, aPosX + 1, posY + 1, aWidth - 2, entry_height - 2);
pax_draw_text(aBuffer, titleColor, font, entry_height - 2, aPosX + 1, posY + 1, aMenu->title);
pax_simple_rect(aBuffer, aMenu->titleBgColor, aPosX, posY, aWidth, entry_height);
//pax_simple_line(aBuffer, aMenu->titleColor, aPosX + 1, aPosY + entry_height, aPosX + aWidth - 2, aPosY + entry_height - 1);
pax_clip(aBuffer, aPosX + 1, posY + text_offset, aWidth - 2, text_height);
pax_draw_text(aBuffer, aMenu->titleColor, font, text_height, aPosX + offsetX + 1, posY + text_offset, aMenu->title);
pax_noclip(aBuffer);
if (aMenu->icon != NULL) {
pax_draw_image(aBuffer, aMenu->icon, aPosX, posY);
}
posY += entry_height;
}
@ -207,8 +244,8 @@ void menu_render(pax_buf_t *aBuffer, menu_t* aMenu, float aPosX, float aPosY, fl
itemOffset = aMenu->position - maxItems + 1;
}
pax_outline_rect(aBuffer, borderColor, aPosX, aPosY, aWidth, aHeight);
pax_simple_rect(aBuffer, bgColor, aPosX, posY, aWidth, aHeight - posY + aPosY);
pax_outline_rect(aBuffer, aMenu->borderColor, aPosX, aPosY, aWidth, aHeight);
pax_simple_rect(aBuffer, aMenu->bgColor, aPosX, posY, aWidth, aHeight - posY + aPosY);
for (size_t index = itemOffset; (index < itemOffset + maxItems) && (index < aMenu->length); index++) {
menu_item_t* item = _menu_find_item(aMenu, index);
@ -216,18 +253,28 @@ void menu_render(pax_buf_t *aBuffer, menu_t* aMenu, float aPosX, float aPosY, fl
printf("Render error: item is NULL at %u\n", index);
break;
}
float iconWidth = 0;
if (item->icon != NULL) {
iconWidth = item->icon->width + 1;
}
if (index == aMenu->position) {
pax_simple_rect(aBuffer, fgColor, aPosX + 1, posY, aWidth - 2, entry_height);
pax_clip(aBuffer, aPosX + 1, posY + 1, aWidth - 4, entry_height - 2);
pax_draw_text(aBuffer, bgTextColor, font, entry_height - 2, aPosX + 1, posY + 1, item->label);
pax_simple_rect(aBuffer, aMenu->selectedItemColor, aPosX + 1, posY, aWidth - 2, entry_height);
pax_clip(aBuffer, aPosX + 1, posY + text_offset, aWidth - 4, text_height);
pax_draw_text(aBuffer, aMenu->bgTextColor, font, text_height, aPosX + iconWidth + 1, posY + text_offset, item->label);
pax_noclip(aBuffer);
} else {
pax_simple_rect(aBuffer, bgColor, aPosX + 1, posY, aWidth - 2, entry_height);
pax_clip(aBuffer, aPosX + 1, posY + 1, aWidth - 4, entry_height - 2);
pax_draw_text(aBuffer, fgColor, font, entry_height - 2, aPosX + 1, posY + 1, item->label);
pax_simple_rect(aBuffer, aMenu->bgColor, aPosX + 1, posY, aWidth - 2, entry_height);
pax_clip(aBuffer, aPosX + 1, posY + text_offset, aWidth - 4, text_height);
pax_draw_text(aBuffer, aMenu->fgColor, font, text_height, aPosX + iconWidth + 1, posY + text_offset, item->label);
pax_noclip(aBuffer);
}
if (item->icon != NULL) {
pax_draw_image(aBuffer, item->icon, aPosX + 1, posY);
}
posY += entry_height;
}
@ -242,8 +289,8 @@ void menu_render(pax_buf_t *aBuffer, menu_t* aMenu, float aPosX, float aPosY, fl
float scrollbarStart = scrollbarHeight * fractionStart;
float scrollbarEnd = scrollbarHeight * fractionEnd;
pax_simple_rect(aBuffer, scrollbarBgColor, aPosX + aWidth - 5, aPosY + entry_height - 1, 4, scrollbarHeight);
pax_simple_rect(aBuffer, scrollbarFgColor, aPosX + aWidth - 5, aPosY + entry_height - 1 + scrollbarStart, 4, scrollbarEnd - scrollbarStart);
pax_simple_rect(aBuffer, aMenu->scrollbarBgColor, aPosX + aWidth - 5, aPosY + entry_height - 1, 4, scrollbarHeight);
pax_simple_rect(aBuffer, aMenu->scrollbarFgColor, aPosX + aWidth - 5, aPosY + entry_height - 1 + scrollbarStart, 4, scrollbarEnd - scrollbarStart);
pax_noclip(aBuffer);
}

View file

@ -10,6 +10,7 @@
#include "appfs.h"
#include "ili9341.h"
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "menu.h"
#include "rp2040.h"
#include "launcher.h"
@ -19,6 +20,10 @@
#include "hardware.h"
#include "file_browser.h"
#include "fpga_test.h"
#include "animation.h"
extern const uint8_t dev_png_start[] asm("_binary_dev_png_start");
extern const uint8_t dev_png_end[] asm("_binary_dev_png_end");
typedef enum action {
ACTION_NONE,
@ -27,21 +32,39 @@ typedef enum action {
ACTION_FPGA_TEST,
ACTION_FILE_BROWSER,
ACTION_FILE_BROWSER_INT,
ACTION_ANIMATION
} menu_dev_action_t;
void render_dev_help(pax_buf_t* pax_buffer) {
const pax_font_t *font = pax_get_font("saira regular");
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] accept [B] back");
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 18, "[A] accept [B] back");
}
void menu_dev(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("Development tools");
menu_t* menu = menu_alloc("Development tools", 32, 18);
menu->fgColor = 0xFF000000;
menu->bgColor = 0xFFFFFFFF;
menu->bgTextColor = 0xFF000000;
menu->selectedItemColor = 0xFFfec859;
menu->borderColor = 0xFFfa448c;
menu->titleColor = 0xFFfec859;
menu->titleBgColor = 0xFFfa448c;
menu->scrollbarBgColor = 0xFFCCCCCC;
menu->scrollbarFgColor = 0xFF555555;
pax_buf_t icon_dev;
pax_decode_png_buf(&icon_dev, (void*) dev_png_start, dev_png_end - dev_png_start, PAX_BUF_32_8888ARGB, 0);
menu_set_icon(menu, &icon_dev);
menu_insert_item(menu, "FPGA download mode", NULL, (void*) ACTION_FPGA_DL, -1);
menu_insert_item(menu, "FPGA selftest", NULL, (void*) ACTION_FPGA_TEST, -1);
menu_insert_item(menu, "File browser (SD card)", NULL, (void*) ACTION_FILE_BROWSER, -1);
menu_insert_item(menu, "File browser (internal)", NULL, (void*) ACTION_FILE_BROWSER_INT, -1);
menu_insert_item(menu, "Animation", NULL, (void*) ACTION_ANIMATION, -1);
bool render = true;
menu_dev_action_t action = ACTION_NONE;
@ -86,7 +109,7 @@ void menu_dev(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341)
}
if (render) {
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF491d88);
ili9341_write(ili9341, pax_buffer->buf);
render = false;
}
@ -100,6 +123,8 @@ void menu_dev(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341)
file_browser(buttonQueue, pax_buffer, ili9341, "/sd");
} else if (action == ACTION_FILE_BROWSER_INT) {
file_browser(buttonQueue, pax_buffer, ili9341, "/internal");
} else if (action == ACTION_ANIMATION) {
display_animation(pax_buffer, ili9341);
} else if (action == ACTION_BACK) {
break;
}
@ -110,4 +135,6 @@ void menu_dev(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341)
}
menu_free(menu);
pax_buf_destroy(&icon_dev);
}

View file

@ -10,10 +10,14 @@
#include "appfs.h"
#include "ili9341.h"
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "menu.h"
#include "rp2040.h"
#include "appfs_wrapper.h"
extern const uint8_t apps_png_start[] asm("_binary_apps_png_start");
extern const uint8_t apps_png_end[] asm("_binary_apps_png_end");
typedef enum {
ACTION_NONE,
ACTION_APPFS,
@ -26,7 +30,23 @@ typedef struct {
} menu_launcher_args_t;
void menu_launcher(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("Apps");
menu_t* menu = menu_alloc("Apps", 32, 18);
menu->fgColor = 0xFF000000;
menu->bgColor = 0xFFFFFFFF;
menu->bgTextColor = 0xFFFFFFFF;
menu->selectedItemColor = 0xFFfa448c;
menu->borderColor = 0xFF491d88;
menu->titleColor = 0xFFfa448c;
menu->titleBgColor = 0xFF491d88;
menu->scrollbarBgColor = 0xFFCCCCCC;
menu->scrollbarFgColor = 0xFF555555;
pax_buf_t icon_apps;
pax_decode_png_buf(&icon_apps, (void*) apps_png_start, apps_png_end - apps_png_start, PAX_BUF_32_8888ARGB, 0);
menu_set_icon(menu, &icon_apps);
const pax_font_t *font = pax_get_font("saira regular");
appfs_handle_t appfs_fd = APPFS_INVALID_FD;
@ -46,7 +66,7 @@ void menu_launcher(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] start app [B] back");
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 18, "[A] start app [B] back");
bool quit = false;
@ -88,7 +108,7 @@ void menu_launcher(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
}
if (render) {
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF491d88);
ili9341_write(ili9341, pax_buffer->buf);
render = false;
}
@ -110,4 +130,5 @@ void menu_launcher(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
}
menu_free(menu);
pax_buf_destroy(&icon_apps);
}

View file

@ -10,6 +10,7 @@
#include "appfs.h"
#include "ili9341.h"
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "menu.h"
#include "rp2040.h"
#include "appfs_wrapper.h"
@ -21,6 +22,9 @@
#include "wifi.h"
#include "uninstall.h"
extern const uint8_t settings_png_start[] asm("_binary_settings_png_start");
extern const uint8_t settings_png_end[] asm("_binary_settings_png_end");
typedef enum action {
ACTION_NONE,
ACTION_BACK,
@ -34,11 +38,27 @@ void render_settings_help(pax_buf_t* pax_buffer) {
const pax_font_t *font = pax_get_font("saira regular");
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] accept [B] back");
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 18, "[A] accept [B] back");
}
void menu_settings(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("Settings");
menu_t* menu = menu_alloc("Settings", 32, 18);
menu->fgColor = 0xFF000000;
menu->bgColor = 0xFFFFFFFF;
menu->bgTextColor = 0xFFFFFFFF;
menu->selectedItemColor = 0xFF491d88;
menu->borderColor = 0xFF43b5a0;
menu->titleColor = 0xFF491d88;
menu->titleBgColor = 0xFF43b5a0;
menu->scrollbarBgColor = 0xFFCCCCCC;
menu->scrollbarFgColor = 0xFF555555;
pax_buf_t icon_settings;
pax_decode_png_buf(&icon_settings, (void*) settings_png_start, settings_png_end - settings_png_start, PAX_BUF_32_8888ARGB, 0);
menu_set_icon(menu, &icon_settings);
menu_insert_item(menu, "WiFi configuration", NULL, (void*) ACTION_WIFI, -1);
menu_insert_item(menu, "Firmware update", NULL, (void*) ACTION_OTA, -1);
menu_insert_item(menu, "Flash RP2040 firmware", NULL, (void*) ACTION_RP2040_BL, -1);
@ -87,7 +107,7 @@ void menu_settings(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
}
if (render) {
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF491d88);
ili9341_write(ili9341, pax_buffer->buf);
render = false;
}
@ -120,4 +140,5 @@ void menu_settings(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
}
menu_free(menu);
pax_buf_destroy(&icon_settings);
}

View file

@ -10,12 +10,25 @@
#include "appfs.h"
#include "ili9341.h"
#include "pax_gfx.h"
#include "pax_codecs.h"
#include "menu.h"
#include "rp2040.h"
#include "launcher.h"
#include "settings.h"
#include "dev.h"
extern const uint8_t home_png_start[] asm("_binary_home_png_start");
extern const uint8_t home_png_end[] asm("_binary_home_png_end");
extern const uint8_t apps_png_start[] asm("_binary_apps_png_start");
extern const uint8_t apps_png_end[] asm("_binary_apps_png_end");
extern const uint8_t dev_png_start[] asm("_binary_dev_png_start");
extern const uint8_t dev_png_end[] asm("_binary_dev_png_end");
extern const uint8_t settings_png_start[] asm("_binary_settings_png_start");
extern const uint8_t settings_png_end[] asm("_binary_settings_png_end");
typedef enum action {
ACTION_NONE,
ACTION_APPS,
@ -27,14 +40,36 @@ void render_start_help(pax_buf_t* pax_buffer) {
const pax_font_t *font = pax_get_font("saira regular");
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] accept");
pax_draw_text(pax_buffer, 0xFF491d88, font, 18, 5, 240 - 18, "[A] accept");
}
void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("Main menu");
menu_insert_item(menu, "Apps", NULL, (void*) ACTION_APPS, -1);
menu_insert_item(menu, "Development tools", NULL, (void*) ACTION_DEV, -1);
menu_insert_item(menu, "Settings", NULL, (void*) ACTION_SETTINGS, -1);
menu_t* menu = menu_alloc("Main menu", 32, 18);
menu->fgColor = 0xFF000000;
menu->bgColor = 0xFFFFFFFF;
menu->bgTextColor = 0xFF000000;
menu->selectedItemColor = 0xFFfec859;
menu->borderColor = 0xFF491d88;
menu->titleColor = 0xFFfec859;
menu->titleBgColor = 0xFF491d88;
menu->scrollbarBgColor = 0xFFCCCCCC;
menu->scrollbarFgColor = 0xFF555555;
pax_buf_t icon_home;
pax_decode_png_buf(&icon_home, (void*) home_png_start, home_png_end - home_png_start, PAX_BUF_32_8888ARGB, 0);
pax_buf_t icon_apps;
pax_decode_png_buf(&icon_apps, (void*) apps_png_start, apps_png_end - apps_png_start, PAX_BUF_32_8888ARGB, 0);
pax_buf_t icon_dev;
pax_decode_png_buf(&icon_dev, (void*) dev_png_start, dev_png_end - dev_png_start, PAX_BUF_32_8888ARGB, 0);
pax_buf_t icon_settings;
pax_decode_png_buf(&icon_settings, (void*) settings_png_start, settings_png_end - settings_png_start, PAX_BUF_32_8888ARGB, 0);
menu_set_icon(menu, &icon_home);
menu_insert_item_icon(menu, "Apps", NULL, (void*) ACTION_APPS, -1, &icon_apps);
menu_insert_item_icon(menu, "Development tools", NULL, (void*) ACTION_DEV, -1, &icon_dev);
menu_insert_item_icon(menu, "Settings", NULL, (void*) ACTION_SETTINGS, -1, &icon_settings);
bool render = true;
@ -74,7 +109,7 @@ void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili934
}
if (render) {
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF000000);
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF491d88);
ili9341_write(ili9341, pax_buffer->buf);
render = false;
}
@ -94,4 +129,8 @@ void menu_start(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili934
}
menu_free(menu);
pax_buf_destroy(&icon_home);
pax_buf_destroy(&icon_apps);
pax_buf_destroy(&icon_dev);
pax_buf_destroy(&icon_settings);
}

View file

@ -63,7 +63,7 @@ void render_wifi_help(pax_buf_t* pax_buffer) {
const pax_font_t *font = pax_get_font("saira regular");
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] accept [B] back");
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 18, "[A] accept [B] back");
}
void wifi_show(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341);
@ -73,7 +73,7 @@ int wifi_auth_menu(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
int wifi_phase2_menu(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, esp_eap_ttls_phase2_types default_mode);
void menu_wifi(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("WiFi configuration");
menu_t* menu = menu_alloc("WiFi configuration", 32, 18);
menu_insert_item(menu, "Show current settings", NULL, (void*) ACTION_SHOW, -1);
menu_insert_item(menu, "Scan for networks", NULL, (void*) ACTION_SCAN, -1);
menu_insert_item(menu, "Configure manually", NULL, (void*) ACTION_MANUAL, -1);
@ -121,7 +121,7 @@ void menu_wifi(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341
}
if (render) {
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF2f55a8);
menu_render(pax_buffer, menu, 0, 0, 320, 220, 0xFF491d88);
ili9341_write(ili9341, pax_buffer->buf);
render = false;
}
@ -195,7 +195,7 @@ void wifi_show(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341
}
wifi_ap_record_t *wifi_scan_results(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, size_t num_aps, wifi_ap_record_t *aps) {
menu_t *menu = menu_alloc("Select network");
menu_t *menu = menu_alloc("Select network", 20, 18);
wifi_ap_record_t *picked = NULL;
render_wifi_help(pax_buffer);
@ -269,7 +269,7 @@ wifi_ap_record_t *wifi_scan_results(xQueueHandle buttonQueue, pax_buf_t* pax_buf
}
int wifi_auth_menu(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, wifi_auth_mode_t default_mode) {
menu_t* menu = menu_alloc("Authentication mode");
menu_t* menu = menu_alloc("Authentication mode", 20, 18);
menu_insert_item(menu, "Insecure", NULL, (void*) ACTION_AUTH_OPEN, -1);
menu_insert_item(menu, "WEP", NULL, (void*) ACTION_AUTH_WEP, -1);
menu_insert_item(menu, "WPA PSK", NULL, (void*) ACTION_AUTH_WPA_PSK, -1);
@ -347,7 +347,7 @@ int wifi_auth_menu(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili
}
int wifi_phase2_menu(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341, esp_eap_ttls_phase2_types default_mode) {
menu_t* menu = menu_alloc("Phase 2 authentication mode");
menu_t* menu = menu_alloc("Phase 2 authentication mode", 20, 18);
menu_insert_item(menu, "ESP", NULL, (void*) ACTION_PHASE2_EAP, -1);
menu_insert_item(menu, "MSCHAPv2", NULL, (void*) ACTION_PHASE2_MSCHAPV2, -1);
menu_insert_item(menu, "MSCHAP", NULL, (void*) ACTION_PHASE2_MSCHAP, -1);

View file

@ -26,7 +26,7 @@ typedef struct _uninstall_menu_args {
} uninstall_menu_args_t;
void uninstall_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341* ili9341) {
menu_t* menu = menu_alloc("Uninstall application");
menu_t* menu = menu_alloc("Uninstall application", 20, 18);
const pax_font_t *font = pax_get_font("saira regular");
appfs_handle_t appfs_fd = APPFS_INVALID_FD;
@ -50,7 +50,7 @@ void uninstall_browser(xQueueHandle buttonQueue, pax_buf_t* pax_buffer, ILI9341*
pax_background(pax_buffer, 0xFFFFFF);
pax_noclip(pax_buffer);
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 19, "[A] uninstall app [B] back");
pax_draw_text(pax_buffer, 0xFF000000, font, 18, 5, 240 - 18, "[A] uninstall app [B] back");
bool quit = false;

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 706 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 468 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 395 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.4 KiB

BIN
resources/icons/apps.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 B

BIN
resources/icons/dev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 857 B

BIN
resources/icons/home.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 439 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1 KiB