Fix my mistake
This commit is contained in:
parent
de66ed9ab3
commit
d28af8e8b6
130
c/src/p2fa.c
130
c/src/p2fa.c
@ -4,12 +4,10 @@
|
||||
|
||||
#include <time.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
#include <ncurses.h>
|
||||
|
||||
#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;
|
||||
|
Loading…
Reference in New Issue
Block a user