Here goes nothing

This commit is contained in:
Steven Tracey 2024-11-21 18:27:46 -05:00
parent 108f7b235f
commit b790dc3013
2 changed files with 41 additions and 3 deletions

View File

@ -60,12 +60,42 @@ void home(UWORD *blackImage) {
} }
EPD_2in13_V4_Display_Base(blackImage); 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) {
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':
getCode(configNames[i]);
break;
case 'q':
return;
}
}
Paint_ClearWindows(110, 5 + (i * 20), 117, 17 + (i * 20), WHITE);
Paint_DrawString(115, 5 + (i * 20), "<", &Font12, WHITE, BLACK);
}
Paint_ClearWindows();
freeCStringArray(configNames, length); freeCStringArray(configNames, length);
DEV_Delay_ms(2000); DEV_Delay_ms(2000);
} }
void code(UWORD *blackImage) { void code(UWORD *blackImage, char* confName) {
int ch; int ch;
codeLoop: codeLoop:
while(1) { while(1) {
@ -80,13 +110,13 @@ void code(UWORD *blackImage) {
Paint_SelectImage(blackImage); Paint_SelectImage(blackImage);
Paint_Clear(WHITE); Paint_Clear(WHITE);
const char *confName = "default";
GoString confStr = {confName, strlen(confName)}; GoString confStr = {confName, strlen(confName)};
const char *code = getCode(confStr); const char *code = getCode(confStr);
DebugLine(3, 0, "Code: %s\n", code); DebugLine(3, 0, "Code: %s\n", code);
Paint_DrawString(5, 5, code, &Font36, WHITE, BLACK); Paint_DrawString(5, 5, code, &Font36, WHITE, BLACK);
Paint_DrawString(5, 100, confName, &Font12, WHITE, BLACK);
Paint_DrawRectangle(10, 112, 240, 92, WHITE, DOT_PIXEL_1X1, DRAW_FILL_EMPTY); Paint_DrawRectangle(10, 112, 240, 92, BLACK, DOT_PIXEL_1X1, DRAW_FILL_EMPTY);
EPD_2in13_V4_Display_Base(blackImage); EPD_2in13_V4_Display_Base(blackImage);
Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE); Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE);

View File

@ -151,6 +151,14 @@ func getCode(configName string) *C.char {
return cCode return cCode
} }
//export getCodeFromI
func getCodeFromI(index int) *C.char {
code := configs[index].TOTP()
cCode := C.CString(code)
runtime.KeepAlive(code)
return cCode
}
//export getTimeRemaining //export getTimeRemaining
func getTimeRemaining(n int) uint64 { func getTimeRemaining(n int) uint64 {
return uint64(n) - (uint64(time.Now().Unix()) % uint64(n)) return uint64(n) - (uint64(time.Now().Unix()) % uint64(n))