Illuminated pushbuttons when powered on - would it be possible?

Hi, I was wondering if there’s a way to have LED backlit pushbuttons to - at least - turn on with the lightsaber and turn off when lightsaber goes into sleep? Or even better - to also blink when buttons are pressed, maybe even with blink type corresponding to actual function that was called by pressing a button?

Thanks in advance,
PS: I don’t know the programming language, but I’m fine with editing and uploading the code, as long as I know what and where to edit, lol

Regards,
M_M

Hello @M_M

It is certainly possible but you have to modify the code.

For example, you can start blinking a button LED using the blink function (documentation here).

Add

config.hw.button_onoff.button.blink(5, 1000, 500);

In line 149, in the PBSaber.cpp file, like the following:

	initialized = true;
	play(fontBoot);
	enterState(stateOff);

	config.hw.button_onoff.button.blink(5, 1000, 500);
	return true;

Where 5 is the pin where the button LED (cathode) is connected (with it’s current limiting resistor, of course). 1000 is the duration of each cycle (in milliseconds), and 500 is the time the LED is on (in milliseconds). You can modify these values.

Unfortunately, there is not a simple configuration to add this feature right now, and code modifications for other custom features might require some knowledge of the language (but if you ever programmed an Arduino, it is completely at your reach).

1 Like

Hello @Ivan

Thank you for sharing detailed instructions how to make it working! I’ll try this for sure, as soon as I finish assembling the lightsaber… Still got few parts to 3d print and assemble everything.

Merry Christmas!

M_M

Hello @Ivan

I got the font working, had to convert all files from 16bit 44kHz to 16bit 22kHz. I’m using two buttons configured on pins 2 and 3 (both “low”). I have one font and 4 profiles. I can’t work out how to fix the following issue, it happens in all profiles:
When I press the “ON/OFF” button, the led strip turns on (ignition_mode = scroll and retraction_mode = scroll), all functions work fine, PropBoard reacts correctly to “FX” button and all movements. But when I want to turn it off, I press and hold “ON/OFF” button, serial monitor says “RETRACTION” and pbsaber goes into “OFF” mode, so I can cycle through profiles by short pressing “FX” button, but the led strip stays lit (ON) as well as “Hum” sound is still being played continuously. When I press “ON/OFF” button again (for IGNITION), the led strip turns OFF for a moment and turns on again with the correct colour setup from chosen profile. It seems that the only way to turn off the led strip and “Hum” sound after I press and hold “ON/OFF” button is to cycle power to the board or disconnect the power by using SPST switch on battery positive to the board. But I don’t want to use additional switch and from my understanding there shouldn’t be one anyway? Could you help me please?

Regards,
M_M

Actually I found out what was wrong…
I used the config_template.ini file provided in PBSaber_v1.0.0 and just now I realised that in the line #65

# Retraction
retraction = pwroff\pwroff
off_min_max = 1,2 # it is not the correct key.

Changed this to

# Retraction
retraction = pwroff\pwroff
retraction_min_max = 1,2

And it worked (obviously haha).

Final assembly to do now…

Hi @M_M

I’m glad you got it working.

Yes. It seems there is an error in the template file. I will correct it. Thank you.