# HG changeset patch # User Paul Boddie # Date 1385321286 0 # Node ID ff34ebd6a31b712a6b3b016bb47dac571a359bdd # Parent 6aa0d0be8062dd231318d80298c23d7187e8200d Added a function to turn off the backlight, control over which seems only to work correctly with DAT2 and not DAT1 for some reason. diff -r 6aa0d0be8062 -r ff34ebd6a31b bitmap.c --- a/bitmap.c Sun Nov 24 19:01:08 2013 +0000 +++ b/bitmap.c Sun Nov 24 19:28:06 2013 +0000 @@ -26,6 +26,12 @@ exit(1); } +void lcd_shutdown(int signum) +{ + LCD_off(); + shutdown(signum); +} + void bitmap(uint8_t image) { LCD_image(0, 0, image_data[image], IMAGE_WIDTH, IMAGE_HEIGHT); @@ -53,6 +59,9 @@ spi_init(); LCD_init(); + + signal(SIGINT, lcd_shutdown); + bitmap(current_image); while (times--) @@ -68,6 +77,8 @@ current_image = (current_image + 1) % NUMBER_OF_IMAGES; } + LCD_off(); + printf("Closing...\n"); ubb_close(0); return 0; diff -r 6aa0d0be8062 -r ff34ebd6a31b pcf8833.c --- a/pcf8833.c Sun Nov 24 19:01:08 2013 +0000 +++ b/pcf8833.c Sun Nov 24 19:28:06 2013 +0000 @@ -38,6 +38,9 @@ OUT(LCD_CLK); OUT(LCD_SEND); OUT(LCD_BACKLIGHT); + + CLR(LCD_RESET); + CLR(LCD_BACKLIGHT); } void spi_begin() @@ -101,7 +104,7 @@ #endif } -void LCD_init(void) +void LCD_init() { /* Perform a hardware reset on the LCD. */ /* CS=1, CLK=0, D/C=0 apparently superfluous */ @@ -141,6 +144,13 @@ SET(LCD_BACKLIGHT); } +void LCD_off() +{ + /* Switch the backlight off. */ + + CLR(LCD_BACKLIGHT); +} + void LCD_window(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax) { LCD_send(LCD_COMMAND, LCD_CASET); @@ -224,7 +234,7 @@ LCD_send(LCD_COMMAND, LCD_NOP); } -void LCD_normal(void) +void LCD_normal() { LCD_send(LCD_COMMAND, LCD_NORON); } diff -r 6aa0d0be8062 -r ff34ebd6a31b pcf8833.h --- a/pcf8833.h Sun Nov 24 19:01:08 2013 +0000 +++ b/pcf8833.h Sun Nov 24 19:28:06 2013 +0000 @@ -22,21 +22,21 @@ * * Sniffer UBB Shifters Shield * ------- ---- ---------- ------ - * DAT2 DAT2 + * DAT2 DAT2 A1 (#2) B1 8 (BACKLIGHT) * CD DAT3 A2 (#1) B2 10 (SS/CS) * CMD CMD A1 (#1) B1 9 (RESET) * VCC VDD LV HV VIN * CLK CLK A4 (#1) B4 13 (SCLK/CLK) * GND GND GND GND GND * DAT0 DAT0 A3 (#1) B3 11 (MOSI/SEND) - * DAT1 DAT1 A1 (#2) B1 8 (BACKLIGHT) + * DAT1 DAT1 */ +#define LCD_BACKLIGHT UBB_DAT2 #define LCD_CS UBB_DAT3 #define LCD_RESET UBB_CMD #define LCD_CLK UBB_CLK #define LCD_SEND UBB_DAT0 -#define LCD_BACKLIGHT UBB_DAT1 typedef enum { LCD_COMMAND = 0, @@ -84,13 +84,14 @@ void LCD_send(lcd_sendmode mode, uint8_t data); void LCD_send_more_data(uint8_t data); void LCD_send_raw(uint8_t data); -void LCD_init(void); +void LCD_init(); +void LCD_off(); void LCD_window(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax); void LCD_blit_int(uint16_t colour); void LCD_area(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax, uint16_t colour); void LCD_image(int x, int y, const uint16_t image[], uint8_t width, uint8_t height); void LCD_image_region(int x, int y, const uint16_t image[], uint8_t width, uint8_t height, uint8_t from_x, uint8_t span_x, uint8_t from_y, uint8_t span_y); -void LCD_normal(void); +void LCD_normal(); void LCD_scroll_area(uint8_t top_fixed, uint8_t scrolling, uint8_t bottom_fixed); void LCD_scroll_start(uint8_t address); diff -r 6aa0d0be8062 -r ff34ebd6a31b spin.c --- a/spin.c Sun Nov 24 19:01:08 2013 +0000 +++ b/spin.c Sun Nov 24 19:28:06 2013 +0000 @@ -25,6 +25,12 @@ exit(1); } +void lcd_shutdown(int signum) +{ + LCD_off(); + shutdown(signum); +} + /** * Show a pattern on the screen. */ @@ -60,6 +66,8 @@ spi_init(); LCD_init(); + signal(SIGINT, lcd_shutdown); + printf("Updating...\n"); pattern(); @@ -75,6 +83,8 @@ state = (state + 1) % 4; } + LCD_off(); + printf("Closing...\n"); ubb_close(0); return 0;