Hi!
Sadly I am stuck at getting my project to work. I tried to simplyfy my problem as much as I coud for this post:
I want to use an SSD1306 OLED display (with u8g2 libary) and a button (with ezButton libary for deboucing with the internal pull-up resistor).
Using the ezButton libary works fine. Whenever I press the button attatched to pin 7 on my Arduino Nano the serialmonitor prints a message if the button is pressed. BUT: as soon as I use the u8g2 libary (using full buffer mode) the button does not work properly. The button presses are not recognized.
The SSD1306 libary itself works fine - I see the text I want on the screen.
Does anybody know, what I can to to get my button work? Why are these two libaries not compatible? Is there a better debouncing libary for buttons than ezButton?
This is the code:
#include <ezButton.h>
#include <U8g2lib.h>
U8G2_SSD1306_128X64_NONAME_F_SW_I2C u8g2(U8G2_R0, /* clock=*/ SCL, /* data=*/ SDA, /* reset=*/ U8X8_PIN_NONE); // All Boards without Reset of the Display
#include <Wire.h>
ezButton b_mode(7); // button connected to D7
byte mode = 1; // set menu for startup
void setup() {
Serial.begin(9600);
u8g2.begin();
b_mode.setDebounceTime(50); // [ms]
}
void loop() {
b_mode.loop();
int b_mode_state = b_mode.getState();
if(b_mode.isPressed()) {
Serial.println("mode pressed");
}
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_6x10_tr);
u8g2.drawStr(12,10,"TEST");
u8g2.sendBuffer(); // transfer internal memory to the display
}