1 /* 2 * Ben NanoNote communication with the Nuelectronics "Color LCD & 3 * Joystick Shield" featuring a Nokia 6100 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 * Here, the level shifters used are the Adafruit "4-channel I2C-safe 35 * Bi-directional Logic Level Converter - BSS138" boards: 36 * 37 * https://www.adafruit.com/products/757 38 */ 39 40 #define LCD_BACKLIGHT UBB_DAT2 41 #define LCD_CS UBB_DAT3 42 #define LCD_RESET UBB_CMD 43 #define LCD_CLK UBB_CLK 44 #define LCD_SEND UBB_DAT0 45 46 typedef enum { 47 LCD_COMMAND = 0, 48 LCD_DATA = 1 49 } lcd_sendmode; 50 51 /* Screen constants. */ 52 53 #define SCREEN_WIDTH 132 54 #define SCREEN_X_MAX 131 55 #define SCREEN_HEIGHT 132 56 #define SCREEN_Y_MAX 131 57 58 /* Commands. */ 59 60 #define LCD_NOP 0x00 61 #define LCD_SWRESET 0x01 62 #define LCD_SLEEPOUT 0x11 63 #define LCD_NORON 0x13 64 #define LCD_SETCON 0x25 65 #define LCD_DISPOFF 0x28 66 #define LCD_DISPON 0x29 67 #define LCD_CASET 0x2a 68 #define LCD_PASET 0x2b 69 #define LCD_RAMWR 0x2c 70 #define LCD_VSCRDEF 0x33 71 #define LCD_SEP 0x37 72 #define LCD_MADCTL 0x36 73 #define LCD_COLMOD 0x3a 74 75 /* Command-specific constants. */ 76 77 #define LCD_MADCTL_MY_MX 0xc0 78 #define LCD_MADCTL_MY_V 0xa0 79 #define LCD_MADCTL_MY_MX_V 0xe0 80 #define LCD_MADCTL_MX_V 0x60 81 82 /* Functions. */ 83 84 void spi_init(); 85 void spi_begin(); 86 void spi_end(); 87 void spi_send(uint8_t v, lcd_sendmode mode); 88 89 void LCD_send(lcd_sendmode mode, uint8_t data); 90 void LCD_send_more_data(uint8_t data); 91 void LCD_send_raw(uint8_t data); 92 void LCD_init(); 93 void LCD_off(); 94 void LCD_window(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax); 95 void LCD_blit_int(uint16_t colour); 96 void LCD_area(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax, uint16_t colour); 97 void LCD_image(int x, int y, const uint16_t image[], uint8_t width, uint8_t height); 98 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); 99 void LCD_normal(); 100 void LCD_scroll_area(uint8_t top_fixed, uint8_t scrolling, uint8_t bottom_fixed); 101 void LCD_scroll_start(uint8_t address); 102 103 #endif /* __PCF8833_H__ */ 104 105 /* vim: tabstop=4 expandtab shiftwidth=4 106 */