fixed library.

Dependents:   Sharp_Memory_LCD_Test hello_GT20L16J1Y_FONT_mlcd

Fork of sharp_mlcd by Masato YAMANISHI

Revision:
1:f8ba3b236d12
Parent:
0:c99dda90f834
Child:
2:c36cdd3ad7ba
--- 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);
       }
     }
   }