Draw loop prog

This commit is contained in:
Steven Tracey 2024-11-21 15:15:56 -05:00
parent 6e320d6166
commit 84b99becb0

View File

@ -6,6 +6,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <ncurses.h>
#include "../libs/go_p2fa.h" #include "../libs/go_p2fa.h"
#include "images.h" #include "images.h"
@ -25,37 +26,29 @@ void Handler(int sigNum) {
Debug("close 5V, Module enters 0 power consumption ...\r\n"); Debug("close 5V, Module enters 0 power consumption ...\r\n");
DEV_Module_Exit(); DEV_Module_Exit();
endwin();
exit(0); exit(0);
} }
void home(UWORD *blackImage) { void home(UWORD *blackImage) {
Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE); Paint_NewImage(blackImage, EPD_2in13_V4_WIDTH, EPD_2in13_V4_HEIGHT, 0, WHITE);
EPD_2in13_V4_Init();
} }
void code(UWORD *blackImage) { void code(UWORD *blackImage) {
int ch;
}
int drawLoop() {
if (DEV_Module_Init() != 0) {
return -1;
}
EPD_2in13_V4_Init();
EPD_2in13_V4_Clear();
UBYTE *BlackImage;
UWORD ImageSize = ((EPD_2in13_V4_WIDTH % 8 == 0) ? (EPD_2in13_V4_WIDTH / 8) : (EPD_2in13_V4_WIDTH / 8 + 1)) * EPD_2in13_V4_HEIGHT;
if ((BlackImage = (UBYTE *) malloc(ImageSize)) == NULL) {
Debug("Failed to apply for black memory...\n");
return -1;
}
while(1) { while(1) {
ch = getch();
if (ch == 'q') {
break;
}
Debug("Key Pressed: %c\n", ch);
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);
EPD_2in13_V4_Init(); EPD_2in13_V4_Init();
Paint_SelectImage(BlackImage); Paint_SelectImage(blackImage);
Paint_Clear(WHITE); Paint_Clear(WHITE);
const char *confName = "default"; const char *confName = "default";
@ -105,9 +98,32 @@ int drawLoop() {
} }
} }
int drawLoop() {
if (DEV_Module_Init() != 0) {
return -1;
}
EPD_2in13_V4_Init();
EPD_2in13_V4_Clear();
UBYTE *blackImage;
UWORD ImageSize = ((EPD_2in13_V4_WIDTH % 8 == 0) ? (EPD_2in13_V4_WIDTH / 8) : (EPD_2in13_V4_WIDTH / 8 + 1)) * EPD_2in13_V4_HEIGHT;
if ((blackImage = (UBYTE *) malloc(ImageSize)) == NULL) {
Debug("Failed to apply for black memory...\n");
return -1;
}
code(blackImage);
return 0;
}
int main() { int main() {
signal(SIGINT, Handler); signal(SIGINT, Handler);
initscr();
cbreak();
noecho();
loadConfigs(); loadConfigs();
drawLoop(); drawLoop();