Skip to content

Commit 48ee3d6

Browse files
committed
le factory test
1 parent 1410f65 commit 48ee3d6

File tree

2 files changed

+108
-0
lines changed

2 files changed

+108
-0
lines changed

Factory_Tests/Feather_ESP32S2_TFT_FactoryTest/.feather_esp32s2_tft.test.only

Whitespace-only changes.
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
#include <Arduino.h>
2+
#include "Adafruit_LC709203F.h"
3+
#include <Adafruit_NeoPixel.h>
4+
#include "Adafruit_TestBed.h"
5+
#include <Adafruit_BME280.h>
6+
#include <Adafruit_ST7789.h>
7+
#include <Fonts/FreeSans12pt7b.h>
8+
9+
Adafruit_BME280 bme; // I2C
10+
bool bmefound = false;
11+
extern Adafruit_TestBed TB;
12+
13+
Adafruit_LC709203F lc;
14+
Adafruit_ST7789 display = Adafruit_ST7789(TFT_CS, TFT_DC, TFT_RST);
15+
16+
GFXcanvas16 canvas(240, 135);
17+
18+
void setup() {
19+
Serial.begin(115200);
20+
// while (! Serial) delay(10);
21+
22+
delay(100);
23+
24+
// turn on the TFT / I2C power supply
25+
pinMode(TFT_I2C_POWER, OUTPUT);
26+
digitalWrite(TFT_I2C_POWER, HIGH);
27+
28+
pinMode(NEOPIXEL_POWER, OUTPUT);
29+
digitalWrite(NEOPIXEL_POWER, HIGH);
30+
delay(10);
31+
32+
TB.neopixelPin = PIN_NEOPIXEL;
33+
TB.neopixelNum = 1;
34+
TB.begin();
35+
TB.setColor(WHITE);
36+
37+
display.init(135, 240); // Init ST7789 240x135
38+
display.setRotation(3);
39+
canvas.setFont(&FreeSans12pt7b);
40+
canvas.setTextColor(ST77XX_WHITE);
41+
42+
if (!lc.begin()) {
43+
Serial.println(F("Couldnt find Adafruit LC709203F?\nMake sure a battery is plugged in!"));
44+
while (1);
45+
}
46+
47+
Serial.println("Found LC709203F");
48+
Serial.print("Version: 0x"); Serial.println(lc.getICversion(), HEX);
49+
lc.setPackSize(LC709203F_APA_500MAH);
50+
51+
if (TB.scanI2CBus(0x77)) {
52+
Serial.println("BME280 address");
53+
54+
unsigned status = bme.begin();
55+
if (!status) {
56+
Serial.println("Could not find a valid BME280 sensor, check wiring, address, sensor ID!");
57+
Serial.print("SensorID was: 0x"); Serial.println(bme.sensorID(),16);
58+
Serial.print(" ID of 0xFF probably means a bad address, a BMP 180 or BMP 085\n");
59+
Serial.print(" ID of 0x56-0x58 represents a BMP 280,\n");
60+
Serial.print(" ID of 0x60 represents a BME 280.\n");
61+
Serial.print(" ID of 0x61 represents a BME 680.\n");
62+
return;
63+
}
64+
Serial.println("BME280 found OK");
65+
bmefound = true;
66+
}
67+
}
68+
69+
uint8_t j = 0;
70+
71+
void loop() {
72+
Serial.println("**********************");
73+
74+
TB.printI2CBusScan();
75+
76+
if (j % 5 == 0) {
77+
canvas.fillScreen(ST77XX_BLACK);
78+
canvas.setCursor(0, 25);
79+
canvas.setTextColor(ST77XX_RED);
80+
canvas.println("Adafruit Feather");
81+
canvas.setTextColor(ST77XX_YELLOW);
82+
canvas.println("ESP32-S2 TFT Demo");
83+
canvas.setTextColor(ST77XX_GREEN);
84+
canvas.print("Battery: ");
85+
canvas.setTextColor(ST77XX_WHITE);
86+
canvas.print(lc.cellVoltage(), 1);
87+
canvas.print(" V / ");
88+
canvas.print(lc.cellPercent(), 0);
89+
canvas.println("%");
90+
canvas.setTextColor(ST77XX_BLUE);
91+
canvas.print("I2C: ");
92+
canvas.setTextColor(ST77XX_WHITE);
93+
for (uint8_t a=0x01; a<=0x7F; a++) {
94+
if (TB.scanI2CBus(a, 0)) {
95+
canvas.print("0x");
96+
canvas.print(a, HEX);
97+
canvas.print(", ");
98+
}
99+
}
100+
display.drawRGBBitmap(0, 0, canvas.getBuffer(), 240, 135);
101+
pinMode(TFT_BACKLITE, OUTPUT);
102+
digitalWrite(TFT_BACKLITE, HIGH);
103+
}
104+
105+
TB.setColor(TB.Wheel(j++));
106+
delay(10);
107+
return;
108+
}

0 commit comments

Comments
 (0)