Simple library for UC1701 based GLCD's

Dependents:   Opensmart_LCD_UC1701

With lots of fonts! Will include more in the future. A couple bitmaps have also been added.

Committer:
Anaesthetix
Date:
Mon Dec 19 23:26:17 2016 +0000
Revision:
5:7494bdca926b
Parent:
4:8da4c691643a
Added basic drawing functions + buffered versions. More will come soon. Has a minor bug with postioning

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anaesthetix 0:a8cfaf48d064 1 /**
Anaesthetix 0:a8cfaf48d064 2 * This is a simple library for UC1701 controlled graphic LCD's.
Anaesthetix 0:a8cfaf48d064 3 * Written for a cheap OPEN-SMART 1.8" 128x64 display
Anaesthetix 0:a8cfaf48d064 4 * See http://www.dx.com/p/open-smart-1-8-128-64-lcd-display-breakout-module-w-blue-backlit-444694
Anaesthetix 1:f396898c2963 5 *
Anaesthetix 0:a8cfaf48d064 6 * Written by: Erik van de Coevering
Anaesthetix 5:7494bdca926b 7 * With thanks to Tim Barr from whom I've reused some code
Anaesthetix 0:a8cfaf48d064 8 * Use this code in whatever way you like, as long as it stays free of charge!
Anaesthetix 0:a8cfaf48d064 9 */
Anaesthetix 0:a8cfaf48d064 10
Anaesthetix 0:a8cfaf48d064 11 #include "UC1701.h"
Anaesthetix 0:a8cfaf48d064 12
Anaesthetix 0:a8cfaf48d064 13 UC1701::UC1701(SPI &lcd, DigitalOut &lcd_cs, DigitalOut &lcd_cd)
Anaesthetix 0:a8cfaf48d064 14 {
Anaesthetix 0:a8cfaf48d064 15 _lcd = &lcd;
Anaesthetix 0:a8cfaf48d064 16 _lcd_cs = &lcd_cs;
Anaesthetix 0:a8cfaf48d064 17 _lcd_cd = &lcd_cd;
Anaesthetix 0:a8cfaf48d064 18 }
Anaesthetix 0:a8cfaf48d064 19
Anaesthetix 0:a8cfaf48d064 20 void UC1701::init()
Anaesthetix 0:a8cfaf48d064 21 {
Anaesthetix 0:a8cfaf48d064 22 _lcd_cs->write(1);
Anaesthetix 0:a8cfaf48d064 23 _lcd->frequency(24000000); // Abusing SPI to save some time..
Anaesthetix 0:a8cfaf48d064 24 _lcd->format(8,3);
Anaesthetix 0:a8cfaf48d064 25 _lcd_cs->write(0); // enable SPI
Anaesthetix 0:a8cfaf48d064 26 _lcd_cd->write(0); // COMMAND mode
Anaesthetix 0:a8cfaf48d064 27
Anaesthetix 0:a8cfaf48d064 28 wait_ms(50);
Anaesthetix 0:a8cfaf48d064 29
Anaesthetix 0:a8cfaf48d064 30 _lcd->write(0xE2); // Reset
Anaesthetix 0:a8cfaf48d064 31 _lcd->write(0x40); // Set display start line to 0
Anaesthetix 0:a8cfaf48d064 32 _lcd->write(0xA1); // Set SEG direction
Anaesthetix 0:a8cfaf48d064 33 _lcd->write(0xC0); // Set COM direction
Anaesthetix 0:a8cfaf48d064 34 _lcd->write(0xA2); // Set bias = 1/9
Anaesthetix 0:a8cfaf48d064 35 _lcd->write(0x2C); // Boost ON
Anaesthetix 0:a8cfaf48d064 36 _lcd->write(0x2E); // Voltage regulator on
Anaesthetix 0:a8cfaf48d064 37 _lcd->write(0x2F); // Voltage follower on
Anaesthetix 0:a8cfaf48d064 38 _lcd->write(0xF8); // Set booster ratio
Anaesthetix 3:baaa16e24adc 39 _lcd->write(0x00);
Anaesthetix 0:a8cfaf48d064 40 _lcd->write(0x23); // Set resistor ratio
Anaesthetix 3:baaa16e24adc 41 _lcd->write(0x81); // Set contrast to
Anaesthetix 3:baaa16e24adc 42 _lcd->write(0x28); // 40
Anaesthetix 3:baaa16e24adc 43 _lcd->write(0xEE); // Set cursor update -> after write, column cursor will be updated (rows will not!)
Anaesthetix 0:a8cfaf48d064 44 _lcd->write(0xAC); // Disable static indicator
Anaesthetix 0:a8cfaf48d064 45 _lcd->write(0x00);
Anaesthetix 0:a8cfaf48d064 46 _lcd->write(0xA6); // Disable inverse
Anaesthetix 0:a8cfaf48d064 47 _lcd->write(0xAF); // Display enable
Anaesthetix 3:baaa16e24adc 48 //_lcd->write(0xA5); // display all points
Anaesthetix 0:a8cfaf48d064 49 _lcd->write(0xA4); // clear
Anaesthetix 3:baaa16e24adc 50 _lcd_cs->write(1); // disable SPI
Anaesthetix 3:baaa16e24adc 51 _lcd_cd->write(1); // DATA mode
Anaesthetix 0:a8cfaf48d064 52
Anaesthetix 0:a8cfaf48d064 53 }
Anaesthetix 0:a8cfaf48d064 54
Anaesthetix 3:baaa16e24adc 55 void UC1701::setContrast(char contrast)
Anaesthetix 3:baaa16e24adc 56 {
Anaesthetix 3:baaa16e24adc 57 _lcd_cs->write(0); // enable SPI
Anaesthetix 3:baaa16e24adc 58 _lcd_cd->write(0); // command mode
Anaesthetix 3:baaa16e24adc 59 _lcd->write(0x81); // command to set contrast
Anaesthetix 3:baaa16e24adc 60 _lcd->write(contrast); // set contrast
Anaesthetix 3:baaa16e24adc 61 _lcd_cs->write(1);
Anaesthetix 3:baaa16e24adc 62 _lcd_cd->write(1);
Anaesthetix 3:baaa16e24adc 63 }
Anaesthetix 3:baaa16e24adc 64
Anaesthetix 0:a8cfaf48d064 65 void UC1701::setCursor(char column, char line)
Anaesthetix 0:a8cfaf48d064 66 {
Anaesthetix 0:a8cfaf48d064 67 int i, j;
Anaesthetix 0:a8cfaf48d064 68 column = column+4;
Anaesthetix 0:a8cfaf48d064 69
Anaesthetix 0:a8cfaf48d064 70 i=(column&0xF0)>>4;
Anaesthetix 0:a8cfaf48d064 71 j=column&0x0F;
Anaesthetix 0:a8cfaf48d064 72 _lcd_cd->write(0);
Anaesthetix 0:a8cfaf48d064 73 _lcd->write(0xb0+line);
Anaesthetix 0:a8cfaf48d064 74 _lcd->write(0x10+i);
Anaesthetix 0:a8cfaf48d064 75 _lcd->write(j);
Anaesthetix 0:a8cfaf48d064 76 _lcd_cd->write(1);
Anaesthetix 0:a8cfaf48d064 77 }
Anaesthetix 0:a8cfaf48d064 78
Anaesthetix 0:a8cfaf48d064 79 void UC1701::clear()
Anaesthetix 0:a8cfaf48d064 80 {
Anaesthetix 0:a8cfaf48d064 81 _lcd_cs->write(0);
Anaesthetix 0:a8cfaf48d064 82 for(unsigned short j = 0; j < 8; j++) {
Anaesthetix 0:a8cfaf48d064 83 UC1701::setCursor(0, j);
Anaesthetix 0:a8cfaf48d064 84 for(unsigned short i = 0; i < 128 ; i++) {
Anaesthetix 0:a8cfaf48d064 85 _lcd->write(0x00);
Anaesthetix 0:a8cfaf48d064 86 }
Anaesthetix 0:a8cfaf48d064 87 }
Anaesthetix 0:a8cfaf48d064 88
Anaesthetix 0:a8cfaf48d064 89 UC1701::setCursor(0, 0);
Anaesthetix 0:a8cfaf48d064 90 _lcd_cs->write(1);
Anaesthetix 0:a8cfaf48d064 91 }
Anaesthetix 0:a8cfaf48d064 92
Anaesthetix 0:a8cfaf48d064 93 // fill() only used to optimize the library. Using command 0xA5 is faster, if needed.
Anaesthetix 0:a8cfaf48d064 94 void UC1701::fill()
Anaesthetix 0:a8cfaf48d064 95 {
Anaesthetix 0:a8cfaf48d064 96 _lcd_cs->write(0);
Anaesthetix 0:a8cfaf48d064 97 _lcd_cd->write(1);
Anaesthetix 0:a8cfaf48d064 98
Anaesthetix 0:a8cfaf48d064 99 for(unsigned short j = 0; j < 8; j++) {
Anaesthetix 0:a8cfaf48d064 100 UC1701::setCursor(0, j);
Anaesthetix 0:a8cfaf48d064 101 for(unsigned short i = 0; i < 128 ; i++) {
Anaesthetix 0:a8cfaf48d064 102 _lcd->write(0xFF);
Anaesthetix 0:a8cfaf48d064 103 }
Anaesthetix 0:a8cfaf48d064 104 }
Anaesthetix 0:a8cfaf48d064 105
Anaesthetix 0:a8cfaf48d064 106 UC1701::setCursor(0, 0);
Anaesthetix 0:a8cfaf48d064 107
Anaesthetix 0:a8cfaf48d064 108 _lcd_cs->write(1);
Anaesthetix 0:a8cfaf48d064 109 }
Anaesthetix 0:a8cfaf48d064 110
Anaesthetix 0:a8cfaf48d064 111 void UC1701::writeText2d(char column, char page, const char font_address[96][8], const char *text, int size)
Anaesthetix 0:a8cfaf48d064 112 {
Anaesthetix 0:a8cfaf48d064 113 _lcd_cs->write(0);
Anaesthetix 0:a8cfaf48d064 114 UC1701::setCursor(column, page);
Anaesthetix 4:8da4c691643a 115 for(int i=0; i<size; i++) {
Anaesthetix 0:a8cfaf48d064 116 for(int a=0; a<8; a++) {
Anaesthetix 0:a8cfaf48d064 117 _lcd->write((font_address[(text[i]-32)][a]));
Anaesthetix 0:a8cfaf48d064 118 }
Anaesthetix 0:a8cfaf48d064 119 }
Anaesthetix 0:a8cfaf48d064 120 _lcd_cs->write(1);
Anaesthetix 0:a8cfaf48d064 121 }
Anaesthetix 0:a8cfaf48d064 122
Anaesthetix 0:a8cfaf48d064 123 void UC1701::writeText(char column, char page, const char *font_address, const char *text, const uint8_t size)
Anaesthetix 0:a8cfaf48d064 124 {
Anaesthetix 0:a8cfaf48d064 125 // Position of character data in memory array
Anaesthetix 0:a8cfaf48d064 126 uint16_t pos_array;
Anaesthetix 0:a8cfaf48d064 127 // temporary column, page address, and column_cnt are used
Anaesthetix 0:a8cfaf48d064 128 // to stay inside display area
Anaesthetix 0:a8cfaf48d064 129 uint8_t i,y, column_cnt = 0;
Anaesthetix 0:a8cfaf48d064 130 uint8_t count = 0;
Anaesthetix 0:a8cfaf48d064 131
Anaesthetix 0:a8cfaf48d064 132 // font information, needed for calculation
Anaesthetix 0:a8cfaf48d064 133 uint8_t start_code, last_code, width, page_height, bytes_p_char;
Anaesthetix 0:a8cfaf48d064 134
Anaesthetix 0:a8cfaf48d064 135 uint8_t *txtbuffer;
Anaesthetix 0:a8cfaf48d064 136
Anaesthetix 0:a8cfaf48d064 137 start_code = font_address[2]; // get first defined character
Anaesthetix 0:a8cfaf48d064 138 last_code = font_address[3]; // get last defined character
Anaesthetix 0:a8cfaf48d064 139 width = font_address[4]; // width in pixel of one char
Anaesthetix 0:a8cfaf48d064 140 page_height = font_address[6]; // page count per char
Anaesthetix 0:a8cfaf48d064 141 bytes_p_char = font_address[7]; // bytes per char
Anaesthetix 0:a8cfaf48d064 142
Anaesthetix 0:a8cfaf48d064 143 _lcd_cs->write(0); // Enable SPI
Anaesthetix 0:a8cfaf48d064 144 _lcd_cd->write(1); // Data mode
Anaesthetix 0:a8cfaf48d064 145
Anaesthetix 0:a8cfaf48d064 146 if(page_height + page > LCDPAGES) //stay inside display area
Anaesthetix 0:a8cfaf48d064 147 page_height = LCDPAGES - page;
Anaesthetix 0:a8cfaf48d064 148
Anaesthetix 0:a8cfaf48d064 149 // The string is displayed character after character. If the font has more then one page,
Anaesthetix 0:a8cfaf48d064 150 // the top page is printed first, then the next page and so on
Anaesthetix 0:a8cfaf48d064 151 for(y = 0; y < page_height; y++) {
Anaesthetix 0:a8cfaf48d064 152 txtbuffer = &_lcdbuffer[page*LCDWIDTH + column];
Anaesthetix 0:a8cfaf48d064 153 column_cnt = 0; // clear column_cnt start point
Anaesthetix 0:a8cfaf48d064 154 i = 0;
Anaesthetix 0:a8cfaf48d064 155 while(( i < size) && ((column_cnt + column) < LCDWIDTH)) {
Anaesthetix 0:a8cfaf48d064 156 if(text[i] < start_code || (uint8_t)text[i] > last_code) //make sure data is valid
Anaesthetix 0:a8cfaf48d064 157 i++;
Anaesthetix 0:a8cfaf48d064 158 else {
Anaesthetix 0:a8cfaf48d064 159 // calculate position of ASCII character in font array
Anaesthetix 0:a8cfaf48d064 160 // bytes for header + (ASCII - startcode) * bytes per char)
Anaesthetix 0:a8cfaf48d064 161 pos_array = 8 + (uint8_t)(text[i++] - start_code) * bytes_p_char;
Anaesthetix 0:a8cfaf48d064 162
Anaesthetix 0:a8cfaf48d064 163 // get the dot pattern for the part of the char to print
Anaesthetix 0:a8cfaf48d064 164 pos_array += y*width;
Anaesthetix 0:a8cfaf48d064 165
Anaesthetix 0:a8cfaf48d064 166 // stay inside display area
Anaesthetix 0:a8cfaf48d064 167 if((column_cnt + width + column) > LCDWIDTH)
Anaesthetix 0:a8cfaf48d064 168 column_cnt = LCDWIDTH-width;
Anaesthetix 0:a8cfaf48d064 169
Anaesthetix 0:a8cfaf48d064 170 // copy character data to buffer
Anaesthetix 0:a8cfaf48d064 171 memcpy (txtbuffer+column_cnt,font_address+pos_array,width);
Anaesthetix 0:a8cfaf48d064 172 }
Anaesthetix 0:a8cfaf48d064 173
Anaesthetix 0:a8cfaf48d064 174 column_cnt += width;
Anaesthetix 0:a8cfaf48d064 175 }
Anaesthetix 0:a8cfaf48d064 176 UC1701::setCursor(column,page); // set start position x and y
Anaesthetix 0:a8cfaf48d064 177
Anaesthetix 0:a8cfaf48d064 178 do {
Anaesthetix 0:a8cfaf48d064 179 _lcd->write(txtbuffer[count]);
Anaesthetix 0:a8cfaf48d064 180 count++;
Anaesthetix 0:a8cfaf48d064 181 } while ((count <= column_cnt));
Anaesthetix 0:a8cfaf48d064 182 }
Anaesthetix 0:a8cfaf48d064 183
Anaesthetix 0:a8cfaf48d064 184 _lcd_cs->write(1); // Disable SPI
Anaesthetix 0:a8cfaf48d064 185
Anaesthetix 0:a8cfaf48d064 186 }
Anaesthetix 0:a8cfaf48d064 187
Anaesthetix 0:a8cfaf48d064 188 void UC1701::drawBitmap(const char *data)
Anaesthetix 0:a8cfaf48d064 189 {
Anaesthetix 0:a8cfaf48d064 190 int cnt = 0;
Anaesthetix 0:a8cfaf48d064 191 _lcd_cs->write(0);
Anaesthetix 0:a8cfaf48d064 192 _lcd_cd->write(1);
Anaesthetix 0:a8cfaf48d064 193 UC1701::setCursor(0,0);
Anaesthetix 0:a8cfaf48d064 194 for(int row=0; row<8; row++) {
Anaesthetix 0:a8cfaf48d064 195 UC1701::setCursor(0, row);
Anaesthetix 0:a8cfaf48d064 196 for(int column=0; column<128; column++) {
Anaesthetix 0:a8cfaf48d064 197 _lcd->write(data[cnt]);
Anaesthetix 0:a8cfaf48d064 198 cnt++;
Anaesthetix 0:a8cfaf48d064 199 }
Anaesthetix 0:a8cfaf48d064 200 }
Anaesthetix 5:7494bdca926b 201 }
Anaesthetix 5:7494bdca926b 202
Anaesthetix 5:7494bdca926b 203 void UC1701::drawLineHor(char posx, char posy, char height, char width)
Anaesthetix 5:7494bdca926b 204 {
Anaesthetix 5:7494bdca926b 205 char page, offset, offset2;
Anaesthetix 5:7494bdca926b 206 char buffer[2] = {0xFF, 0xFF};
Anaesthetix 5:7494bdca926b 207
Anaesthetix 5:7494bdca926b 208 _lcd_cs->write(0);
Anaesthetix 5:7494bdca926b 209 _lcd_cd->write(1);
Anaesthetix 5:7494bdca926b 210
Anaesthetix 5:7494bdca926b 211 if(width+posx > LCDWIDTH) width = (LCDWIDTH-posx); // keep inside display area
Anaesthetix 5:7494bdca926b 212
Anaesthetix 5:7494bdca926b 213 page = posy/8;
Anaesthetix 5:7494bdca926b 214 offset = posy - (page*8);
Anaesthetix 5:7494bdca926b 215 buffer[0] = buffer[0] >> (8-height);
Anaesthetix 5:7494bdca926b 216 buffer[0] = buffer[0] << offset;
Anaesthetix 5:7494bdca926b 217
Anaesthetix 5:7494bdca926b 218 if((offset + height) > 8) {
Anaesthetix 5:7494bdca926b 219 offset2 = ((offset+height)-8);
Anaesthetix 5:7494bdca926b 220 buffer[1] = buffer[1] - (0xFF << (offset2));
Anaesthetix 5:7494bdca926b 221 }
Anaesthetix 5:7494bdca926b 222
Anaesthetix 5:7494bdca926b 223 UC1701::setCursor(posx, page);
Anaesthetix 5:7494bdca926b 224
Anaesthetix 5:7494bdca926b 225 for(int i=0; i<width; i++) _lcd->write(buffer[0]);
Anaesthetix 5:7494bdca926b 226
Anaesthetix 5:7494bdca926b 227 if(buffer[1] != 0xFF && (page+1) < 8) { // only write if line takes up > 1 page & keep inside display area
Anaesthetix 5:7494bdca926b 228 UC1701::setCursor(posx, (page+1));
Anaesthetix 5:7494bdca926b 229 for(int i=0; i<width; i++) _lcd->write(buffer[1]);
Anaesthetix 5:7494bdca926b 230 }
Anaesthetix 5:7494bdca926b 231 _lcd_cs->write(1);
Anaesthetix 5:7494bdca926b 232 }
Anaesthetix 5:7494bdca926b 233
Anaesthetix 5:7494bdca926b 234 void UC1701::drawLineVert(char posx, char posy, char height, char width)
Anaesthetix 5:7494bdca926b 235 {
Anaesthetix 5:7494bdca926b 236 char page, pagecount, offset, offset2;
Anaesthetix 5:7494bdca926b 237
Anaesthetix 5:7494bdca926b 238 _lcd_cs->write(0);
Anaesthetix 5:7494bdca926b 239 _lcd_cd->write(1);
Anaesthetix 5:7494bdca926b 240
Anaesthetix 5:7494bdca926b 241 page = posy/8;
Anaesthetix 5:7494bdca926b 242 pagecount = height/8;
Anaesthetix 5:7494bdca926b 243 offset2 = height - (pagecount*8);
Anaesthetix 5:7494bdca926b 244
Anaesthetix 5:7494bdca926b 245 UC1701::setCursor(posx, page);
Anaesthetix 5:7494bdca926b 246 for(int i=0; i<width; i++) _lcd->write((0xFF>>offset));
Anaesthetix 5:7494bdca926b 247
Anaesthetix 5:7494bdca926b 248 for(; pagecount > 1; pagecount--) {
Anaesthetix 5:7494bdca926b 249 page++;
Anaesthetix 5:7494bdca926b 250 UC1701::setCursor(posx, page);
Anaesthetix 5:7494bdca926b 251 for(int i=0; i<width; i++) _lcd->write(0xFF);
Anaesthetix 5:7494bdca926b 252 }
Anaesthetix 5:7494bdca926b 253
Anaesthetix 5:7494bdca926b 254 UC1701::setCursor(posx, (page+1));
Anaesthetix 5:7494bdca926b 255 for(int i=0; i<width; i++) _lcd->write((0xFF<<offset2));
Anaesthetix 5:7494bdca926b 256
Anaesthetix 5:7494bdca926b 257 _lcd_cs->write(1);
Anaesthetix 5:7494bdca926b 258 }
Anaesthetix 5:7494bdca926b 259
Anaesthetix 5:7494bdca926b 260 void UC1701::clearBuffer(void)
Anaesthetix 5:7494bdca926b 261 {
Anaesthetix 5:7494bdca926b 262 for(int i=0; i<(LCDWIDTH*LCDPAGES); i++) buff[i] = 0;
Anaesthetix 5:7494bdca926b 263 }
Anaesthetix 5:7494bdca926b 264
Anaesthetix 5:7494bdca926b 265 void UC1701::update(void)
Anaesthetix 5:7494bdca926b 266 {
Anaesthetix 5:7494bdca926b 267 int cnt = 0;
Anaesthetix 5:7494bdca926b 268 _lcd_cs->write(0);
Anaesthetix 5:7494bdca926b 269 _lcd_cd->write(1);
Anaesthetix 5:7494bdca926b 270 UC1701::setCursor(0,0);
Anaesthetix 5:7494bdca926b 271 for(int row=0; row<8; row++) {
Anaesthetix 5:7494bdca926b 272 UC1701::setCursor(0, row);
Anaesthetix 5:7494bdca926b 273 for(int column=0; column<128; column++) {
Anaesthetix 5:7494bdca926b 274 _lcd->write(buff[cnt]);
Anaesthetix 5:7494bdca926b 275 cnt++;
Anaesthetix 5:7494bdca926b 276 }
Anaesthetix 5:7494bdca926b 277 }
Anaesthetix 5:7494bdca926b 278 _lcd_cs->write(1);
Anaesthetix 5:7494bdca926b 279 }
Anaesthetix 5:7494bdca926b 280
Anaesthetix 5:7494bdca926b 281 void UC1701::drawbufferLineHor(char posx, char posy, char height, char width)
Anaesthetix 5:7494bdca926b 282 {
Anaesthetix 5:7494bdca926b 283 char page, offset, offset2;
Anaesthetix 5:7494bdca926b 284 int cursor;
Anaesthetix 5:7494bdca926b 285 char buffer[2] = {0xFF, 0xFF};
Anaesthetix 5:7494bdca926b 286
Anaesthetix 5:7494bdca926b 287 if(width+posx > LCDWIDTH) width = (LCDWIDTH-posx); // keep inside display area
Anaesthetix 5:7494bdca926b 288
Anaesthetix 5:7494bdca926b 289 page = posy/8;
Anaesthetix 5:7494bdca926b 290 offset = posy - (page*8);
Anaesthetix 5:7494bdca926b 291 buffer[0] = buffer[0] >> (8-height);
Anaesthetix 5:7494bdca926b 292 buffer[0] = buffer[0] << offset;
Anaesthetix 5:7494bdca926b 293
Anaesthetix 5:7494bdca926b 294 if((offset + height) > 8) {
Anaesthetix 5:7494bdca926b 295 offset2 = ((offset+height)-8);
Anaesthetix 5:7494bdca926b 296 buffer[1] = buffer[1] - (0xFF << (offset2));
Anaesthetix 5:7494bdca926b 297 }
Anaesthetix 5:7494bdca926b 298
Anaesthetix 5:7494bdca926b 299 cursor = posx + (page*128);
Anaesthetix 5:7494bdca926b 300
Anaesthetix 5:7494bdca926b 301 for(int i=0; i<width; i++) UC1701::buff[cursor+i] |= buffer[0];
Anaesthetix 5:7494bdca926b 302
Anaesthetix 5:7494bdca926b 303 if(buffer[1] != 0xFF && (page+1) < 8) { // only write if line takes up > 1 page & keep inside display area
Anaesthetix 5:7494bdca926b 304 for(int i=0; i<width; i++) UC1701::buff[cursor+i+128] |= buffer[1];
Anaesthetix 5:7494bdca926b 305 }
Anaesthetix 5:7494bdca926b 306 }
Anaesthetix 5:7494bdca926b 307
Anaesthetix 5:7494bdca926b 308 void UC1701::drawbufferLineVert(char posx, char posy, char height, char width)
Anaesthetix 5:7494bdca926b 309 {
Anaesthetix 5:7494bdca926b 310 char page, pagecount, offset, offset2;
Anaesthetix 5:7494bdca926b 311 int cursor;
Anaesthetix 5:7494bdca926b 312
Anaesthetix 5:7494bdca926b 313 page = posy/8;
Anaesthetix 5:7494bdca926b 314 pagecount = height/8;
Anaesthetix 5:7494bdca926b 315 offset2 = height - (pagecount*8);
Anaesthetix 5:7494bdca926b 316 cursor = posx + (page*128); // LCDWIDTH
Anaesthetix 5:7494bdca926b 317
Anaesthetix 5:7494bdca926b 318 for(int i=0; i<width; i++) UC1701::buff[cursor+i] |= (0xFF>>offset);
Anaesthetix 5:7494bdca926b 319
Anaesthetix 5:7494bdca926b 320 for(; pagecount > 1; pagecount--) {
Anaesthetix 5:7494bdca926b 321 page++;
Anaesthetix 5:7494bdca926b 322 cursor += 128;
Anaesthetix 5:7494bdca926b 323 for(int i=0; i<width; i++) UC1701::buff[cursor+i] |= 0xFF;
Anaesthetix 5:7494bdca926b 324 }
Anaesthetix 5:7494bdca926b 325
Anaesthetix 5:7494bdca926b 326 cursor += 128;
Anaesthetix 5:7494bdca926b 327 for(int i=0; i<width; i++) UC1701::buff[cursor+i] |= (0xFF >> offset2);
Anaesthetix 0:a8cfaf48d064 328 }