#define OLED_SDA GPIO_NUM_4
#define OLED_SCL GPIO_NUM_15
#define OLED_ADDR 0x3C
#define OLED_RESET GPIO_UNUSED
void setup()
{
Serial.
begin(115200); delay(500); Serial.write(
"\n\n\n");
PS2Controller.
begin(PS2Preset::KeyboardPort0_MousePort1, KbdMode::GenerateVirtualKeys);
I2C.begin(OLED_SDA, OLED_SCL);
DisplayController.
begin(&
I2C, OLED_ADDR, OLED_RESET);
while (DisplayController.
available() ==
false) {
Serial.write("Error, SSD1306 not available!\n");
delay(5000);
}
}
class MyApp : public uiApp {
void init() {
appProps().realtimeReshaping = true;
auto label1 = new uiLabel(rootWindow(), "Enter you name", Point(0, 0));
auto textEdit1 = new uiTextEdit(rootWindow(), "", Point(0, 19), Size(128, 20));
setFocusedWindow(textEdit1);
auto button1 = new uiButton(rootWindow(), "OK", Point(48, 42), Size(30, 20));
button1->onClick = [=]() { button1Click(textEdit1->text()); };
}
void button1Click(char const * txt) {
auto frame = new uiFrame(rootWindow(), " ", Point(10, 10), Size(108, 44));
auto label1 = new uiLabel(frame, "", Point(10, 20));
label1->labelStyle().textFont = &fabgl::FONT_std_16;
label1->setTextFmt("Hello %s!!", txt);
setActiveWindow(frame);
}
} app;
void loop()
{
app.run(&DisplayController);
}
I2C class allows multiple tasks to communicate with I2C devices, serializing read/write jobs.
static void begin(gpio_num_t port0_clkGPIO, gpio_num_t port0_datGPIO, gpio_num_t port1_clkGPIO=GPIO_UNUSED, gpio_num_t port1_datGPIO=GPIO_UNUSED)
Initializes PS2 device controller.
The PS2 device controller class.
void setResolution(char const *modeline, int viewPortWidth=-1, int viewPortHeight=-1, bool doubleBuffered=false)
Sets SSD1306 resolution and viewport size.
bool available()
Checks the SSD1306 device availability.
void begin(I2C *i2c, int address=0x3C, gpio_num_t resetGPIO=GPIO_UNUSED)
Initializes SSD1306 assigning I2C bus, reset pin and address.
Display driver for SSD1306 based OLED display, with I2C connection.
This file is the all in one include file. Application can just include this file to use FabGL library...
This file contains all classes related to FabGL Graphical User Interface.