![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
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
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.
main.cpp
- Committer:
- joeata2wh
- Date:
- 2016-03-21
- Revision:
- 2:dc3e84d595c3
- Parent:
- 1:90d213185462
- Child:
- 3:47148198f5f2
File content as of revision 2:dc3e84d595c3:
/* 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 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 The Datasheet. https://www.adafruit.com/datasheets/SSD1306.pdf Unfortunately this part never turns on using the SSD1308 library. but did find that the https://developer.mbed.org/users/nkhorman/code/Adafruit_GFX/ library works. Unfortunately the Adafruit library doesn't include the scroll functionality. Using my I2C address scanner I found that it responds on Added 120 (x78) ,121 (x79) and when the part was unsoldered nothing responded on 120 or 121. According to to the page #19 (8.1.5) of the data sheet the I2C address should be 011110 which seems to map correctly to dec=120 hex=79 */ #include "mbed.h" //#include "SSD1308.h" #include "Adafruit_SSD1306.h" //#include "mbed_logo.h" //Pin Defines for I2C Bus #define D_SDA PB_7 // specific for Nucleo-F303K8 #define D_SCL PB_6 // specific for Nucleo-F303K8 I2C i2c(D_SDA, D_SCL); // Host PC Communication channels Serial pc(USBTX, USBRX); // tx, rx AnalogIn pa0(PA_0); AnalogIn pa1(PA_1); DigitalOut myled(LED1); const float voltMeterARef = 3.3; // an I2C sub-class that provides a constructed default class I2CPreInit : public I2C { public: I2CPreInit(PinName sda, PinName scl) : I2C(sda, scl) { frequency(400000); start(); }; }; I2CPreInit gI2C(D_SDA,D_SCL); Adafruit_SSD1306_I2c gOled2(gI2C,PB_5); float readPrint(AnalogIn ain, char *label) { float tval = ain.read(); float volts = tval * voltMeterARef; float perc = tval * 100.0; unsigned short tvalu16 = ain.read_u16 (); 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; } int main() { // Display with the Adafruit Library gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height()); wait(5); gOled2.clearDisplay(); while(1) { myled = !myled; gOled2.clearDisplay(); gOled2.setTextCursor(1,1); readPrint(pa0, "PA_0"); wait(0.1); gOled2.setTextCursor(1,10); readPrint(pa1, "PA_1"); wait(3.0); } }