diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 93 |
1 files changed, 93 insertions, 0 deletions
@@ -0,0 +1,93 @@ +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <g15daemon_client.h> +#include <libg15render.h> +#include <sys/stat.h> /* struct stat, fchmod (), stat (), S_ISREG, S_ISDIR */ + +int g15screen_fd; + +int main() +{ +g15canvas *canvas; + +if((g15screen_fd = new_g15_screen(G15_G15RBUF))<0) + { + fprintf(stderr,"Can't connect to G15daemon\n"); + return -1; + } + +canvas = (g15canvas *)malloc(sizeof(g15canvas)); +if(canvas != NULL){g15r_initCanvas(canvas);} +else {fprintf(stderr,"Malloc failed!\n"); return -1;} + +g15r_loadWbmpSplash(canvas,"splash.wbmp"); +g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); +sleep(1); //show logo for 1 second +g15r_clearScreen (canvas, G15_COLOR_WHITE); + +/* +//checkerboard pattern +int i,j; +for (j=0;j<G15_LCD_HEIGHT;++j) + { + if(j % 2 == 0 ){for(i=0;i<G15_LCD_WIDTH;i+=4){g15r_setPixel(canvas,i,j,1);}} + else{for(i=2;i<G15_LCD_WIDTH;i+=4){g15r_setPixel(canvas,i,j,1);}} + } +g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); +sleep(1);//sleep for 1 second +//g15r_clearScreen (canvas, G15_COLOR_WHITE); +*/ + +char image[] = "badapple/out0000.wbmp"; + +struct stat sts;//for stat + +int i,j; + +//todo: Actual proper for loops +for (;image[12]!=':';++image[12]) +{ + for(;image[13]!=':';++image[13]) + { + for (;image[14]!=':';++image[14]) + { + for (i=0;i<9;++i) + { + if ((stat(image, &sts)) == -1){goto exit;}//exit if file does not exist + g15r_loadWbmpSplash(canvas,image);//The splash function is the best option since g15r_drawXBM() doesn't seem to exist anymore + + g15_send(g15screen_fd,(char *)canvas->buffer,G15_BUFFER_LEN); + ++image[15]; + //1 second = 1000000 microseconds + //todo: Accurate frame timing. Currently too fast + usleep(42666);//~24fps + //printf("%s\n",image); + } + image[15] = '0'; + } + image[14] = '0'; + } +image[13]='0'; +} + +exit:; + +//g15r_clearScreen(canvas, G15_COLOR_WHITE); + +//g15r_drawCircle(canvas, G15_LCD_HEIGHT, 0, 30, 100, G15_COLOR_BLACK); +//g15r_drawBar(canvas, 0, 0, 40, 40, G15_COLOR_BLACK, 1,1,0); + +//space for up to 4 lines when TEXT_LARGE, 5 when TEXT_MED and 6 when TEXT_SMALL +//g15r_renderString(canvas, "Install Gentoo", 0, G15_TEXT_LARGE,0,0); + +//g15r_setPixel(canvas,0,0,1); +//g15r_setPixel(canvas,G15_LCD_WIDTH-1,G15_LCD_HEIGHT-1,1); + +//wait for enter keypress to terminate (while(1) burns CPU cycles like no tommorrow) +//while(getchar() != '\n'); + +close(g15screen_fd); +//canvas is freed by g15daemon on close(g15screen_fd) it seems +return 0; +} |