Skip to content

Commit 9eb41bb

Browse files
committed
add S3 feather test
1 parent 1089b04 commit 9eb41bb

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

Factory_Tests/Feather_ESP32S3_TFT_FactoryTest/.feather_esp32s3_tft.test.only

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

0 commit comments

Comments
 (0)