Nokia 5110 Library

Revision:
51:f3b30020324f
Parent:
50:c299b1099189
diff -r c299b1099189 -r f3b30020324f N5110.cpp
--- a/N5110.cpp	Wed Jan 15 16:41:35 2020 +0000
+++ b/N5110.cpp	Fri Jan 14 21:36:29 2022 +0000
@@ -56,17 +56,18 @@
 void N5110::init()
 {
     turnOn();     // power up
+      wait_ms(10);  // small delay seems to prevent spurious pixels during mbed reset
     reset();      // reset LCD - must be done within 100 ms
-    initSPI();    
+   // initSPI();    
     
-    setContrast(0.5);  // this may need tuning (say 0.4 to 0.6)
-    setBias(5);   // datasheet - 48:1 mux - don't mess with if you don't know what you're doing! (0 to 7)
+    setContrast(0.55);  // this may need tuning (say 0.4 to 0.6)
+    setBias(3);   // datasheet - 48:1 mux - don't mess with if you don't know what you're doing! (0 to 7)
     setTempCoefficient(0); // datasheet - may need increasing (range 0 to 3) at very low temperatures
     normalMode();  // normal video mode by default
     
     clearRAM();      // RAM is undefined at power-up so clear to be sure
     clear();   // clear buffer
-    setBrightness(0.1);
+    setBrightness(0.5);
 }
 
 // sets normal video mode (black on white)
@@ -188,8 +189,8 @@
 // function to initialise SPI peripheral
 void N5110::initSPI()
 {
-    _spi->format(8,0);    // 8 bits, Mode 1 - polarity 0, phase 1 - base value of clock is 0, data captured on falling edge/propagated on rising edge
-    _spi->frequency(2250000);  // maximum of screen is 4 MHz
+    _spi->format(8,1);    // 8 bits, Mode 1 - polarity 0, phase 1 - base value of clock is 0, data captured on falling edge/propagated on rising edge
+    _spi->frequency(4000000);  // maximum of screen is 4 MHz
 }
 
 // send a command to the display
@@ -283,8 +284,8 @@
 
     _sce->write(0);  //set CE low to begin frame
 
-    for(int j = BANKS-1; j>=0; j--) {  // be careful to use correct order (j,i) for horizontal addressing
-        for(int i =WIDTH-1; i>=0; i--) {
+    for(int j = 0; j < BANKS; j++) {  // be careful to use correct order (j,i) for horizontal addressing
+        for(int i = 0; i < WIDTH; i++) {
             _spi->write(buffer[i][j]);  // send buffer
         }
     }