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 "EPD.h" 19 #include "bsp.h" 20 21 static uint8_t old_image[264 * 176 / 8], 22 new_image[264 * 176 / 8]; 23 24 /** 25 * Handle termination of the process. 26 */ 27 void shutdown(int signum) 28 { 29 printf("Closing...\n"); 30 ubb_close(0); 31 exit(1); 32 } 33 34 /* Main program and basic initialisation. */ 35 36 int main(int argc, char *argv[]) 37 { 38 signal(SIGINT, &shutdown); 39 40 if (ubb_open(0) < 0) { 41 perror("ubb_open"); 42 return 1; 43 } 44 45 /* Need to initialise the board. */ 46 47 EPD_init(EPD_2_7); 48 printf("Initialised.\n"); 49 50 /* Initialise an array containing the current image. */ 51 52 memset(old_image, 0, sizeof(old_image)); 53 /* memset(new_image, 0, sizeof(new_image)); */ 54 memcpy(new_image, (uint8_t *) image_data[0], sizeof(new_image)); 55 56 printf("Clear image.\n"); 57 58 EPD_begin(); 59 EPD_setFactor(bsp_getTemp()); 60 EPD_clear(); 61 EPD_end(); 62 63 printf("Set image.\n"); 64 65 EPD_begin(); 66 EPD_setFactor(bsp_getTemp()); 67 EPD_image_change(old_image, new_image); 68 EPD_end(); 69 70 /* memcpy(old_image, new_image, sizeof(old_image)); */ 71 72 printf("Closing...\n"); 73 ubb_close(0); 74 75 return 0; 76 }