Add "binary counter" effect
This commit is contained in:
parent
e5df7c5e5b
commit
f370cff1a7
@ -1,6 +1,9 @@
|
|||||||
#gpio_badge
|
#gpio_badge
|
||||||
|
|
||||||
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
|
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
|
||||||
|
|
||||||
## Instructions
|
## 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.
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
#gpio_badge
|
#gpio_badge
|
||||||
|
|
||||||
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
|
This is an app for the [GPIO Diagnostics Card](https://tindie.com/stores/MakeItHackin) by MakeItHackin.
|
||||||
|
|
||||||
## Instructions
|
## 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.
|
||||||
|
@ -23,6 +23,7 @@ typedef enum {
|
|||||||
EffectIdLRL,
|
EffectIdLRL,
|
||||||
EffectIdBothLRL,
|
EffectIdBothLRL,
|
||||||
EffectIdLR,
|
EffectIdLR,
|
||||||
|
EffectIdCounter,
|
||||||
EffectIdCount // Make sure this is last
|
EffectIdCount // Make sure this is last
|
||||||
} EffectId;
|
} 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() {
|
void do_effects() {
|
||||||
while(furi_hal_gpio_read(pin_back)) {
|
while(furi_hal_gpio_read(pin_back)) {
|
||||||
switch(effect) {
|
switch(effect) {
|
||||||
@ -146,6 +168,9 @@ void do_effects() {
|
|||||||
case EffectIdBothLRL:
|
case EffectIdBothLRL:
|
||||||
do_effect_both_lrl();
|
do_effect_both_lrl();
|
||||||
break;
|
break;
|
||||||
|
case EffectIdCounter:
|
||||||
|
do_effect_counter();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
do_effect_lr();
|
do_effect_lr();
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user