1 /* 2 * A demonstration of bitmap plotting. 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 "pcf8833.h" 13 #include <stdio.h> 14 #include <unistd.h> 15 #include <signal.h> 16 #include <stdlib.h> 17 #include "bitmaps.h" 18 19 /** 20 * Handle termination of the process. 21 */ 22 void shutdown(int signum) 23 { 24 printf("Closing...\n"); 25 ubb_close(0); 26 exit(1); 27 } 28 29 void bitmap(uint8_t image) 30 { 31 LCD_image(0, 0, image_data[image], IMAGE_WIDTH, IMAGE_HEIGHT); 32 } 33 34 uint8_t states[] = {LCD_MADCTL_MY_MX, LCD_MADCTL_MY_V, 0, LCD_MADCTL_MX_V}; 35 36 int main(int argc, char *argv[]) 37 { 38 uint8_t state = 1; 39 uint8_t times; 40 uint8_t current_image = 0; 41 42 signal(SIGINT, shutdown); 43 44 /* Access the 8:10 port. */ 45 46 if (ubb_open(0) < 0) { 47 perror("ubb_open"); 48 return 1; 49 } 50 51 ubb_power(1); 52 printf("Power on.\n"); 53 54 spi_init(); 55 LCD_init(); 56 bitmap(current_image); 57 58 while (times--) 59 { 60 sleep(1); 61 printf("Updating...\n"); 62 63 LCD_send(LCD_COMMAND, LCD_MADCTL); 64 LCD_send(LCD_DATA, states[state]); 65 bitmap(current_image); 66 67 state = (state + 1) % 4; 68 current_image = (current_image + 1) % NUMBER_OF_IMAGES; 69 } 70 71 printf("Closing...\n"); 72 ubb_close(0); 73 return 0; 74 } 75 76 /* vim: tabstop=4 expandtab shiftwidth=4 77 */