Add "binary counter" effect

This commit is contained in:
Derek Jamison 2023-08-10 17:30:19 -07:00
parent e5df7c5e5b
commit f370cff1a7
3 changed files with 35 additions and 4 deletions

View File

@ -1,6 +1,9 @@
#gpio_badge
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
## Instructions
Left/Right buttons to change speed.
Back button to exit.
- Left/Right buttons to change speed. Up/Down buttons to change effect.
- When effect is Left/Right, you can use OK button to stop/start (try to get it to start near the middle RED led!)
- Back button to exit.

View File

@ -1,6 +1,9 @@
#gpio_badge
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
## Instructions
Left/Right buttons to change speed.
Back button to exit.
- Left/Right buttons to change speed. Up/Down buttons to change effect.
- When effect is Left/Right, you can use OK button to stop/start (try to get it to start near the middle RED led!)
- Back button to exit.

View File

@ -23,6 +23,7 @@ typedef enum {
EffectIdLRL,
EffectIdBothLRL,
EffectIdLR,
EffectIdCounter,
EffectIdCount // Make sure this is last
} EffectId;
@ -137,6 +138,27 @@ void do_effect_lr() {
}
}
void do_effect_counter() {
uint32_t c = 0;
while(true) {
for(size_t i = 0; i < COUNT_OF(pin_leds); i++) {
if((c & (1 << i)) != 0) {
furi_hal_gpio_write(pin_leds[i], true);
}
}
furi_delay_ms(speed);
for(size_t i = 0; i < COUNT_OF(pin_leds); i++) {
furi_hal_gpio_write(pin_leds[i], false);
}
c++;
if(furi_hal_gpio_read(pin_back) == false || effect != EffectIdCounter) {
break;
}
}
}
void do_effects() {
while(furi_hal_gpio_read(pin_back)) {
switch(effect) {
@ -146,6 +168,9 @@ void do_effects() {
case EffectIdBothLRL:
do_effect_both_lrl();
break;
case EffectIdCounter:
do_effect_counter();
break;
default:
do_effect_lr();
break;