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