options menu clarify; factory reset menu item placeholder
This commit is contained in:
parent
82c428e1b9
commit
d1e8c49c54
|
@ -35,8 +35,8 @@ 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, show cpu usage, show accel "angle",
|
||||
const MenuItem menu_5 = {7, MENU_FLAG_SCROLL | MENU_FLAG_SAVE_ON_EXIT,
|
||||
// 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,
|
||||
(MenuItem *)&menu_0, 5, &menu_5_disp, &menu_5_enter};
|
||||
|
||||
// about menu
|
||||
|
|
|
@ -17,6 +17,18 @@
|
|||
#include <string.h>
|
||||
|
||||
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
||||
const uint16_t sleep_times[] = {
|
||||
0,
|
||||
300,
|
||||
|
@ -27,6 +39,11 @@ const uint16_t sleep_times[] = {
|
|||
};
|
||||
|
||||
|
||||
|
||||
static uint8_t factory_reset;
|
||||
|
||||
|
||||
|
||||
__HIGH_CODE
|
||||
void menu_5_disp(uint8_t idx)
|
||||
{
|
||||
|
@ -39,12 +56,12 @@ void menu_5_disp(uint8_t idx)
|
|||
|
||||
// which item selected?
|
||||
switch (idx) {
|
||||
case 0: {
|
||||
case LI_ENABLE_LEDS: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "Enable LEDs", 1);
|
||||
strcpy(txt, (uconf.flags & UCONF_FLAGS_LEDS_ENABLE) ? "On" : "Off");
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
case LI_NO_MOVE_TIMEOUT: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "No Movement Sleep Time", 0);
|
||||
if (uconf.sleep_timeout) {
|
||||
sprintf(txt, "%dmin", (uconf.sleep_timeout / 60));
|
||||
|
@ -53,17 +70,17 @@ void menu_5_disp(uint8_t idx)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
case LI_NO_MOVE_THRESH: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "No Movement Threshold", 0);
|
||||
strcpy(txt, "Normal");
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
case LI_WAKEUP_THRESH: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "Wakeup Threshold", 1);
|
||||
strcpy(txt, "Normal");
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case LI_LSENS_DARK_CAL: {
|
||||
// constantly save value at this screen
|
||||
uconf.lsens_dark_thresh = lsens_get_dark_threshold();
|
||||
// ensure LEDs are disabled when calibrating
|
||||
|
@ -73,25 +90,45 @@ void menu_5_disp(uint8_t idx)
|
|||
sprintf(txt, "%d", uconf.lsens_dark_thresh);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
case LI_FACTORY_RESET: {
|
||||
// todo: implement manual button checking here
|
||||
// yes, this means reset speed depends on framerate lol
|
||||
if (factory_reset >= 32) {
|
||||
// do the factory reset
|
||||
}
|
||||
|
||||
ssd1306fb_draw_str(font_table[0].font, "Hold Set to Factory Reset...", 0);
|
||||
//ssd1306fb_set_color(SSD1306_STATE_CLR_PIXEL);
|
||||
//ssd1306fb_draw_rect_fill(50, 18, 86, 31);
|
||||
//ssd1306fb_set_color(SSD1306_STATE_SET_PIXEL);
|
||||
txt[0] = 0;
|
||||
ssd1306fb_draw_rect(50, 18, 86, 31);
|
||||
for (w = 0; w < (factory_reset >> 1); w++) {
|
||||
ssd1306fb_draw_vline(50 + w, 18, 31);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case LI_DEBUG_SHOW_CPU: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "Debug: Show CPU%", 1);
|
||||
strcpy(txt, (uconf.flags & UCONF_FLAGS_SHOW_CPU_USAGE) ? "Yes" : "No");
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case LI_DEBUG_SHOW_ACCEL: {
|
||||
ssd1306fb_draw_str(font_table[0].font, "Debug: Show Accel", 1);
|
||||
strcpy(txt, (uconf.flags & UCONF_FLAGS_SHOW_ACCEL_ANGLE) ? "Yes" : "No");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
w = ssd1306fb_get_str_width(font_DejaVu_Sans_Mono_Bold_11, txt, strlen(txt), 1);
|
||||
x = 68 - (w >> 1);
|
||||
ssd1306fb_set_cursor(x, 18);
|
||||
ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, txt, 1);
|
||||
if (strlen(txt)) {
|
||||
w = ssd1306fb_get_str_width(font_DejaVu_Sans_Mono_Bold_11, txt, strlen(txt), 1);
|
||||
x = 68 - (w >> 1);
|
||||
ssd1306fb_set_cursor(x, 18);
|
||||
ssd1306fb_draw_str(font_DejaVu_Sans_Mono_Bold_11, txt, 1);
|
||||
|
||||
// draw box
|
||||
ssd1306fb_draw_rect(x - 2, 18, x + w + 2, 31);
|
||||
// draw box
|
||||
ssd1306fb_draw_rect(x - 2, 18, x + w + 2, 31);
|
||||
}
|
||||
|
||||
// draw extras
|
||||
menu_draw_tabs(idx);
|
||||
|
@ -104,7 +141,7 @@ void menu_5_enter(uint8_t idx)
|
|||
int i, j;
|
||||
|
||||
switch (idx) {
|
||||
case 0: {
|
||||
case LI_ENABLE_LEDS: {
|
||||
if (uconf.flags & UCONF_FLAGS_LEDS_ENABLE) {
|
||||
uconf.flags &= ~UCONF_FLAGS_LEDS_ENABLE;
|
||||
} else {
|
||||
|
@ -112,7 +149,7 @@ void menu_5_enter(uint8_t idx)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
case LI_NO_MOVE_TIMEOUT: {
|
||||
j = sizeof(sleep_times) / sizeof(sleep_times[0]);
|
||||
for (i = 0; i < j; i++) {
|
||||
if (uconf.sleep_timeout == sleep_times[i]) {
|
||||
|
@ -130,12 +167,15 @@ void menu_5_enter(uint8_t idx)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 4: {
|
||||
case LI_LSENS_DARK_CAL: {
|
||||
// reset sensor threshold to recal value
|
||||
lsens_set_dark_threshold(0xffff);
|
||||
break;
|
||||
}
|
||||
case 5: {
|
||||
case LI_FACTORY_RESET: {
|
||||
break;
|
||||
}
|
||||
case LI_DEBUG_SHOW_CPU: {
|
||||
if (uconf.flags & UCONF_FLAGS_SHOW_CPU_USAGE) {
|
||||
uconf.flags &= ~UCONF_FLAGS_SHOW_CPU_USAGE;
|
||||
} else {
|
||||
|
@ -143,7 +183,7 @@ void menu_5_enter(uint8_t idx)
|
|||
}
|
||||
break;
|
||||
}
|
||||
case 6: {
|
||||
case LI_DEBUG_SHOW_ACCEL: {
|
||||
if (uconf.flags & UCONF_FLAGS_SHOW_ACCEL_ANGLE) {
|
||||
uconf.flags &= ~UCONF_FLAGS_SHOW_ACCEL_ANGLE;
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue