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 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 */ 11 12 #include <ubb/ubb.h> 13 #include <stdio.h> 14 #include <stdlib.h> 15 #include <string.h> 16 #include <signal.h> 17 #include "logo.h" 18 #include "Display_Controller.h" 19 #include "bsp.h" 20 21 /** 22 * Handle termination of the process. 23 */ 24 void shutdown(int signum) 25 { 26 printf("Closing...\n"); 27 ubb_close(0); 28 exit(1); 29 } 30 31 /* Main program and basic initialisation. */ 32 33 int main(int argc, char *argv[]) 34 { 35 uint8_t *current_image, blank_image[176][33]; 36 37 signal(SIGINT, &shutdown); 38 39 if (ubb_open(0) < 0) { 40 perror("ubb_open"); 41 return 1; 42 } 43 44 ubb_power(1); 45 printf("Power on.\n"); 46 47 /* Need to initialise the board. */ 48 49 bsp_init(); 50 printf("Initialised.\n"); 51 52 /* Initialise an array containing the current image. */ 53 54 memset((uint8_t*) &blank_image[0][0], 0xff, 176*33); 55 current_image = (uint8_t*) &blank_image[0][0]; 56 printf("Set blank image.\n"); 57 58 /* Call epd_DisplayImg with the new image and current image. */ 59 60 epd_DisplayImg(DISPLAY_IN_USE, (uint8_t *) &image_data[0][0][0], current_image); 61 printf("Updated image.\n"); 62 63 /* Set the current image to the new image. */ 64 65 current_image = &image_data[0][0][0]; 66 67 printf("Closing...\n"); 68 ubb_close(0); 69 70 return 0; 71 }