EDIT: Solved - it turned out that the ssd.InitializeI2C(4, 0x3c) was the problem. For the 64 x 48 display, it needs to be ssd.InitializeI2C(0, 0x3c).
Hi All,
I have a 64 x 48 OLED display shield that I've been trying to get working using the various examples in the forum, however have had no luck.
In the end I ran the I2C scanner in the Arduino IDE (that Erel suggested in another thread) & confirmed that the display was correctly connected to my Wemos D1 R2, however I still couldn't get the bouncy ball (or other) demos to work.
Finally I downloaded the code below & compiled & uploaded it in the Arduino IDE & it worked. So my question is, what is the B4R equivalent to this? I suspect that the "magic ingredient" is the Adafruit SSD1306 library, but I'm not sure...
- Colin.
Hi All,
I have a 64 x 48 OLED display shield that I've been trying to get working using the various examples in the forum, however have had no luck.
In the end I ran the I2C scanner in the Arduino IDE (that Erel suggested in another thread) & confirmed that the display was correctly connected to my Wemos D1 R2, however I still couldn't get the bouncy ball (or other) demos to work.
Finally I downloaded the code below & compiled & uploaded it in the Arduino IDE & it worked. So my question is, what is the B4R equivalent to this? I suspect that the "magic ingredient" is the Adafruit SSD1306 library, but I'm not sure...
B4X:
#include "SPI.h"
#include "Wire.h"
#include "Adafruit_GFX.h"
#include "Adafruit_SSD1306.h"
#define OLED_RESET 0 // GPIO0
Adafruit_SSD1306 display(OLED_RESET);
void setup() {
Serial.begin(9600);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
// init done
display.display();
delay(2000);
// Clear the buffer.
display.clearDisplay();
// text display tests
display.setTextSize(2);
display.setTextColor(WHITE);
display.setCursor(0,10);
display.println("Hello");
display.println("World");
display.display();
delay(10000);
display.clearDisplay();
}
void loop() {
}
- Colin.