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