Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
fleur
firmware
Commits
dc2c4452
Commit
dc2c4452
authored
Aug 28, 2019
by
fleur
Browse files
everything seems to be working kinda
parent
0a1b82c3
Pipeline
#3608
failed with stages
in 1 minute and 2 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
epicardium/epicardium.h
View file @
dc2c4452
...
...
@@ -58,8 +58,10 @@ typedef _Bool bool;
#define API_DISP_BACKLIGHT_AUTO_START 0x2c
#define API_DISP_BACKLIGHT_AUTO_STOP 0x2d
#define API_DISP_WAKE 0x2e
#define API_DISP_SET_TIMEOUT_CYCLES 0x2f
#define API_DISP_SET_BRIGHTNESS_TABLE 0x130
#define API_DISP_TUCK_IN 0x2f
#define API_DISP_SET_TIMEOUT_CYCLES 0x130
#define API_DISP_SET_BRIGHTNESS_TABLE 0x131
/* API_BATTERY_VOLTAGE 0x30 */
#define API_BATTERY_CURRENT 0x31
...
...
@@ -1423,6 +1425,7 @@ API(API_DISP_BACKLIGHT, int epic_disp_backlight(uint16_t brightness));
API
(
API_DISP_BACKLIGHT_AUTO_START
,
void
epic_disp_backlight_auto_start
(
void
));
API
(
API_DISP_BACKLIGHT_AUTO_STOP
,
void
epic_disp_backlight_auto_stop
(
void
));
API
(
API_DISP_WAKE
,
void
epic_disp_wake
(
void
));
API
(
API_DISP_TUCK_IN
,
void
epic_disp_tuck_in
(
void
));
API
(
API_DISP_SET_TIMEOUT_CYCLES
,
void
epic_disp_set_timeout_cycles
(
int
cycles
));
API
(
API_DISP_SET_BRIGHTNESS_TABLE
,
void
epic_disp_set_brightness_table
(
uint8_t
*
table
));
...
...
epicardium/modules/display.c
View file @
dc2c4452
...
...
@@ -18,10 +18,10 @@ static TaskHandle_t lock = NULL;
static
TimerHandle_t
display_timer
;
static
StaticTimer_t
display_timer_buffer
;
static
bool
display_on
;
static
bool
display_on
=
true
;
static
bool
wake_event
;
static
uint16_t
timeout_cycles
=
100
0
;
static
uint8_t
lpf_speed
=
10
;
//ca. 1Hz f_g
static
uint16_t
timeout_cycles
=
0
;
static
uint8_t
lpf_speed
=
10
;
//
10 =
ca. 1Hz f_g
static
uint8_t
brightness_table
[
MAX_BRIGHTNESS
];
static
int
check_lock
()
...
...
@@ -43,12 +43,12 @@ void epic_disp_set_brightness_table(uint8_t table[MAX_BRIGHTNESS])
static
uint16_t
limit
(
uint16_t
input
,
uint16_t
max
,
uint16_t
min
){
uint16_t
output
=
input
>
max
?
max
:
input
;
return
output
<
0
?
0
:
output
;
return
output
<
min
?
min
:
output
;
}
static
uint16_t
lpf
(
uint16_t
input
,
uint8_t
speed
){
static
uint16_t
output
;
output
=
speed
*
input
+
(
~
speed
)
*
output
;
output
=
speed
*
input
+
(
(
uint8_t
)
~
speed
)
*
output
;
output
=
output
>>
8
;
return
output
;
}
...
...
@@ -73,16 +73,20 @@ void epic_disp_wake(){
wake_event
=
true
;
}
void
epic_disp_tuck_in
(){
display_on
=
false
;
}
static
void
CALLBACK_power_mgmt
(){
//u gotta loop dis
uint16_t
buttonT
imeout
=
0
;
static
uint16_t
t
imeout
=
0
;
if
(
!
timeout_cycles
){
display_on
=
true
;
}
else
if
(
wake_event
){
buttonT
imeout
=
timeout_cycles
;
t
imeout
=
timeout_cycles
;
display_on
=
true
;
wake_event
=
false
;
}
else
if
(
buttonT
imeout
){
buttonT
imeout
--
;
}
else
if
(
t
imeout
){
t
imeout
--
;
}
else
{
display_on
=
false
;
}
...
...
epicardium/modules/status.c
View file @
dc2c4452
...
...
@@ -19,7 +19,7 @@ static float bat_volt = 0;
static
float
bat_cur
=
0
;
static
float
char_volt
=
0
;
static
float
char_cur
=
0
;
static
bool
power_led_on
=
true
;
static
uint8_t
power_led_on
=
true
;
static
TimerHandle_t
status_timer
;
static
StaticTimer_t
status_timer_buffer
;
...
...
@@ -79,9 +79,14 @@ static void update_power_led(){
}
static
void
CALLBACK_led
(){
static
bool
prev_power_led_on
;
get_power_status
();
if
(
power_led_on
){
update_power_led
();
prev_power_led_on
=
true
;
}
else
if
(
prev_power_led_on
)
{
epic_leds_set
(
POWERLED
,
0
,
0
,
0
);
prev_power_led_on
=
false
;
}
}
...
...
pycardium/modules/buttons.c
View file @
dc2c4452
...
...
@@ -13,9 +13,60 @@ static mp_obj_t mp_buttons_read(mp_obj_t mask_in)
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
buttons_read_obj
,
mp_buttons_read
);
static
mp_obj_t
mp_buttons_start
()
{
epic_buttons_start
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
buttons_start_obj
,
mp_buttons_start
);
static
mp_obj_t
mp_buttons_stop
()
{
epic_buttons_stop
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
buttons_stop_obj
,
mp_buttons_stop
);
static
mp_obj_t
mp_buttons_get
(
mp_obj_t
mask_in
)
{
uint8_t
mask
=
mp_obj_get_int
(
mask_in
);
uint8_t
button_states
=
epic_buttons_get
(
mask
);
return
MP_OBJ_NEW_SMALL_INT
(
button_states
);
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
buttons_get_obj
,
mp_buttons_get
);
static
mp_obj_t
mp_buttons_get_memory
(
mp_obj_t
mask_in
)
{
uint8_t
mask
=
mp_obj_get_int
(
mask_in
);
uint8_t
button_states
=
epic_buttons_get_memory
(
mask
);
return
MP_OBJ_NEW_SMALL_INT
(
button_states
);
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
buttons_get_memory_obj
,
mp_buttons_get_memory
);
static
mp_obj_t
mp_buttons_reset_memory
()
{
epic_buttons_reset_memory
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
buttons_reset_memory_obj
,
mp_buttons_reset_memory
);
static
mp_obj_t
mp_buttons_set_display_wake_mask
(
mp_obj_t
mask_in
)
{
uint8_t
mask
=
mp_obj_get_int
(
mask_in
);
epic_buttons_set_display_wake_mask
(
mask
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
buttons_set_display_wake_mask_obj
,
mp_buttons_set_display_wake_mask
);
static
const
mp_rom_map_elem_t
buttons_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_buttons
)
},
{
MP_ROM_QSTR
(
MP_QSTR_read
),
MP_ROM_PTR
(
&
buttons_read_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_start
),
MP_ROM_PTR
(
&
buttons_start_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_stop
),
MP_ROM_PTR
(
&
buttons_stop_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get
),
MP_ROM_PTR
(
&
buttons_get_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_get_memory
),
MP_ROM_PTR
(
&
buttons_get_memory_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_reset_memory
),
MP_ROM_PTR
(
&
buttons_reset_memory_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_display_wake_mask
),
MP_ROM_PTR
(
&
buttons_set_display_wake_mask_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_BOTTOM_LEFT
),
MP_OBJ_NEW_SMALL_INT
(
BUTTON_LEFT_BOTTOM
)
},
{
MP_ROM_QSTR
(
MP_QSTR_BOTTOM_RIGHT
),
...
...
pycardium/modules/py/display.py
View file @
dc2c4452
...
...
@@ -181,6 +181,25 @@ class Display:
sys_display
.
circ
(
x
,
y
,
rad
,
col
,
filled
,
size
)
return
self
def
backlight_auto_start
(
self
):
sys_display
.
backlight_auto_start
()
def
backlight_auto_stop
(
self
):
sys_display
.
backlight_auto_stop
()
def
wake
(
self
):
sys_display
.
wake
()
def
tuck_in
(
self
):
sys_display
.
tuck_in
()
def
set_timeout_cycles
(
self
,
timeout
=
1000
):
sys_display
.
set_timeout_cycles
(
timeout
)
def
set_brightness_table
(
self
):
table
=
[
min
(
100
,(
max
(
i
-
12
,
0
)
*
10
))
for
i
in
range
(
300
)]
sys_display
.
set_brightness_table
(
table
)
open
=
Display
.
open
close
=
Display
.
close
pycardium/modules/qstrdefs.h
View file @
dc2c4452
...
...
@@ -27,6 +27,12 @@ Q(TOP_RIGHT)
/* buttons */
Q
(
buttons
)
Q
(
read
)
Q
(
start
)
Q
(
stop
)
Q
(
get
)
Q
(
get_memory
)
Q
(
reset_memory
)
Q
(
set_display_wake_mask
)
Q
(
BOTTOM_LEFT
)
Q
(
TOP_LEFT
)
Q
(
BOTTOM_RIGHT
)
...
...
@@ -92,6 +98,12 @@ Q(line)
Q
(
rect
)
Q
(
circ
)
Q
(
clear
)
Q
(
backlight_auto_start
)
Q
(
backlight_auto_stop
)
Q
(
wake
)
Q
(
tuck_in
)
Q
(
set_timeout_cycles
)
Q
(
set_brightness_table
)
/* ambient */
Q
(
light_sensor
)
...
...
pycardium/modules/sys_display.c
View file @
dc2c4452
...
...
@@ -252,6 +252,56 @@ static mp_obj_t mp_display_close()
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_close_obj
,
mp_display_close
);
static
mp_obj_t
mp_display_backlight_auto_start
()
{
epic_disp_backlight_auto_start
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_backlight_auto_start_obj
,
mp_display_backlight_auto_start
);
static
mp_obj_t
mp_display_backlight_auto_stop
()
{
epic_disp_backlight_auto_stop
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_backlight_auto_stop_obj
,
mp_display_backlight_auto_stop
);
static
mp_obj_t
mp_display_wake
()
{
epic_disp_wake
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_wake_obj
,
mp_display_wake
);
static
mp_obj_t
mp_display_tuck_in
()
{
epic_disp_tuck_in
();
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_0
(
display_tuck_in_obj
,
mp_display_tuck_in
);
static
mp_obj_t
mp_display_set_timeout_cycles
(
mp_obj_t
cycles_in
)
{
int
cycles
=
mp_obj_get_int
(
cycles_in
);
epic_disp_set_timeout_cycles
(
cycles
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
display_set_timeout_cycles_obj
,
mp_display_set_timeout_cycles
);
static
mp_obj_t
mp_display_set_brightness_table
(
mp_obj_t
table_in
)
{
if
(
mp_obj_get_int
(
mp_obj_len
(
table_in
))
!=
300
)
{
mp_raise_ValueError
(
"table must have 300 elements"
);
}
uint8_t
table
[
300
];
for
(
int
i
=
0
;
i
<
256
;
i
++
)
{
table
[
i
]
=
mp_obj_get_int
(
mp_obj_subscr
(
table_in
,
mp_obj_new_int
(
i
),
MP_OBJ_SENTINEL
));
}
epic_disp_set_brightness_table
(
table
);
return
mp_const_none
;
}
static
MP_DEFINE_CONST_FUN_OBJ_1
(
display_set_brightness_table_obj
,
mp_display_set_brightness_table
);
/* The globals table for this module */
static
const
mp_rom_map_elem_t
display_module_globals_table
[]
=
{
{
MP_ROM_QSTR
(
MP_QSTR___name__
),
MP_ROM_QSTR
(
MP_QSTR_sys_display
)
},
...
...
@@ -266,6 +316,12 @@ static const mp_rom_map_elem_t display_module_globals_table[] = {
{
MP_ROM_QSTR
(
MP_QSTR_circ
),
MP_ROM_PTR
(
&
display_circ_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_clear
),
MP_ROM_PTR
(
&
display_clear_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_update
),
MP_ROM_PTR
(
&
display_update_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_backlight_auto_start
),
MP_ROM_PTR
(
&
display_backlight_auto_start_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_backlight_auto_stop
),
MP_ROM_PTR
(
&
display_backlight_auto_stop_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_wake
),
MP_ROM_PTR
(
&
display_wake_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_tuck_in
),
MP_ROM_PTR
(
&
display_tuck_in_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_timeout_cycles
),
MP_ROM_PTR
(
&
display_set_timeout_cycles_obj
)
},
{
MP_ROM_QSTR
(
MP_QSTR_set_brightness_table
),
MP_ROM_PTR
(
&
display_set_brightness_table_obj
)
},
};
static
MP_DEFINE_CONST_DICT
(
display_module_globals
,
display_module_globals_table
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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