From d28af8e8b6d553c36705d990a494639aaf89eb19 Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Thu, 21 Nov 2024 22:41:13 -0500 Subject: [PATCH] Fix my mistake --- c/src/p2fa.c | 130 +++++++++++++++++++++++++-------------------------- 1 file changed, 64 insertions(+), 66 deletions(-) diff --git a/c/src/p2fa.c b/c/src/p2fa.c index 1696376..845ebc7 100644 --- a/c/src/p2fa.c +++ b/c/src/p2fa.c @@ -4,12 +4,10 @@ #include #include -#include #include #include #include "../libs/go_p2fa.h" -#include "images.h" #include "../libs/e-Paper/EPD_2in13_V4.h" #include "../libs/GUI/GUI_Paint.h" #include "../libs/GUI/GUI_BMPfile.h" @@ -35,70 +33,6 @@ void Handler(int sigNum) { exit(0); } -void home(UWORD *blackImage) { - struct getConfigNames_return configNamesReturn = getConfigNames(); - int length = configNamesReturn.r1; - char** configNames = configNamesReturn.r0; - - DebugLine(12, 0, "Len: %d\n", length); - - if (configNames == NULL || length == 0) { - DebugLine(10, 0, "No configs found\n"); - return; - } - - Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE); - EPD_2in13_V4_Init(); - Paint_SelectImage(blackImage); - Paint_Clear(WHITE); - - for (int i = 0; i < length; i++) { - if (configNames[i] == NULL) { - DebugLine(13, 0, "Null Config: %d\n", i); - } - Paint_DrawString(5, 5 + (i * 20), configNames[i], &Font12, WHITE, BLACK); - } - EPD_2in13_V4_Display_Base(blackImage); - - - Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE); - Paint_SelectImage(blackImage); - - int i = 0; - int ch; - while (1) { - timeout(-1); - ch = getch(); - if (ch != ERR) { - switch(ch) { - case KEY_UP: - if (i > 0) i--; - break; - case KEY_DOWN: - if (i < length - 1) i++; - break; - case '\n': - timeout(0); - GoString goConfigName; - goConfigName.p = configNames[i]; - goConfigName.n = strlen(configNames[i]); - getCode(goConfigName); - break; - case 'q': - return; - } - } - - Paint_ClearWindows(110, 5 + (i * 20), 117, 17 + (i * 20), WHITE); - Paint_DrawString(115, 5 + (i * 20), "<", &Font12, WHITE, BLACK); - EPD_2in13_V4_Display_Partial(blackImage); - } - - freeCStringArray(configNames, length); - - DEV_Delay_ms(2000); -} - void code(UWORD *blackImage, char* confName) { int ch; codeLoop: @@ -166,6 +100,70 @@ void code(UWORD *blackImage, char* confName) { } } +void home(UWORD *blackImage) { + struct getConfigNames_return configNamesReturn = getConfigNames(); + int length = configNamesReturn.r1; + char** configNames = configNamesReturn.r0; + + DebugLine(12, 0, "Len: %d\n", length); + + if (configNames == NULL || length == 0) { + DebugLine(10, 0, "No configs found\n"); + return; + } + + Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE); + EPD_2in13_V4_Init(); + Paint_SelectImage(blackImage); + Paint_Clear(WHITE); + + for (int i = 0; i < length; i++) { + if (configNames[i] == NULL) { + DebugLine(13, 0, "Null Config: %d\n", i); + } + Paint_DrawString(5, 5 + (i * 20), configNames[i], &Font12, WHITE, BLACK); + } + EPD_2in13_V4_Display_Base(blackImage); + + + Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE); + Paint_SelectImage(blackImage); + + int i = 0; + Paint_DrawString(115, 5 + (i * 20), "<", &Font12, WHITE, BLACK); + + int ch; + while (1) { + timeout(-1); + ch = getch(); + if (ch != ERR) { + switch(ch) { + case KEY_UP: + if (i > 0) i--; + break; + case KEY_DOWN: + if (i < length - 1) i++; + break; + case '\n': + timeout(0); + code(blackImage, configNames[i]); + break; + case 'q': + return; + } + } + + Paint_ClearWindows(115, 5 + (i * 20), 122, 17 + (i * 20), WHITE); + Paint_DrawString(115, 5 + (i * 20), "<", &Font12, WHITE, BLACK); + EPD_2in13_V4_Display_Partial(blackImage); + } + + freeCStringArray(configNames, length); + + DEV_Delay_ms(2000); +} + + int drawLoop() { if (DEV_Module_Init() != 0) { return -1;