temp poti

Dependents:   2016-01-28_TINF_Temperatur_einlesen

Committer:
tauchi88
Date:
Thu Jan 28 19:53:13 2016 +0000
Revision:
0:4a09a5e0d6d8
temp

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tauchi88 0:4a09a5e0d6d8 1 /* mbed library for the mbed Lab Board 128*32 pixel LCD
tauchi88 0:4a09a5e0d6d8 2 * use C12832 controller
tauchi88 0:4a09a5e0d6d8 3 * Copyright (c) 2012 Peter Drescher - DC2PD
tauchi88 0:4a09a5e0d6d8 4 * Released under the MIT License: http://mbed.org/license/mit
tauchi88 0:4a09a5e0d6d8 5 *
tauchi88 0:4a09a5e0d6d8 6 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
tauchi88 0:4a09a5e0d6d8 7 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
tauchi88 0:4a09a5e0d6d8 8 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
tauchi88 0:4a09a5e0d6d8 9 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
tauchi88 0:4a09a5e0d6d8 10 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
tauchi88 0:4a09a5e0d6d8 11 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
tauchi88 0:4a09a5e0d6d8 12 * THE SOFTWARE.
tauchi88 0:4a09a5e0d6d8 13 */
tauchi88 0:4a09a5e0d6d8 14
tauchi88 0:4a09a5e0d6d8 15 // 13.10.12 initial design
tauchi88 0:4a09a5e0d6d8 16 // 25.10.12 add autorefresh of screen
tauchi88 0:4a09a5e0d6d8 17 // 25.10.12 add standart font
tauchi88 0:4a09a5e0d6d8 18
tauchi88 0:4a09a5e0d6d8 19 // optional defines :
tauchi88 0:4a09a5e0d6d8 20 // #define debug_lcd 1
tauchi88 0:4a09a5e0d6d8 21
tauchi88 0:4a09a5e0d6d8 22 #include "C12832_lcd.h"
tauchi88 0:4a09a5e0d6d8 23 #include "mbed.h"
tauchi88 0:4a09a5e0d6d8 24 #include "stdio.h"
tauchi88 0:4a09a5e0d6d8 25 #include "Small_7.h"
tauchi88 0:4a09a5e0d6d8 26
tauchi88 0:4a09a5e0d6d8 27 #define BPP 1 // Bits per pixel
tauchi88 0:4a09a5e0d6d8 28
tauchi88 0:4a09a5e0d6d8 29 C12832_LCD::C12832_LCD(const char* name)
tauchi88 0:4a09a5e0d6d8 30 : _spi(p5,NC,p7),_reset(p6),_A0(p8),_CS(p11),GraphicsDisplay(name)
tauchi88 0:4a09a5e0d6d8 31 {
tauchi88 0:4a09a5e0d6d8 32 orientation = 1;
tauchi88 0:4a09a5e0d6d8 33 draw_mode = NORMAL;
tauchi88 0:4a09a5e0d6d8 34 char_x = 0;
tauchi88 0:4a09a5e0d6d8 35 lcd_reset();
tauchi88 0:4a09a5e0d6d8 36 }
tauchi88 0:4a09a5e0d6d8 37
tauchi88 0:4a09a5e0d6d8 38 int C12832_LCD::width()
tauchi88 0:4a09a5e0d6d8 39 {
tauchi88 0:4a09a5e0d6d8 40 if (orientation == 0 || orientation == 2) return 32;
tauchi88 0:4a09a5e0d6d8 41 else return 128;
tauchi88 0:4a09a5e0d6d8 42 }
tauchi88 0:4a09a5e0d6d8 43
tauchi88 0:4a09a5e0d6d8 44 int C12832_LCD::height()
tauchi88 0:4a09a5e0d6d8 45 {
tauchi88 0:4a09a5e0d6d8 46 if (orientation == 0 || orientation == 2) return 128;
tauchi88 0:4a09a5e0d6d8 47 else return 32;
tauchi88 0:4a09a5e0d6d8 48 }
tauchi88 0:4a09a5e0d6d8 49
tauchi88 0:4a09a5e0d6d8 50
tauchi88 0:4a09a5e0d6d8 51 /*void C12832_LCD::set_orientation(unsigned int o)
tauchi88 0:4a09a5e0d6d8 52 {
tauchi88 0:4a09a5e0d6d8 53 orientation = o;
tauchi88 0:4a09a5e0d6d8 54 switch (o) {
tauchi88 0:4a09a5e0d6d8 55 case (0):
tauchi88 0:4a09a5e0d6d8 56 wr_cmd(0xA0);
tauchi88 0:4a09a5e0d6d8 57 wr_cmd(0xC0);
tauchi88 0:4a09a5e0d6d8 58 break;
tauchi88 0:4a09a5e0d6d8 59 case (1):
tauchi88 0:4a09a5e0d6d8 60 wr_cmd(0xA0);
tauchi88 0:4a09a5e0d6d8 61 wr_cmd(0xC8);
tauchi88 0:4a09a5e0d6d8 62 break;
tauchi88 0:4a09a5e0d6d8 63 case (2):
tauchi88 0:4a09a5e0d6d8 64 wr_cmd(0xA1);
tauchi88 0:4a09a5e0d6d8 65 wr_cmd(0xC8);
tauchi88 0:4a09a5e0d6d8 66 break;
tauchi88 0:4a09a5e0d6d8 67 case (3):
tauchi88 0:4a09a5e0d6d8 68 wr_cmd(0xA1);
tauchi88 0:4a09a5e0d6d8 69 wr_cmd(0xC0);
tauchi88 0:4a09a5e0d6d8 70 break;
tauchi88 0:4a09a5e0d6d8 71 }
tauchi88 0:4a09a5e0d6d8 72 }
tauchi88 0:4a09a5e0d6d8 73
tauchi88 0:4a09a5e0d6d8 74 */
tauchi88 0:4a09a5e0d6d8 75
tauchi88 0:4a09a5e0d6d8 76 void C12832_LCD::invert(unsigned int o)
tauchi88 0:4a09a5e0d6d8 77 {
tauchi88 0:4a09a5e0d6d8 78 if(o == 0) wr_cmd(0xA6);
tauchi88 0:4a09a5e0d6d8 79 else wr_cmd(0xA7);
tauchi88 0:4a09a5e0d6d8 80 }
tauchi88 0:4a09a5e0d6d8 81
tauchi88 0:4a09a5e0d6d8 82
tauchi88 0:4a09a5e0d6d8 83 void C12832_LCD::set_contrast(unsigned int o)
tauchi88 0:4a09a5e0d6d8 84 {
tauchi88 0:4a09a5e0d6d8 85 contrast = o;
tauchi88 0:4a09a5e0d6d8 86 wr_cmd(0x81); // set volume
tauchi88 0:4a09a5e0d6d8 87 wr_cmd(o & 0x3F);
tauchi88 0:4a09a5e0d6d8 88 }
tauchi88 0:4a09a5e0d6d8 89
tauchi88 0:4a09a5e0d6d8 90 unsigned int C12832_LCD::get_contrast(void)
tauchi88 0:4a09a5e0d6d8 91 {
tauchi88 0:4a09a5e0d6d8 92 return(contrast);
tauchi88 0:4a09a5e0d6d8 93 }
tauchi88 0:4a09a5e0d6d8 94
tauchi88 0:4a09a5e0d6d8 95
tauchi88 0:4a09a5e0d6d8 96 // write command to lcd controller
tauchi88 0:4a09a5e0d6d8 97
tauchi88 0:4a09a5e0d6d8 98 void C12832_LCD::wr_cmd(unsigned char cmd)
tauchi88 0:4a09a5e0d6d8 99 {
tauchi88 0:4a09a5e0d6d8 100 _A0 = 0;
tauchi88 0:4a09a5e0d6d8 101 _CS = 0;
tauchi88 0:4a09a5e0d6d8 102 #if defined TARGET_LPC1768 // fast without mbed lib
tauchi88 0:4a09a5e0d6d8 103 LPC_SSP1->DR = cmd;
tauchi88 0:4a09a5e0d6d8 104 do {
tauchi88 0:4a09a5e0d6d8 105 } while ((LPC_SSP1->SR & 0x10) == 0x10); // wait for SPI1 idle
tauchi88 0:4a09a5e0d6d8 106 #else
tauchi88 0:4a09a5e0d6d8 107 _spi.write(cmd);
tauchi88 0:4a09a5e0d6d8 108 #endif
tauchi88 0:4a09a5e0d6d8 109 _CS = 1;
tauchi88 0:4a09a5e0d6d8 110 }
tauchi88 0:4a09a5e0d6d8 111
tauchi88 0:4a09a5e0d6d8 112 // write data to lcd controller
tauchi88 0:4a09a5e0d6d8 113
tauchi88 0:4a09a5e0d6d8 114 void C12832_LCD::wr_dat(unsigned char dat)
tauchi88 0:4a09a5e0d6d8 115 {
tauchi88 0:4a09a5e0d6d8 116 _A0 = 1;
tauchi88 0:4a09a5e0d6d8 117 _CS = 0;
tauchi88 0:4a09a5e0d6d8 118 #if defined TARGET_LPC1768 // fast without mbed lib
tauchi88 0:4a09a5e0d6d8 119 LPC_SSP1->DR = dat;
tauchi88 0:4a09a5e0d6d8 120 do {
tauchi88 0:4a09a5e0d6d8 121 } while ((LPC_SSP1->SR & 0x10) == 0x10); // wait for SPI1 idle
tauchi88 0:4a09a5e0d6d8 122 #else
tauchi88 0:4a09a5e0d6d8 123 _spi.write(dat);
tauchi88 0:4a09a5e0d6d8 124 #endif
tauchi88 0:4a09a5e0d6d8 125 _CS = 1;
tauchi88 0:4a09a5e0d6d8 126 }
tauchi88 0:4a09a5e0d6d8 127
tauchi88 0:4a09a5e0d6d8 128 // reset and init the lcd controller
tauchi88 0:4a09a5e0d6d8 129
tauchi88 0:4a09a5e0d6d8 130 void C12832_LCD::lcd_reset()
tauchi88 0:4a09a5e0d6d8 131 {
tauchi88 0:4a09a5e0d6d8 132
tauchi88 0:4a09a5e0d6d8 133 _spi.format(8,3); // 8 bit spi mode 3
tauchi88 0:4a09a5e0d6d8 134 _spi.frequency(20000000); // 19,2 Mhz SPI clock
tauchi88 0:4a09a5e0d6d8 135 DigitalOut _reset(p6);
tauchi88 0:4a09a5e0d6d8 136 _A0 = 0;
tauchi88 0:4a09a5e0d6d8 137 _CS = 1;
tauchi88 0:4a09a5e0d6d8 138 _reset = 0; // display reset
tauchi88 0:4a09a5e0d6d8 139 wait_us(50);
tauchi88 0:4a09a5e0d6d8 140 _reset = 1; // end reset
tauchi88 0:4a09a5e0d6d8 141 wait_ms(5);
tauchi88 0:4a09a5e0d6d8 142
tauchi88 0:4a09a5e0d6d8 143 /* Start Initial Sequence ----------------------------------------------------*/
tauchi88 0:4a09a5e0d6d8 144
tauchi88 0:4a09a5e0d6d8 145 wr_cmd(0xAE); // display off
tauchi88 0:4a09a5e0d6d8 146 wr_cmd(0xA2); // bias voltage
tauchi88 0:4a09a5e0d6d8 147
tauchi88 0:4a09a5e0d6d8 148 wr_cmd(0xA0);
tauchi88 0:4a09a5e0d6d8 149 wr_cmd(0xC8); // colum normal
tauchi88 0:4a09a5e0d6d8 150
tauchi88 0:4a09a5e0d6d8 151 wr_cmd(0x22); // voltage resistor ratio
tauchi88 0:4a09a5e0d6d8 152 wr_cmd(0x2F); // power on
tauchi88 0:4a09a5e0d6d8 153 //wr_cmd(0xA4); // LCD display ram
tauchi88 0:4a09a5e0d6d8 154 wr_cmd(0x40); // start line = 0
tauchi88 0:4a09a5e0d6d8 155 wr_cmd(0xAF); // display ON
tauchi88 0:4a09a5e0d6d8 156
tauchi88 0:4a09a5e0d6d8 157 wr_cmd(0x81); // set contrast
tauchi88 0:4a09a5e0d6d8 158 wr_cmd(0x17); // set contrast
tauchi88 0:4a09a5e0d6d8 159
tauchi88 0:4a09a5e0d6d8 160 wr_cmd(0xA6); // display normal
tauchi88 0:4a09a5e0d6d8 161
tauchi88 0:4a09a5e0d6d8 162
tauchi88 0:4a09a5e0d6d8 163 #if defined TARGET_LPC1768 //setup DMA channel 0
tauchi88 0:4a09a5e0d6d8 164 LPC_SC->PCONP |= (1UL << 29); // Power up the GPDMA
tauchi88 0:4a09a5e0d6d8 165 LPC_GPDMA->DMACConfig = 1; // enable DMA controller
tauchi88 0:4a09a5e0d6d8 166 LPC_GPDMA->DMACIntTCClear = 0x1;
tauchi88 0:4a09a5e0d6d8 167 LPC_GPDMA->DMACIntErrClr = 0x1;
tauchi88 0:4a09a5e0d6d8 168 LPC_GPDMACH0->DMACCLLI = 0;
tauchi88 0:4a09a5e0d6d8 169 #endif
tauchi88 0:4a09a5e0d6d8 170 // clear and update LCD
tauchi88 0:4a09a5e0d6d8 171 memset(buffer,0x00,512); // clear display buffer
tauchi88 0:4a09a5e0d6d8 172 copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 173 auto_up = 1; // switch on auto update
tauchi88 0:4a09a5e0d6d8 174 claim(stdout); // redirekt printf to lcd
tauchi88 0:4a09a5e0d6d8 175 locate(0,0);
tauchi88 0:4a09a5e0d6d8 176 set_font((unsigned char*)Small_7); // standart font
tauchi88 0:4a09a5e0d6d8 177 }
tauchi88 0:4a09a5e0d6d8 178
tauchi88 0:4a09a5e0d6d8 179 // set one pixel in buffer
tauchi88 0:4a09a5e0d6d8 180
tauchi88 0:4a09a5e0d6d8 181 void C12832_LCD::pixel(int x, int y, int color)
tauchi88 0:4a09a5e0d6d8 182 {
tauchi88 0:4a09a5e0d6d8 183 // first check parameter
tauchi88 0:4a09a5e0d6d8 184 if(x > 128 || y > 32 || x < 0 || y < 0) return;
tauchi88 0:4a09a5e0d6d8 185
tauchi88 0:4a09a5e0d6d8 186 if(draw_mode == NORMAL) {
tauchi88 0:4a09a5e0d6d8 187 if(color == 0)
tauchi88 0:4a09a5e0d6d8 188 buffer[x + ((y/8) * 128)] &= ~(1 << (y%8)); // erase pixel
tauchi88 0:4a09a5e0d6d8 189 else
tauchi88 0:4a09a5e0d6d8 190 buffer[x + ((y/8) * 128)] |= (1 << (y%8)); // set pixel
tauchi88 0:4a09a5e0d6d8 191 } else { // XOR mode
tauchi88 0:4a09a5e0d6d8 192 if(color == 1)
tauchi88 0:4a09a5e0d6d8 193 buffer[x + ((y/8) * 128)] ^= (1 << (y%8)); // xor pixel
tauchi88 0:4a09a5e0d6d8 194 }
tauchi88 0:4a09a5e0d6d8 195 }
tauchi88 0:4a09a5e0d6d8 196
tauchi88 0:4a09a5e0d6d8 197 // update lcd
tauchi88 0:4a09a5e0d6d8 198
tauchi88 0:4a09a5e0d6d8 199 void C12832_LCD::copy_to_lcd(void)
tauchi88 0:4a09a5e0d6d8 200 {
tauchi88 0:4a09a5e0d6d8 201 #ifndef TARGET_LPC1768
tauchi88 0:4a09a5e0d6d8 202 int i;
tauchi88 0:4a09a5e0d6d8 203 #endif
tauchi88 0:4a09a5e0d6d8 204 //page 0
tauchi88 0:4a09a5e0d6d8 205 wr_cmd(0x00); // set column low nibble 0
tauchi88 0:4a09a5e0d6d8 206 wr_cmd(0x10); // set column hi nibble 0
tauchi88 0:4a09a5e0d6d8 207 wr_cmd(0xB0); // set page address 0
tauchi88 0:4a09a5e0d6d8 208 _A0 = 1;
tauchi88 0:4a09a5e0d6d8 209 #if defined TARGET_LPC1768
tauchi88 0:4a09a5e0d6d8 210 _CS = 0;
tauchi88 0:4a09a5e0d6d8 211 // start 128 byte DMA transfer to SPI1
tauchi88 0:4a09a5e0d6d8 212 LPC_GPDMACH0->DMACCDestAddr = (uint32_t)&LPC_SSP1->DR; // we send to SSP1
tauchi88 0:4a09a5e0d6d8 213 LPC_SSP1->DMACR = 0x2; // Enable SSP1 for DMA.
tauchi88 0:4a09a5e0d6d8 214 LPC_GPDMA->DMACIntTCClear = 0x1;
tauchi88 0:4a09a5e0d6d8 215 LPC_GPDMA->DMACIntErrClr = 0x1;
tauchi88 0:4a09a5e0d6d8 216 LPC_GPDMACH0->DMACCSrcAddr = (uint32_t) (buffer);
tauchi88 0:4a09a5e0d6d8 217 LPC_GPDMACH0->DMACCControl = 128 | (1UL << 31) | DMA_CHANNEL_SRC_INC ; // 8 bit transfer , address increment, interrupt
tauchi88 0:4a09a5e0d6d8 218 LPC_GPDMACH0->DMACCConfig = DMA_CHANNEL_ENABLE | DMA_TRANSFER_TYPE_M2P | DMA_DEST_SSP1_TX;
tauchi88 0:4a09a5e0d6d8 219 LPC_GPDMA->DMACSoftSReq = 0x1;
tauchi88 0:4a09a5e0d6d8 220 do {
tauchi88 0:4a09a5e0d6d8 221 } while ((LPC_GPDMA->DMACRawIntTCStat & 0x01) == 0); // DMA is running
tauchi88 0:4a09a5e0d6d8 222 do {
tauchi88 0:4a09a5e0d6d8 223 } while ((LPC_SSP1->SR & 0x10) == 0x10); // SPI1 not idle
tauchi88 0:4a09a5e0d6d8 224 _CS = 1;
tauchi88 0:4a09a5e0d6d8 225 #else // no DMA
tauchi88 0:4a09a5e0d6d8 226 for(i=0;i<128;i++){
tauchi88 0:4a09a5e0d6d8 227 wr_dat(buffer[i]);
tauchi88 0:4a09a5e0d6d8 228 }
tauchi88 0:4a09a5e0d6d8 229 #endif
tauchi88 0:4a09a5e0d6d8 230
tauchi88 0:4a09a5e0d6d8 231 // page 1
tauchi88 0:4a09a5e0d6d8 232 wr_cmd(0x00); // set column low nibble 0
tauchi88 0:4a09a5e0d6d8 233 wr_cmd(0x10); // set column hi nibble 0
tauchi88 0:4a09a5e0d6d8 234 wr_cmd(0xB1); // set page address 1
tauchi88 0:4a09a5e0d6d8 235 _A0 = 1;
tauchi88 0:4a09a5e0d6d8 236 #if defined TARGET_LPC1768
tauchi88 0:4a09a5e0d6d8 237 _CS = 0;
tauchi88 0:4a09a5e0d6d8 238 // start 128 byte DMA transfer to SPI1
tauchi88 0:4a09a5e0d6d8 239 LPC_GPDMA->DMACIntTCClear = 0x1;
tauchi88 0:4a09a5e0d6d8 240 LPC_GPDMA->DMACIntErrClr = 0x1;
tauchi88 0:4a09a5e0d6d8 241 LPC_GPDMACH0->DMACCSrcAddr = (uint32_t) (buffer + 128);
tauchi88 0:4a09a5e0d6d8 242 LPC_GPDMACH0->DMACCControl = 128 | (1UL << 31) | DMA_CHANNEL_SRC_INC ; // 8 bit transfer , address increment, interrupt
tauchi88 0:4a09a5e0d6d8 243 LPC_GPDMACH0->DMACCConfig = DMA_CHANNEL_ENABLE | DMA_TRANSFER_TYPE_M2P | DMA_DEST_SSP1_TX;
tauchi88 0:4a09a5e0d6d8 244 LPC_GPDMA->DMACSoftSReq = 0x1;
tauchi88 0:4a09a5e0d6d8 245 do {
tauchi88 0:4a09a5e0d6d8 246 } while ((LPC_GPDMA->DMACRawIntTCStat & 0x01) == 0); // DMA is running
tauchi88 0:4a09a5e0d6d8 247 do {
tauchi88 0:4a09a5e0d6d8 248 } while ((LPC_SSP1->SR & 0x10) == 0x10); // SPI1 not idle
tauchi88 0:4a09a5e0d6d8 249 _CS = 1;
tauchi88 0:4a09a5e0d6d8 250 #else // no DMA
tauchi88 0:4a09a5e0d6d8 251 for(i=128;i<256;i++){
tauchi88 0:4a09a5e0d6d8 252 wr_dat(buffer[i]);
tauchi88 0:4a09a5e0d6d8 253 }
tauchi88 0:4a09a5e0d6d8 254 #endif
tauchi88 0:4a09a5e0d6d8 255
tauchi88 0:4a09a5e0d6d8 256 //page 2
tauchi88 0:4a09a5e0d6d8 257 wr_cmd(0x00); // set column low nibble 0
tauchi88 0:4a09a5e0d6d8 258 wr_cmd(0x10); // set column hi nibble 0
tauchi88 0:4a09a5e0d6d8 259 wr_cmd(0xB2); // set page address 2
tauchi88 0:4a09a5e0d6d8 260 _A0 = 1;
tauchi88 0:4a09a5e0d6d8 261 #if defined TARGET_LPC1768
tauchi88 0:4a09a5e0d6d8 262 _CS = 0;
tauchi88 0:4a09a5e0d6d8 263 // start 128 byte DMA transfer to SPI1
tauchi88 0:4a09a5e0d6d8 264 LPC_GPDMA->DMACIntTCClear = 0x1;
tauchi88 0:4a09a5e0d6d8 265 LPC_GPDMA->DMACIntErrClr = 0x1;
tauchi88 0:4a09a5e0d6d8 266 LPC_GPDMACH0->DMACCSrcAddr = (uint32_t) (buffer + 256);
tauchi88 0:4a09a5e0d6d8 267 LPC_GPDMACH0->DMACCControl = 128 | (1UL << 31) | DMA_CHANNEL_SRC_INC ; // 8 bit transfer , address increment, interrupt
tauchi88 0:4a09a5e0d6d8 268 LPC_GPDMACH0->DMACCConfig = DMA_CHANNEL_ENABLE | DMA_TRANSFER_TYPE_M2P | DMA_DEST_SSP1_TX ;
tauchi88 0:4a09a5e0d6d8 269 LPC_GPDMA->DMACSoftSReq = 0x1;
tauchi88 0:4a09a5e0d6d8 270 do {
tauchi88 0:4a09a5e0d6d8 271 } while ((LPC_GPDMA->DMACRawIntTCStat & 0x01) == 0); // DMA is running
tauchi88 0:4a09a5e0d6d8 272 do {
tauchi88 0:4a09a5e0d6d8 273 } while ((LPC_SSP1->SR & 0x10) == 0x10); // SPI1 not idle
tauchi88 0:4a09a5e0d6d8 274 _CS = 1;
tauchi88 0:4a09a5e0d6d8 275 #else // no DMA
tauchi88 0:4a09a5e0d6d8 276 for(i=256;i<384;i++){
tauchi88 0:4a09a5e0d6d8 277 wr_dat(buffer[i]);
tauchi88 0:4a09a5e0d6d8 278 }
tauchi88 0:4a09a5e0d6d8 279 #endif
tauchi88 0:4a09a5e0d6d8 280
tauchi88 0:4a09a5e0d6d8 281 //page 3
tauchi88 0:4a09a5e0d6d8 282 wr_cmd(0x00); // set column low nibble 0
tauchi88 0:4a09a5e0d6d8 283 wr_cmd(0x10); // set column hi nibble 0
tauchi88 0:4a09a5e0d6d8 284 wr_cmd(0xB3); // set page address 3
tauchi88 0:4a09a5e0d6d8 285 _A0 = 1;
tauchi88 0:4a09a5e0d6d8 286
tauchi88 0:4a09a5e0d6d8 287 _CS = 0;
tauchi88 0:4a09a5e0d6d8 288 #if defined TARGET_LPC1768
tauchi88 0:4a09a5e0d6d8 289 // start 128 byte DMA transfer to SPI1
tauchi88 0:4a09a5e0d6d8 290 LPC_GPDMA->DMACIntTCClear = 0x1;
tauchi88 0:4a09a5e0d6d8 291 LPC_GPDMA->DMACIntErrClr = 0x1;
tauchi88 0:4a09a5e0d6d8 292 LPC_GPDMACH0->DMACCSrcAddr = (uint32_t) (buffer + 384);
tauchi88 0:4a09a5e0d6d8 293 LPC_GPDMACH0->DMACCControl = 128 | (1UL << 31) | DMA_CHANNEL_SRC_INC ; // 8 bit transfer , address increment, interrupt
tauchi88 0:4a09a5e0d6d8 294 LPC_GPDMACH0->DMACCConfig = DMA_CHANNEL_ENABLE | DMA_TRANSFER_TYPE_M2P | DMA_DEST_SSP1_TX;
tauchi88 0:4a09a5e0d6d8 295 LPC_GPDMA->DMACSoftSReq = 0x1;
tauchi88 0:4a09a5e0d6d8 296 do {
tauchi88 0:4a09a5e0d6d8 297 } while ((LPC_GPDMA->DMACRawIntTCStat & 0x01) == 0); // DMA is running
tauchi88 0:4a09a5e0d6d8 298 do {
tauchi88 0:4a09a5e0d6d8 299 } while ((LPC_SSP1->SR & 0x10) == 0x10); // SPI1 not idle
tauchi88 0:4a09a5e0d6d8 300 _CS = 1;
tauchi88 0:4a09a5e0d6d8 301 #else // no DMA
tauchi88 0:4a09a5e0d6d8 302 for(i=384;i<512;i++){
tauchi88 0:4a09a5e0d6d8 303 wr_dat(buffer[i]);
tauchi88 0:4a09a5e0d6d8 304 }
tauchi88 0:4a09a5e0d6d8 305 #endif
tauchi88 0:4a09a5e0d6d8 306 }
tauchi88 0:4a09a5e0d6d8 307
tauchi88 0:4a09a5e0d6d8 308 void C12832_LCD::cls(void)
tauchi88 0:4a09a5e0d6d8 309 {
tauchi88 0:4a09a5e0d6d8 310 memset(buffer,0x00,512); // clear display buffer
tauchi88 0:4a09a5e0d6d8 311 copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 312 }
tauchi88 0:4a09a5e0d6d8 313
tauchi88 0:4a09a5e0d6d8 314
tauchi88 0:4a09a5e0d6d8 315 void C12832_LCD::line(int x0, int y0, int x1, int y1, int color)
tauchi88 0:4a09a5e0d6d8 316 {
tauchi88 0:4a09a5e0d6d8 317 int dx = 0, dy = 0;
tauchi88 0:4a09a5e0d6d8 318 int dx_sym = 0, dy_sym = 0;
tauchi88 0:4a09a5e0d6d8 319 int dx_x2 = 0, dy_x2 = 0;
tauchi88 0:4a09a5e0d6d8 320 int di = 0;
tauchi88 0:4a09a5e0d6d8 321
tauchi88 0:4a09a5e0d6d8 322 dx = x1-x0;
tauchi88 0:4a09a5e0d6d8 323 dy = y1-y0;
tauchi88 0:4a09a5e0d6d8 324
tauchi88 0:4a09a5e0d6d8 325 // if (dx == 0) { /* vertical line */
tauchi88 0:4a09a5e0d6d8 326 // if (y1 > y0) vline(x0,y0,y1,color);
tauchi88 0:4a09a5e0d6d8 327 // else vline(x0,y1,y0,color);
tauchi88 0:4a09a5e0d6d8 328 // return;
tauchi88 0:4a09a5e0d6d8 329 // }
tauchi88 0:4a09a5e0d6d8 330
tauchi88 0:4a09a5e0d6d8 331 if (dx > 0) {
tauchi88 0:4a09a5e0d6d8 332 dx_sym = 1;
tauchi88 0:4a09a5e0d6d8 333 } else {
tauchi88 0:4a09a5e0d6d8 334 dx_sym = -1;
tauchi88 0:4a09a5e0d6d8 335 }
tauchi88 0:4a09a5e0d6d8 336 // if (dy == 0) { /* horizontal line */
tauchi88 0:4a09a5e0d6d8 337 // if (x1 > x0) hline(x0,x1,y0,color);
tauchi88 0:4a09a5e0d6d8 338 // else hline(x1,x0,y0,color);
tauchi88 0:4a09a5e0d6d8 339 // return;
tauchi88 0:4a09a5e0d6d8 340 // }
tauchi88 0:4a09a5e0d6d8 341
tauchi88 0:4a09a5e0d6d8 342 if (dy > 0) {
tauchi88 0:4a09a5e0d6d8 343 dy_sym = 1;
tauchi88 0:4a09a5e0d6d8 344 } else {
tauchi88 0:4a09a5e0d6d8 345 dy_sym = -1;
tauchi88 0:4a09a5e0d6d8 346 }
tauchi88 0:4a09a5e0d6d8 347
tauchi88 0:4a09a5e0d6d8 348 dx = dx_sym*dx;
tauchi88 0:4a09a5e0d6d8 349 dy = dy_sym*dy;
tauchi88 0:4a09a5e0d6d8 350
tauchi88 0:4a09a5e0d6d8 351 dx_x2 = dx*2;
tauchi88 0:4a09a5e0d6d8 352 dy_x2 = dy*2;
tauchi88 0:4a09a5e0d6d8 353
tauchi88 0:4a09a5e0d6d8 354 if (dx >= dy) {
tauchi88 0:4a09a5e0d6d8 355 di = dy_x2 - dx;
tauchi88 0:4a09a5e0d6d8 356 while (x0 != x1) {
tauchi88 0:4a09a5e0d6d8 357
tauchi88 0:4a09a5e0d6d8 358 pixel(x0, y0, color);
tauchi88 0:4a09a5e0d6d8 359 x0 += dx_sym;
tauchi88 0:4a09a5e0d6d8 360 if (di<0) {
tauchi88 0:4a09a5e0d6d8 361 di += dy_x2;
tauchi88 0:4a09a5e0d6d8 362 } else {
tauchi88 0:4a09a5e0d6d8 363 di += dy_x2 - dx_x2;
tauchi88 0:4a09a5e0d6d8 364 y0 += dy_sym;
tauchi88 0:4a09a5e0d6d8 365 }
tauchi88 0:4a09a5e0d6d8 366 }
tauchi88 0:4a09a5e0d6d8 367 pixel(x0, y0, color);
tauchi88 0:4a09a5e0d6d8 368 } else {
tauchi88 0:4a09a5e0d6d8 369 di = dx_x2 - dy;
tauchi88 0:4a09a5e0d6d8 370 while (y0 != y1) {
tauchi88 0:4a09a5e0d6d8 371 pixel(x0, y0, color);
tauchi88 0:4a09a5e0d6d8 372 y0 += dy_sym;
tauchi88 0:4a09a5e0d6d8 373 if (di < 0) {
tauchi88 0:4a09a5e0d6d8 374 di += dx_x2;
tauchi88 0:4a09a5e0d6d8 375 } else {
tauchi88 0:4a09a5e0d6d8 376 di += dx_x2 - dy_x2;
tauchi88 0:4a09a5e0d6d8 377 x0 += dx_sym;
tauchi88 0:4a09a5e0d6d8 378 }
tauchi88 0:4a09a5e0d6d8 379 }
tauchi88 0:4a09a5e0d6d8 380 pixel(x0, y0, color);
tauchi88 0:4a09a5e0d6d8 381 }
tauchi88 0:4a09a5e0d6d8 382 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 383 }
tauchi88 0:4a09a5e0d6d8 384
tauchi88 0:4a09a5e0d6d8 385 void C12832_LCD::rect(int x0, int y0, int x1, int y1, int color)
tauchi88 0:4a09a5e0d6d8 386 {
tauchi88 0:4a09a5e0d6d8 387
tauchi88 0:4a09a5e0d6d8 388 if (x1 > x0) line(x0,y0,x1,y0,color);
tauchi88 0:4a09a5e0d6d8 389 else line(x1,y0,x0,y0,color);
tauchi88 0:4a09a5e0d6d8 390
tauchi88 0:4a09a5e0d6d8 391 if (y1 > y0) line(x0,y0,x0,y1,color);
tauchi88 0:4a09a5e0d6d8 392 else line(x0,y1,x0,y0,color);
tauchi88 0:4a09a5e0d6d8 393
tauchi88 0:4a09a5e0d6d8 394 if (x1 > x0) line(x0,y1,x1,y1,color);
tauchi88 0:4a09a5e0d6d8 395 else line(x1,y1,x0,y1,color);
tauchi88 0:4a09a5e0d6d8 396
tauchi88 0:4a09a5e0d6d8 397 if (y1 > y0) line(x1,y0,x1,y1,color);
tauchi88 0:4a09a5e0d6d8 398 else line(x1,y1,x1,y0,color);
tauchi88 0:4a09a5e0d6d8 399
tauchi88 0:4a09a5e0d6d8 400 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 401 }
tauchi88 0:4a09a5e0d6d8 402
tauchi88 0:4a09a5e0d6d8 403 void C12832_LCD::fillrect(int x0, int y0, int x1, int y1, int color)
tauchi88 0:4a09a5e0d6d8 404 {
tauchi88 0:4a09a5e0d6d8 405 int l,c,i;
tauchi88 0:4a09a5e0d6d8 406 if(x0 > x1) {
tauchi88 0:4a09a5e0d6d8 407 i = x0;
tauchi88 0:4a09a5e0d6d8 408 x0 = x1;
tauchi88 0:4a09a5e0d6d8 409 x1 = i;
tauchi88 0:4a09a5e0d6d8 410 }
tauchi88 0:4a09a5e0d6d8 411
tauchi88 0:4a09a5e0d6d8 412 if(y0 > y1) {
tauchi88 0:4a09a5e0d6d8 413 i = y0;
tauchi88 0:4a09a5e0d6d8 414 y0 = y1;
tauchi88 0:4a09a5e0d6d8 415 y1 = i;
tauchi88 0:4a09a5e0d6d8 416 }
tauchi88 0:4a09a5e0d6d8 417
tauchi88 0:4a09a5e0d6d8 418 for(l = x0; l<= x1; l ++) {
tauchi88 0:4a09a5e0d6d8 419 for(c = y0; c<= y1; c++) {
tauchi88 0:4a09a5e0d6d8 420 pixel(l,c,color);
tauchi88 0:4a09a5e0d6d8 421 }
tauchi88 0:4a09a5e0d6d8 422 }
tauchi88 0:4a09a5e0d6d8 423 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 424 }
tauchi88 0:4a09a5e0d6d8 425
tauchi88 0:4a09a5e0d6d8 426
tauchi88 0:4a09a5e0d6d8 427
tauchi88 0:4a09a5e0d6d8 428 void C12832_LCD::circle(int x0, int y0, int r, int color)
tauchi88 0:4a09a5e0d6d8 429 {
tauchi88 0:4a09a5e0d6d8 430
tauchi88 0:4a09a5e0d6d8 431 int draw_x0, draw_y0;
tauchi88 0:4a09a5e0d6d8 432 int draw_x1, draw_y1;
tauchi88 0:4a09a5e0d6d8 433 int draw_x2, draw_y2;
tauchi88 0:4a09a5e0d6d8 434 int draw_x3, draw_y3;
tauchi88 0:4a09a5e0d6d8 435 int draw_x4, draw_y4;
tauchi88 0:4a09a5e0d6d8 436 int draw_x5, draw_y5;
tauchi88 0:4a09a5e0d6d8 437 int draw_x6, draw_y6;
tauchi88 0:4a09a5e0d6d8 438 int draw_x7, draw_y7;
tauchi88 0:4a09a5e0d6d8 439 int xx, yy;
tauchi88 0:4a09a5e0d6d8 440 int di;
tauchi88 0:4a09a5e0d6d8 441 //WindowMax();
tauchi88 0:4a09a5e0d6d8 442 if (r == 0) { /* no radius */
tauchi88 0:4a09a5e0d6d8 443 return;
tauchi88 0:4a09a5e0d6d8 444 }
tauchi88 0:4a09a5e0d6d8 445
tauchi88 0:4a09a5e0d6d8 446 draw_x0 = draw_x1 = x0;
tauchi88 0:4a09a5e0d6d8 447 draw_y0 = draw_y1 = y0 + r;
tauchi88 0:4a09a5e0d6d8 448 if (draw_y0 < height()) {
tauchi88 0:4a09a5e0d6d8 449 pixel(draw_x0, draw_y0, color); /* 90 degree */
tauchi88 0:4a09a5e0d6d8 450 }
tauchi88 0:4a09a5e0d6d8 451
tauchi88 0:4a09a5e0d6d8 452 draw_x2 = draw_x3 = x0;
tauchi88 0:4a09a5e0d6d8 453 draw_y2 = draw_y3 = y0 - r;
tauchi88 0:4a09a5e0d6d8 454 if (draw_y2 >= 0) {
tauchi88 0:4a09a5e0d6d8 455 pixel(draw_x2, draw_y2, color); /* 270 degree */
tauchi88 0:4a09a5e0d6d8 456 }
tauchi88 0:4a09a5e0d6d8 457
tauchi88 0:4a09a5e0d6d8 458 draw_x4 = draw_x6 = x0 + r;
tauchi88 0:4a09a5e0d6d8 459 draw_y4 = draw_y6 = y0;
tauchi88 0:4a09a5e0d6d8 460 if (draw_x4 < width()) {
tauchi88 0:4a09a5e0d6d8 461 pixel(draw_x4, draw_y4, color); /* 0 degree */
tauchi88 0:4a09a5e0d6d8 462 }
tauchi88 0:4a09a5e0d6d8 463
tauchi88 0:4a09a5e0d6d8 464 draw_x5 = draw_x7 = x0 - r;
tauchi88 0:4a09a5e0d6d8 465 draw_y5 = draw_y7 = y0;
tauchi88 0:4a09a5e0d6d8 466 if (draw_x5>=0) {
tauchi88 0:4a09a5e0d6d8 467 pixel(draw_x5, draw_y5, color); /* 180 degree */
tauchi88 0:4a09a5e0d6d8 468 }
tauchi88 0:4a09a5e0d6d8 469
tauchi88 0:4a09a5e0d6d8 470 if (r == 1) {
tauchi88 0:4a09a5e0d6d8 471 return;
tauchi88 0:4a09a5e0d6d8 472 }
tauchi88 0:4a09a5e0d6d8 473
tauchi88 0:4a09a5e0d6d8 474 di = 3 - 2*r;
tauchi88 0:4a09a5e0d6d8 475 xx = 0;
tauchi88 0:4a09a5e0d6d8 476 yy = r;
tauchi88 0:4a09a5e0d6d8 477 while (xx < yy) {
tauchi88 0:4a09a5e0d6d8 478
tauchi88 0:4a09a5e0d6d8 479 if (di < 0) {
tauchi88 0:4a09a5e0d6d8 480 di += 4*xx + 6;
tauchi88 0:4a09a5e0d6d8 481 } else {
tauchi88 0:4a09a5e0d6d8 482 di += 4*(xx - yy) + 10;
tauchi88 0:4a09a5e0d6d8 483 yy--;
tauchi88 0:4a09a5e0d6d8 484 draw_y0--;
tauchi88 0:4a09a5e0d6d8 485 draw_y1--;
tauchi88 0:4a09a5e0d6d8 486 draw_y2++;
tauchi88 0:4a09a5e0d6d8 487 draw_y3++;
tauchi88 0:4a09a5e0d6d8 488 draw_x4--;
tauchi88 0:4a09a5e0d6d8 489 draw_x5++;
tauchi88 0:4a09a5e0d6d8 490 draw_x6--;
tauchi88 0:4a09a5e0d6d8 491 draw_x7++;
tauchi88 0:4a09a5e0d6d8 492 }
tauchi88 0:4a09a5e0d6d8 493 xx++;
tauchi88 0:4a09a5e0d6d8 494 draw_x0++;
tauchi88 0:4a09a5e0d6d8 495 draw_x1--;
tauchi88 0:4a09a5e0d6d8 496 draw_x2++;
tauchi88 0:4a09a5e0d6d8 497 draw_x3--;
tauchi88 0:4a09a5e0d6d8 498 draw_y4++;
tauchi88 0:4a09a5e0d6d8 499 draw_y5++;
tauchi88 0:4a09a5e0d6d8 500 draw_y6--;
tauchi88 0:4a09a5e0d6d8 501 draw_y7--;
tauchi88 0:4a09a5e0d6d8 502
tauchi88 0:4a09a5e0d6d8 503 if ( (draw_x0 <= width()) && (draw_y0>=0) ) {
tauchi88 0:4a09a5e0d6d8 504 pixel(draw_x0, draw_y0, color);
tauchi88 0:4a09a5e0d6d8 505 }
tauchi88 0:4a09a5e0d6d8 506
tauchi88 0:4a09a5e0d6d8 507 if ( (draw_x1 >= 0) && (draw_y1 >= 0) ) {
tauchi88 0:4a09a5e0d6d8 508 pixel(draw_x1, draw_y1, color);
tauchi88 0:4a09a5e0d6d8 509 }
tauchi88 0:4a09a5e0d6d8 510
tauchi88 0:4a09a5e0d6d8 511 if ( (draw_x2 <= width()) && (draw_y2 <= height()) ) {
tauchi88 0:4a09a5e0d6d8 512 pixel(draw_x2, draw_y2, color);
tauchi88 0:4a09a5e0d6d8 513 }
tauchi88 0:4a09a5e0d6d8 514
tauchi88 0:4a09a5e0d6d8 515 if ( (draw_x3 >=0 ) && (draw_y3 <= height()) ) {
tauchi88 0:4a09a5e0d6d8 516 pixel(draw_x3, draw_y3, color);
tauchi88 0:4a09a5e0d6d8 517 }
tauchi88 0:4a09a5e0d6d8 518
tauchi88 0:4a09a5e0d6d8 519 if ( (draw_x4 <= width()) && (draw_y4 >= 0) ) {
tauchi88 0:4a09a5e0d6d8 520 pixel(draw_x4, draw_y4, color);
tauchi88 0:4a09a5e0d6d8 521 }
tauchi88 0:4a09a5e0d6d8 522
tauchi88 0:4a09a5e0d6d8 523 if ( (draw_x5 >= 0) && (draw_y5 >= 0) ) {
tauchi88 0:4a09a5e0d6d8 524 pixel(draw_x5, draw_y5, color);
tauchi88 0:4a09a5e0d6d8 525 }
tauchi88 0:4a09a5e0d6d8 526 if ( (draw_x6 <=width()) && (draw_y6 <= height()) ) {
tauchi88 0:4a09a5e0d6d8 527 pixel(draw_x6, draw_y6, color);
tauchi88 0:4a09a5e0d6d8 528 }
tauchi88 0:4a09a5e0d6d8 529 if ( (draw_x7 >= 0) && (draw_y7 <= height()) ) {
tauchi88 0:4a09a5e0d6d8 530 pixel(draw_x7, draw_y7, color);
tauchi88 0:4a09a5e0d6d8 531 }
tauchi88 0:4a09a5e0d6d8 532 }
tauchi88 0:4a09a5e0d6d8 533 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 534 }
tauchi88 0:4a09a5e0d6d8 535
tauchi88 0:4a09a5e0d6d8 536 void C12832_LCD::fillcircle(int x, int y, int r, int color)
tauchi88 0:4a09a5e0d6d8 537 {
tauchi88 0:4a09a5e0d6d8 538 int i,up;
tauchi88 0:4a09a5e0d6d8 539 up = auto_up;
tauchi88 0:4a09a5e0d6d8 540 auto_up = 0; // off
tauchi88 0:4a09a5e0d6d8 541 for (i = 0; i <= r; i++)
tauchi88 0:4a09a5e0d6d8 542 circle(x,y,i,color);
tauchi88 0:4a09a5e0d6d8 543 auto_up = up;
tauchi88 0:4a09a5e0d6d8 544 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 545 }
tauchi88 0:4a09a5e0d6d8 546
tauchi88 0:4a09a5e0d6d8 547 void C12832_LCD::setmode(int mode)
tauchi88 0:4a09a5e0d6d8 548 {
tauchi88 0:4a09a5e0d6d8 549 draw_mode = mode;
tauchi88 0:4a09a5e0d6d8 550 }
tauchi88 0:4a09a5e0d6d8 551
tauchi88 0:4a09a5e0d6d8 552 void C12832_LCD::locate(int x, int y)
tauchi88 0:4a09a5e0d6d8 553 {
tauchi88 0:4a09a5e0d6d8 554 char_x = x;
tauchi88 0:4a09a5e0d6d8 555 char_y = y;
tauchi88 0:4a09a5e0d6d8 556 }
tauchi88 0:4a09a5e0d6d8 557
tauchi88 0:4a09a5e0d6d8 558
tauchi88 0:4a09a5e0d6d8 559
tauchi88 0:4a09a5e0d6d8 560 int C12832_LCD::columns()
tauchi88 0:4a09a5e0d6d8 561 {
tauchi88 0:4a09a5e0d6d8 562 return width() / font[1];
tauchi88 0:4a09a5e0d6d8 563 }
tauchi88 0:4a09a5e0d6d8 564
tauchi88 0:4a09a5e0d6d8 565
tauchi88 0:4a09a5e0d6d8 566
tauchi88 0:4a09a5e0d6d8 567 int C12832_LCD::rows()
tauchi88 0:4a09a5e0d6d8 568 {
tauchi88 0:4a09a5e0d6d8 569 return height() / font[2];
tauchi88 0:4a09a5e0d6d8 570 }
tauchi88 0:4a09a5e0d6d8 571
tauchi88 0:4a09a5e0d6d8 572
tauchi88 0:4a09a5e0d6d8 573
tauchi88 0:4a09a5e0d6d8 574 int C12832_LCD::_putc(int value)
tauchi88 0:4a09a5e0d6d8 575 {
tauchi88 0:4a09a5e0d6d8 576 if (value == '\n') { // new line
tauchi88 0:4a09a5e0d6d8 577 char_x = 0;
tauchi88 0:4a09a5e0d6d8 578 char_y = char_y + font[2];
tauchi88 0:4a09a5e0d6d8 579 if (char_y >= height() - font[2]) {
tauchi88 0:4a09a5e0d6d8 580 char_y = 0;
tauchi88 0:4a09a5e0d6d8 581 }
tauchi88 0:4a09a5e0d6d8 582 } else {
tauchi88 0:4a09a5e0d6d8 583 character(char_x, char_y, value);
tauchi88 0:4a09a5e0d6d8 584 if(auto_up) copy_to_lcd();
tauchi88 0:4a09a5e0d6d8 585 }
tauchi88 0:4a09a5e0d6d8 586 return value;
tauchi88 0:4a09a5e0d6d8 587 }
tauchi88 0:4a09a5e0d6d8 588
tauchi88 0:4a09a5e0d6d8 589 void C12832_LCD::character(int x, int y, int c)
tauchi88 0:4a09a5e0d6d8 590 {
tauchi88 0:4a09a5e0d6d8 591 unsigned int hor,vert,offset,bpl,j,i,b;
tauchi88 0:4a09a5e0d6d8 592 unsigned char* zeichen;
tauchi88 0:4a09a5e0d6d8 593 unsigned char z,w;
tauchi88 0:4a09a5e0d6d8 594
tauchi88 0:4a09a5e0d6d8 595 if ((c < 31) || (c > 127)) return; // test char range
tauchi88 0:4a09a5e0d6d8 596
tauchi88 0:4a09a5e0d6d8 597 // read font parameter from start of array
tauchi88 0:4a09a5e0d6d8 598 offset = font[0]; // bytes / char
tauchi88 0:4a09a5e0d6d8 599 hor = font[1]; // get hor size of font
tauchi88 0:4a09a5e0d6d8 600 vert = font[2]; // get vert size of font
tauchi88 0:4a09a5e0d6d8 601 bpl = font[3]; // bytes per line
tauchi88 0:4a09a5e0d6d8 602
tauchi88 0:4a09a5e0d6d8 603 if (char_x + hor > width()) {
tauchi88 0:4a09a5e0d6d8 604 char_x = 0;
tauchi88 0:4a09a5e0d6d8 605 char_y = char_y + vert;
tauchi88 0:4a09a5e0d6d8 606 if (char_y >= height() - font[2]) {
tauchi88 0:4a09a5e0d6d8 607 char_y = 0;
tauchi88 0:4a09a5e0d6d8 608 }
tauchi88 0:4a09a5e0d6d8 609 }
tauchi88 0:4a09a5e0d6d8 610
tauchi88 0:4a09a5e0d6d8 611 zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap
tauchi88 0:4a09a5e0d6d8 612 w = zeichen[0]; // width of actual char
tauchi88 0:4a09a5e0d6d8 613 // construct the char into the buffer
tauchi88 0:4a09a5e0d6d8 614 for (j=0; j<vert; j++) { // vert line
tauchi88 0:4a09a5e0d6d8 615 for (i=0; i<hor; i++) { // horz line
tauchi88 0:4a09a5e0d6d8 616 z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
tauchi88 0:4a09a5e0d6d8 617 b = 1 << (j & 0x07);
tauchi88 0:4a09a5e0d6d8 618 if (( z & b ) == 0x00) {
tauchi88 0:4a09a5e0d6d8 619 pixel(x+i,y+j,0);
tauchi88 0:4a09a5e0d6d8 620 } else {
tauchi88 0:4a09a5e0d6d8 621 pixel(x+i,y+j,1);
tauchi88 0:4a09a5e0d6d8 622 }
tauchi88 0:4a09a5e0d6d8 623
tauchi88 0:4a09a5e0d6d8 624 }
tauchi88 0:4a09a5e0d6d8 625 }
tauchi88 0:4a09a5e0d6d8 626
tauchi88 0:4a09a5e0d6d8 627 char_x += w;
tauchi88 0:4a09a5e0d6d8 628 }
tauchi88 0:4a09a5e0d6d8 629
tauchi88 0:4a09a5e0d6d8 630
tauchi88 0:4a09a5e0d6d8 631 void C12832_LCD::set_font(unsigned char* f)
tauchi88 0:4a09a5e0d6d8 632 {
tauchi88 0:4a09a5e0d6d8 633 font = f;
tauchi88 0:4a09a5e0d6d8 634 }
tauchi88 0:4a09a5e0d6d8 635
tauchi88 0:4a09a5e0d6d8 636 void C12832_LCD::set_auto_up(unsigned int up)
tauchi88 0:4a09a5e0d6d8 637 {
tauchi88 0:4a09a5e0d6d8 638 if(up ) auto_up = 1;
tauchi88 0:4a09a5e0d6d8 639 }
tauchi88 0:4a09a5e0d6d8 640
tauchi88 0:4a09a5e0d6d8 641 unsigned int C12832_LCD::get_auto_up(void){
tauchi88 0:4a09a5e0d6d8 642 return (auto_up);
tauchi88 0:4a09a5e0d6d8 643 }
tauchi88 0:4a09a5e0d6d8 644
tauchi88 0:4a09a5e0d6d8 645