Skip to content

Commit

Permalink
better strip power management on enable/disable from bento
Browse files Browse the repository at this point in the history
  • Loading branch information
benkuper committed May 6, 2024
1 parent 965ddd7 commit 6816043
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Firmware/Bentuino/.vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@
]
},
"defines": [
"PLATFORMIO=60114",
"PLATFORMIO=60115",
"ARDUINO_ESP32_DEV",
"USE_SERIAL",
"USE_SERVER",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ void LedStripComponent::clearInternal()
{
clearColors();
showLeds();
setStripPower(false);

delete neoPixelStrip;
neoPixelStrip = NULL;

delete dotStarStrip;
dotStarStrip = NULL;

setStripPower(false);
}

void LedStripComponent::setBrightness(float val)
Expand Down
2 changes: 1 addition & 1 deletion Modules/juce_organicui
17 changes: 15 additions & 2 deletions Source/Prop/props/bento/BentoProp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ BentoProp::BentoProp(var params) :
brightness = generalCC.addFloatParameter("Brightness", "Brightness of the prop", 1, 0, 1);
battery = generalCC.addFloatParameter("Battery", "Battery level of the prop", 1, 0, 1);
battery->setControllableFeedbackOnly(true);
clearLedsOnRemove = generalCC.addBoolParameter("Clear LEDs on remove", "Clear LEDs when the prop is removed", true);
enableLedsOnConnect = generalCC.addBoolParameter("Enable LEDs on connect", "Enable LEDs when the prop is connected", true);

artnet.inputCC->enabled->setValue(false);

Expand All @@ -54,6 +56,7 @@ BentoProp::BentoProp(var params) :

playbackAddress = "/leds/strip1/playbackLayer";
streamingAddress = "/leds/strip1/streamLayer";
ledEnabledAddress = "/leds/strip1/enabled";
}

BentoProp::~BentoProp()
Expand All @@ -63,7 +66,10 @@ BentoProp::~BentoProp()

void BentoProp::clearItem()
{
if (clearLedsOnRemove->boolValue()) sendMessageToProp(OSCMessage(ledEnabledAddress, 0));

Prop::clearItem();

setSerialDevice(nullptr);
}

Expand Down Expand Up @@ -91,7 +97,7 @@ void BentoProp::onContainerParameterChangedInternal(Parameter* p)

if (p == enabled)
{
sendMessageToProp(OSCMessage("/leds/strip1/enabled", enabled->boolValue() ? 1 : 0));
sendMessageToProp(OSCMessage(ledEnabledAddress, enabled->boolValue() ? 1 : 0));
}
}

Expand Down Expand Up @@ -136,6 +142,13 @@ void BentoProp::onControllableFeedbackUpdateInternal(ControllableContainer* cc,
{
battery->setValue(batteryRef->floatValue());
}
else if (c == isConnected)
{
if (isConnected->boolValue() && enabled->boolValue())
{
if(enableLedsOnConnect->boolValue()) sendMessageToProp(OSCMessage(ledEnabledAddress, 1));
}
}
}

void BentoProp::serialDataReceived(SerialDevice* d, const var& data)
Expand Down Expand Up @@ -163,7 +176,7 @@ void BentoProp::sendColorsToPropInternal()
int numChannels = jmax(0, jmin(colors.size() - startLed, 170));

data.fill(0);

for (int i = 0; i < numChannels; i++)
{
int channelIndex = i * 3;
Expand Down
5 changes: 5 additions & 0 deletions Source/Prop/props/bento/BentoProp.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@ class BentoProp :
const int remotePort = 9000;
OSCSender oscSender;


SerialDeviceParameter* serialParam;
SerialDevice* serialDevice;
BoolParameter* enableLedsOnConnect;
BoolParameter* clearLedsOnRemove;

DMXArtNetDevice artnet;
OwnedArray<DMXUniverse, CriticalSection> universes;
Expand All @@ -34,8 +37,10 @@ class BentoProp :
IntParameter* resolutionRef;
FloatParameter* brightnessRef;


String playbackAddress;
String streamingAddress;
String ledEnabledAddress;

virtual void clearItem() override;

Expand Down

0 comments on commit 6816043

Please sign in to comment.