Here goes nothing
This commit is contained in:
parent
108f7b235f
commit
b790dc3013
36
c/src/p2fa.c
36
c/src/p2fa.c
@ -60,12 +60,42 @@ void home(UWORD *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);
|
||||
|
||||
DEV_Delay_ms(2000);
|
||||
}
|
||||
|
||||
void code(UWORD *blackImage) {
|
||||
void code(UWORD *blackImage, char* confName) {
|
||||
int ch;
|
||||
codeLoop:
|
||||
while(1) {
|
||||
@ -80,13 +110,13 @@ void code(UWORD *blackImage) {
|
||||
Paint_SelectImage(blackImage);
|
||||
Paint_Clear(WHITE);
|
||||
|
||||
const char *confName = "default";
|
||||
GoString confStr = {confName, strlen(confName)};
|
||||
const char *code = getCode(confStr);
|
||||
DebugLine(3, 0, "Code: %s\n", code);
|
||||
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);
|
||||
|
||||
Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 90, WHITE);
|
||||
|
@ -151,6 +151,14 @@ func getCode(configName string) *C.char {
|
||||
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
|
||||
func getTimeRemaining(n int) uint64 {
|
||||
return uint64(n) - (uint64(time.Now().Unix()) % uint64(n))
|
||||
|
Loading…
Reference in New Issue
Block a user