Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
firmware
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zenox
firmware
Commits
bb72cdaf
Commit
bb72cdaf
authored
Apr 18, 2020
by
zenox
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'blink_multi_rocket'
parents
861d604a
beafdeea
Pipeline
#4543
passed with stages
in 2 minutes and 34 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
73 additions
and
0 deletions
+73
-0
epicardium/epicardium.h
epicardium/epicardium.h
+14
-0
epicardium/modules/leds.c
epicardium/modules/leds.c
+26
-0
pycardium/modules/py/leds.py
pycardium/modules/py/leds.py
+14
-0
pycardium/modules/qstrdefs.h
pycardium/modules/qstrdefs.h
+1
-0
pycardium/modules/sys_leds.c
pycardium/modules/sys_leds.c
+18
-0
No files found.
epicardium/epicardium.h
View file @
bb72cdaf
...
...
@@ -100,6 +100,7 @@ typedef _Bool bool;
#define API_LEDS_CLEAR_ALL 0x6d
#define API_LEDS_GET_ROCKET 0x6e
#define API_LEDS_GET 0x6f
#define API_LEDS_BLINK_ROCKET 0x72
#define API_VIBRA_SET 0x70
#define API_VIBRA_VIBRATE 0x71
...
...
@@ -618,6 +619,19 @@ API(API_LEDS_SET, void epic_leds_set(int led, uint8_t r, uint8_t g, uint8_t b));
*/
API
(
API_LEDS_GET
,
int
epic_leds_get_rgb
(
int
led
,
uint8_t
*
rgb
));
/**
* Set one of the rockets to blink for a certain time.
*
* :c:func:`epic_leds_blink_rocket` will set a timer for blinking of the rocket.
*
* :param int led: Number of rocket to let blink
* :param uint8_t value: brightness of the 'on'-state of this rocket ( 0 < value < 32)
* :param int millis: time in milliseconds the rocket should be 'on'
*
* .. versionadded:: 1.??
*/
API
(
API_LEDS_BLINK_ROCKET
,
void
epic_leds_blink_rocket
(
int
led
,
uint8_t
valiue
,
int
millis
));
/**
* Set one of card10's RGB LEDs to a certain color in HSV format.
*
...
...
epicardium/modules/leds.c
View file @
bb72cdaf
#include "leds.h"
#include "pmic.h"
#include "FreeRTOS.h"
#include "timers.h"
#include "task.h"
#include "epicardium.h"
#include "modules.h"
...
...
@@ -128,6 +129,31 @@ int epic_leds_get_rocket(int led)
return
ret
;
}
static
TimerHandle_t
blink_timer
[]
=
{
NULL
,
NULL
,
NULL
};
static
void
rocket_timer_callback
(
TimerHandle_t
blink_timer
)
{
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
,
rocket_timer_callback
);
epic_leds_set_rocket
(
led
,
value
);
}
epic_leds_set_rocket
(
led
,
value
);
xTimerChangePeriod
(
blink_timer
[
id
],
ticks
,
0
);
}
void
epic_set_flashlight
(
bool
power
)
{
hwlock_acquire
(
HWLOCK_I2C
);
...
...
pycardium/modules/py/leds.py
View file @
bb72cdaf
...
...
@@ -95,6 +95,20 @@ 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
blocking the python interpreter.
:param int led: Choose your rocket!
:param int value: brightness value (0 < value < 32)
:param int millis: duration of the rocket being on in milliseconds.
.. versionadded:: 1.??
"""
return
sys_leds
.
blink_rocket
(
led
,
value
,
millis
)
def
dim_top
(
value
):
"""
Set global brightness for top RGB LEDs.
...
...
pycardium/modules/qstrdefs.h
View file @
bb72cdaf
...
...
@@ -17,6 +17,7 @@ Q(set_all_hsv)
Q
(
set_flashlight
)
Q
(
set_rocket
)
Q
(
get_rocket
)
Q
(
blink_rocket
)
Q
(
set_powersave
)
Q
(
set_gamma
)
Q
(
dim_top
)
...
...
pycardium/modules/sys_leds.c
View file @
bb72cdaf
...
...
@@ -213,6 +213,22 @@ 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
)
{
int
led
=
mp_obj_get_int
(
led_in
);
int
value
=
mp_obj_get_int
(
value_in
);
int
time
=
mp_obj_get_int
(
time_in
);
if
(
value
>
31
)
{
mp_raise_ValueError
(
"brightness must be < 32"
);
}
epic_leds_blink_rocket
(
led
,
value
,
time
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_3
(
leds_blink_rocket_obj
,
mp_leds_blink_rocket
);
static
mp_obj_t
mp_leds_dim_top
(
mp_obj_t
dim_in
)
{
int
dim
=
mp_obj_get_int
(
dim_in
);
...
...
@@ -283,6 +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_set_flashlight
),
MP_ROM_PTR
(
&
leds_set_flashlight_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_update
),
MP_ROM_PTR
(
&
leds_update_obj
)
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment