Skip to content

Commit

Permalink
simplify addressing of RGB LEDs
Browse files Browse the repository at this point in the history
- change Faust string IDs of said LEDs
  • Loading branch information
mzuther committed Jul 10, 2020
1 parent a422526 commit 2d86719
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 189 deletions.
197 changes: 64 additions & 133 deletions src/ProtoFaust.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,139 +123,45 @@ ProtoFaust::ProtoFaust()

// ------ RGB LEDs ------

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_1_R,
"/ProtoFaust/Lights/1_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_1_G,
"/ProtoFaust/Lights/1_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_1_B,
"/ProtoFaust/Lights/1_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_2_R,
"/ProtoFaust/Lights/2_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_2_G,
"/ProtoFaust/Lights/2_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_2_B,
"/ProtoFaust/Lights/2_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_3_R,
"/ProtoFaust/Lights/3_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_3_G,
"/ProtoFaust/Lights/3_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_3_B,
"/ProtoFaust/Lights/3_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_4_R,
"/ProtoFaust/Lights/4_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_4_G,
"/ProtoFaust/Lights/4_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_4_B,
"/ProtoFaust/Lights/4_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_5_R,
"/ProtoFaust/Lights/5_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_5_G,
"/ProtoFaust/Lights/5_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_5_B,
"/ProtoFaust/Lights/5_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_6_R,
"/ProtoFaust/Lights/6_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_6_G,
"/ProtoFaust/Lights/6_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_6_B,
"/ProtoFaust/Lights/6_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_7_R,
"/ProtoFaust/Lights/7_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_7_G,
"/ProtoFaust/Lights/7_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_7_B,
"/ProtoFaust/Lights/7_B" );



addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_8_R,
"/ProtoFaust/Lights/8_R" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_8_G,
"/ProtoFaust/Lights/8_G" );

addParameter( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_8_B,
"/ProtoFaust/Lights/8_B" );
addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_1,
"/ProtoFaust/Lights/1" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_2,
"/ProtoFaust/Lights/2" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_3,
"/ProtoFaust/Lights/3" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_4,
"/ProtoFaust/Lights/4" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_5,
"/ProtoFaust/Lights/5" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_6,
"/ProtoFaust/Lights/6" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_7,
"/ProtoFaust/Lights/7" );

addParameterLed( passiveWidgets,
ProtoFaustWidget::LED_RGB,
LED_8,
"/ProtoFaust/Lights/8" );
}


Expand Down Expand Up @@ -307,6 +213,31 @@ void ProtoFaust::addParameter( std::vector<WidgetAccess>& widgets,
}


void ProtoFaust::addParameterLed( std::vector<WidgetAccess>& widgets,
int widgetType,
int parameterId,
const std::string& faustStringId )
{
// add a parameter for each virtual LED pin (red, green and blue)

addParameter( widgets,
widgetType,
parameterId,
faustStringId + "_Red" );

addParameter( widgets,
widgetType,
parameterId + 1,
faustStringId + "_Green" );

addParameter( widgets,
widgetType,
parameterId + 2,
faustStringId + "_Blue" );

}


void ProtoFaust::onAdd()
{
FaustDSP.buildUserInterface( &FaustUI );
Expand Down
53 changes: 29 additions & 24 deletions src/ProtoFaust.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,37 +79,37 @@ struct ProtoFaust : Module {
};

enum LedIds {
LED_1_R,
LED_1_G,
LED_1_B,
LED_1,
LED_1_GREEN_INTERNAL_USE_ONLY,
LED_1_BLUE_INTERNAL_USE_ONLY,

LED_2_R,
LED_2_G,
LED_2_B,
LED_2,
LED_2_GREEN_INTERNAL_USE_ONLY,
LED_2_BLUE_INTERNAL_USE_ONLY,

LED_3_R,
LED_3_G,
LED_3_B,
LED_3,
LED_3_GREEN_INTERNAL_USE_ONLY,
LED_3_BLUE_INTERNAL_USE_ONLY,

LED_4_R,
LED_4_G,
LED_4_B,
LED_4,
LED_4_GREEN_INTERNAL_USE_ONLY,
LED_4_BLUE_INTERNAL_USE_ONLY,

LED_5_R,
LED_5_G,
LED_5_B,
LED_5,
LED_5_GREEN_INTERNAL_USE_ONLY,
LED_5_BLUE_INTERNAL_USE_ONLY,

LED_6_R,
LED_6_G,
LED_6_B,
LED_6,
LED_6_GREEN_INTERNAL_USE_ONLY,
LED_6_BLUE_INTERNAL_USE_ONLY,

LED_7_R,
LED_7_G,
LED_7_B,
LED_7,
LED_7_GREEN_INTERNAL_USE_ONLY,
LED_7_BLUE_INTERNAL_USE_ONLY,

LED_8_R,
LED_8_G,
LED_8_B,
LED_8,
LED_8_GREEN_INTERNAL_USE_ONLY,
LED_8_BLUE_INTERNAL_USE_ONLY,

NUM_LED_PINS
};
Expand Down Expand Up @@ -142,6 +142,11 @@ struct ProtoFaust : Module {
int parameterId,
const std::string& faustStringId );

void addParameterLed( std::vector<WidgetAccess>& widgets,
int widgetType,
int parameterId,
const std::string& faustStringId );

void attachFaustParameter( WidgetAccess& widget );
void updateParameter( WidgetAccess& widget );
};
Expand Down
18 changes: 10 additions & 8 deletions src/ProtoFaustWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ ProtoFaustWidget::ProtoFaustWidget( ProtoFaust* module ) :
setPanel( APP->window->loadSvg(
asset::plugin( pluginInstance, "res/ProtoFaust.svg" ) ) );

// "repetitive" takes on a whole new meaning here

// ------ screws ------

placeWidget( ProtoFaustWidget::SCREW,
Expand Down Expand Up @@ -229,42 +231,42 @@ ProtoFaustWidget::ProtoFaustWidget( ProtoFaust* module ) :
// ------ RGB LEDs ------

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_1_R,
ProtoFaust::LED_1,
99.06,
21.82 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_2_R,
ProtoFaust::LED_2,
99.06,
34.52 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_3_R,
ProtoFaust::LED_3,
99.06,
49.76 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_4_R,
ProtoFaust::LED_4,
99.06,
62.46 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_5_R,
ProtoFaust::LED_5,
99.06,
77.7 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_6_R,
ProtoFaust::LED_6,
99.06,
90.4 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_7_R,
ProtoFaust::LED_7,
99.06,
105.64 );

placeWidget( ProtoFaustWidget::LED_RGB,
ProtoFaust::LED_8_R,
ProtoFaust::LED_8,
99.06,
118.34 );
}
Expand Down
Loading

0 comments on commit 2d86719

Please sign in to comment.