Code for driving 9x OLED displays and reding from an HX711 load cell aplifier.
Dependencies: Adafruit_GFX SPI_TFT_ILI9341 TFT_fonts hx711 mbed
Revision 0:3745349c0c83, committed 2015-01-30
- Comitter:
- jimconner
- Date:
- Fri Jan 30 00:01:26 2015 +0000
- Child:
- 1:c09b25119427
- Commit message:
- Added single pin mux support for a CD4067 (will add more pins later)
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Adafruit_GFX.lib Fri Jan 30 00:01:26 2015 +0000 @@ -0,0 +1,1 @@ +http://developer.mbed.org/users/nkhorman/code/Adafruit_GFX/#bf0e4072b06d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jan 30 00:01:26 2015 +0000 @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2012 Neal Horman - http://www.wanlink.com + * + * License: MIT open source (http://opensource.org/licenses/MIT) + * Summary; + * Use / modify / distribute / publish it how you want and + * if you use it, or don't, you can't hold me liable for how + * it does or doesn't work. + * If it doesn't work how you want, don't use it, or change + * it so that it does work. + */ + +#include "mbed.h" +#include "Adafruit_SSD1306.h" +#include "Adafruit_GFX.h" +#include "PinNames.h" + +PwmOut led1(LED1); +PwmOut led2(LED2); + + +// an SPI sub-class that provides a constructed default +class SPIPreInit : public SPI +{ +public: + SPIPreInit(PinName mosi, PinName miso, PinName clk) : SPI(mosi,miso,clk) + { + format(8,3); + frequency(2000000); + }; +}; + +// an I2C sub-class that provides a constructed default +class I2CPreInit : public I2C +{ +public: + I2CPreInit(PinName PTE0, PinName PTE1) : I2C(PTE0, PTE1) + { + frequency(800000); + start(); + wait(0.1); // needed so that the displays initialise properly at power-on. + }; +}; + +//SPIPreInit gSpi(p5,NC,p7); +//Adafruit_SSD1306_Spi gOled1(gSpi,p26,p25,p24); + +I2CPreInit gI2C(PTE0,PTE1); +mux_SSD1306_I2c gOled1(gI2C,PTD1,PTB0, 0, 0x78,64); +mux_SSD1306_I2c gOled2(gI2C,PTD1,PTB0, 0, 0x7A,64); +mux_SSD1306_I2c gOled3(gI2C,PTD1,PTB0, 1, 0x78,64); +mux_SSD1306_I2c gOled4(gI2C,PTD1,PTB0, 1, 0x7A,64); + +void testdrawline() { + for (int16_t i=0; i<gOled1.width(); i+=4) { + gOled1.drawLine(0, 0, i, gOled1.height()-1, WHITE); + gOled1.display(); + } + for (int16_t i=0; i<gOled2.height(); i+=4) { + gOled2.drawLine(0, 0, gOled2.width()-1, i, WHITE); + gOled2.display(); + } + for (int16_t i=0; i<gOled3.height(); i+=4) { + gOled3.drawLine(0, 0, gOled3.width()-1, i, WHITE); + gOled3.display(); + } + for (int16_t i=0; i<gOled4.width(); i+=4) { + gOled4.drawLine(0, 0, i, gOled4.height()-1, WHITE); + gOled4.display(); + } + +} + + + +int main() +{ uint16_t x=0; + uint16_t y=65535; + uint16_t a=16348; + uint16_t b=49152; + led1=1; + led2=1; + + + gOled1.clearDisplay(); + gOled2.clearDisplay(); + gOled3.clearDisplay(); + gOled4.clearDisplay(); + + testdrawline(); + + gOled1.clearDisplay(); + gOled2.clearDisplay(); + gOled3.clearDisplay(); + gOled4.clearDisplay(); + + gOled1.printf(" Counting Up \r\n\n\n\n", gOled1.width(), gOled1.height()); + gOled2.printf(" Counting Down \r\n\n\n\n", gOled2.width(), gOled2.height()); + gOled3.printf(" More going up \r\n\n\n\n", gOled3.width(), gOled3.height()); + gOled4.printf(" More going down \r\n\n\n\n", gOled4.width(), gOled4.height()); + gOled1.setTextSize(2); + gOled2.setTextSize(2); + gOled3.setTextSize(2); + gOled4.setTextSize(2); + + + while(1) + { + led1 = 0.98; + gOled1.printf(" %uml\r",x); + gOled1.display(); + led1 = 1; + led2 = 0.98; + gOled2.printf(" %uml\r",y); + gOled2.display(); + gOled3.printf(" %uK\r",a); + gOled3.display(); + gOled4.printf(" %uK\r",b); + gOled4.display(); + led2 = 1; + x++; + y--; + a++; + b--; + //wait(0.1); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri Jan 30 00:01:26 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file