So here is my simple sketch just to make sure everything works as intended. I believe the battery is now charging since the display is on while not connected to any power. I am still not able to get the buttons to do anything nor can i see the battery charge levels to display or the LED, hopefully it is just something in the code.
#include <M5GFX.h>
M5GFX display; // Create a display instance
NessoBattery battery; // ---- Battery ----
void setup() {
Serial.begin(115200);
display.begin();
display.setRotation(1); // Set to landscape mode
// Configure the built-in LED as an output
pinMode(LED_BUILTIN, OUTPUT);
// ----Buttons ----
pinMode(KEY1, INPUT_PULLUP);
pinMode(KEY2, INPUT_PULLUP);
// Set text properties
display.setTextDatum(MC_DATUM); // Middle-Center datum for text alignment
display.setTextColor(TFT_YELLOW, TFT_BLUE); // White text, black background
display.setTextSize(2);
// Clear the screen and draw the string
display.fillScreen(TFT_BLUE);
display.drawString("Hello, Nesso N1!", display.width() / 2, display.height() / 2);
// ---- Battery ----
battery.enableCharge();
uint16_t chargeLevel = battery.getChargeLevel();
Serial.print("Charge Level: ");
Serial.print(chargeLevel);
Serial.println(" %");
}
void loop() {
//---- Buttons -----
if (digitalRead(KEY1) == LOW) {
Serial.println("Button 1 pressed!");
delay(200); // Simple debounce
}
if (digitalRead(KEY2) == LOW) {
Serial.println("Button 2 pressed!");
delay(200); // Simple debounce
// Blink the LED
digitalWrite(LED_BUILTIN, LOW); // Turn LED ON
delay(500);
digitalWrite(LED_BUILTIN, HIGH); // Turn LED OFF
delay(500);
}
}
"
oops, helps if i include Drawstrings... This one shows me the battery charge but still no buttons clicks
#include <M5GFX.h>
M5GFX display;
NessoBattery battery;
// Button pins on Nesso N1
#define BTN1 KEY1
#define BTN2 KEY2
void setup() {
Serial.begin(115200);
display.begin();
display.setRotation(1);
display.fillScreen(TFT_BLACK);
display.setTextSize(2);
display.setTextDatum(TL_DATUM);
display.setTextColor(TFT_WHITE, TFT_BLACK);
pinMode(KEY1, INPUT_PULLUP);
pinMode(KEY2, INPUT_PULLUP);
battery.enableCharge();
display.drawString("Battery & Button Test", 10, 10);
}
void loop() {
// -------- BATTERY ----------
static uint32_t lastBattUpdate = 0;
if (millis() - lastBattUpdate > 1000) { // update every 1 second
lastBattUpdate = millis();
uint16_t level = battery.getChargeLevel();
// Clear area before redrawing
display.fillRect(10, 40, 200, 30, TFT_BLACK);
char buf[32];
sprintf(buf, "Battery: %d %%", level);
display.drawString(buf, 10, 40);
}
// -------- BUTTONS ----------
if (digitalRead(KEY1) == LOW) {
display.fillRect(10, 80, 200, 30, TFT_BLACK);
display.drawString("BTN1 pressed", 10, 80);
Serial.println("BTN1 pressed");
delay(200);
}
if (digitalRead(KEY2) == LOW) {
display.fillRect(10, 120, 200, 30, TFT_BLACK);
display.drawString("BTN2 pressed", 10, 120);
Serial.println("BTN2 pressed");
delay(200);
}
}
