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