Skip to content

Commit cfdb0e3

Browse files
authored
Merge pull request #2523 from adafruit/updated_s3tft_factoryreset
Updating the Feather ESP32-S3 TFT Factory Reset
2 parents e7549f2 + aa40afb commit cfdb0e3

File tree

1 file changed

+39
-14
lines changed

1 file changed

+39
-14
lines changed

Factory_Tests/Feather_ESP32S3_TFT_FactoryTest/Feather_ESP32S3_TFT_FactoryTest.ino

Lines changed: 39 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// SPDX-License-Identifier: MIT
44

55
#include <Arduino.h>
6+
#include "Adafruit_MAX1704X.h"
67
#include "Adafruit_LC709203F.h"
78
#include <Adafruit_NeoPixel.h>
89
#include "Adafruit_TestBed.h"
@@ -14,14 +15,19 @@ Adafruit_BME280 bme; // I2C
1415
bool bmefound = false;
1516
extern Adafruit_TestBed TB;
1617

17-
Adafruit_LC709203F lc;
18+
Adafruit_LC709203F lc_bat;
19+
Adafruit_MAX17048 max_bat;
20+
1821
Adafruit_ST7789 display = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
1922

2023
GFXcanvas16 canvas(240, 135);
2124

25+
bool maxfound = false;
26+
bool lcfound = false;
27+
2228
void setup() {
2329
Serial.begin(115200);
24-
// while (! Serial) delay(10);
30+
// while (! Serial) delay(10);
2531

2632
delay(100);
2733

@@ -42,15 +48,26 @@ void setup() {
4248
display.setRotation(3);
4349
canvas.setFont(&FreeSans12pt7b);
4450
canvas.setTextColor(ST77XX_WHITE);
45-
46-
if (!lc.begin()) {
47-
Serial.println(F("Couldnt find Adafruit LC709203F?\nMake sure a battery is plugged in!"));
48-
while (1);
51+
if (lc_bat.begin()) {
52+
Serial.println("Found LC709203F");
53+
Serial.print("Version: 0x"); Serial.println(lc_bat.getICversion(), HEX);
54+
lc_bat.setPackSize(LC709203F_APA_500MAH);
55+
lcfound = true;
4956
}
57+
else {
58+
Serial.println(F("Couldnt find Adafruit LC709203F?\nChecking for Adafruit MAX1704X.."));
59+
delay(200);
60+
if (!max_bat.begin()) {
61+
Serial.println(F("Couldnt find Adafruit MAX1704X?\nMake sure a battery is plugged in!"));
62+
while (1) delay(10);
63+
}
64+
Serial.print(F("Found MAX17048"));
65+
Serial.print(F(" with Chip ID: 0x"));
66+
Serial.println(max_bat.getChipID(), HEX);
67+
maxfound = true;
5068

51-
Serial.println("Found LC709203F");
52-
Serial.print("Version: 0x"); Serial.println(lc.getICversion(), HEX);
53-
lc.setPackSize(LC709203F_APA_500MAH);
69+
}
70+
5471

5572
if (TB.scanI2CBus(0x77)) {
5673
Serial.println("BME280 address");
@@ -87,10 +104,18 @@ void loop() {
87104
canvas.setTextColor(ST77XX_GREEN);
88105
canvas.print("Battery: ");
89106
canvas.setTextColor(ST77XX_WHITE);
90-
canvas.print(lc.cellVoltage(), 1);
91-
canvas.print(" V / ");
92-
canvas.print(lc.cellPercent(), 0);
93-
canvas.println("%");
107+
if (lcfound == true) {
108+
canvas.print(lc_bat.cellVoltage(), 1);
109+
canvas.print(" V / ");
110+
canvas.print(lc_bat.cellPercent(), 0);
111+
canvas.println("%");
112+
}
113+
else {
114+
canvas.print(max_bat.cellVoltage(), 1);
115+
canvas.print(" V / ");
116+
canvas.print(max_bat.cellPercent(), 0);
117+
canvas.println("%");
118+
}
94119
canvas.setTextColor(ST77XX_BLUE);
95120
canvas.print("I2C: ");
96121
canvas.setTextColor(ST77XX_WHITE);
@@ -109,4 +134,4 @@ void loop() {
109134
TB.setColor(TB.Wheel(j++));
110135
delay(10);
111136
return;
112-
}
137+
}

0 commit comments

Comments
 (0)