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