Skip to content

Commit

Permalink
Remove debug print and add LED
Browse files Browse the repository at this point in the history
Add an LED that's lit when the bluetooth remote connects and goes out when it disconnects. Also remove some debug print statements.
  • Loading branch information
ofthedove committed Jul 21, 2022
1 parent 51fea5c commit dd637a9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 17 deletions.
4 changes: 4 additions & 0 deletions RainSpeaker/src/Bluetooth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ static BLERemoteCharacteristic *pRemoteCharacteristicEnc;
static BLERemoteCharacteristic *pRemoteCharacteristicBtn;
static BLEAdvertisedDevice *myDevice;

extern int greenLedPin;

Bluetooth::Bluetooth()
{
}
Expand Down Expand Up @@ -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);
}
};

Expand Down
21 changes: 4 additions & 17 deletions RainSpeaker/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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);
}

Expand Down

0 comments on commit dd637a9

Please sign in to comment.