Skip to content

Commit eb969fa

Browse files
committed
factory reset for sparkle motion stick
adding factory reset for sparkle motion stick
1 parent 0b7aa5d commit eb969fa

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed

Factory_Tests/Adafruit_Sparkle_Motion_Stick_FactoryTest/.feather_esp32_v2.test.only

Whitespace-only changes.
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// SPDX-FileCopyrightText: 2025 Limor Fried for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
#include <Arduino.h>
5+
#include "WiFi.h"
6+
#include <Adafruit_TestBed.h>
7+
#include "ESP_I2S.h"
8+
extern Adafruit_TestBed TB;
9+
10+
// I2S pin definitions
11+
const uint8_t I2S_SCK = 14; // BCLK
12+
const uint8_t I2S_WS = 12; // LRCLK
13+
const uint8_t I2S_DIN = 13; // DATA_IN
14+
I2SClass i2s;
15+
16+
// the setup routine runs once when you press reset:
17+
void setup() {
18+
Serial.begin(115200);
19+
pinMode(LED_BUILTIN, OUTPUT);
20+
digitalWrite(LED_BUILTIN, HIGH);
21+
i2s.setPins(I2S_SCK, I2S_WS, -1, I2S_DIN);
22+
if (!i2s.begin(I2S_MODE_STD, 44100, I2S_DATA_BIT_WIDTH_16BIT, I2S_SLOT_MODE_MONO, I2S_STD_SLOT_LEFT)) {
23+
Serial.println("Failed to initialize I2S bus!");
24+
return;
25+
}
26+
// TestBed will handle the neopixel swirl for us
27+
TB.neopixelPin = PIN_NEOPIXEL;
28+
TB.neopixelNum = 1;
29+
TB.begin();
30+
31+
// Set WiFi to station mode and disconnect from an AP if it was previously connected
32+
WiFi.mode(WIFI_STA);
33+
WiFi.disconnect();
34+
}
35+
36+
// the loop routine runs over and over again forever:
37+
uint8_t wheelColor=0;
38+
void loop() {
39+
if (wheelColor == 0) {
40+
// Test WiFi Scan!
41+
// WiFi.scanNetworks will return the number of networks found
42+
int n = WiFi.scanNetworks();
43+
Serial.print("WiFi AP scan done...");
44+
if (n == 0) {
45+
Serial.println("no networks found");
46+
} else {
47+
Serial.print(n);
48+
Serial.println(" networks found");
49+
for (int i = 0; i < n; ++i) {
50+
// Print SSID and RSSI for each network found
51+
Serial.print(i + 1);
52+
Serial.print(": ");
53+
Serial.print(WiFi.SSID(i));
54+
Serial.print(" (");
55+
Serial.print(WiFi.RSSI(i));
56+
Serial.print(")");
57+
Serial.println((WiFi.encryptionType(i) == WIFI_AUTH_OPEN)?" ":"*");
58+
delay(10);
59+
}
60+
}
61+
Serial.println("");
62+
for (int i=0; i < 5; i++) {
63+
int32_t sample = i2s.read();
64+
if (sample >= 0){
65+
Serial.print("Amplitude: ");
66+
Serial.println(sample);
67+
68+
// Delay to avoid printing too quickly
69+
delay(200);
70+
}
71+
}
72+
}
73+
74+
TB.setColor(TB.Wheel(wheelColor++)); // swirl NeoPixel
75+
digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
76+
77+
delay(5);
78+
}

0 commit comments

Comments
 (0)