/*************************************************************
* Sketch for testing ESP32-C3 with LCD screen.
*
* This sketch Copyright Tochinet 2026, MIT license
*
* Tried the proposed OLED_Display_SSD1306 library of WokWi
* - won't compile, the yield added for ESP8266 is defined without #ifdef
* - corrected by adding #ifdef and copying .h and .cpp files here
* - incredibly slow refresh ! ABORT
* Tried lcdgfx instead
* - supposedly very fast
*
************************************************************/
#define RGBLED 8 // GPIO for RGB LED, unused
#define SCLPIN 9 // always OUT, should be OK sharing with LED
#define SDAPIN 8
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#include <Arduino.h>
#include <FlexWire.h> // recommended by WokWi instead of Wire.h
FlexWire Wire = FlexWire(SDAPIN, SCLPIN); // No default pins on ESP32-C3 devkitm-1
//#include <OLED_Display_SSD1306.h> // local file, from gitHub repo
#include <lcdgfx.h>
DisplaySSD1306_128x64_I2C display(-1); // as object
void setup() {
Serial.begin(115200);
Serial.println("ESP32-C3, ready to shine !");
//OLED_Display_SSD1306_init(); // default I2C address 0x3C OK
}
uint16_t color=0;
void loop() {
for(int x=0; x<SCREEN_WIDTH; x++) {
Serial.print(".");
display.drawPixel(x, x/2, color); // Diagonal line
}
Serial.print("Line drawn! Color = ");
Serial.println(color);
//OLED_Display_SSD1306_display();
color++;
if (color>2) color=0;
}