Commit 039066d8 authored by zenox's avatar zenox

for annoyatron

parent 0f67e1d3
Pipeline #4082 passed with stages
in 1 minute and 3 seconds
......@@ -145,30 +145,30 @@ int epic_leds_get_rocket(int led)
return ret;
}
static TimerHandle_t blink_timer[] = {NULL, NULL ,NULL};
static TimerHandle_t blink_timer[] = { NULL, NULL, NULL };
void bTimerCallback(TimerHandle_t blink_timer)
{
uint32_t id = (uint32_t) pvTimerGetTimerID(blink_timer);
epic_leds_set_rocket(id, 0);
uint32_t id = (uint32_t)pvTimerGetTimerID(blink_timer);
epic_leds_set_rocket(id, 0);
}
void epic_leds_blink_rocket(int led, uint8_t value, int millis)
{
int ticks = millis * (configTICK_RATE_HZ / 1000);
int32_t id = led;
if (blink_timer[id] == NULL) {
blink_timer[id] = xTimerCreate(
"blinktimer",
ticks,
pdFALSE,
(void*) id,
bTimerCallback
);
epic_leds_set_rocket(led, value);
}
epic_leds_set_rocket(led, value);
xTimerChangePeriod(blink_timer[id], ticks, 0);
int ticks = millis * (configTICK_RATE_HZ / 1000);
int32_t id = led;
if (blink_timer[id] == NULL) {
blink_timer[id] = xTimerCreate(
"blinktimer",
ticks,
pdFALSE,
(void *)id,
bTimerCallback
);
epic_leds_set_rocket(led, value);
}
epic_leds_set_rocket(led, value);
xTimerChangePeriod(blink_timer[id], ticks, 0);
}
void epic_set_flashlight(bool power)
{
......
......@@ -94,6 +94,7 @@ def get_rocket(led):
"""
return sys_leds.get_rocket(led)
def blink_rocket(led, value, millis):
"""
Let one of the rockets blink for a certain time without
......
......@@ -213,11 +213,12 @@ static mp_obj_t mp_leds_get_rocket(mp_obj_t led_in)
}
static MP_DEFINE_CONST_FUN_OBJ_1(leds_get_rocket_obj, mp_leds_get_rocket);
static mp_obj_t mp_leds_blink_rocket(mp_obj_t led_in, mp_obj_t value_in, mp_obj_t time_in)
static mp_obj_t
mp_leds_blink_rocket(mp_obj_t led_in, mp_obj_t value_in, mp_obj_t time_in)
{
int led = mp_obj_get_int(led_in);
int value = mp_obj_get_int(value_in);
int time = mp_obj_get_int(time_in);
int time = mp_obj_get_int(time_in);
if (value > 31) {
mp_raise_ValueError("brightness must by < 32");
......@@ -298,7 +299,8 @@ static const mp_rom_map_elem_t leds_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_set_all_hsv), MP_ROM_PTR(&leds_set_all_hsv_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_rocket), MP_ROM_PTR(&leds_set_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_get_rocket), MP_ROM_PTR(&leds_get_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_blink_rocket), MP_ROM_PTR(&leds_blink_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_blink_rocket),
MP_ROM_PTR(&leds_blink_rocket_obj) },
{ MP_ROM_QSTR(MP_QSTR_set_flashlight),
MP_ROM_PTR(&leds_set_flashlight_obj) },
{ MP_ROM_QSTR(MP_QSTR_update), MP_ROM_PTR(&leds_update_obj) },
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment