Package: advanced-led-control
AboutA package to ease the control of theblinkstick nanoSource code is athttps://github.com/weshouman/advanced_led_controlExampleSave this example astest.pythen run it as in theUsagesection belowimportadvanced_led_control.models.colorsascfromadvanced_led_control.models.ledsimport*fromadvanced_led_control.models.ValueIndicationimport*fromadvanced_led_control.models.Indicatorimport*fromadvanced_led_control.models.Procedureimport*defindic1_func():# Indication values are best shown between 1 and 10value_indication=ValueIndication(c.RED,10)returnvalue_indicationdefindic2_func():value_indication=ValueIndication(c.BLUE,NO_FLICKER)returnvalue_indicationindic1=Indicator(m_col=c.GREEN,func=indic1_func,i_time=4)indic2=Indicator(m_col=c.GREEN,func=indic2_func,i_time=4)stick=blinkstick.find_first()procedure=Procedure(stick=stick,mode_led=LED_2,quiet=10,sync_duration=10)# Append all indicators to be runprocedure.indicators.append(indic1)procedure.indicators.append(indic2)# Run the specified procedureprocedure.run()UsageThis utility needssudoto execute, as required by theblinkstickpackage.
If you are using a virtualenv, runvirtualenv -p python3 venv
pip install advanced-led-control
source venv/bin/activate
# Follow this [answer](https://stackoverflow.com/a/50335946/2730737) for why we need to use fully qualified path with sudo
sudo venv/bin/python test.pyIf you are using sudo natively, runsudo -E python test.pyConfigurationIndicator Paramsm_col: the indication mode color, based on any of the color types defined belowfunc: a callback that will be called to evaluate the color and flickering for the value led.brightness: a value in range [0, 1] that gets multiplied by both the mode and value indication.i_time: indication time, is how much time is allocated for this mode.Indicator CallbackReturnscolor: the indication value color, based on any of the color types defined belowNOTE: CSS names don't work with flickering, follow thisreportflickering: an integer that shows the speed of flickering of this color,
the higher the value the faster the flickering.
Recommended Values are in range [1, 20].
UseNO_FLICKERor1001to set the led on without flickering.Color TypeAn indication color is either one of the 3 typesRGB: a list of 3 vals in RGB ie. [0, 10, 0].HEX: a string ie. '#00ffff'.CSS_NAME: a string ie. 'aliceblue'.Procedure Paramsmode_led: Choose betweenLED_1andLED_2, currentlyLED_1isn't supported
as the blinkstick doesn't allow flickering the second led
while the first is set constantly.Follow thisreport.quiet: A percentage to be taken from the indication time for the stick to shutdown.Settingquiet=0will disable this feature,
and force all the indications to run consecutively.Settingquiet=100is useless, as it will take all the indication time as a break!sync_duration: Allows starting the procedure at a specific second,
as this package is made to run for multiple machines/RPis that are working separately,
and to avoid using communication to control the led,
we allow sync based on real time.Use async_durationof at least 1.2 total indication time to count for the
delay the pulses make, and if it's less than the total indication time,
it will be almost useless.NOTE: Setsync_duration=0to disable this feature.NOTE: Settingsync_durationto say 8 will start at every eighth second,
In example, [0, 8, 16, 24, 32 ...]NotesThis project was inspired by thePi Dramble