1 /* 2 * A demonstration of area filling using different orientations. 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 18 /** 19 * Handle termination of the process. 20 */ 21 void shutdown(int signum) 22 { 23 printf("Closing...\n"); 24 ubb_close(0); 25 exit(1); 26 } 27 28 /** 29 * Show a pattern on the screen. 30 */ 31 void pattern() 32 { 33 LCD_area(0, 0, 131, 131, 0x000); 34 LCD_area(21, 21, 35, 65, 0xf800); LCD_area(21, 66, 35, 110, 0xfbe0); 35 LCD_area(36, 21, 50, 65, 0xffe0); LCD_area(36, 66, 50, 110, 0x7fe0); 36 LCD_area(51, 21, 65, 65, 0x07e0); LCD_area(51, 66, 65, 110, 0x07ef); 37 LCD_area(66, 21, 80, 65, 0x07ff); LCD_area(66, 66, 80, 110, 0x0bff); 38 LCD_area(81, 21, 95, 65, 0x001f); LCD_area(81, 66, 95, 110, 0x781f); 39 LCD_area(96, 21, 110, 65, 0xf81f); LCD_area(96, 66, 110, 110, 0xf80f); 40 } 41 42 uint8_t states[] = {LCD_MADCTL_MY_MX, LCD_MADCTL_MY_V, 0, LCD_MADCTL_MX_V}; 43 44 int main(int argc, char *argv[]) 45 { 46 uint8_t state = 1, times = 10; 47 48 signal(SIGINT, shutdown); 49 50 /* Access the 8:10 port. */ 51 52 if (ubb_open(0) < 0) { 53 perror("ubb_open"); 54 return 1; 55 } 56 57 ubb_power(1); 58 printf("Power on.\n"); 59 60 spi_init(); 61 LCD_init(); 62 63 printf("Updating...\n"); 64 pattern(); 65 66 while (times--) 67 { 68 sleep(1); 69 printf("Updating...\n"); 70 71 LCD_send(LCD_COMMAND, LCD_MADCTL); 72 LCD_send(LCD_DATA, states[state]); 73 pattern(); 74 75 state = (state + 1) % 4; 76 } 77 78 printf("Closing...\n"); 79 ubb_close(0); 80 return 0; 81 } 82 83 /* vim: tabstop=4 expandtab shiftwidth=4 84 */