#define OLED_SDA GPIO_NUM_4
#define OLED_SCL GPIO_NUM_15
#define OLED_ADDR 0x3C
#define OLED_RESET GPIO_UNUSED // ie Heltec has GPIO_NUM_16 for reset
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);
}