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