Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 17:b116da3bffbb, committed 2021-04-19
- Comitter:
- pfammjur
- Date:
- Mon Apr 19 19:21:26 2021 +0000
- Parent:
- 16:7fb1d4d3525d
- Child:
- 18:6ab8b740e55a
- Commit message:
- 1st running display test.
Changed in this revision
--- a/Adafruit_SSD1306.cpp Tue Nov 11 22:08:20 2014 +0000
+++ b/Adafruit_SSD1306.cpp Mon Apr 19 19:21:26 2021 +0000
@@ -22,6 +22,7 @@
#include "mbed.h"
#include "Adafruit_SSD1306.h"
+#include "platform/mbed_thread.h" //Muss immer rein
#define SSD1306_SETCONTRAST 0x81
#define SSD1306_DISPLAYALLON_RESUME 0xA4
@@ -49,11 +50,11 @@
{
rst = 1;
// VDD (3.3V) goes high at start, lets just chill for a ms
- wait_ms(1);
+ thread_sleep_for(1);
// bring reset low
rst = 0;
// wait 10ms
- wait_ms(10);
+ thread_sleep_for(10);
// bring out of reset
rst = 1;
// turn on VCC (9V?)
--- a/Adafruit_SSD1306.h Tue Nov 11 22:08:20 2014 +0000
+++ b/Adafruit_SSD1306.h Mon Apr 19 19:21:26 2021 +0000
@@ -158,7 +158,7 @@
class Adafruit_SSD1306_I2c : public Adafruit_SSD1306
{
public:
- #define SSD_I2C_ADDRESS 0x78
+ #define SSD_I2C_ADDRESS 0x7A
/** Create a SSD1306 I2C transport display driver instance with the specified RST pin name, the I2C address, as well as the display dimensions
*
* Required parameters
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/OLEDTest.cpp Mon Apr 19 19:21:26 2021 +0000
@@ -0,0 +1,63 @@
+/*
+ * 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 "platform/mbed_thread.h" //Muss immer rein
+#define SCREEN_ADRESS 0x3D
+
+DigitalOut myled(LED1);
+static BufferedSerial pc(USBTX, USBRX); //pc Seriel für baud
+
+using namespace std::chrono; //Namespce für printf
+
+
+
+// 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(I2C_SDA, I2C_SCL); //I2CPreInit gI2C(d9,d10);
+Adafruit_SSD1306_I2c gOled2(gI2C,D4,0x7A,64,128); //Adafruit_SSD1306_I2c gOled2(gI2C,p27);
+
+int main()
+{ uint16_t i=0;
+ //gOled2.begin(SSD1306_SWITCHCAPVCC);
+ thread_sleep_for(1000);
+ pc.set_baud(9600); //baudrate
+ gOled2.clearDisplay();
+ gOled2.drawPixel (10, 10,WHITE);
+ gOled2.display();
+ thread_sleep_for(1000);
+ gOled2.clearDisplay();
+ while(true)
+ {
+ gOled2.setTextCursor(0,0);
+ gOled2.printf("%ux%u OLED Display\r\n", gOled2.width(), gOled2.height());
+ gOled2.printf("Hello World\n");
+ gOled2.printf("Laufnr.: %d\r",i);
+ gOled2.display();
+ i++;
+ myled = !myled;
+ thread_sleep_for(1000);
+ gOled2.clearDisplay();
+ //printf("%d",i);
+ }
+}
\ No newline at end of file