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