1 /* 2 * Ben NanoNote communication with the Nu Electronics "Color LCD & 3 * Joystick Shield" featuring a Nokia 6110 and the PCF8833 display 4 * controller. 5 * 6 * http://shieldlist.org/nuelectronics/colorlcd-joystick 7 * 8 * Copyright (C) 2013 Paul Boddie 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 */ 15 16 #ifndef __PCF8833_H__ 17 #define __PCF8833_H__ 18 19 #include <ubb/ubb.h> 20 21 /* Pin assignments: 22 * 23 * Sniffer UBB Shifters Shield 24 * ------- ---- ---------- ------ 25 * DAT2 DAT2 A1 (#2) B1 8 (BACKLIGHT) 26 * CD DAT3 A2 (#1) B2 10 (SS/CS) 27 * CMD CMD A1 (#1) B1 9 (RESET) 28 * VCC VDD LV HV VIN 29 * CLK CLK A4 (#1) B4 13 (SCLK/CLK) 30 * GND GND GND GND GND 31 * DAT0 DAT0 A3 (#1) B3 11 (MOSI/SEND) 32 * DAT1 DAT1 33 */ 34 35 #define LCD_BACKLIGHT UBB_DAT2 36 #define LCD_CS UBB_DAT3 37 #define LCD_RESET UBB_CMD 38 #define LCD_CLK UBB_CLK 39 #define LCD_SEND UBB_DAT0 40 41 typedef enum { 42 LCD_COMMAND = 0, 43 LCD_DATA = 1 44 } lcd_sendmode; 45 46 /* Screen constants. */ 47 48 #define SCREEN_WIDTH 132 49 #define SCREEN_X_MAX 131 50 #define SCREEN_HEIGHT 132 51 #define SCREEN_Y_MAX 131 52 53 /* Commands. */ 54 55 #define LCD_NOP 0x00 56 #define LCD_SWRESET 0x01 57 #define LCD_SLEEPOUT 0x11 58 #define LCD_NORON 0x13 59 #define LCD_SETCON 0x25 60 #define LCD_DISPOFF 0x28 61 #define LCD_DISPON 0x29 62 #define LCD_CASET 0x2a 63 #define LCD_PASET 0x2b 64 #define LCD_RAMWR 0x2c 65 #define LCD_VSCRDEF 0x33 66 #define LCD_SEP 0x37 67 #define LCD_MADCTL 0x36 68 #define LCD_COLMOD 0x3a 69 70 /* Command-specific constants. */ 71 72 #define LCD_MADCTL_MY_MX 0xc0 73 #define LCD_MADCTL_MY_V 0xa0 74 #define LCD_MADCTL_MY_MX_V 0xe0 75 #define LCD_MADCTL_MX_V 0x60 76 77 /* Functions. */ 78 79 void spi_init(); 80 void spi_begin(); 81 void spi_end(); 82 void spi_send(uint8_t v, lcd_sendmode mode); 83 84 void LCD_send(lcd_sendmode mode, uint8_t data); 85 void LCD_send_more_data(uint8_t data); 86 void LCD_send_raw(uint8_t data); 87 void LCD_init(); 88 void LCD_off(); 89 void LCD_window(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax); 90 void LCD_blit_int(uint16_t colour); 91 void LCD_area(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax, uint16_t colour); 92 void LCD_image(int x, int y, const uint16_t image[], uint8_t width, uint8_t height); 93 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); 94 void LCD_normal(); 95 void LCD_scroll_area(uint8_t top_fixed, uint8_t scrolling, uint8_t bottom_fixed); 96 void LCD_scroll_start(uint8_t address); 97 98 #endif /* __PCF8833_H__ */ 99 100 /* vim: tabstop=4 expandtab shiftwidth=4 101 */