library for Sharp memory LCD (LS027B4DH01)
Dependents: Sharp_Memory_LCD_Test Sharp_Memory_LCD_Test
Revision 1:f8ba3b236d12, committed 2014-05-11
- Comitter:
- masato
- Date:
- Sun May 11 14:03:39 2014 +0000
- Parent:
- 0:c99dda90f834
- Commit message:
- RC1
Changed in this revision
sharp_mlcd.cpp | Show annotated file Show diff for this revision Revisions of this file |
sharp_mlcd.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r c99dda90f834 -r f8ba3b236d12 sharp_mlcd.cpp --- a/sharp_mlcd.cpp Sat May 10 15:32:38 2014 +0000 +++ b/sharp_mlcd.cpp Sun May 11 14:03:39 2014 +0000 @@ -58,10 +58,11 @@ void sharp_mlcd::lcd_reset() { _CS = 0; - _spi.format(8, 0); // 8 bit spi mode 0 + _spi.format(8, 0); // 8 bit spi mode 0 _spi.frequency(2000000); // 2 Mhz SPI clock _DISP = 1; flip = 0; + set_reverse_mode(0); // timer.attach(attime, 0.5); // 1KHz _CS = 1; @@ -82,6 +83,11 @@ set_font((unsigned char*)Small_7); // standart font } +void sharp_mlcd::set_reverse_mode(unsigned int r = 0) +{ + reverse = r; +} + // set one pixel in buffer void sharp_mlcd::pixel(int x, int y, int color) @@ -90,12 +96,12 @@ if(x > WIDTH || y > HEIGHT || x < 0 || y < 0) return; if(draw_mode == NORMAL) { - if(color == 0) + if(color != reverse) buffer[x/8 + (y*WIDTH/8)] &= ~(1 << (7-(x%8))); // set pixel else buffer[x/8 + (y*WIDTH/8)] |= (1 << (7-(x%8))); // erase pixel } else { // XOR mode - if(color == 1) + if(color != reverse) buffer[x/8 + (y*WIDTH/8)] ^= (1 << (7-(x%8))); // xor pixel } } @@ -139,7 +145,7 @@ void sharp_mlcd::cls(void) { - memset(buffer,0x00,BUFFER_SIZE); // clear display buffer + memset(buffer, reverse? 0x00: 0xff, BUFFER_SIZE); // clear display buffer copy_to_lcd(); } @@ -475,7 +481,7 @@ return (auto_up); } -void sharp_mlcd::print_bm(Bitmap bm, int x, int y) +void sharp_mlcd::print_bm(Bitmap bm, int x, int y, int color = 1) { int h,v,b; char d; @@ -487,9 +493,9 @@ d = bm.data[bm.Byte_in_Line * v + ((h & 0xF8) >> 3)]; b = 0x80 >> (h & 0x07); if((d & b) == 0) { - pixel(x+h,y+v,0); + pixel(x+h,y+v,!color); } else { - pixel(x+h,y+v,1); + pixel(x+h,y+v,color); } } }
diff -r c99dda90f834 -r f8ba3b236d12 sharp_mlcd.h --- a/sharp_mlcd.h Sat May 10 15:32:38 2014 +0000 +++ b/sharp_mlcd.h Sun May 11 14:03:39 2014 +0000 @@ -231,8 +231,9 @@ * */ - void print_bm(Bitmap bm, int x, int y); + void print_bm(Bitmap bm, int x, int y, int color); void attime(); + void set_reverse_mode(unsigned int r); protected: @@ -280,7 +281,7 @@ unsigned int char_x; unsigned int char_y; unsigned char buffer[BUFFER_SIZE]; - unsigned int contrast; + unsigned int reverse; unsigned int auto_up; unsigned int flip;