|
@@ -22,8 +22,9 @@
|
|
|
//#define DEVICE_INITIALIZATION
|
|
|
|
|
|
static const char welcome_message0[]= " Waveblender ";
|
|
|
-static const char welcome_message1[]= " (c) 2020 ";
|
|
|
-static const char welcome_message2[]= " danielinux ";
|
|
|
+static const char welcome_message1[]= "(c) danielinux ";
|
|
|
+static const char welcome_message2[]= " GPL v.2 ";
|
|
|
+static const char welcome_message3[]= "src: wb.vado.li";
|
|
|
|
|
|
static uint32_t last_action = 0;
|
|
|
static uint32_t offset = 0;
|
|
@@ -88,6 +89,7 @@ static void ui_display_menu_refresh(void)
|
|
|
const struct display_menu *menu = CurrentMenu;
|
|
|
uint8_t vline;
|
|
|
int i;
|
|
|
+ char txt[16];
|
|
|
display_scroll(NULL, display_cur_v);
|
|
|
display_clear(NULL);
|
|
|
|
|
@@ -95,10 +97,74 @@ static void ui_display_menu_refresh(void)
|
|
|
vline = i + 4;
|
|
|
if (vline > 7)
|
|
|
vline -= 8;
|
|
|
+ switch (menu->entry[i].type) {
|
|
|
+ case ENTRY_TYPE_TEXT:
|
|
|
+ strncpy(txt, menu->entry[i].label, 15);
|
|
|
+ break;
|
|
|
+ case ENTRY_TYPE_HEX:
|
|
|
+ {
|
|
|
+ int x = *menu->entry[i].var ;
|
|
|
+ int j;
|
|
|
+ strncpy(txt, menu->entry[i].label, 11);
|
|
|
+ for (j = strlen(menu->entry[i].label); j < 12; j++)
|
|
|
+ txt[j] = ' ';
|
|
|
+ if (x > 0xFF) {
|
|
|
+ if (((x >> 8) & 0x0F) > 9)
|
|
|
+ txt[12] = (((x >> 8) & 0x0F) - 10) + 'A';
|
|
|
+ else
|
|
|
+ txt[12] = ((x >> 8) & 0x0F) + '0';
|
|
|
+ } else
|
|
|
+ txt[12] = ' ';
|
|
|
+ if (x > 0x0F) {
|
|
|
+ if (((x >> 4) & 0x0F) > 9)
|
|
|
+ txt[13] = (((x >> 4) & 0x0F) - 10) + 'A';
|
|
|
+ else
|
|
|
+ txt[13] = ((x >> 4) & 0x0F) + '0';
|
|
|
+ } else
|
|
|
+ txt[13] = ' ';
|
|
|
+ if ((x & 0x0F) > 9)
|
|
|
+ txt[14] = ((x & 0x0F) - 10) + 'A';
|
|
|
+ else
|
|
|
+ txt[14] = (x & 0x0F) + '0';
|
|
|
+ }
|
|
|
+
|
|
|
+ break;
|
|
|
+ case ENTRY_TYPE_BOOL:
|
|
|
+ {
|
|
|
+ int x = *menu->entry[i].var ;
|
|
|
+ int j;
|
|
|
+ strncpy(txt, menu->entry[i].label, 10);
|
|
|
+ for (j = strlen(menu->entry[i].label); j < 12; j++)
|
|
|
+ txt[j] = ' ';
|
|
|
+ if (x)
|
|
|
+ strcpy(txt + 10, "[ ON]");
|
|
|
+ else
|
|
|
+ strcpy(txt + 10, "[OFF]");
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case ENTRY_TYPE_DEC:
|
|
|
+ {
|
|
|
+ int x = *menu->entry[i].var ;
|
|
|
+ int j;
|
|
|
+ strncpy(txt, menu->entry[i].label, 11);
|
|
|
+ for (j = strlen(menu->entry[i].label); j < 12; j++)
|
|
|
+ txt[j] = ' ';
|
|
|
+ if (x > 99) {
|
|
|
+ txt[12] = (x / 100) + '0';
|
|
|
+ } else
|
|
|
+ txt[12] = ' ';
|
|
|
+ if (x > 9) {
|
|
|
+ txt[13] = ((x % 100)/10) + '0';
|
|
|
+ } else
|
|
|
+ txt[13] = ' ';
|
|
|
+ txt[14] = (x % 10) + '0';
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
if (i == menu_selection)
|
|
|
- display_text_inverse(vline, menu->entry[i].title);
|
|
|
+ display_text_inverse(vline, txt);
|
|
|
else
|
|
|
- display_text(vline, menu->entry[i].title);
|
|
|
+ display_text(vline, txt);
|
|
|
}
|
|
|
WFI();
|
|
|
}
|
|
@@ -115,32 +181,52 @@ void ui_display_menu(const struct display_menu *menu)
|
|
|
|
|
|
void ui_button_press(uint8_t b, int hold)
|
|
|
{
|
|
|
- if (b == '+') {
|
|
|
- int n = menu_selection;
|
|
|
- menu_selection = 0;
|
|
|
- if (CurrentMenu->entry[n].action) {
|
|
|
- display_cur_v = 0;
|
|
|
- display_clear(NULL);
|
|
|
- display_scroll(NULL, display_cur_v);
|
|
|
- CurrentMenu->entry[n].action(
|
|
|
- CurrentMenu->entry[n].arg);
|
|
|
-
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
- if (b == 'U') {
|
|
|
- if (menu_selection > 0) {
|
|
|
- menu_selection--;
|
|
|
- ui_menu_autoscroll();
|
|
|
- ui_display_menu_refresh();
|
|
|
- }
|
|
|
- }
|
|
|
- if (b == 'D') {
|
|
|
- if (menu_selection < CurrentMenu->entry_n - 1) {
|
|
|
- menu_selection++;
|
|
|
- ui_menu_autoscroll();
|
|
|
- ui_display_menu_refresh();
|
|
|
- }
|
|
|
+ int n = menu_selection;
|
|
|
+ struct display_menu_entry e;
|
|
|
+ switch (b) {
|
|
|
+ case 'U':
|
|
|
+ if (menu_selection > 0) {
|
|
|
+ menu_selection--;
|
|
|
+ ui_menu_autoscroll();
|
|
|
+ ui_display_menu_refresh();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 'D':
|
|
|
+ if (menu_selection < CurrentMenu->entry_n - 1) {
|
|
|
+ menu_selection++;
|
|
|
+ ui_menu_autoscroll();
|
|
|
+ ui_display_menu_refresh();
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ e = CurrentMenu->entry[n];
|
|
|
+ int changed = 0;
|
|
|
+ /* Default actions for '-', '+', '*' */
|
|
|
+ if (e.var && (e.type == ENTRY_TYPE_BOOL)) {
|
|
|
+ if ((*e.var) && ((b == '-') || (b == '*'))) {
|
|
|
+ *e.var = 0;
|
|
|
+ changed = 1;
|
|
|
+ } else if ((!(*e.var)) && ((b == '+') || (b == '*'))) {
|
|
|
+ *e.var = 1;
|
|
|
+ changed = 1;
|
|
|
+ }
|
|
|
+ } else if ((e.min != e.max) && e.var && ((e.type == ENTRY_TYPE_DEC) || (e.type == ENTRY_TYPE_DEC))) {
|
|
|
+ if ((*e.var > e.min) && (b == '-')) {
|
|
|
+ *e.var -= e.step;
|
|
|
+ changed = 1;
|
|
|
+ } else if ((*e.var < e.max) && (b == '+')) {
|
|
|
+ *e.var += e.step;
|
|
|
+ changed = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ /* Custom actions for '-', '+', '*' (after changes are applied) */
|
|
|
+ if (b != 0 && e.action) {
|
|
|
+ e.action(&e, b);
|
|
|
+ changed = 1;
|
|
|
+ }
|
|
|
+ if (changed) {
|
|
|
+ ui_display_menu_refresh();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -152,16 +238,17 @@ void ui_init(void)
|
|
|
display_text(0, welcome_message0);
|
|
|
display_text(1, welcome_message1);
|
|
|
display_text(2, welcome_message2);
|
|
|
+ display_text(3, welcome_message3);
|
|
|
now = jiffies;
|
|
|
for (i = 0x3f; i >= 0x20; i--) {
|
|
|
display_scroll(NULL, i);
|
|
|
- while ((jiffies - now) < 30)
|
|
|
+ while ((jiffies - now) < 20)
|
|
|
WFI();
|
|
|
now = jiffies;
|
|
|
}
|
|
|
for (i = display_getcontrast(NULL); i >= 0; i--) {
|
|
|
display_setcontrast(NULL, i);
|
|
|
- while ((jiffies - now) < 10)
|
|
|
+ while ((jiffies - now) < 16)
|
|
|
WFI();
|
|
|
now = jiffies;
|
|
|
}
|