From dd637a95714909da0a3ee8ed380dd8b53c663308 Mon Sep 17 00:00:00 2001 From: Andrew Combs Date: Wed, 20 Jul 2022 22:05:20 -0400 Subject: [PATCH] Remove debug print and add LED Add an LED that's lit when the bluetooth remote connects and goes out when it disconnects. Also remove some debug print statements. --- RainSpeaker/src/Bluetooth.cpp | 4 ++++ RainSpeaker/src/main.cpp | 21 ++++----------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/RainSpeaker/src/Bluetooth.cpp b/RainSpeaker/src/Bluetooth.cpp index d45eea6..e3bc2fc 100644 --- a/RainSpeaker/src/Bluetooth.cpp +++ b/RainSpeaker/src/Bluetooth.cpp @@ -12,6 +12,8 @@ static BLERemoteCharacteristic *pRemoteCharacteristicEnc; static BLERemoteCharacteristic *pRemoteCharacteristicBtn; static BLEAdvertisedDevice *myDevice; +extern int greenLedPin; + Bluetooth::Bluetooth() { } @@ -58,12 +60,14 @@ class MyClientCallback : public BLEClientCallbacks { void onConnect(BLEClient *pclient) { + digitalWrite(greenLedPin, HIGH); } void onDisconnect(BLEClient *pclient) { connected = false; Serial.println("onDisconnect"); + digitalWrite(greenLedPin, LOW); } }; diff --git a/RainSpeaker/src/main.cpp b/RainSpeaker/src/main.cpp index 216a84f..3b97586 100644 --- a/RainSpeaker/src/main.cpp +++ b/RainSpeaker/src/main.cpp @@ -19,11 +19,15 @@ uint8_t volume; uint8_t prevVol; int actualVolume = 70; +int greenLedPin = selfAudioKit->pinGreenLed(); + void setup() { Serial.begin(115200); // AudioLogger::instance().begin(Serial, AudioLogger::Info); + pinMode(greenLedPin, OUTPUT); + bt.Init(); bt.SetVolumePointer(&volume); @@ -50,13 +54,6 @@ void loop() bt.Run(); int delta = volume - prevVol; - Serial.print(volume); - Serial.print(" | "); - Serial.print(prevVol); - Serial.print(" | "); - Serial.print(delta); - Serial.print(" | "); - prevVol = volume; if (delta > 128) @@ -69,14 +66,8 @@ void loop() delta = delta + 256; } - Serial.print(delta); - Serial.print(" | "); - actualVolume += delta; - Serial.print(actualVolume); - Serial.print(" | "); - if (actualVolume < 0) { actualVolume = 0; @@ -87,11 +78,7 @@ void loop() actualVolume = 100; } - Serial.print(actualVolume); - Serial.print(" | "); - float vol = (float)actualVolume / 100.0; - Serial.println(vol); player.setVolume(vol); }