diff --git a/nametag8_CH592/user/ui/menu.h b/nametag8_CH592/user/ui/menu.h index a92aef1..47ca072 100644 --- a/nametag8_CH592/user/ui/menu.h +++ b/nametag8_CH592/user/ui/menu.h @@ -1,5 +1,5 @@ /* - * $Id: menu.h 495 2021-07-22 20:53:39Z true $ + * menu.h * begin 20190527 true */ @@ -82,12 +82,12 @@ void menu_0_disp(uint8_t idx); void menu_0_enter(uint8_t idx); // menu_1_name -extern const MenuItem menu_1; +extern const MenuItem menu_1_name_setup; void menu_1_disp(uint8_t idx); void menu_1_enter(uint8_t idx); // menu_2_led -extern const MenuItem menu_2; +extern const MenuItem menu_2_led_setup; void menu_2_disp(uint8_t idx); void menu_2_enter(uint8_t idx); @@ -96,12 +96,12 @@ extern const MenuItem menu_3_snek; void snek_disp(uint8_t idx); // menu_5_options -extern const MenuItem menu_5; +extern const MenuItem menu_5_options; void menu_5_disp(uint8_t idx); void menu_5_enter(uint8_t idx); // menu_6_about -extern const MenuItem menu_6; +extern const MenuItem menu_6_about; void menu_6_disp(uint8_t idx); diff --git a/nametag8_CH592/user/ui/menu_entry_0.c b/nametag8_CH592/user/ui/menu0_main.c similarity index 94% rename from nametag8_CH592/user/ui/menu_entry_0.c rename to nametag8_CH592/user/ui/menu0_main.c index ca34a0d..0ab772a 100644 --- a/nametag8_CH592/user/ui/menu_entry_0.c +++ b/nametag8_CH592/user/ui/menu0_main.c @@ -1,8 +1,9 @@ /* - * menu_entry_0.c + * menu0_main.c * begin 20190527 true * * main menu functions + * nametag display */ #include "menu.h" @@ -19,6 +20,7 @@ #include + #define ROTATE_TARGET_WIDTH 40 #define ROTATE_TARGET_HEIGHT 32 @@ -35,6 +37,7 @@ #define DEMOWAVE_ADD2 25 + uint8_t rotsrc_fb[(ROTATE_TARGET_WIDTH * (ROTATE_TARGET_HEIGHT >> 3)) + 1]; uint8_t rotdst_fb[(ROTATE_TARGET_WIDTH * (ROTATE_TARGET_HEIGHT >> 3)) + 1]; @@ -46,6 +49,7 @@ uint8_t wiggle = 1; int8_t waves = 0; + static void menu_none_init() { rotsrc.width = rotdst.width = ROTATE_TARGET_WIDTH; @@ -316,7 +320,7 @@ __HIGH_CODE void menu_0_disp(uint8_t idx) { char txt[14]; - uint8_t w; + // uint8_t w; ssd1306fb_set_color(SSD1306_STATE_SET_PIXEL); @@ -329,14 +333,25 @@ void menu_0_disp(uint8_t idx) case 0: strcpy(txt, "Nametag!"); break; case 1: strcpy(txt, "Name Setup"); break; case 2: strcpy(txt, "RGB Setup"); break; - case 3: strcpy(txt, "Snek"); break; - case 4: strcpy(txt, "Morble"); break; + case 3: strcpy(txt, "Messages"); break; + case 4: { + ssd1306fb_set_cursor(32, 9); + ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "I", 1); + + ssd1306fb_set_cursor(39, 8); + ssd1306fb_draw_str(font_Dialog_plain_8, "2", 1); + + ssd1306fb_set_cursor(45, 9); + strcpy(txt, "C Sniffer"); + break; + } case 5: strcpy(txt, "Options"); break; case 6: strcpy(txt, "About & Dbg"); break; } ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, txt, 1); // disabled / incomplete entries + /* switch (idx) { case 4: { w = ssd1306fb_get_str_width(font_DejaVu_Sans_Mono_Bold_11, txt, strlen(txt), 1); @@ -344,6 +359,7 @@ void menu_0_disp(uint8_t idx) ssd1306fb_draw_hline(32, w + 32, 17); } } + */ // draw extras menu_draw_tabs(idx); @@ -358,29 +374,28 @@ void menu_0_enter(uint8_t idx) return; } case 1: { - menu = (MenuItem *)&menu_1; + menu = (MenuItem *)&menu_1_name_setup; menu_idx = 0; return; } case 2: { - menu = (MenuItem *)&menu_2; + menu = (MenuItem *)&menu_2_led_setup; menu_idx = 0; return; } case 3: { - menu = (MenuItem *)&menu_3_snek; return; } case 4: { return; } case 5: { - menu = (MenuItem *)&menu_5; + menu = (MenuItem *)&menu_5_options; menu_idx = 0; return; } case 6: { - menu = (MenuItem *)&menu_6; + menu = (MenuItem *)&menu_6_about; menu_idx = 0; return; } diff --git a/nametag8_CH592/user/ui/menu_entry_1.c b/nametag8_CH592/user/ui/menu1_name_setup.c similarity index 100% rename from nametag8_CH592/user/ui/menu_entry_1.c rename to nametag8_CH592/user/ui/menu1_name_setup.c diff --git a/nametag8_CH592/user/ui/menu_entry_2.c b/nametag8_CH592/user/ui/menu2_led_setup.c similarity index 100% rename from nametag8_CH592/user/ui/menu_entry_2.c rename to nametag8_CH592/user/ui/menu2_led_setup.c diff --git a/nametag8_CH592/user/ui/menu_entry_5.c b/nametag8_CH592/user/ui/menu5_options.c similarity index 82% rename from nametag8_CH592/user/ui/menu_entry_5.c rename to nametag8_CH592/user/ui/menu5_options.c index 063f3c0..9f0d2d7 100644 --- a/nametag8_CH592/user/ui/menu_entry_5.c +++ b/nametag8_CH592/user/ui/menu5_options.c @@ -1,5 +1,5 @@ /* - * menu_entry_5.c + * menu5_options.c * begin 20190613 true * * settings menu functions @@ -19,18 +19,20 @@ #define LI_ENABLE_LEDS 0 -#define LI_NO_MOVE_TIMEOUT 1 -#define LI_NO_MOVE_THRESH 2 -#define LI_WAKEUP_THRESH 3 -#define LI_LSENS_DARK_CAL 4 -#define LI_FACTORY_RESET 5 -#define LI_DEBUG_SHOW_CPU 6 -#define LI_DEBUG_SHOW_ACCEL 7 +#define LI_NO_MOVE_SLP_TIME 1 +#define LI_NO_MOVE_DIM_TIME 2 +#define LI_NO_MOVE_THRESH 3 +#define LI_WAKEUP_THRESH 4 +#define LI_LSENS_DARK_CAL 5 +#define LI_FACTORY_RESET 6 +#define LI_DEBUG_SHOW_CPU 7 +#define LI_DEBUG_SHOW_ACCEL 8 const uint16_t sleep_times[] = { 0, + 60, 300, 600, 900, @@ -44,7 +46,6 @@ static uint8_t factory_reset; -__HIGH_CODE void menu_5_disp(uint8_t idx) { int8_t w, x; @@ -61,7 +62,7 @@ void menu_5_disp(uint8_t idx) strcpy(txt, (uconf.flags & UCONF_FLAGS_LEDS_ENABLE) ? "On" : "Off"); break; } - case LI_NO_MOVE_TIMEOUT: { + case LI_NO_MOVE_SLP_TIME: { ssd1306fb_draw_str(font_table[0].font, "No Movement Sleep Time", 0); if (uconf.sleep_timeout) { sprintf(txt, "%dmin", (uconf.sleep_timeout / 60)); @@ -70,6 +71,15 @@ void menu_5_disp(uint8_t idx) } break; } + case LI_NO_MOVE_DIM_TIME: { + ssd1306fb_draw_str(font_table[0].font, "No Move LED Autodim Time", 0); + if (uconf.dim_timeout) { + sprintf(txt, "%dmin", (uconf.dim_timeout / 60)); + } else { + strcpy(txt, "Off"); + } + break; + } case LI_NO_MOVE_THRESH: { ssd1306fb_draw_str(font_table[0].font, "No Movement Threshold", 0); strcpy(txt, "Normal"); @@ -139,6 +149,7 @@ void menu_5_disp(uint8_t idx) void menu_5_enter(uint8_t idx) { int i, j; + uint16_t *t; switch (idx) { case LI_ENABLE_LEDS: { @@ -149,13 +160,16 @@ void menu_5_enter(uint8_t idx) } break; } - case LI_NO_MOVE_TIMEOUT: { + case LI_NO_MOVE_SLP_TIME: + case LI_NO_MOVE_DIM_TIME: { + t = (idx == LI_NO_MOVE_SLP_TIME) ? &uconf.sleep_timeout : &uconf.dim_timeout; + j = sizeof(sleep_times) / sizeof(sleep_times[0]); for (i = 0; i < j; i++) { - if (uconf.sleep_timeout == sleep_times[i]) { + if (*t == sleep_times[i]) { i++; i %= j; - uconf.sleep_timeout = sleep_times[i]; + *t = sleep_times[i]; j = 0xff; break; } @@ -163,7 +177,7 @@ void menu_5_enter(uint8_t idx) // couldn't find a match, so set default if (j != 0xff) { - uconf.sleep_timeout = sleep_times[4]; + *t = sleep_times[4]; } break; } diff --git a/nametag8_CH592/user/ui/menu_entry_6.c b/nametag8_CH592/user/ui/menu6_about.c similarity index 91% rename from nametag8_CH592/user/ui/menu_entry_6.c rename to nametag8_CH592/user/ui/menu6_about.c index 1b35292..6d48e22 100644 --- a/nametag8_CH592/user/ui/menu_entry_6.c +++ b/nametag8_CH592/user/ui/menu6_about.c @@ -27,6 +27,19 @@ #define MCU_SRAM 24+2 +#define LI_ABOUT 0 +#define LI_CONTACT 1 +#define LI_LED_1_4 2 +#define LI_LED_5_8 3 +#define LI_LED_9_12 4 +#define LI_ACCELEROMETER 5 +#define LI_CPU_USAGE 6 +#define LI_MISC_STATS 7 +#define LI_ERROR_COUNTERS 8 +#define LI_FONT_GLYPH_TEST 9 + + + uint8_t font_index = 0; uint8_t font_glyph = 0; @@ -78,7 +91,7 @@ void menu_6_font_prev(uint8_t idx) */ } -void menu_6_accel_reset(uint8_t idx) +static void menu_6_accel_reset(uint8_t idx) { // todo: figure out what this does movement_worst = 0; @@ -114,7 +127,7 @@ void menu_6_disp(uint8_t idx) // which item selected? switch (idx) { - case 0: { // about + case LI_ABOUT: { // about ssd1306fb_set_cursor(11, 0); ssd1306fb_draw_str(font_DSEG14_Classic_18, "GAT", 1); ssd1306fb_set_cursor(11, 22); @@ -136,7 +149,7 @@ void menu_6_disp(uint8_t idx) break; } - case 1: { // manual + case LI_CONTACT: { // manual ssd1306fb_set_cursor(11, 0); ssd1306fb_draw_str(font_Dialog_plain_8, "Manual and code at", 1); ssd1306fb_set_cursor(11, 11); @@ -146,7 +159,7 @@ void menu_6_disp(uint8_t idx) break; } - case 2: { // led 1-4 + case LI_LED_1_4: { // led 1-4 ssd1306fb_set_cursor(54, 4); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "LED", 1); ssd1306fb_set_cursor(54, 15); @@ -163,7 +176,7 @@ void menu_6_disp(uint8_t idx) } break; } - case 3: { // led 5-8 + case LI_LED_5_8: { // led 5-8 ssd1306fb_set_cursor(54, 4); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "LED", 1); ssd1306fb_set_cursor(54, 15); @@ -180,7 +193,7 @@ void menu_6_disp(uint8_t idx) } break; } - case 4: { // led 9-12 + case LI_LED_9_12: { // led 9-12 ssd1306fb_set_cursor(54, 4); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "LED", 1); ssd1306fb_set_cursor(53, 15); @@ -201,7 +214,7 @@ void menu_6_disp(uint8_t idx) } break; } - case 5: { // accelerometer + case LI_ACCELEROMETER: { // accelerometer ssd1306fb_set_cursor(10, -1); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "Accelerometer", 1); @@ -229,7 +242,7 @@ void menu_6_disp(uint8_t idx) break; } - case 6: { // cpu stats + case LI_CPU_USAGE: { // cpu stats sprintf(txt, "CPU Load: %3u%%", cpu_pct); ssd1306fb_set_cursor(10, -1); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, txt, 1); @@ -243,7 +256,7 @@ void menu_6_disp(uint8_t idx) ssd1306fb_draw_str(font_Dialog_plain_8, txt, 0); break; } - case 7: { // misc stats + case LI_MISC_STATS: { // misc stats ssd1306fb_set_cursor(10, -1); ssd1306fb_draw_str(font_Dialog_plain_8, "Light: ", 1); oled.cursor_x = 39; @@ -276,7 +289,7 @@ void menu_6_disp(uint8_t idx) break; } - case 8: { // error counters + case LI_ERROR_COUNTERS: { // error counters ssd1306fb_set_cursor(10, -1); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "Error Counters", 1); @@ -300,7 +313,7 @@ void menu_6_disp(uint8_t idx) break; } - case 9: { + case LI_FONT_GLYPH_TEST: { ssd1306fb_set_cursor(10, -1); ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, "Font Test", 1); @@ -325,20 +338,21 @@ void menu_6_disp(uint8_t idx) // buttons switch (idx) { - case 0: - case 1: - case 2: - case 3: - case 4: { + case LI_ABOUT: + case LI_CONTACT: + case LI_LED_1_4: + case LI_LED_5_8: + case LI_LED_9_12: + case LI_CPU_USAGE: { menu_btn_use_std(); break; } - case 5: { + case LI_ACCELEROMETER: { menu_btn_use_std(); btn[2].cb_push = menu_6_accel_reset; break; } - case 9: { + case LI_FONT_GLYPH_TEST: { menu_6_btn_use(); menu_draw_buttons(MENU_BTNSTYLE_ABOUT, 0x0c); break; diff --git a/nametag8_CH592/user/ui/menu_base.c b/nametag8_CH592/user/ui/menu_base.c index f427d42..5629c5b 100644 --- a/nametag8_CH592/user/ui/menu_base.c +++ b/nametag8_CH592/user/ui/menu_base.c @@ -26,10 +26,10 @@ void menu_tick() menu->dispfn(menu_idx); // // do we flip the display? - if ((menu == &menu_6) && (menu_idx == 5)) { // about > accelerometer + if ((menu == &menu_6_about) && (menu_idx == 5)) { // about > accelerometer // accelerometer page never flips ssd1306_set_flipmirror(0); - } else if (menu != &menu_none) { // not nametag + } else if (menu != &menu_none) { // not nametag if (sysflags & SYS_OLED_ROTATE_X) { ssd1306_set_flipmirror(1); } else { @@ -173,8 +173,8 @@ void menu_draw_buttons(uint8_t mode, uint8_t mask) case MENU_BTNSTYLE_MAIN: { switch (mask) { case 0: strcpy(button_txt[1], "Resume"); break; - case 3: - case 4: strcpy(button_txt[1], "Play"); break; + //case 3: + //case 4: strcpy(button_txt[1], "Play"); break; default: strcpy(button_txt[1], "Select"); break; } strcpy(button_txt[3], " "); diff --git a/nametag8_CH592/user/ui/menu_def.c b/nametag8_CH592/user/ui/menu_def.c index a932201..c52801e 100644 --- a/nametag8_CH592/user/ui/menu_def.c +++ b/nametag8_CH592/user/ui/menu_def.c @@ -15,31 +15,31 @@ const MenuItem menu_none = {1, 0, 0, 0, &menu_none_disp, &menu_start}; // root menu - // exit, snek, morble, set name, leds, options, about + // exit (nametag), name setup, led setup, messages, i2c sniffer, options, about const MenuItem menu_0 = {7, MENU_FLAG_SCROLL, 0, 0, &menu_0_disp, &menu_0_enter}; // name menu // set name, display mode, flip mode, font select, char spacing, y-offset, half-width, color invert -const MenuItem menu_1 = {8, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, +const MenuItem menu_1_name_setup = {8, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, (MenuItem *)&menu_0, 1, &menu_1_disp, &menu_1_enter}; // led menu // edge mode, edge setup, eyes mode, eyes setup, favcolor hue, sat, val, altcolor hue, sat, val -const MenuItem menu_2 = {10, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, +const MenuItem menu_2_led_setup = {10, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, (MenuItem *)&menu_0, 2, &menu_2_disp, &menu_2_enter}; // snek menu -const MenuItem menu_3_snek = {1, MENU_FLAG_NONE, //MENU_FLAG_SAVE_ON_EXIT, - (MenuItem *)&menu_0, 3, &snek_disp, NULL}; +//const MenuItem menu_3_snek = {1, MENU_FLAG_NONE, //MENU_FLAG_SAVE_ON_EXIT, +// (MenuItem *)&menu_0, 3, &snek_disp, NULL}; // options menu - // leds on/off, sleep on/off, sleep threshold, wake threshold, recal lightsense, factory reset, show cpu usage, show accel "angle", -const MenuItem menu_5 = {8, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, + // leds on/off, sleep time, dim time, sleep threshold, wake threshold, recal lightsense, factory reset, show cpu usage, show accel "angle", +const MenuItem menu_5_options = {9, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT, (MenuItem *)&menu_0, 5, &menu_5_disp, &menu_5_enter}; // about menu // credits, leds, leds, leds, accel, cpu usage/uptime, light/temp, errors, font test -const MenuItem menu_6 = {10, MENU_FLAG_SCROLL, +const MenuItem menu_6_about = {9, MENU_FLAG_SCROLL, (MenuItem *)&menu_0, 6, &menu_6_disp, 0}; diff --git a/nametag8_CH592/user/ui/menu_entry_7.c b/nametag8_CH592/user/ui/menu_entry_7.c deleted file mode 100644 index e69de29..0000000 diff --git a/nametag8_CH592/user/ui/menu_entry_3.c b/nametag8_CH592/user/ui/menux_snek.c similarity index 100% rename from nametag8_CH592/user/ui/menu_entry_3.c rename to nametag8_CH592/user/ui/menux_snek.c diff --git a/nametag8_CH592/user/user_config.h b/nametag8_CH592/user/user_config.h index 162fe0f..4e06e8e 100644 --- a/nametag8_CH592/user/user_config.h +++ b/nametag8_CH592/user/user_config.h @@ -84,9 +84,10 @@ typedef struct UserConf { uint8_t padding0; // 52 uint8_t ledprog_rgb[16]; // 68 uint8_t ledprog_rgb_data[16][8]; // 196 - uint8_t padding1[50]; // 246 - uint16_t lsens_dark_thresh; // 248 - uint16_t menu_timeout; // 250 + uint8_t padding1[48]; // 244 + uint16_t lsens_dark_thresh; // 246 + uint16_t menu_timeout; // 248 + uint16_t dim_timeout; // 250 uint16_t sleep_timeout; // 252 uint16_t tempcx10_offset; // 253-254 uint16_t checksum; // 255-256