Skip to content

Commit f29376d

Browse files
committed
Added MatrixPortal S3 Factory Test
1 parent 76d29b8 commit f29376d

File tree

2 files changed

+130
-0
lines changed

2 files changed

+130
-0
lines changed

Factory_Tests/MatrixPortal_S3_FacoryTest/.matrixportal_s3.test.only

Whitespace-only changes.
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
#include <Adafruit_LIS3DH.h>
2+
#include <Adafruit_TestBed.h>
3+
#include <WiFi.h>
4+
#include <WiFiAP.h>
5+
#include <Adafruit_Protomatter.h>
6+
7+
8+
extern Adafruit_TestBed TB;
9+
Adafruit_LIS3DH lis = Adafruit_LIS3DH();
10+
11+
uint8_t mcp1_matrix_pins[8] = {45, 21, 37, 39, 38, 40, 41, 42}; // A, E, B2, G2, R2, B1, G1, R1
12+
uint8_t mcp2_matrix_pins[8] = {12, 14, 47, 2, 255, 35, 48, 36}; // A0, OE, LAT, CLK, NC, D, C, B
13+
#define LIGHT_SENSOR 5
14+
15+
int32_t total_time;
16+
17+
bool matrixpinsOK = false, accelOK = false, gpioOK = false, jstOK = false, wifiOK = false, testMode = false, lightOK = false;
18+
uint8_t j=0;
19+
20+
uint8_t rgbPins[] = {42, 41, 40, 38, 39, 37};
21+
uint8_t addrPins[] = {45, 36, 48, 35, 21};
22+
uint8_t clockPin = 2;
23+
uint8_t latchPin = 47;
24+
uint8_t oePin = 14;
25+
Adafruit_Protomatter matrix(
26+
64, // Width of matrix (or matrix chain) in pixels
27+
4, // Bit depth, 1-6
28+
1, rgbPins, // # of matrix chains, array of 6 RGB pins for each
29+
4, addrPins, // # of address pins (height is inferred), array of pins
30+
clockPin, latchPin, oePin, // Other matrix control pins
31+
false); // No double-buffering here (see "doublebuffer" example)
32+
33+
34+
void setup() {
35+
Serial.begin(115200);
36+
//while (!Serial) delay(10);
37+
38+
TB.ledPin = LED_BUILTIN;
39+
TB.neopixelPin = PIN_NEOPIXEL;
40+
TB.neopixelNum = 1;
41+
TB.begin();
42+
43+
total_time = millis();
44+
45+
WiFi.softAPIP();
46+
WiFi.softAP("Matrix Portal ESP32-S3", "adafruit");
47+
48+
if (! testMode) {
49+
// Initialize matrix...
50+
ProtomatterStatus status = matrix.begin();
51+
Serial.print("Protomatter begin() status: ");
52+
Serial.println((int)status);
53+
if(status != PROTOMATTER_OK) {
54+
// DO NOT CONTINUE if matrix setup encountered an error.
55+
for(;;);
56+
}
57+
// Make four color bars (red, green, blue, white) with brightness ramp:
58+
for(int x=0; x<matrix.width(); x++) {
59+
uint8_t level = x * 256 / matrix.width(); // 0-255 brightness
60+
matrix.drawPixel(x, matrix.height() - 4, matrix.color565(level, 0, 0));
61+
matrix.drawPixel(x, matrix.height() - 3, matrix.color565(0, level, 0));
62+
matrix.drawPixel(x, matrix.height() - 2, matrix.color565(0, 0, level));
63+
matrix.drawPixel(x, matrix.height() - 1,
64+
matrix.color565(level, level, level));
65+
}
66+
// You'll notice the ramp looks smoother as bit depth increases
67+
// (second argument to the matrix constructor call above setup()).
68+
69+
// Simple shapes and text, showing GFX library calls:
70+
matrix.drawCircle(12, 10, 9, matrix.color565(255, 0, 0));
71+
matrix.drawRect(14, 6, 17, 17, matrix.color565(0, 255, 0));
72+
matrix.drawTriangle(32, 9, 41, 27, 23, 27, matrix.color565(0, 0, 255));
73+
matrix.println("ADAFRUIT"); // Default text color is white
74+
if (matrix.height() > 32) {
75+
matrix.setCursor(0, 32);
76+
matrix.println("64 pixel"); // Default text color is white
77+
matrix.println("matrix"); // Default text color is white
78+
}
79+
80+
// AFTER DRAWING, A show() CALL IS REQUIRED TO UPDATE THE MATRIX!
81+
82+
matrix.show(); // Copy data to matrix buffers
83+
}
84+
pinMode(LIGHT_SENSOR, INPUT);
85+
}
86+
87+
88+
89+
void loop() {
90+
if (!testMode) {
91+
if (j == 64) {
92+
TB.printI2CBusScan();
93+
}
94+
95+
if (j == 255) {
96+
TB.setColor(WHITE);
97+
pinMode(13, OUTPUT);
98+
digitalWrite(13, HIGH);
99+
Serial.println("scan start");
100+
// WiFi.scanNetworks will return the number of networks found
101+
int n = WiFi.scanNetworks();
102+
Serial.println("scan done");
103+
if (n == 0) {
104+
Serial.println("no networks found");
105+
} else {
106+
Serial.print(n);
107+
Serial.println(" networks found");
108+
for (int i = 0; i < n; ++i) {
109+
// Print SSID and RSSI for each network found
110+
Serial.print(i + 1);
111+
Serial.print(": ");
112+
Serial.print(WiFi.SSID(i));
113+
Serial.print(" (");
114+
Serial.print(WiFi.RSSI(i));
115+
Serial.print(")");
116+
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
117+
delay(10);
118+
}
119+
}
120+
Serial.println("");
121+
digitalWrite(13, LOW);
122+
}
123+
124+
TB.setColor(TB.Wheel(j++));
125+
delay(10);
126+
return;
127+
}
128+
delay(100);
129+
130+
}

0 commit comments

Comments
 (0)