Skip to content

Commit

Permalink
Added setAuxDimmer(0 to DimmerBLEServer. This dimmer, if set, will be…
Browse files Browse the repository at this point in the history
… turned off if the main dimmer is turned off through the BLE interface.
  • Loading branch information
jackjansen committed Dec 27, 2024
1 parent beb4b50 commit 07eb34b
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
5 changes: 5 additions & 0 deletions libLissabon/src/DimmerBLEServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ bool DimmerBLEServer::blePutHandler(UUIDstring charUUID) {
int value = bleApi.getAsInt(Lissabon::Dimmer::isOnUUIDstring);
dimmer.isOn = (bool)value;
IFDEBUG IotsaSerial.printf("xxxjack ble: wrote isOn %s value %d\n", Lissabon::Dimmer::isOnUUIDstring, dimmer.isOn);
if (!value && auxDimmer != nullptr) {
auxDimmer->isOn = false;
auxDimmer->updateDimmer();
IFDEBUG IotsaSerial.printf("xxxjack ble: also turned off auxdimmer\n");
}
anyChanged = true;
}
if (charUUID == Lissabon::Dimmer::identifyUUIDstring) {
Expand Down
4 changes: 3 additions & 1 deletion libLissabon/src/DimmerBLEServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ namespace Lissabon {

class DimmerBLEServer : public IotsaBLEApiProvider {
public:
DimmerBLEServer(AbstractDimmer& _dimmer) : dimmer(_dimmer) {};
DimmerBLEServer(AbstractDimmer& _dimmer) : dimmer(_dimmer), auxDimmer(nullptr) {};
void setup();
void setAuxDimmer(AbstractDimmer* _auxDimmer) { auxDimmer = _auxDimmer; }
protected:
AbstractDimmer& dimmer;
AbstractDimmer* auxDimmer;
IotsaBleApiService bleApi;
bool blePutHandler(UUIDstring charUUID);
bool bleGetHandler(UUIDstring charUUID);
Expand Down
7 changes: 5 additions & 2 deletions lissabonDimmer/lissabonDimmer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -326,12 +326,15 @@ void LissabonDimmerMod::setup() {
#elif defined(WITH_ROTARY)
iotsaConfig.allowRCMDescription("press button 4 times");
dimmerUI.setRotaryEncoder(button, encoder);
#else
#error "No UI defined"
#endif
dimmer.setup();
dimmerBLEServer.setup();
dimmer.updateDimmer();
#ifdef WITH_DOUBLE_DIMMER
dimmer2.setup();
dimmerBLEServer.setAuxDimmer(&dimmer2);
dimmer2.updateDimmer();
#endif
}

void LissabonDimmerMod::loop() {
Expand Down

0 comments on commit 07eb34b

Please sign in to comment.