Test code attempting to drive a Ebay SSD1306 128X65 LCD from STM F303K8. The chip responds my I2C address scanner but the LCD never turns on or displays anything.

Dependencies:   SSD1308_128x64_I2C mbed Adafruit_GFX

Fork of Nucleo-F303K8-ADC-TEST by Joseph Ellsworth

Update of sample using Adafruit library to drive a generic Ebay SSD1306 OLED display. On Nucleo-F303K8 it will display reading of first two ADC lines once every couple seconds. Should work with other CPU boards.

Files at this revision

API Documentation at this revision

Comitter:
joeata2wh
Date:
Wed Mar 30 14:49:21 2016 +0000
Parent:
2:dc3e84d595c3
Commit message:
update to use MIT license

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r dc3e84d595c3 -r 47148198f5f2 main.cpp
--- a/main.cpp	Mon Mar 21 03:42:56 2016 +0000
+++ b/main.cpp	Wed Mar 30 14:49:21 2016 +0000
@@ -1,7 +1,12 @@
 /* Example of Reading all the ADC pins PIN and display ot OLED display using
- Nucleo_F303K8 by Joseph Ellsworth CTO A2WH -  Free for all but no warranty, no promises
- Displays voltage read from first 2 ADC lines on OLED display
+ Nucleo_F303K8. Displays voltage read from first 2 ADC lines on OLED display
 
+  By Joseph Ellsworth CTO of A2WH
+  Take a look at A2WH.com Producing Water from Air using Solar Energy
+  March-2016 License: https://developer.mbed.org/handbook/MIT-Licence 
+  Please contact us http://a2wh.com for help with custom design projects.
+
+  
   Used to Drive:
    ebay part http://www.ebay.com/itm/152000005331?_trksid=p2057872.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT
   0-96-I2C-IIC-SPI-Serial-White-OLED-LCD-LED-Display-Module-128X64
@@ -34,6 +39,10 @@
 
 AnalogIn   pa0(PA_0);
 AnalogIn   pa1(PA_1);
+PwmOut  fan1(D11);
+//PwmOut  fan2(D12);
+//PwmOut  fan3(PA_2);
+DigitalOut fan2x(D12);
 
 DigitalOut myled(LED1);
 const float voltMeterARef = 3.3;
@@ -57,9 +66,9 @@
 {
     float tval = ain.read();
     float volts = tval * voltMeterARef;
-    float perc = tval * 100.0;
+    float perc = tval * 100.0f;
     unsigned short  tvalu16 = ain.read_u16 ();
-    printf("adc %s R=%3.3f V=%3.3f%% U16=%u\r\n",label, tval, volts, tvalu16);
+    pc.printf("adc %s R=%3.3f V=%3.3f U16=%u\r\n",label, tval, volts, tvalu16);
     gOled2.printf("%s=%3.3fV\r\n",label,volts);
     gOled2.display();
     return tval;
@@ -68,6 +77,7 @@
 
 int main()
 {
+    pc.baud(9600);
     // Display with the Adafruit Library
     gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height());
     wait(5);
@@ -80,8 +90,64 @@
         wait(0.1);
         gOled2.setTextCursor(1,10);
         readPrint(pa1, "PA_1");
+        
+         float pwmpw = 0.3; //0.0005; //0.09; // 0.1001;
+         float pwmpp = 3.0; //0.00001; //0.0001; // 0.01001;
+         //fan2.period_ms();
+         //fan2.pulsewidth_ms(200);
+         
+         //float pwmpw = 0.1; //0.0005; //0.09; // 0.1001;
+         //float pwmpp = 1.0; //0.00001; //0.0001; // 0.01001;
+        //fan2.pulsewidth(0.1);
+        //fan2.period(1.0  / 10.0);
+        //fan2.pulsewidth(2.0);
+        //fan2.period(20);
+        float pwmduty = 0.1f;
+        float unit_time = 10.0;                  
+        float total_period = 0.1; //0.7; //3.5; //0.8;
+        float num_cycle = (unit_time / total_period) + 1;
+
+        while (pwmduty <= 1.1f) {
+            float on_time = total_period * pwmduty;
+            float off_time = total_period - on_time;
+            //gOled2.clearDisplay();
+            gOled2.setTextCursor(1,20);
+            wait(0.1);
+            gOled2.printf("pwm=%3.3f\r\n", pwmduty);            
+            wait(0.1);
+            gOled2.display();
+            wait(0.1);
+            gOled2.display();
+            wait(0.1);
+            pc.printf("pwm=%3.3f\r\n", pwmduty);            
+            //wait(3.0);
+            fan2x = 1;
+            wait(0.15);
+            for (int x=0; x<= num_cycle; x++) {
+            
+            fan2x = 1;
+            wait(on_time);
+            fan2x = 0;
+            wait(off_time);
+            // accelerate to get the motor turning
+            // then slow down to the current speed;
+            //fan1 = 0.0;
+            //fan2 = 0.0;
+            //fan3 = 0.0;
+            //wait(0.02);
+            //fan1 = pwmduty;
+            //fan2 = pwmduty;
+            //fan3 = pwmduty;
+            //fan2 = pwmduty;
+            //fan2.period(pwmduty/100);
+            //fan2.period(pwmduty);
+            
+            }
+            pwmduty+= 0.1f;
+        }        
+        //fan1 = 0.0;
+        //fan2 = 0.0;
+        //fan3 = 0.0;
         wait(3.0);
     }
-
-
 }