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