1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/pcf8833.h Fri Nov 22 22:13:07 2013 +0000
1.3 @@ -0,0 +1,100 @@
1.4 +/*
1.5 + * Ben NanoNote communication with the Nu Electronics "Color LCD &
1.6 + * Joystick Shield" featuring a Nokia 6110 and the PCF8833 display
1.7 + * controller.
1.8 + *
1.9 + * http://shieldlist.org/nuelectronics/colorlcd-joystick
1.10 + *
1.11 + * Copyright (C) 2013 Paul Boddie
1.12 + *
1.13 + * This program is free software; you can redistribute it and/or modify
1.14 + * it under the terms of the GNU General Public License as published by
1.15 + * the Free Software Foundation; either version 2 of the License, or
1.16 + * (at your option) any later version.
1.17 + */
1.18 +
1.19 +#ifndef __PCF8833_H__
1.20 +#define __PCF8833_H__
1.21 +
1.22 +#include <ubb/ubb.h>
1.23 +
1.24 +/* Pin assignments:
1.25 + *
1.26 + * Sniffer UBB Shifters Shield
1.27 + * ------- ---- ---------- ------
1.28 + * DAT2 DAT2
1.29 + * CD DAT3 A2 (#1) B2 10 (SS/CS)
1.30 + * CMD CMD A1 (#1) B1 9 (RESET)
1.31 + * VCC VDD LV HV VIN
1.32 + * CLK CLK A4 (#1) B4 13 (SCLK/CLK)
1.33 + * GND GND GND GND GND
1.34 + * DAT0 DAT0 A3 (#1) B3 11 (MOSI/SEND)
1.35 + * DAT1 DAT1 A1 (#2) B1 8 (BACKLIGHT)
1.36 + */
1.37 +
1.38 +#define LCD_CS UBB_DAT3
1.39 +#define LCD_RESET UBB_CMD
1.40 +#define LCD_CLK UBB_CLK
1.41 +#define LCD_SEND UBB_DAT0
1.42 +#define LCD_BACKLIGHT UBB_DAT1
1.43 +
1.44 +typedef enum {
1.45 + LCD_COMMAND = 0,
1.46 + LCD_DATA = 1
1.47 +} lcd_sendmode;
1.48 +
1.49 +/* Screen constants. */
1.50 +
1.51 +#define SCREEN_WIDTH 132
1.52 +#define SCREEN_X_MAX 131
1.53 +#define SCREEN_HEIGHT 132
1.54 +#define SCREEN_Y_MAX 131
1.55 +
1.56 +/* Commands. */
1.57 +
1.58 +#define LCD_NOP 0x00
1.59 +#define LCD_SWRESET 0x01
1.60 +#define LCD_SLEEPOUT 0x11
1.61 +#define LCD_NORON 0x13
1.62 +#define LCD_SETCON 0x25
1.63 +#define LCD_DISPOFF 0x28
1.64 +#define LCD_DISPON 0x29
1.65 +#define LCD_CASET 0x2a
1.66 +#define LCD_PASET 0x2b
1.67 +#define LCD_RAMWR 0x2c
1.68 +#define LCD_VSCRDEF 0x33
1.69 +#define LCD_SEP 0x37
1.70 +#define LCD_MADCTL 0x36
1.71 +#define LCD_COLMOD 0x3a
1.72 +
1.73 +/* Command-specific constants. */
1.74 +
1.75 +#define LCD_MADCTL_MY_MX 0xc0
1.76 +#define LCD_MADCTL_MY_V 0xa0
1.77 +#define LCD_MADCTL_MY_MX_V 0xe0
1.78 +#define LCD_MADCTL_MX_V 0x60
1.79 +
1.80 +/* Functions. */
1.81 +
1.82 +void spi_init();
1.83 +void spi_begin();
1.84 +void spi_end();
1.85 +void spi_send(uint8_t v, lcd_sendmode mode);
1.86 +
1.87 +void LCD_send(lcd_sendmode mode, uint8_t data);
1.88 +void LCD_send_more_data(uint8_t data);
1.89 +void LCD_send_raw(uint8_t data);
1.90 +void LCD_init(void);
1.91 +void LCD_window(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax);
1.92 +void LCD_blit_int(uint16_t colour);
1.93 +void LCD_area(uint8_t xmin, uint8_t ymin, uint8_t xmax, uint8_t ymax, uint16_t colour);
1.94 +void LCD_image(int x, int y, uint16_t image[], uint8_t width, uint8_t height);
1.95 +void LCD_image_region(int x, int y, 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);
1.96 +void LCD_normal(void);
1.97 +void LCD_scroll_area(uint8_t top_fixed, uint8_t scrolling, uint8_t bottom_fixed);
1.98 +void LCD_scroll_start(uint8_t address);
1.99 +
1.100 +#endif /* __PCF8833_H__ */
1.101 +
1.102 +/* vim: tabstop=4 expandtab shiftwidth=4
1.103 + */