The final project of Embedde class.
Revision 19:e0ff672950db, committed 2021-06-03
- Comitter:
- pkr7098
- Date:
- Thu Jun 03 07:05:21 2021 +0000
- Parent:
- 18:03069e3deaa4
- Commit message:
- The final project of Embedded class.
Changed in this revision
C12832.cpp | Show annotated file Show diff for this revision Revisions of this file |
C12832.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/C12832.cpp Fri May 09 23:03:21 2014 +0000 +++ b/C12832.cpp Thu Jun 03 07:05:21 2021 +0000 @@ -466,6 +466,20 @@ } +int C12832::_putcI(int value) +{ + if (value == '\n') { // new line + char_x = 0; + char_y = char_y + font[2]; + if (char_y >= height() - font[2]) { + char_y = 0; + } + } else { + characterI(char_x, char_y, value); + if(auto_up) copy_to_lcd(); + } + return value; +} int C12832::_putc(int value) { @@ -523,6 +537,46 @@ char_x += w; } +void C12832::characterI(int x, int y, int c) +{ + unsigned int hor,vert,offset,bpl,j,i,b; + unsigned char* zeichen; + unsigned char z,w; + + if ((c < 31) || (c > 127)) return; // test char range + + // read font parameter from start of array + offset = font[0]; // bytes / char + hor = font[1]; // get hor size of font + vert = font[2]; // get vert size of font + bpl = font[3]; // bytes per line + + if (char_x + hor > width()) { + char_x = 0; + char_y = char_y + vert; + if (char_y >= height() - font[2]) { + char_y = 0; + } + } + + zeichen = &font[((c -32) * offset) + 4]; // start of char bitmap + w = zeichen[0]; // width of actual char + // construct the char into the buffer + for (j=0; j<vert; j++) { // vert line + for (i=0; i<hor; i++) { // horz line + z = zeichen[bpl * i + ((j & 0xF8) >> 3)+1]; + b = 1 << (j & 0x07); + if (( z & b ) == 0x00) { + pixel(x+i,y+j,1); + } else { + pixel(x+i,y+j,0); + } + + } + } + + char_x += w; +} void C12832::set_font(unsigned char* f) {
--- a/C12832.h Fri May 09 23:03:21 2014 +0000 +++ b/C12832.h Thu Jun 03 07:05:21 2021 +0000 @@ -190,6 +190,13 @@ virtual int _putc(int value); /** + * Put a color inverted char on the screen + * + * @param value char to print + * @returns printed char + */ + virtual int _putcI(int value); + /** * Draw a character on given position out of the active font to the LCD * * @param x x-position of char (top left) @@ -199,6 +206,14 @@ virtual void character(int x, int y, int c); /** + * Draw a inverted color character on given position out of the active font to the LCD + * + * @param x x-position of char (top left) + * @param y y-position + * @param c char to print + */ + virtual void characterI(int x, int y, int c); + /** * Setup cursor position * * @param x x-position (top left)