1 /* 2 * Ben NanoNote and EM027AS012 E-Paper Display Adapter Board communication. 3 * 4 * Copyright (C) 2013 Paul Boddie 5 * 6 * This program is free software; you can redistribute it and/or modify it under 7 * the terms of the GNU General Public License as published by the Free Software 8 * Foundation; either version 3 of the License, or (at your option) any later 9 * version. 10 * 11 * This program is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 13 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 14 * details. 15 * 16 * You should have received a copy of the GNU General Public License along with 17 * this program. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #include <ubb/ubb.h> 21 #include <stdio.h> 22 #include <stdlib.h> 23 #include <string.h> 24 #include <signal.h> 25 #include "images.h" 26 #include "Display_Controller.h" 27 #include "bsp.h" 28 29 /** 30 * Handle termination of the process. 31 */ 32 void shutdown(int signum) 33 { 34 printf("Closing...\n"); 35 ubb_close(0); 36 exit(1); 37 } 38 39 /* Main program and basic initialisation. */ 40 41 int main(int argc, char *argv[]) 42 { 43 uint8_t *current_image, blank_image[176][33]; 44 45 signal(SIGINT, &shutdown); 46 47 if (ubb_open(0) < 0) { 48 perror("ubb_open"); 49 return 1; 50 } 51 52 ubb_power(1); 53 printf("Power on.\n"); 54 55 /* Need to initialise the board. */ 56 57 bsp_init(); 58 printf("Initialised.\n"); 59 60 /* Initialise an array containing the current image. */ 61 62 memset((uint8_t*) &blank_image[0][0], 0xff, 176*33); 63 current_image = (uint8_t*) &blank_image[0][0]; 64 printf("Set blank image.\n"); 65 66 /* Call epd_DisplayImg with the new image and current image. */ 67 68 epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image); 69 printf("Updated image. Press Enter...\n"); 70 71 fgetc(stdin); 72 73 /* Set the current image to the new image. */ 74 75 current_image = &image_data[0][0][0]; 76 77 /* Call epd_DisplayImg with the new image and current image. */ 78 79 epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[1][0][0], current_image); 80 printf("Updated image.\n"); 81 82 /* Detach from the board. */ 83 84 printf("Closing...\n"); 85 ubb_close(0); 86 87 return 0; 88 }