got PAM amp working on analog pin

This commit is contained in:
zyphlar
2026-07-04 03:28:13 -07:00
parent 81e4fffc02
commit 8a6d096635
+15 -12
View File
@@ -70,8 +70,8 @@ using namespace Adafruit_LittleFS_Namespace;
// Map these to your actual PCB connections.
// Audio
#define PIN_AUDIO_PWM 8 // Any PWM-capable pin
#define PIN_AMP_SD 14 // PAM8302A shutdown (HIGH=enabled)
#define PIN_AUDIO_PWM 0 // Any PWM-capable pin
#define PIN_AMP_SD 6 // PAM8302A shutdown (HIGH=enabled)
// Motor
#define PIN_MOTOR_PWM 15 // PWM to MOSFET gate
@@ -81,7 +81,7 @@ using namespace Adafruit_LittleFS_Namespace;
// SPI MOSI/MISO/SCK use default SPI pins
// Buttons (directly to GPIO, active LOW with internal pull-up)
#define PIN_BTN1 0
#define PIN_BTN1 4
#define PIN_BTN2 1
#define PIN_BTN3 5
#define PIN_BTN4 3
@@ -690,7 +690,7 @@ void setupBLE() {
uint32_t g_nextSampleUs = 0;
// Software gain: 1=unity, 2=2x, etc. (clips at 0/255). Adjustable via 'u'/'d' serial.
static uint8_t g_audioGain = 3;
static uint8_t g_audioGain = 1;
// Called from loop() every 125µs while g_playing
void audioTick(void) {
@@ -925,12 +925,15 @@ void setup() {
int c=0;
while(c<10) {
delay(250);
digitalWrite(PIN_LED, LOW);
// Serial.println("0");
// pinMode(c, OUTPUT);
delay(250);
digitalWrite(PIN_LED, HIGH);
// Serial.println("1");
// digitalWrite(c, HIGH);
// Serial.println("0");
delay(250);
digitalWrite(PIN_LED, LOW);
// digitalWrite(c, LOW);
// Serial.println(c);
c++;
}
@@ -981,8 +984,8 @@ void setup() {
#ifdef POC_INTERNAL_FLASH
// Boot test tone: 440Hz square wave for 1 second
// If you hear a beep, the amp/PWM chain is working.
Serial.println("Boot tone...");
digitalWrite(PIN_AMP_SD, HIGH);
Serial.println("Boot tone disabled...");
// digitalWrite(PIN_AMP_SD, HIGH);
delay(20);
for (int i = 0; i < 8000; i++) {
// 440Hz at 8kHz sample rate: 8000/440 ≈ 18 samples/cycle
@@ -1263,7 +1266,7 @@ void loop() {
btnLastMs[btn] = millis();
Serial.print("BTN"); Serial.println(btn);
g_lastActivity = millis();
/*
switch (btn) {
case 1: // Play / Pause
case 2:
@@ -1312,7 +1315,7 @@ void loop() {
audioStop();
motorStop();
break;
}
}*/
waitButtonRelease(btn);
}