# HG changeset patch # User Paul Boddie # Date 1369665732 0 # Node ID f496318bed7884d2f1e17f901ad9a95a13fcad97 # Parent 4827a244756bfee80aac37e60f316c5ae48baa9e Added command options for either setting or blanking the display. diff -r 4827a244756b -r f496318bed78 test.c --- a/test.c Sat May 25 23:01:04 2013 +0000 +++ b/test.c Mon May 27 14:42:12 2013 +0000 @@ -21,11 +21,17 @@ #include #include #include +#include #include #include "images.h" #include "Display_Controller.h" #include "bsp.h" +typedef enum { + FALSE=0, + TRUE=1 +} bool; + /** * Handle termination of the process. */ @@ -40,7 +46,8 @@ int main(int argc, char *argv[]) { - uint8_t *current_image, blank_image[176][33]; + uint8_t *current_image, *next_image, blank_image[176][33], image_number, image_number_arg; + bool blank_screen; signal(SIGINT, &shutdown); @@ -57,26 +64,55 @@ bsp_init(); printf("Initialised.\n"); - /* Initialise an array containing the current image. */ + /* Initialise an array containing the blank image. */ memset((uint8_t*) &blank_image[0][0], 0xff, 176*33); - current_image = (uint8_t*) &blank_image[0][0]; - printf("Set blank image.\n"); + + /* Determine whether to blank the screen or leave an image on it. */ + + blank_screen = (argc > 2) && (strcmp(argv[1], "--blank") == 0); + image_number_arg = blank_screen ? 2 : 1; + + if ((argc < 2) || (!isdigit(argv[image_number_arg][0]))) + { + printf("Usage: %s [ --blank ] \n", argv[0]); + ubb_close(0); + return 1; + } + else + { + image_number = atoi(argv[image_number_arg]); + + if (image_number > MAX_IMAGE) + { + printf("Image number cannot be greater than %d.\n", MAX_IMAGE); + ubb_close(0); + return 1; + } + + /* When blanking, indicate an image presumably on screen already. */ + + if (blank_screen) + { + next_image = (uint8_t*) &blank_image[0][0]; + current_image = (uint8_t *) &image_data[image_number][0][0]; + printf("Set blank image.\n"); + } + + /* When leaving an image on screen, indicate that the screen starts off + being blank. */ + + else + { + next_image = (uint8_t *) &image_data[image_number][0][0]; + current_image = (uint8_t*) &blank_image[0][0]; + printf("Set first image.\n"); + } + } /* Call epd_DisplayImg with the new image and current image. */ - epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image); - printf("Updated image. Press Enter...\n"); - - fgetc(stdin); - - /* Set the current image to the new image. */ - - current_image = &image_data[0][0][0]; - - /* Call epd_DisplayImg with the new image and current image. */ - - epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[1][0][0], current_image); + epd_DisplayImg(DISPLAY_IN_USE, next_image, current_image); printf("Updated image.\n"); /* Detach from the board. */