Librarie pour ecran 128x32 de MyLab

Dependents:   MyLab_Lib

Committer:
lucas_favre
Date:
Tue Mar 29 20:46:43 2016 +0000
Revision:
14:88fc5dbc0993
Parent:
12:00bbd42614c7
Suppression du menu -> Mis dans la librairie

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lucas_favre 12:00bbd42614c7 1 /* mbed library for the mbed Lab Board 128*32 pixel LCD
lucas_favre 12:00bbd42614c7 2 * use C12832 controller
lucas_favre 12:00bbd42614c7 3 * Copyright (c) 2012 Peter Drescher - DC2PD
lucas_favre 12:00bbd42614c7 4 * Released under the MIT License: http://mbed.org/license/mit
lucas_favre 12:00bbd42614c7 5 *
lucas_favre 12:00bbd42614c7 6 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
lucas_favre 12:00bbd42614c7 7 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
lucas_favre 12:00bbd42614c7 8 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
lucas_favre 12:00bbd42614c7 9 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
lucas_favre 12:00bbd42614c7 10 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
lucas_favre 12:00bbd42614c7 11 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
lucas_favre 12:00bbd42614c7 12 * THE SOFTWARE.
lucas_favre 12:00bbd42614c7 13 */
lucas_favre 12:00bbd42614c7 14
lucas_favre 12:00bbd42614c7 15 // 13.10.12 initial design
lucas_favre 12:00bbd42614c7 16 // 25.10.12 add autorefresh of screen
lucas_favre 12:00bbd42614c7 17 // 25.10.12 add standart font
lucas_favre 12:00bbd42614c7 18 // 20.12.12 add bitmap graphics
lucas_favre 11:c00a727f140f 19
lucas_favre 11:c00a727f140f 20 // optional defines :
lucas_favre 11:c00a727f140f 21 // #define debug_lcd 1
lucas_favre 11:c00a727f140f 22
lucas_favre 11:c00a727f140f 23 #include "C12832.h"
lucas_favre 11:c00a727f140f 24 #include "mbed.h"
lucas_favre 11:c00a727f140f 25 #include "stdio.h"
lucas_favre 11:c00a727f140f 26 #include "Small_7.h"
lucas_favre 11:c00a727f140f 27 #include "Arial_9.h"
lucas_favre 11:c00a727f140f 28
lucas_favre 11:c00a727f140f 29 #define BPP 1 // Bits per pixel
lucas_favre 11:c00a727f140f 30
lucas_favre 11:c00a727f140f 31
lucas_favre 12:00bbd42614c7 32 C12832::C12832(PinName e,PinName rw, PinName a0,PinName cs, PinName d0, PinName d1,PinName d2, PinName d3,PinName d4,PinName d5,PinName d6,PinName d7,const char* name) : GraphicsDisplay(name), _e(e), _a0(a0),_cs(cs),_rw(rw),
lucas_favre 11:c00a727f140f 33 _d(d0, d1, d2, d3,d4,d5,d6,d7) {
lucas_favre 11:c00a727f140f 34
lucas_favre 11:c00a727f140f 35 _cs = 1;
lucas_favre 11:c00a727f140f 36 RESET();
lucas_favre 11:c00a727f140f 37 Delay(1000);
lucas_favre 11:c00a727f140f 38 CLEAR_ADC(); //Normal disrect (SEG0-SEG128)
lucas_favre 11:c00a727f140f 39 SET_SHL(); // SHL 1,COM33-COM0
lucas_favre 11:c00a727f140f 40 SET_BIAS(); // 1/7 BIAS
lucas_favre 11:c00a727f140f 41 Power_Control(0x07); //Booster circuit: ON Voltage regulator circuit: ON Voltage follower circuit: ON
lucas_favre 11:c00a727f140f 42 Regulor_Resistor_Select(0x05); //V0 voltage regulator internal resistance ratio register value and (1 + Rb/Ra) ratio (Reference value) 5.5
lucas_favre 11:c00a727f140f 43 Set_Contrast_Control_Register(19);
lucas_favre 11:c00a727f140f 44 Initial_Dispay_Line(0x00); //Dispay Line 0
lucas_favre 11:c00a727f140f 45 wr_cmd(0xF8); //select booster ratio
lucas_favre 11:c00a727f140f 46 wr_cmd(0x00); //4X
lucas_favre 11:c00a727f140f 47 DISPLAY_ON();
lucas_favre 11:c00a727f140f 48 // clear and update LCD
lucas_favre 11:c00a727f140f 49 memset(buffer,0x00,512); // clear display buffer
lucas_favre 11:c00a727f140f 50 copy_to_lcd();
lucas_favre 11:c00a727f140f 51 auto_up = 1; // switch on auto update
lucas_favre 11:c00a727f140f 52 // dont do this by default. Make the user call
lucas_favre 11:c00a727f140f 53 claim(stdout); // redirekt printf to lcd
lucas_favre 11:c00a727f140f 54 locate(0,0);
lucas_favre 11:c00a727f140f 55 set_font((unsigned char*)Small_7); // standart font
lucas_favre 11:c00a727f140f 56
lucas_favre 11:c00a727f140f 57
lucas_favre 11:c00a727f140f 58
lucas_favre 11:c00a727f140f 59 }
lucas_favre 11:c00a727f140f 60
lucas_favre 11:c00a727f140f 61 void C12832::Delay(uint32_t n)
lucas_favre 11:c00a727f140f 62 {
lucas_favre 11:c00a727f140f 63 uint32_t a;
lucas_favre 11:c00a727f140f 64 for (a = 0; a < n; a++);
lucas_favre 11:c00a727f140f 65 }
lucas_favre 11:c00a727f140f 66 //Specify DDRAM line for COM0 0~63
lucas_favre 11:c00a727f140f 67 void C12832::Initial_Dispay_Line(unsigned char line)
lucas_favre 11:c00a727f140f 68 {
lucas_favre 11:c00a727f140f 69 line|=0x40;
lucas_favre 11:c00a727f140f 70 wr_cmd(line);
lucas_favre 11:c00a727f140f 71 return;
lucas_favre 11:c00a727f140f 72 }
lucas_favre 11:c00a727f140f 73
lucas_favre 11:c00a727f140f 74 void C12832::Power_Control(unsigned char vol)
lucas_favre 11:c00a727f140f 75 {
lucas_favre 11:c00a727f140f 76 wr_cmd((0x28|vol));
lucas_favre 11:c00a727f140f 77 return;
lucas_favre 11:c00a727f140f 78 }
lucas_favre 11:c00a727f140f 79
lucas_favre 11:c00a727f140f 80 /* Regulor resistor select
lucas_favre 11:c00a727f140f 81 ** 1+Rb/Ra Vo=(1+Rb/Ra)Vev Vev=(1-(63-a)/162)Vref 2.1v
lucas_favre 11:c00a727f140f 82 ** 0 3.0 4 5.0(default)
lucas_favre 11:c00a727f140f 83 ** 1 3.5 5 5.5
lucas_favre 11:c00a727f140f 84 ** 2 4 6 6
lucas_favre 11:c00a727f140f 85 ** 3 4.5 7 6.4
lucas_favre 11:c00a727f140f 86 */
lucas_favre 11:c00a727f140f 87 void C12832::Regulor_Resistor_Select(unsigned char r)
lucas_favre 11:c00a727f140f 88 {
lucas_favre 11:c00a727f140f 89 wr_cmd((0x20|r));
lucas_favre 11:c00a727f140f 90 return;
lucas_favre 11:c00a727f140f 91 }
lucas_favre 11:c00a727f140f 92
lucas_favre 11:c00a727f140f 93 //a(0-63) 32default Vev=(1-(63-a)/162)Vref 2.1v
lucas_favre 11:c00a727f140f 94 void C12832::Set_Contrast_Control_Register(unsigned char mod)
lucas_favre 11:c00a727f140f 95 {
lucas_favre 11:c00a727f140f 96 wr_cmd(0x81);
lucas_favre 11:c00a727f140f 97 wr_cmd(mod);
lucas_favre 11:c00a727f140f 98 return;
lucas_favre 11:c00a727f140f 99 }
lucas_favre 11:c00a727f140f 100
lucas_favre 11:c00a727f140f 101 int C12832::width()
lucas_favre 11:c00a727f140f 102 {
lucas_favre 11:c00a727f140f 103 return 128;
lucas_favre 11:c00a727f140f 104 }
lucas_favre 11:c00a727f140f 105
lucas_favre 11:c00a727f140f 106 int C12832::height()
lucas_favre 11:c00a727f140f 107 {
lucas_favre 11:c00a727f140f 108 return 32;
lucas_favre 11:c00a727f140f 109 }
lucas_favre 11:c00a727f140f 110
lucas_favre 11:c00a727f140f 111
lucas_favre 11:c00a727f140f 112 void C12832::invert(unsigned int o)
lucas_favre 11:c00a727f140f 113 {
lucas_favre 11:c00a727f140f 114 if(o == 0) wr_cmd(0xA6);
lucas_favre 11:c00a727f140f 115 else wr_cmd(0xA7);
lucas_favre 11:c00a727f140f 116 }
lucas_favre 11:c00a727f140f 117
lucas_favre 11:c00a727f140f 118
lucas_favre 11:c00a727f140f 119 void C12832::set_contrast(unsigned int o)
lucas_favre 11:c00a727f140f 120 {
lucas_favre 11:c00a727f140f 121 contrast = o;
lucas_favre 11:c00a727f140f 122 wr_cmd(0x81); // set volume
lucas_favre 11:c00a727f140f 123 wr_cmd(o & 0x3F);
lucas_favre 11:c00a727f140f 124 }
lucas_favre 11:c00a727f140f 125
lucas_favre 11:c00a727f140f 126 unsigned int C12832::get_contrast(void)
lucas_favre 11:c00a727f140f 127 {
lucas_favre 11:c00a727f140f 128 return(contrast);
lucas_favre 11:c00a727f140f 129 }
lucas_favre 11:c00a727f140f 130
lucas_favre 11:c00a727f140f 131
lucas_favre 11:c00a727f140f 132 // write command to lcd controller
lucas_favre 11:c00a727f140f 133
lucas_favre 11:c00a727f140f 134 void C12832::wr_cmd(unsigned char cmd)
lucas_favre 11:c00a727f140f 135 {
lucas_favre 11:c00a727f140f 136 _cs =0;
lucas_favre 11:c00a727f140f 137 _a0 = 0;
lucas_favre 11:c00a727f140f 138 _rw = 0;
lucas_favre 11:c00a727f140f 139 _d = cmd;
lucas_favre 11:c00a727f140f 140 LPC_GPIO2->FIODIR |= 0xFF;
lucas_favre 11:c00a727f140f 141 _e = 1;
lucas_favre 11:c00a727f140f 142 asm("nop");
lucas_favre 11:c00a727f140f 143 _e = 0;
lucas_favre 11:c00a727f140f 144 LPC_GPIO2->FIODIR &= ~0xFF;
lucas_favre 11:c00a727f140f 145 _rw=1;
lucas_favre 11:c00a727f140f 146 _cs=1;
lucas_favre 11:c00a727f140f 147 }
lucas_favre 11:c00a727f140f 148
lucas_favre 11:c00a727f140f 149 // write data to lcd controller
lucas_favre 11:c00a727f140f 150
lucas_favre 11:c00a727f140f 151 void C12832::wr_dat(unsigned char dat)
lucas_favre 11:c00a727f140f 152 {
lucas_favre 11:c00a727f140f 153 _cs = 0;
lucas_favre 11:c00a727f140f 154 _a0 = 1;
lucas_favre 11:c00a727f140f 155 _rw = 0;
lucas_favre 11:c00a727f140f 156 _d = dat;
lucas_favre 11:c00a727f140f 157 LPC_GPIO2->FIODIR |= 0xFF;
lucas_favre 11:c00a727f140f 158 _e = 1;
lucas_favre 11:c00a727f140f 159 asm("nop");
lucas_favre 11:c00a727f140f 160 _e = 0;
lucas_favre 11:c00a727f140f 161 LPC_GPIO2->FIODIR &= ~0xFF;
lucas_favre 11:c00a727f140f 162 _rw=1;
lucas_favre 11:c00a727f140f 163 _cs=1;
lucas_favre 11:c00a727f140f 164 }
lucas_favre 11:c00a727f140f 165
lucas_favre 11:c00a727f140f 166 // set one pixel in buffer
lucas_favre 11:c00a727f140f 167
lucas_favre 11:c00a727f140f 168 void C12832::pixel(int x, int y, int color)
lucas_favre 11:c00a727f140f 169 {
lucas_favre 11:c00a727f140f 170 // first check parameter
lucas_favre 11:c00a727f140f 171 if(x > 128 || y > 32 || x < 0 || y < 0) return;
lucas_favre 11:c00a727f140f 172
lucas_favre 11:c00a727f140f 173 if(draw_mode == NORMAL) {
lucas_favre 11:c00a727f140f 174 if(color == 0)
lucas_favre 11:c00a727f140f 175 buffer[x + ((y/8) * 128)] &= ~(1 << (y%8)); // erase pixel
lucas_favre 11:c00a727f140f 176 else
lucas_favre 11:c00a727f140f 177 buffer[x + ((y/8) * 128)] |= (1 << (y%8)); // set pixel
lucas_favre 11:c00a727f140f 178 } else { // XOR mode
lucas_favre 11:c00a727f140f 179 if(color == 1)
lucas_favre 11:c00a727f140f 180 buffer[x + ((y/8) * 128)] ^= (1 << (y%8)); // xor pixel
lucas_favre 11:c00a727f140f 181 }
lucas_favre 11:c00a727f140f 182 }
lucas_favre 11:c00a727f140f 183
lucas_favre 11:c00a727f140f 184 // update lcd
lucas_favre 11:c00a727f140f 185
lucas_favre 11:c00a727f140f 186 void C12832::copy_to_lcd(void)
lucas_favre 11:c00a727f140f 187 {
lucas_favre 11:c00a727f140f 188
lucas_favre 11:c00a727f140f 189 int i=0;
lucas_favre 11:c00a727f140f 190
lucas_favre 11:c00a727f140f 191 //page 0
lucas_favre 11:c00a727f140f 192 wr_cmd(0x00); // set column low nibble 0
lucas_favre 11:c00a727f140f 193 wr_cmd(0x10); // set column hi nibble 0
lucas_favre 11:c00a727f140f 194 wr_cmd(0xB0); // set page address 0
lucas_favre 11:c00a727f140f 195 _a0 = 1;
lucas_favre 11:c00a727f140f 196 for(i=0; i<128; i++) {
lucas_favre 11:c00a727f140f 197 wr_dat(buffer[i]);
lucas_favre 11:c00a727f140f 198 }
lucas_favre 11:c00a727f140f 199
lucas_favre 11:c00a727f140f 200 // page 1
lucas_favre 11:c00a727f140f 201 wr_cmd(0x00); // set column low nibble 0
lucas_favre 11:c00a727f140f 202 wr_cmd(0x10); // set column hi nibble 0
lucas_favre 11:c00a727f140f 203 wr_cmd(0xB1); // set page address 1
lucas_favre 11:c00a727f140f 204 _a0 = 1;
lucas_favre 11:c00a727f140f 205 for(i=128; i<256; i++) {
lucas_favre 11:c00a727f140f 206 wr_dat(buffer[i]);
lucas_favre 11:c00a727f140f 207 }
lucas_favre 11:c00a727f140f 208
lucas_favre 11:c00a727f140f 209 //page 2
lucas_favre 11:c00a727f140f 210 wr_cmd(0x00); // set column low nibble 0
lucas_favre 11:c00a727f140f 211 wr_cmd(0x10); // set column hi nibble 0
lucas_favre 11:c00a727f140f 212 wr_cmd(0xB2); // set page address 2
lucas_favre 11:c00a727f140f 213 _a0 = 1;
lucas_favre 11:c00a727f140f 214 for(i=256; i<384; i++) {
lucas_favre 11:c00a727f140f 215 wr_dat(buffer[i]);
lucas_favre 11:c00a727f140f 216 }
lucas_favre 11:c00a727f140f 217
lucas_favre 11:c00a727f140f 218 //page 3
lucas_favre 11:c00a727f140f 219 wr_cmd(0x00); // set column low nibble 0
lucas_favre 11:c00a727f140f 220 wr_cmd(0x10); // set column hi nibble 0
lucas_favre 11:c00a727f140f 221 wr_cmd(0xB3); // set page address 3
lucas_favre 11:c00a727f140f 222 _a0 = 1;
lucas_favre 11:c00a727f140f 223
lucas_favre 11:c00a727f140f 224 _cs = 0;
lucas_favre 11:c00a727f140f 225
lucas_favre 11:c00a727f140f 226 for(i=384; i<512; i++) {
lucas_favre 11:c00a727f140f 227 wr_dat(buffer[i]);
lucas_favre 11:c00a727f140f 228 }
lucas_favre 11:c00a727f140f 229
lucas_favre 11:c00a727f140f 230 }
lucas_favre 11:c00a727f140f 231
lucas_favre 11:c00a727f140f 232 void C12832::cls(void)
lucas_favre 11:c00a727f140f 233 {
lucas_favre 11:c00a727f140f 234 memset(buffer,0x00,512); // clear display buffer
lucas_favre 11:c00a727f140f 235 copy_to_lcd();
lucas_favre 11:c00a727f140f 236 }
lucas_favre 11:c00a727f140f 237
lucas_favre 11:c00a727f140f 238
lucas_favre 11:c00a727f140f 239
lucas_favre 11:c00a727f140f 240
lucas_favre 11:c00a727f140f 241 void C12832::setmode(int mode)
lucas_favre 11:c00a727f140f 242 {
lucas_favre 11:c00a727f140f 243 draw_mode = mode;
lucas_favre 11:c00a727f140f 244 }
lucas_favre 11:c00a727f140f 245
lucas_favre 11:c00a727f140f 246 void C12832::locate(int x, int y)
lucas_favre 11:c00a727f140f 247 {
lucas_favre 11:c00a727f140f 248 char_x = x;
lucas_favre 11:c00a727f140f 249 char_y = y;
lucas_favre 11:c00a727f140f 250 }
lucas_favre 11:c00a727f140f 251
lucas_favre 11:c00a727f140f 252
lucas_favre 11:c00a727f140f 253
lucas_favre 11:c00a727f140f 254 int C12832::columns()
lucas_favre 11:c00a727f140f 255 {
lucas_favre 11:c00a727f140f 256 return width() / font[1];
lucas_favre 11:c00a727f140f 257 }
lucas_favre 11:c00a727f140f 258
lucas_favre 11:c00a727f140f 259
lucas_favre 11:c00a727f140f 260
lucas_favre 11:c00a727f140f 261 int C12832::rows()
lucas_favre 11:c00a727f140f 262 {
lucas_favre 11:c00a727f140f 263 return height() / font[2];
lucas_favre 11:c00a727f140f 264 }
lucas_favre 11:c00a727f140f 265
lucas_favre 11:c00a727f140f 266
lucas_favre 11:c00a727f140f 267
lucas_favre 11:c00a727f140f 268 int C12832::_putc(int value)
lucas_favre 11:c00a727f140f 269 {
lucas_favre 11:c00a727f140f 270 if (value == '\n') { // new line
lucas_favre 11:c00a727f140f 271 char_x = 0;
lucas_favre 11:c00a727f140f 272 char_y = char_y + font[2];
lucas_favre 11:c00a727f140f 273 if (char_y >= height() - font[2]) {
lucas_favre 11:c00a727f140f 274 char_y = 0;
lucas_favre 11:c00a727f140f 275 }
lucas_favre 11:c00a727f140f 276 } else {
lucas_favre 11:c00a727f140f 277 character(char_x, char_y, value);
lucas_favre 11:c00a727f140f 278 if(auto_up) copy_to_lcd();
lucas_favre 11:c00a727f140f 279 }
lucas_favre 11:c00a727f140f 280 return value;
lucas_favre 11:c00a727f140f 281 }
lucas_favre 11:c00a727f140f 282
lucas_favre 11:c00a727f140f 283 void C12832::character(int x, int y, int c)
lucas_favre 11:c00a727f140f 284 {
lucas_favre 11:c00a727f140f 285 unsigned int hor,vert,offset,bpl,j,i,b;
lucas_favre 11:c00a727f140f 286 unsigned char* zeichen;
lucas_favre 11:c00a727f140f 287 unsigned char z,w;
lucas_favre 11:c00a727f140f 288
lucas_favre 11:c00a727f140f 289 if ((c < 31) || (c > 127)) return; // test char range
lucas_favre 11:c00a727f140f 290
lucas_favre 11:c00a727f140f 291 // read font parameter from start of array
lucas_favre 11:c00a727f140f 292 offset = font[0]; // bytes / char
lucas_favre 11:c00a727f140f 293 hor = font[1]; // get hor size of font
lucas_favre 11:c00a727f140f 294 vert = font[2]; // get vert size of font
lucas_favre 11:c00a727f140f 295 bpl = font[3]; // bytes per line
lucas_favre 11:c00a727f140f 296
lucas_favre 11:c00a727f140f 297 if (char_x + hor > width()) {
lucas_favre 11:c00a727f140f 298 char_x = 0;
lucas_favre 11:c00a727f140f 299 char_y = char_y + vert;
lucas_favre 11:c00a727f140f 300 if (char_y >= height() - font[2]) {
lucas_favre 11:c00a727f140f 301 char_y = 0;
lucas_favre 11:c00a727f140f 302 }
lucas_favre 11:c00a727f140f 303 }
lucas_favre 11:c00a727f140f 304
lucas_favre 11:c00a727f140f 305 zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap
lucas_favre 11:c00a727f140f 306 w = zeichen[0]; // width of actual char
lucas_favre 11:c00a727f140f 307 // construct the char into the buffer
lucas_favre 11:c00a727f140f 308 for (j=0; j<vert; j++) { // vert line
lucas_favre 11:c00a727f140f 309 for (i=0; i<hor; i++) { // horz line
lucas_favre 11:c00a727f140f 310 z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1];
lucas_favre 11:c00a727f140f 311 b = 1 << (j & 0x07);
lucas_favre 11:c00a727f140f 312 if (( z & b ) == 0x00) {
lucas_favre 11:c00a727f140f 313 pixel(x+i,y+j,0);
lucas_favre 11:c00a727f140f 314 } else {
lucas_favre 11:c00a727f140f 315 pixel(x+i,y+j,1);
lucas_favre 11:c00a727f140f 316 }
lucas_favre 11:c00a727f140f 317
lucas_favre 11:c00a727f140f 318 }
lucas_favre 11:c00a727f140f 319 }
lucas_favre 11:c00a727f140f 320
lucas_favre 11:c00a727f140f 321 char_x += w;
lucas_favre 11:c00a727f140f 322 }
lucas_favre 11:c00a727f140f 323
lucas_favre 11:c00a727f140f 324
lucas_favre 11:c00a727f140f 325 void C12832::set_font(unsigned char* f)
lucas_favre 11:c00a727f140f 326 {
lucas_favre 11:c00a727f140f 327 font = f;
lucas_favre 11:c00a727f140f 328 }
lucas_favre 11:c00a727f140f 329
lucas_favre 11:c00a727f140f 330 void C12832::set_auto_up(unsigned int up)
lucas_favre 11:c00a727f140f 331 {
lucas_favre 11:c00a727f140f 332 if(up ) auto_up = 1;
lucas_favre 11:c00a727f140f 333 else auto_up = 0;
lucas_favre 11:c00a727f140f 334 }
lucas_favre 11:c00a727f140f 335
lucas_favre 11:c00a727f140f 336 unsigned int C12832::get_auto_up(void)
lucas_favre 11:c00a727f140f 337 {
lucas_favre 11:c00a727f140f 338 return (auto_up);
lucas_favre 11:c00a727f140f 339 }
lucas_favre 11:c00a727f140f 340
lucas_favre 11:c00a727f140f 341 void C12832::print_bm(Bitmap bm, int x, int y)
lucas_favre 11:c00a727f140f 342 {
lucas_favre 11:c00a727f140f 343 int h,v,b;
lucas_favre 11:c00a727f140f 344 char d;
lucas_favre 11:c00a727f140f 345
lucas_favre 11:c00a727f140f 346 for(v=0; v < bm.ySize; v++) { // lines
lucas_favre 11:c00a727f140f 347 for(h=0; h < bm.xSize; h++) { // pixel
lucas_favre 11:c00a727f140f 348 if(h + x > 127) break;
lucas_favre 11:c00a727f140f 349 if(v + y > 31) break;
lucas_favre 11:c00a727f140f 350 d = bm.data[bm.Byte_in_Line * v + ((h & 0xF8) >> 3)];
lucas_favre 11:c00a727f140f 351 b = 0x80 >> (h & 0x07);
lucas_favre 11:c00a727f140f 352 if((d & b) == 0) {
lucas_favre 11:c00a727f140f 353 pixel(x+h,y+v,0);
lucas_favre 11:c00a727f140f 354 } else {
lucas_favre 11:c00a727f140f 355 pixel(x+h,y+v,1);
lucas_favre 11:c00a727f140f 356 }
lucas_favre 11:c00a727f140f 357 }
lucas_favre 11:c00a727f140f 358 }
lucas_favre 11:c00a727f140f 359
lucas_favre 11:c00a727f140f 360 }
lucas_favre 11:c00a727f140f 361
lucas_favre 11:c00a727f140f 362