![](/media/cache/group/site_id.gif.50x50_q85.jpg)
A "Hello" program for MARMEX_VB library. This application may work 40pin type mbed platforms ;) This application expects to have the MARMEX_VB module on a "MAPLE mini type-B (MARM03-BASE)" baseboard (slot2) with a MARMEX_OB module (on slot1)
Dependencies: MARMEX_VB NokiaLCD mbed
Sample code for MARMEX-VB (MARY-VB) camera module.
This is a very simple program just copies the data from camera to OELD.
NokiaLCD/NokiaLCD.cpp@2:7294334432d4, 2014-06-20 (annotated)
- Committer:
- nxpfan
- Date:
- Fri Jun 20 09:19:00 2014 +0000
- Revision:
- 2:7294334432d4
- Parent:
- 0:139f0c46d0fd
sample code with latest libraries (SPI-FIFO optimize option version)
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
nxpfan | 0:139f0c46d0fd | 1 | /* mbed Nokia LCD Library |
nxpfan | 0:139f0c46d0fd | 2 | * Copyright (c) 2007-2010, sford |
nxpfan | 0:139f0c46d0fd | 3 | */ |
nxpfan | 0:139f0c46d0fd | 4 | |
nxpfan | 0:139f0c46d0fd | 5 | #include "NokiaLCD.h" |
nxpfan | 0:139f0c46d0fd | 6 | |
nxpfan | 0:139f0c46d0fd | 7 | #include "mbed.h" |
nxpfan | 0:139f0c46d0fd | 8 | |
nxpfan | 0:139f0c46d0fd | 9 | #define NOKIALCD_ROWS 16 |
nxpfan | 0:139f0c46d0fd | 10 | #define NOKIALCD_COLS 16 |
nxpfan | 0:139f0c46d0fd | 11 | #define NOKIALCD_WIDTH 130 |
nxpfan | 0:139f0c46d0fd | 12 | #define NOKIALCD_HEIGHT 130 |
nxpfan | 0:139f0c46d0fd | 13 | #define NOKIALCD_FREQUENCY 5000000 |
nxpfan | 0:139f0c46d0fd | 14 | |
nxpfan | 0:139f0c46d0fd | 15 | NokiaLCD::NokiaLCD(PinName mosi, PinName sclk, PinName cs, PinName rst, LCDType type) |
nxpfan | 0:139f0c46d0fd | 16 | : _spi(mosi, NC, sclk) |
nxpfan | 0:139f0c46d0fd | 17 | , _rst(rst) |
nxpfan | 0:139f0c46d0fd | 18 | , _cs(cs) { |
nxpfan | 0:139f0c46d0fd | 19 | |
nxpfan | 0:139f0c46d0fd | 20 | _type = type; |
nxpfan | 0:139f0c46d0fd | 21 | |
nxpfan | 0:139f0c46d0fd | 22 | _row = 0; |
nxpfan | 0:139f0c46d0fd | 23 | _column = 0; |
nxpfan | 0:139f0c46d0fd | 24 | _foreground = 0x00FFFFFF; |
nxpfan | 0:139f0c46d0fd | 25 | _background = 0x00000000; |
nxpfan | 0:139f0c46d0fd | 26 | |
nxpfan | 0:139f0c46d0fd | 27 | reset(); |
nxpfan | 0:139f0c46d0fd | 28 | } |
nxpfan | 0:139f0c46d0fd | 29 | |
nxpfan | 0:139f0c46d0fd | 30 | void NokiaLCD::reset() { |
nxpfan | 0:139f0c46d0fd | 31 | |
nxpfan | 0:139f0c46d0fd | 32 | // setup the SPI interface and bring display out of reset |
nxpfan | 0:139f0c46d0fd | 33 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 34 | _rst = 0; |
nxpfan | 0:139f0c46d0fd | 35 | _spi.format(9); |
nxpfan | 0:139f0c46d0fd | 36 | _spi.frequency(NOKIALCD_FREQUENCY); |
nxpfan | 0:139f0c46d0fd | 37 | wait_ms(1); |
nxpfan | 0:139f0c46d0fd | 38 | _rst = 1; |
nxpfan | 0:139f0c46d0fd | 39 | wait_ms(1); |
nxpfan | 0:139f0c46d0fd | 40 | |
nxpfan | 0:139f0c46d0fd | 41 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 42 | |
nxpfan | 0:139f0c46d0fd | 43 | switch (_type) { |
nxpfan | 0:139f0c46d0fd | 44 | case LCD6100: |
nxpfan | 0:139f0c46d0fd | 45 | command(0xCA); // display control |
nxpfan | 0:139f0c46d0fd | 46 | data(0); |
nxpfan | 0:139f0c46d0fd | 47 | data(32); |
nxpfan | 0:139f0c46d0fd | 48 | data(0); |
nxpfan | 0:139f0c46d0fd | 49 | command(0xBB); |
nxpfan | 0:139f0c46d0fd | 50 | data(1); |
nxpfan | 0:139f0c46d0fd | 51 | command(0xD1); // oscillator on |
nxpfan | 0:139f0c46d0fd | 52 | command(0x94); // sleep out |
nxpfan | 0:139f0c46d0fd | 53 | command(0x20); // power control |
nxpfan | 0:139f0c46d0fd | 54 | data(0x0F); |
nxpfan | 0:139f0c46d0fd | 55 | command(0xA7); // invert display |
nxpfan | 0:139f0c46d0fd | 56 | command(0x81); // Voltage control |
nxpfan | 0:139f0c46d0fd | 57 | data(39); // contrast setting: 0..63 |
nxpfan | 0:139f0c46d0fd | 58 | data(3); // resistance ratio |
nxpfan | 0:139f0c46d0fd | 59 | wait_ms(1); |
nxpfan | 0:139f0c46d0fd | 60 | command(0xBC); |
nxpfan | 0:139f0c46d0fd | 61 | data(0); |
nxpfan | 0:139f0c46d0fd | 62 | data(1); |
nxpfan | 0:139f0c46d0fd | 63 | data(4); |
nxpfan | 0:139f0c46d0fd | 64 | command(0xAF); // turn on the display |
nxpfan | 0:139f0c46d0fd | 65 | break; |
nxpfan | 0:139f0c46d0fd | 66 | |
nxpfan | 0:139f0c46d0fd | 67 | case LCD6610: |
nxpfan | 0:139f0c46d0fd | 68 | command(0xCA); // display control |
nxpfan | 0:139f0c46d0fd | 69 | data(0); |
nxpfan | 0:139f0c46d0fd | 70 | data(31); |
nxpfan | 0:139f0c46d0fd | 71 | data(0); |
nxpfan | 0:139f0c46d0fd | 72 | command(0xBB); |
nxpfan | 0:139f0c46d0fd | 73 | data(1); |
nxpfan | 0:139f0c46d0fd | 74 | command(0xD1); // oscillator on |
nxpfan | 0:139f0c46d0fd | 75 | command(0x94); // sleep out |
nxpfan | 0:139f0c46d0fd | 76 | command(0x20); // power control |
nxpfan | 0:139f0c46d0fd | 77 | data(0x0F); |
nxpfan | 0:139f0c46d0fd | 78 | command(0xA7); // invert display |
nxpfan | 0:139f0c46d0fd | 79 | command(0x81); // Voltage control |
nxpfan | 0:139f0c46d0fd | 80 | data(39); // contrast setting: 0..63 |
nxpfan | 0:139f0c46d0fd | 81 | data(3); // resistance ratio |
nxpfan | 0:139f0c46d0fd | 82 | wait_ms(1); |
nxpfan | 0:139f0c46d0fd | 83 | command(0xBC); |
nxpfan | 0:139f0c46d0fd | 84 | data(0); |
nxpfan | 0:139f0c46d0fd | 85 | data(0); |
nxpfan | 0:139f0c46d0fd | 86 | data(2); |
nxpfan | 0:139f0c46d0fd | 87 | command(0xAF); // turn on the display |
nxpfan | 0:139f0c46d0fd | 88 | break; |
nxpfan | 0:139f0c46d0fd | 89 | |
nxpfan | 0:139f0c46d0fd | 90 | case PCF8833: |
nxpfan | 0:139f0c46d0fd | 91 | command(0x11); // sleep out |
nxpfan | 0:139f0c46d0fd | 92 | command(0x3A); // column mode |
nxpfan | 0:139f0c46d0fd | 93 | data(0x05); |
nxpfan | 0:139f0c46d0fd | 94 | command(0x36); // madctl |
nxpfan | 0:139f0c46d0fd | 95 | data(0x60); // vertical RAM, flip x |
nxpfan | 0:139f0c46d0fd | 96 | command(0x25); // setcon |
nxpfan | 0:139f0c46d0fd | 97 | data(0x30);// contrast 0x30 |
nxpfan | 0:139f0c46d0fd | 98 | wait_ms(2); |
nxpfan | 0:139f0c46d0fd | 99 | command(0x29);//DISPON |
nxpfan | 0:139f0c46d0fd | 100 | command(0x03);//BSTRON |
nxpfan | 0:139f0c46d0fd | 101 | break; |
nxpfan | 0:139f0c46d0fd | 102 | } |
nxpfan | 0:139f0c46d0fd | 103 | |
nxpfan | 0:139f0c46d0fd | 104 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 105 | |
nxpfan | 0:139f0c46d0fd | 106 | cls(); |
nxpfan | 0:139f0c46d0fd | 107 | } |
nxpfan | 0:139f0c46d0fd | 108 | |
nxpfan | 0:139f0c46d0fd | 109 | void NokiaLCD::command(int value) { |
nxpfan | 0:139f0c46d0fd | 110 | _spi.write(value & 0xFF); |
nxpfan | 0:139f0c46d0fd | 111 | } |
nxpfan | 0:139f0c46d0fd | 112 | |
nxpfan | 0:139f0c46d0fd | 113 | void NokiaLCD::data(int value) { |
nxpfan | 0:139f0c46d0fd | 114 | _spi.write(value | 0x100); |
nxpfan | 0:139f0c46d0fd | 115 | } |
nxpfan | 0:139f0c46d0fd | 116 | |
nxpfan | 0:139f0c46d0fd | 117 | void NokiaLCD::_window(int x, int y, int width, int height) { |
nxpfan | 0:139f0c46d0fd | 118 | int x1 = x + 2; |
nxpfan | 0:139f0c46d0fd | 119 | int y1 = y + 0; |
nxpfan | 0:139f0c46d0fd | 120 | int x2 = x1 + width - 1; |
nxpfan | 0:139f0c46d0fd | 121 | int y2 = y1 + height - 1; |
nxpfan | 0:139f0c46d0fd | 122 | |
nxpfan | 0:139f0c46d0fd | 123 | switch (_type) { |
nxpfan | 0:139f0c46d0fd | 124 | case LCD6100: |
nxpfan | 0:139f0c46d0fd | 125 | case LCD6610: |
nxpfan | 0:139f0c46d0fd | 126 | command(0x15); // column |
nxpfan | 0:139f0c46d0fd | 127 | data(x1); |
nxpfan | 0:139f0c46d0fd | 128 | data(x2); |
nxpfan | 0:139f0c46d0fd | 129 | command(0x75); // row |
nxpfan | 0:139f0c46d0fd | 130 | data(y1); |
nxpfan | 0:139f0c46d0fd | 131 | data(y2); |
nxpfan | 0:139f0c46d0fd | 132 | command(0x5C); // start write to ram |
nxpfan | 0:139f0c46d0fd | 133 | break; |
nxpfan | 0:139f0c46d0fd | 134 | case PCF8833: |
nxpfan | 0:139f0c46d0fd | 135 | command(0x2A); // column |
nxpfan | 0:139f0c46d0fd | 136 | data(x1); |
nxpfan | 0:139f0c46d0fd | 137 | data(x2); |
nxpfan | 0:139f0c46d0fd | 138 | command(0x2B); // row |
nxpfan | 0:139f0c46d0fd | 139 | data(y1); |
nxpfan | 0:139f0c46d0fd | 140 | data(y2); |
nxpfan | 0:139f0c46d0fd | 141 | command(0x2C); // start write to ram |
nxpfan | 0:139f0c46d0fd | 142 | break; |
nxpfan | 0:139f0c46d0fd | 143 | } |
nxpfan | 0:139f0c46d0fd | 144 | } |
nxpfan | 0:139f0c46d0fd | 145 | |
nxpfan | 0:139f0c46d0fd | 146 | void NokiaLCD::_putp(int colour) { |
nxpfan | 0:139f0c46d0fd | 147 | int gr = ((colour >> 20) & 0x0F) |
nxpfan | 0:139f0c46d0fd | 148 | | ((colour >> 8 ) & 0xF0); |
nxpfan | 0:139f0c46d0fd | 149 | int nb = ((colour >> 4 ) & 0x0F); |
nxpfan | 0:139f0c46d0fd | 150 | data(nb); |
nxpfan | 0:139f0c46d0fd | 151 | data(gr); |
nxpfan | 0:139f0c46d0fd | 152 | } |
nxpfan | 0:139f0c46d0fd | 153 | |
nxpfan | 0:139f0c46d0fd | 154 | const unsigned char FONT8x8[97][8] = { |
nxpfan | 0:139f0c46d0fd | 155 | 0x08,0x08,0x08,0x00,0x00,0x00,0x00,0x00, // columns, rows, num_bytes_per_char |
nxpfan | 0:139f0c46d0fd | 156 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, // space 0x20 |
nxpfan | 0:139f0c46d0fd | 157 | 0x30,0x78,0x78,0x30,0x30,0x00,0x30,0x00, // ! |
nxpfan | 0:139f0c46d0fd | 158 | 0x6C,0x6C,0x6C,0x00,0x00,0x00,0x00,0x00, // " |
nxpfan | 0:139f0c46d0fd | 159 | 0x6C,0x6C,0xFE,0x6C,0xFE,0x6C,0x6C,0x00, // # |
nxpfan | 0:139f0c46d0fd | 160 | 0x18,0x3E,0x60,0x3C,0x06,0x7C,0x18,0x00, // $ |
nxpfan | 0:139f0c46d0fd | 161 | 0x00,0x63,0x66,0x0C,0x18,0x33,0x63,0x00, // % |
nxpfan | 0:139f0c46d0fd | 162 | 0x1C,0x36,0x1C,0x3B,0x6E,0x66,0x3B,0x00, // & |
nxpfan | 0:139f0c46d0fd | 163 | 0x30,0x30,0x60,0x00,0x00,0x00,0x00,0x00, // ' |
nxpfan | 0:139f0c46d0fd | 164 | 0x0C,0x18,0x30,0x30,0x30,0x18,0x0C,0x00, // ( |
nxpfan | 0:139f0c46d0fd | 165 | 0x30,0x18,0x0C,0x0C,0x0C,0x18,0x30,0x00, // ) |
nxpfan | 0:139f0c46d0fd | 166 | 0x00,0x66,0x3C,0xFF,0x3C,0x66,0x00,0x00, // * |
nxpfan | 0:139f0c46d0fd | 167 | 0x00,0x30,0x30,0xFC,0x30,0x30,0x00,0x00, // + |
nxpfan | 0:139f0c46d0fd | 168 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x30, // , |
nxpfan | 0:139f0c46d0fd | 169 | 0x00,0x00,0x00,0x7E,0x00,0x00,0x00,0x00, // - |
nxpfan | 0:139f0c46d0fd | 170 | 0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x00, // . |
nxpfan | 0:139f0c46d0fd | 171 | 0x03,0x06,0x0C,0x18,0x30,0x60,0x40,0x00, // / (forward slash) |
nxpfan | 0:139f0c46d0fd | 172 | 0x3E,0x63,0x63,0x6B,0x63,0x63,0x3E,0x00, // 0 0x30 |
nxpfan | 0:139f0c46d0fd | 173 | 0x18,0x38,0x58,0x18,0x18,0x18,0x7E,0x00, // 1 |
nxpfan | 0:139f0c46d0fd | 174 | 0x3C,0x66,0x06,0x1C,0x30,0x66,0x7E,0x00, // 2 |
nxpfan | 0:139f0c46d0fd | 175 | 0x3C,0x66,0x06,0x1C,0x06,0x66,0x3C,0x00, // 3 |
nxpfan | 0:139f0c46d0fd | 176 | 0x0E,0x1E,0x36,0x66,0x7F,0x06,0x0F,0x00, // 4 |
nxpfan | 0:139f0c46d0fd | 177 | 0x7E,0x60,0x7C,0x06,0x06,0x66,0x3C,0x00, // 5 |
nxpfan | 0:139f0c46d0fd | 178 | 0x1C,0x30,0x60,0x7C,0x66,0x66,0x3C,0x00, // 6 |
nxpfan | 0:139f0c46d0fd | 179 | 0x7E,0x66,0x06,0x0C,0x18,0x18,0x18,0x00, // 7 |
nxpfan | 0:139f0c46d0fd | 180 | 0x3C,0x66,0x66,0x3C,0x66,0x66,0x3C,0x00, // 8 |
nxpfan | 0:139f0c46d0fd | 181 | 0x3C,0x66,0x66,0x3E,0x06,0x0C,0x38,0x00, // 9 |
nxpfan | 0:139f0c46d0fd | 182 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00, // : |
nxpfan | 0:139f0c46d0fd | 183 | 0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x30, // ; |
nxpfan | 0:139f0c46d0fd | 184 | 0x0C,0x18,0x30,0x60,0x30,0x18,0x0C,0x00, // < |
nxpfan | 0:139f0c46d0fd | 185 | 0x00,0x00,0x7E,0x00,0x00,0x7E,0x00,0x00, // = |
nxpfan | 0:139f0c46d0fd | 186 | 0x30,0x18,0x0C,0x06,0x0C,0x18,0x30,0x00, // > |
nxpfan | 0:139f0c46d0fd | 187 | 0x3C,0x66,0x06,0x0C,0x18,0x00,0x18,0x00, // ? |
nxpfan | 0:139f0c46d0fd | 188 | 0x3E,0x63,0x6F,0x69,0x6F,0x60,0x3E,0x00, // @ 0x40 |
nxpfan | 0:139f0c46d0fd | 189 | 0x18,0x3C,0x66,0x66,0x7E,0x66,0x66,0x00, // A |
nxpfan | 0:139f0c46d0fd | 190 | 0x7E,0x33,0x33,0x3E,0x33,0x33,0x7E,0x00, // B |
nxpfan | 0:139f0c46d0fd | 191 | 0x1E,0x33,0x60,0x60,0x60,0x33,0x1E,0x00, // C |
nxpfan | 0:139f0c46d0fd | 192 | 0x7C,0x36,0x33,0x33,0x33,0x36,0x7C,0x00, // D |
nxpfan | 0:139f0c46d0fd | 193 | 0x7F,0x31,0x34,0x3C,0x34,0x31,0x7F,0x00, // E |
nxpfan | 0:139f0c46d0fd | 194 | 0x7F,0x31,0x34,0x3C,0x34,0x30,0x78,0x00, // F |
nxpfan | 0:139f0c46d0fd | 195 | 0x1E,0x33,0x60,0x60,0x67,0x33,0x1F,0x00, // G |
nxpfan | 0:139f0c46d0fd | 196 | 0x66,0x66,0x66,0x7E,0x66,0x66,0x66,0x00, // H |
nxpfan | 0:139f0c46d0fd | 197 | 0x3C,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // I |
nxpfan | 0:139f0c46d0fd | 198 | 0x0F,0x06,0x06,0x06,0x66,0x66,0x3C,0x00, // J |
nxpfan | 0:139f0c46d0fd | 199 | 0x73,0x33,0x36,0x3C,0x36,0x33,0x73,0x00, // K |
nxpfan | 0:139f0c46d0fd | 200 | 0x78,0x30,0x30,0x30,0x31,0x33,0x7F,0x00, // L |
nxpfan | 0:139f0c46d0fd | 201 | 0x63,0x77,0x7F,0x7F,0x6B,0x63,0x63,0x00, // M |
nxpfan | 0:139f0c46d0fd | 202 | 0x63,0x73,0x7B,0x6F,0x67,0x63,0x63,0x00, // N |
nxpfan | 0:139f0c46d0fd | 203 | 0x3E,0x63,0x63,0x63,0x63,0x63,0x3E,0x00, // O |
nxpfan | 0:139f0c46d0fd | 204 | 0x7E,0x33,0x33,0x3E,0x30,0x30,0x78,0x00, // P 0x50 |
nxpfan | 0:139f0c46d0fd | 205 | 0x3C,0x66,0x66,0x66,0x6E,0x3C,0x0E,0x00, // Q |
nxpfan | 0:139f0c46d0fd | 206 | 0x7E,0x33,0x33,0x3E,0x36,0x33,0x73,0x00, // R |
nxpfan | 0:139f0c46d0fd | 207 | 0x3C,0x66,0x30,0x18,0x0C,0x66,0x3C,0x00, // S |
nxpfan | 0:139f0c46d0fd | 208 | 0x7E,0x5A,0x18,0x18,0x18,0x18,0x3C,0x00, // T |
nxpfan | 0:139f0c46d0fd | 209 | 0x66,0x66,0x66,0x66,0x66,0x66,0x7E,0x00, // U |
nxpfan | 0:139f0c46d0fd | 210 | 0x66,0x66,0x66,0x66,0x66,0x3C,0x18,0x00, // V |
nxpfan | 0:139f0c46d0fd | 211 | 0x63,0x63,0x63,0x6B,0x7F,0x77,0x63,0x00, // W |
nxpfan | 0:139f0c46d0fd | 212 | 0x63,0x63,0x36,0x1C,0x1C,0x36,0x63,0x00, // X |
nxpfan | 0:139f0c46d0fd | 213 | 0x66,0x66,0x66,0x3C,0x18,0x18,0x3C,0x00, // Y |
nxpfan | 0:139f0c46d0fd | 214 | 0x7F,0x63,0x46,0x0C,0x19,0x33,0x7F,0x00, // Z |
nxpfan | 0:139f0c46d0fd | 215 | 0x3C,0x30,0x30,0x30,0x30,0x30,0x3C,0x00, // [ |
nxpfan | 0:139f0c46d0fd | 216 | 0x60,0x30,0x18,0x0C,0x06,0x03,0x01,0x00, // \ (back slash) |
nxpfan | 0:139f0c46d0fd | 217 | 0x3C,0x0C,0x0C,0x0C,0x0C,0x0C,0x3C,0x00, // ] |
nxpfan | 0:139f0c46d0fd | 218 | 0x08,0x1C,0x36,0x63,0x00,0x00,0x00,0x00, // ^ |
nxpfan | 0:139f0c46d0fd | 219 | 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xFF, // _ |
nxpfan | 0:139f0c46d0fd | 220 | 0x18,0x18,0x0C,0x00,0x00,0x00,0x00,0x00, // ` 0x60 |
nxpfan | 0:139f0c46d0fd | 221 | 0x00,0x00,0x3C,0x06,0x3E,0x66,0x3B,0x00, // a |
nxpfan | 0:139f0c46d0fd | 222 | 0x70,0x30,0x3E,0x33,0x33,0x33,0x6E,0x00, // b |
nxpfan | 0:139f0c46d0fd | 223 | 0x00,0x00,0x3C,0x66,0x60,0x66,0x3C,0x00, // c |
nxpfan | 0:139f0c46d0fd | 224 | 0x0E,0x06,0x3E,0x66,0x66,0x66,0x3B,0x00, // d |
nxpfan | 0:139f0c46d0fd | 225 | 0x00,0x00,0x3C,0x66,0x7E,0x60,0x3C,0x00, // e |
nxpfan | 0:139f0c46d0fd | 226 | 0x1C,0x36,0x30,0x78,0x30,0x30,0x78,0x00, // f |
nxpfan | 0:139f0c46d0fd | 227 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x7C, // g |
nxpfan | 0:139f0c46d0fd | 228 | 0x70,0x30,0x36,0x3B,0x33,0x33,0x73,0x00, // h |
nxpfan | 0:139f0c46d0fd | 229 | 0x18,0x00,0x38,0x18,0x18,0x18,0x3C,0x00, // i |
nxpfan | 0:139f0c46d0fd | 230 | 0x06,0x00,0x06,0x06,0x06,0x66,0x66,0x3C, // j |
nxpfan | 0:139f0c46d0fd | 231 | 0x70,0x30,0x33,0x36,0x3C,0x36,0x73,0x00, // k |
nxpfan | 0:139f0c46d0fd | 232 | 0x38,0x18,0x18,0x18,0x18,0x18,0x3C,0x00, // l |
nxpfan | 0:139f0c46d0fd | 233 | 0x00,0x00,0x66,0x7F,0x7F,0x6B,0x63,0x00, // m |
nxpfan | 0:139f0c46d0fd | 234 | 0x00,0x00,0x7C,0x66,0x66,0x66,0x66,0x00, // n |
nxpfan | 0:139f0c46d0fd | 235 | 0x00,0x00,0x3C,0x66,0x66,0x66,0x3C,0x00, // o |
nxpfan | 0:139f0c46d0fd | 236 | 0x00,0x00,0x6E,0x33,0x33,0x3E,0x30,0x78, // p |
nxpfan | 0:139f0c46d0fd | 237 | 0x00,0x00,0x3B,0x66,0x66,0x3E,0x06,0x0F, // q |
nxpfan | 0:139f0c46d0fd | 238 | 0x00,0x00,0x6E,0x3B,0x33,0x30,0x78,0x00, // r |
nxpfan | 0:139f0c46d0fd | 239 | 0x00,0x00,0x3E,0x60,0x3C,0x06,0x7C,0x00, // s |
nxpfan | 0:139f0c46d0fd | 240 | 0x08,0x18,0x3E,0x18,0x18,0x1A,0x0C,0x00, // t |
nxpfan | 0:139f0c46d0fd | 241 | 0x00,0x00,0x66,0x66,0x66,0x66,0x3B,0x00, // u |
nxpfan | 0:139f0c46d0fd | 242 | 0x00,0x00,0x66,0x66,0x66,0x3C,0x18,0x00, // v |
nxpfan | 0:139f0c46d0fd | 243 | 0x00,0x00,0x63,0x6B,0x7F,0x7F,0x36,0x00, // w |
nxpfan | 0:139f0c46d0fd | 244 | 0x00,0x00,0x63,0x36,0x1C,0x36,0x63,0x00, // x |
nxpfan | 0:139f0c46d0fd | 245 | 0x00,0x00,0x66,0x66,0x66,0x3E,0x06,0x7C, // y |
nxpfan | 0:139f0c46d0fd | 246 | 0x00,0x00,0x7E,0x4C,0x18,0x32,0x7E,0x00, // z |
nxpfan | 0:139f0c46d0fd | 247 | 0x0E,0x18,0x18,0x70,0x18,0x18,0x0E,0x00, // { |
nxpfan | 0:139f0c46d0fd | 248 | 0x0C,0x0C,0x0C,0x00,0x0C,0x0C,0x0C,0x00, // | |
nxpfan | 0:139f0c46d0fd | 249 | 0x70,0x18,0x18,0x0E,0x18,0x18,0x70,0x00, // } |
nxpfan | 0:139f0c46d0fd | 250 | 0x3B,0x6E,0x00,0x00,0x00,0x00,0x00,0x00, // ~ |
nxpfan | 0:139f0c46d0fd | 251 | 0x1C,0x36,0x36,0x1C,0x00,0x00,0x00,0x00 |
nxpfan | 0:139f0c46d0fd | 252 | }; // DEL |
nxpfan | 0:139f0c46d0fd | 253 | |
nxpfan | 0:139f0c46d0fd | 254 | void NokiaLCD::locate(int column, int row) { |
nxpfan | 0:139f0c46d0fd | 255 | _column = column; |
nxpfan | 0:139f0c46d0fd | 256 | _row = row; |
nxpfan | 0:139f0c46d0fd | 257 | } |
nxpfan | 0:139f0c46d0fd | 258 | |
nxpfan | 0:139f0c46d0fd | 259 | void NokiaLCD::newline() { |
nxpfan | 0:139f0c46d0fd | 260 | _column = 0; |
nxpfan | 0:139f0c46d0fd | 261 | _row++; |
nxpfan | 0:139f0c46d0fd | 262 | if (_row >= _rows) { |
nxpfan | 0:139f0c46d0fd | 263 | _row = 0; |
nxpfan | 0:139f0c46d0fd | 264 | } |
nxpfan | 0:139f0c46d0fd | 265 | } |
nxpfan | 0:139f0c46d0fd | 266 | |
nxpfan | 0:139f0c46d0fd | 267 | int NokiaLCD::_putc(int value) { |
nxpfan | 0:139f0c46d0fd | 268 | int x = _column * 8; // FIXME: Char sizes |
nxpfan | 0:139f0c46d0fd | 269 | int y = _row * 8; |
nxpfan | 0:139f0c46d0fd | 270 | bitblit(x + 1, y + 1, 8, 8, (char*)&(FONT8x8[value - 0x1F][0])); |
nxpfan | 0:139f0c46d0fd | 271 | |
nxpfan | 0:139f0c46d0fd | 272 | _column++; |
nxpfan | 0:139f0c46d0fd | 273 | |
nxpfan | 0:139f0c46d0fd | 274 | if (_column >= NOKIALCD_COLS) { |
nxpfan | 0:139f0c46d0fd | 275 | _row++; |
nxpfan | 0:139f0c46d0fd | 276 | _column = 0; |
nxpfan | 0:139f0c46d0fd | 277 | } |
nxpfan | 0:139f0c46d0fd | 278 | |
nxpfan | 0:139f0c46d0fd | 279 | if (_row >= NOKIALCD_ROWS) { |
nxpfan | 0:139f0c46d0fd | 280 | _row = 0; |
nxpfan | 0:139f0c46d0fd | 281 | } |
nxpfan | 0:139f0c46d0fd | 282 | |
nxpfan | 0:139f0c46d0fd | 283 | return value; |
nxpfan | 0:139f0c46d0fd | 284 | } |
nxpfan | 0:139f0c46d0fd | 285 | |
nxpfan | 0:139f0c46d0fd | 286 | void NokiaLCD::cls() { |
nxpfan | 0:139f0c46d0fd | 287 | fill(0, 0, NOKIALCD_WIDTH, NOKIALCD_HEIGHT, _background); |
nxpfan | 0:139f0c46d0fd | 288 | _row = 0; |
nxpfan | 0:139f0c46d0fd | 289 | _column = 0; |
nxpfan | 0:139f0c46d0fd | 290 | } |
nxpfan | 0:139f0c46d0fd | 291 | |
nxpfan | 0:139f0c46d0fd | 292 | |
nxpfan | 0:139f0c46d0fd | 293 | void NokiaLCD::window(int x, int y, int width, int height) { |
nxpfan | 0:139f0c46d0fd | 294 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 295 | _window(x, y, width, height); |
nxpfan | 0:139f0c46d0fd | 296 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 297 | } |
nxpfan | 0:139f0c46d0fd | 298 | |
nxpfan | 0:139f0c46d0fd | 299 | void NokiaLCD::putp(int colour) { |
nxpfan | 0:139f0c46d0fd | 300 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 301 | _putp(colour); |
nxpfan | 0:139f0c46d0fd | 302 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 303 | } |
nxpfan | 0:139f0c46d0fd | 304 | |
nxpfan | 0:139f0c46d0fd | 305 | void NokiaLCD::pixel(int x, int y, int colour) { |
nxpfan | 0:139f0c46d0fd | 306 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 307 | _window(x, y, 1, 1); |
nxpfan | 0:139f0c46d0fd | 308 | _putp(colour); |
nxpfan | 0:139f0c46d0fd | 309 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 310 | } |
nxpfan | 0:139f0c46d0fd | 311 | |
nxpfan | 0:139f0c46d0fd | 312 | void NokiaLCD::fill(int x, int y, int width, int height, int colour) { |
nxpfan | 0:139f0c46d0fd | 313 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 314 | _window(x, y, width, height); |
nxpfan | 0:139f0c46d0fd | 315 | switch (_type) { |
nxpfan | 0:139f0c46d0fd | 316 | case LCD6100: |
nxpfan | 0:139f0c46d0fd | 317 | case PCF8833: |
nxpfan | 0:139f0c46d0fd | 318 | for (int i=0; i<width*height; i++) { |
nxpfan | 0:139f0c46d0fd | 319 | _putp(colour); |
nxpfan | 0:139f0c46d0fd | 320 | } |
nxpfan | 0:139f0c46d0fd | 321 | break; |
nxpfan | 0:139f0c46d0fd | 322 | case LCD6610: |
nxpfan | 0:139f0c46d0fd | 323 | for (int i=0; i<width*height/2; i++) { |
nxpfan | 0:139f0c46d0fd | 324 | int r4 = (colour >> (16 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 325 | int g4 = (colour >> (8 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 326 | int b4 = (colour >> (0 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 327 | int d1 = (r4 << 4) | g4; |
nxpfan | 0:139f0c46d0fd | 328 | int d2 = (b4 << 4) | r4; |
nxpfan | 0:139f0c46d0fd | 329 | int d3 = (g4 << 4) | b4; |
nxpfan | 0:139f0c46d0fd | 330 | data(d1); |
nxpfan | 0:139f0c46d0fd | 331 | data(d2); |
nxpfan | 0:139f0c46d0fd | 332 | data(d3); |
nxpfan | 0:139f0c46d0fd | 333 | } |
nxpfan | 0:139f0c46d0fd | 334 | break; |
nxpfan | 0:139f0c46d0fd | 335 | } |
nxpfan | 0:139f0c46d0fd | 336 | _window(0, 0, NOKIALCD_WIDTH, NOKIALCD_HEIGHT); |
nxpfan | 0:139f0c46d0fd | 337 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 338 | } |
nxpfan | 0:139f0c46d0fd | 339 | |
nxpfan | 0:139f0c46d0fd | 340 | void NokiaLCD::blit(int x, int y, int width, int height, const int* colour) { |
nxpfan | 0:139f0c46d0fd | 341 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 342 | _window(x, y, width, height); |
nxpfan | 0:139f0c46d0fd | 343 | |
nxpfan | 0:139f0c46d0fd | 344 | switch (_type) { |
nxpfan | 0:139f0c46d0fd | 345 | case LCD6100: |
nxpfan | 0:139f0c46d0fd | 346 | case PCF8833: |
nxpfan | 0:139f0c46d0fd | 347 | for (int i=0; i<width*height; i++) { |
nxpfan | 0:139f0c46d0fd | 348 | _putp(colour[i]); |
nxpfan | 0:139f0c46d0fd | 349 | } |
nxpfan | 0:139f0c46d0fd | 350 | break; |
nxpfan | 0:139f0c46d0fd | 351 | case LCD6610: |
nxpfan | 0:139f0c46d0fd | 352 | for (int i=0; i<width*height/2; i++) { |
nxpfan | 0:139f0c46d0fd | 353 | int r41 = (colour[i*2] >> (16 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 354 | int g41 = (colour[i*2] >> (8 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 355 | int b41 = (colour[i*2] >> (0 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 356 | |
nxpfan | 0:139f0c46d0fd | 357 | int r42 = (colour[i*2+1] >> (16 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 358 | int g42 = (colour[i*2+1] >> (8 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 359 | int b42 = (colour[i*2+1] >> (0 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 360 | int d1 = (r41 << 4) | g41; |
nxpfan | 0:139f0c46d0fd | 361 | int d2 = (b41 << 4) | r42; |
nxpfan | 0:139f0c46d0fd | 362 | int d3 = (g42 << 4) | b42; |
nxpfan | 0:139f0c46d0fd | 363 | data(d1); |
nxpfan | 0:139f0c46d0fd | 364 | data(d2); |
nxpfan | 0:139f0c46d0fd | 365 | data(d3); |
nxpfan | 0:139f0c46d0fd | 366 | } |
nxpfan | 0:139f0c46d0fd | 367 | break; |
nxpfan | 0:139f0c46d0fd | 368 | } |
nxpfan | 0:139f0c46d0fd | 369 | _window(0, 0, NOKIALCD_WIDTH, NOKIALCD_HEIGHT); |
nxpfan | 0:139f0c46d0fd | 370 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 371 | } |
nxpfan | 0:139f0c46d0fd | 372 | |
nxpfan | 0:139f0c46d0fd | 373 | void NokiaLCD::bitblit(int x, int y, int width, int height, const char* bitstream) { |
nxpfan | 0:139f0c46d0fd | 374 | _cs = 0; |
nxpfan | 0:139f0c46d0fd | 375 | _window(x, y, width, height); |
nxpfan | 0:139f0c46d0fd | 376 | |
nxpfan | 0:139f0c46d0fd | 377 | switch (_type) { |
nxpfan | 0:139f0c46d0fd | 378 | case LCD6100: |
nxpfan | 0:139f0c46d0fd | 379 | case PCF8833: |
nxpfan | 0:139f0c46d0fd | 380 | for (int i=0; i<height*width; i++) { |
nxpfan | 0:139f0c46d0fd | 381 | int byte = i / 8; |
nxpfan | 0:139f0c46d0fd | 382 | int bit = i % 8; |
nxpfan | 0:139f0c46d0fd | 383 | int colour = ((bitstream[byte] << bit) & 0x80) ? _foreground : _background; |
nxpfan | 0:139f0c46d0fd | 384 | _putp(colour); |
nxpfan | 0:139f0c46d0fd | 385 | } |
nxpfan | 0:139f0c46d0fd | 386 | break; |
nxpfan | 0:139f0c46d0fd | 387 | case LCD6610: |
nxpfan | 0:139f0c46d0fd | 388 | for(int i=0; i<height*width/2; i++) { |
nxpfan | 0:139f0c46d0fd | 389 | int byte1 = (i*2) / 8; |
nxpfan | 0:139f0c46d0fd | 390 | int bit1 = (i*2) % 8; |
nxpfan | 0:139f0c46d0fd | 391 | int colour1 = ((bitstream[byte1] << bit1) & 0x80) ? _foreground : _background; |
nxpfan | 0:139f0c46d0fd | 392 | int byte2 = (i*2+1) / 8; |
nxpfan | 0:139f0c46d0fd | 393 | int bit2 = (i*2+1) % 8; |
nxpfan | 0:139f0c46d0fd | 394 | int colour2 = ((bitstream[byte2] << bit2) & 0x80) ? _foreground : _background; |
nxpfan | 0:139f0c46d0fd | 395 | |
nxpfan | 0:139f0c46d0fd | 396 | int r41 = (colour1 >> (16 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 397 | int g41 = (colour1 >> (8 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 398 | int b41 = (colour1 >> (0 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 399 | |
nxpfan | 0:139f0c46d0fd | 400 | int r42 = (colour2 >> (16 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 401 | int g42 = (colour2 >> (8 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 402 | int b42 = (colour2 >> (0 + 4)) & 0xF; |
nxpfan | 0:139f0c46d0fd | 403 | int d1 = (r41 << 4) | g41; |
nxpfan | 0:139f0c46d0fd | 404 | int d2 = (b41 << 4) | r42; |
nxpfan | 0:139f0c46d0fd | 405 | int d3 = (g42 << 4) | b42; |
nxpfan | 0:139f0c46d0fd | 406 | data(d1); |
nxpfan | 0:139f0c46d0fd | 407 | data(d2); |
nxpfan | 0:139f0c46d0fd | 408 | data(d3); |
nxpfan | 0:139f0c46d0fd | 409 | } |
nxpfan | 0:139f0c46d0fd | 410 | break; |
nxpfan | 0:139f0c46d0fd | 411 | } |
nxpfan | 0:139f0c46d0fd | 412 | _window(0, 0, _width, _height); |
nxpfan | 0:139f0c46d0fd | 413 | _cs = 1; |
nxpfan | 0:139f0c46d0fd | 414 | } |
nxpfan | 0:139f0c46d0fd | 415 | |
nxpfan | 0:139f0c46d0fd | 416 | void NokiaLCD::foreground(int c) { |
nxpfan | 0:139f0c46d0fd | 417 | _foreground = c; |
nxpfan | 0:139f0c46d0fd | 418 | } |
nxpfan | 0:139f0c46d0fd | 419 | |
nxpfan | 0:139f0c46d0fd | 420 | void NokiaLCD::background(int c) { |
nxpfan | 0:139f0c46d0fd | 421 | _background = c; |
nxpfan | 0:139f0c46d0fd | 422 | } |
nxpfan | 0:139f0c46d0fd | 423 | |
nxpfan | 0:139f0c46d0fd | 424 | int NokiaLCD::width() { |
nxpfan | 0:139f0c46d0fd | 425 | return NOKIALCD_WIDTH; |
nxpfan | 0:139f0c46d0fd | 426 | } |
nxpfan | 0:139f0c46d0fd | 427 | |
nxpfan | 0:139f0c46d0fd | 428 | int NokiaLCD::height() { |
nxpfan | 0:139f0c46d0fd | 429 | return NOKIALCD_HEIGHT; |
nxpfan | 0:139f0c46d0fd | 430 | } |
nxpfan | 0:139f0c46d0fd | 431 | |
nxpfan | 0:139f0c46d0fd | 432 | int NokiaLCD::columns() { |
nxpfan | 0:139f0c46d0fd | 433 | return NOKIALCD_COLS; |
nxpfan | 0:139f0c46d0fd | 434 | } |
nxpfan | 0:139f0c46d0fd | 435 | |
nxpfan | 0:139f0c46d0fd | 436 | int NokiaLCD::rows() { |
nxpfan | 0:139f0c46d0fd | 437 | return NOKIALCD_ROWS; |
nxpfan | 0:139f0c46d0fd | 438 | } |