Erik van de Coevering / UC1701

Dependents:   Opensmart_LCD_UC1701

Files at this revision

API Documentation at this revision

Comitter:
Anaesthetix
Date:
Mon Dec 19 12:58:10 2016 +0000
Parent:
2:d9e9d326c4bb
Child:
4:8da4c691643a
Commit message:
Added setContrast() function

Changed in this revision

UC1701.cpp Show annotated file Show diff for this revision Revisions of this file
UC1701.h Show annotated file Show diff for this revision Revisions of this file
--- a/UC1701.cpp	Sun Dec 18 21:17:42 2016 +0000
+++ b/UC1701.cpp	Mon Dec 19 12:58:10 2016 +0000
@@ -36,22 +36,32 @@
     _lcd->write(0x2E);              // Voltage regulator on
     _lcd->write(0x2F);              // Voltage follower on
     _lcd->write(0xF8);              // Set booster ratio
-    _lcd->write(0x00);              // to 4
+    _lcd->write(0x00);              
     _lcd->write(0x23);              // Set resistor ratio
-    _lcd->write(0x81);              // to 3
-    _lcd->write(0x28);              // Set Electronic volume to 40
-    _lcd->write(0xEE);              // Set cursor update ON -> after write, column cursor will be updated (rows will not!)
+    _lcd->write(0x81);              // Set contrast to
+    _lcd->write(0x28);              // 40
+    _lcd->write(0xEE);              // Set cursor update -> after write, column cursor will be updated (rows will not!)
     _lcd->write(0xAC);              // Disable static indicator
     _lcd->write(0x00);
     _lcd->write(0xA6);              // Disable inverse
     _lcd->write(0xAF);              // Display enable
-    //_lcd->write(0xA5);              // display all points
+    //_lcd->write(0xA5);            // display all points
     _lcd->write(0xA4);              // clear
-    _lcd_cs->write(1);                  // disable SPI
-    _lcd_cd->write(1);                  // DATA mode
+    _lcd_cs->write(1);              // disable SPI
+    _lcd_cd->write(1);              // DATA mode
 
 }
 
+void UC1701::setContrast(char contrast)
+{
+    _lcd_cs->write(0);              // enable SPI
+    _lcd_cd->write(0);              // command mode
+    _lcd->write(0x81);              // command to set contrast
+    _lcd->write(contrast);          // set contrast
+    _lcd_cs->write(1);
+    _lcd_cd->write(1);
+    }
+
 void UC1701::setCursor(char column, char line)
 {
     int i, j;
--- a/UC1701.h	Sun Dec 18 21:17:42 2016 +0000
+++ b/UC1701.h	Mon Dec 19 12:58:10 2016 +0000
@@ -41,6 +41,9 @@
 
     // Initialize LCD
     void init(void);
+    
+    // Set contrast (0 - 63), initialized to 40
+    void setContrast(char contrast);
 
     // Place cursor at position
     void setCursor(char column, char line);
@@ -54,7 +57,7 @@
     // Write text to LCD where font format is a 2-dimensional array (only 96x8, 8x8 pixel fonts supported)
     void writeText2d(char column, char page, const char font_address[96][8], const char *text, int size);
 
-    // Write text to LCD where font format is a 1-dimensional array
+    // Write text to LCD where font format is a 1-dimensional array. Fonts bigger than 8 pix high should work but isn't tested
     void writeText(char column, char page, const char *font_address, const char *str, const uint8_t size);
 
     // Draw a 128x64 pixel bitmap