/*
程序: ESP32 OLED 使用 U8G2库
大家可以尝试一下改写成为FREERTOS
公众号:孤独的二进制
*/
#include <U8g2lib.h>
#include <Wire.h>
#include "Font7Seg.h"
U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
const int out05 = 5; // Status LED
const int out04 = 4;
const int out02 = 2;
const int output = 5;
const int buttonPin = 15;
void setup() {
Serial.begin(9600);
u8g2.begin();
pinMode(out02, OUTPUT);
pinMode(out04, INPUT_PULLUP);
pinMode(buttonPin, INPUT_PULLUP); // 15
}
int x;
void loop() {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_baby_tf); // choose a suitable font
u8g2.drawStr(15, 10, "LONELY BINARY"); // write something to the internal memory
u8g2.sendBuffer(); // transfer internal memory to the display
x = digitalRead(out04);
Serial.println("3 " + String(x));
x = digitalRead(buttonPin);
Serial.println("4 " + String(x));
digitalWrite(out02, HIGH);
delay(500);
digitalWrite(out02, LOW);
delay(500);
}