parent
f9ffe8b366
commit
7e9d9aa9bc
@ -0,0 +1,66 @@ |
||||
#include <stdio.h> |
||||
#include "app_gui.h" |
||||
#include "gui_event.h" |
||||
#include "ds_rtc.h" |
||||
#include "app_io.h" |
||||
#include "lcd.h" |
||||
#include "app_config.h" |
||||
|
||||
static int value; |
||||
static int cursor; |
||||
|
||||
void screen_delka_zalivky(GuiEvent event) |
||||
{ |
||||
char buf[100]; |
||||
|
||||
switch (event) { |
||||
case GUI_EVENT_SCREEN_INIT: |
||||
value = 0; |
||||
cursor = 0; |
||||
break; |
||||
|
||||
case GUI_EVENT_PAINT: |
||||
LcdBuffer_Write(&lcd, 0, 0, "Zadej základní délku"); |
||||
LcdBuffer_Write(&lcd, 1, 0, "zálivky (1 okruh)"); |
||||
|
||||
LcdBuffer_SetCursor(&lcd, 2, cursor, CURSOR_BOTH); |
||||
|
||||
if (cursor > 0) { |
||||
snprintf(buf, 100, "%d s", value); |
||||
LcdBuffer_Write(&lcd, 2, 0, buf); |
||||
} else { |
||||
// show orig value
|
||||
snprintf(buf, 100, "%d s", settings_scratch.circuit_base_time_s); |
||||
LcdBuffer_Write(&lcd, 2, 0, buf); |
||||
} |
||||
|
||||
LcdBuffer_Write(&lcd, 3, 0, cursor == 0 ? "🅳Zrušit" : "🅳Zrušit 🅰Uložit"); |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_A: // Confirm
|
||||
if (cursor > 0) { |
||||
settings_scratch.circuit_base_time_s = value; |
||||
switch_screen(screen_settings, false); |
||||
} |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_D: // CANCEL
|
||||
switch_screen(screen_settings, false); |
||||
break; |
||||
|
||||
default: |
||||
if (event >= '0' && event <= '9') { |
||||
int digit = event - '0'; |
||||
int th2 = value * 10 + digit; |
||||
if (th2 <= 10000) { // just some sensible big number that doesn't overflow the LCD row
|
||||
value = th2; |
||||
if (cursor == 0) { |
||||
// clear the line
|
||||
LcdBuffer_Write(&lcd, 2, 0, " "); |
||||
} |
||||
cursor++; |
||||
request_paint(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,80 @@ |
||||
#include <stdio.h> |
||||
#include <string.h> |
||||
#include "app_gui.h" |
||||
#include "gui_event.h" |
||||
#include "ds_rtc.h" |
||||
#include "app_io.h" |
||||
#include "lcd.h" |
||||
#include "app_config.h" |
||||
|
||||
static uint16_t ratios[CIRCUIT_COUNT]; |
||||
static int cursor; |
||||
|
||||
void screen_kompenzace_tlaku(GuiEvent event) |
||||
{ |
||||
char buf[100]; |
||||
|
||||
switch (event) { |
||||
case GUI_EVENT_SCREEN_INIT: |
||||
cursor = 0; |
||||
memcpy(ratios, settings_scratch.circuit_time_percent, sizeof(settings_scratch.circuit_time_percent)); |
||||
break; |
||||
|
||||
case GUI_EVENT_PAINT: |
||||
LcdBuffer_Write(&lcd, 0, 0, "Relativní čas okruhů"); |
||||
|
||||
snprintf(buf, 100, "1. %3d%% 3. %3d%%", ratios[0], ratios[2]); |
||||
LcdBuffer_Write(&lcd, 1, 0, buf); |
||||
snprintf(buf, 100, "2. %3d%% 4. %3d%%", ratios[1], ratios[3]); |
||||
LcdBuffer_Write(&lcd, 2, 0, buf); |
||||
|
||||
switch (cursor) { |
||||
case 0: |
||||
LcdBuffer_SetCursor(&lcd, 1, 0, CURSOR_BOTH); |
||||
break; |
||||
case 1: |
||||
LcdBuffer_SetCursor(&lcd, 2, 0, CURSOR_BOTH); |
||||
break; |
||||
case 2: |
||||
LcdBuffer_SetCursor(&lcd, 1, 10, CURSOR_BOTH); |
||||
break; |
||||
case 3: |
||||
LcdBuffer_SetCursor(&lcd, 2, 10, CURSOR_BOTH); |
||||
break; |
||||
} |
||||
|
||||
LcdBuffer_Write(&lcd, 3, 0, "⊛- ¤+ 🅳Zruš 🅰Ulož"); |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_A: // Confirm
|
||||
memcpy(settings_scratch.circuit_time_percent, ratios, sizeof(settings_scratch.circuit_time_percent)); |
||||
switch_screen(screen_settings, false); |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_D: // CANCEL
|
||||
switch_screen(screen_settings, false); |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_1: |
||||
case GUI_EVENT_KEY_2: |
||||
case GUI_EVENT_KEY_3: |
||||
case GUI_EVENT_KEY_4: |
||||
cursor = event - '1'; |
||||
request_paint(); |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_STAR: |
||||
if (ratios[cursor] >= 5) { |
||||
ratios[cursor] -= 5; |
||||
request_paint(); |
||||
} |
||||
break; |
||||
|
||||
case GUI_EVENT_KEY_HASH: |
||||
if (ratios[cursor] < 65535) { |
||||
ratios[cursor] += 5; |
||||
request_paint(); |
||||
} |
||||
break; |
||||
} |
||||
} |
Loading…
Reference in new issue