Commit fe7d1182 authored by fleur's avatar fleur
Browse files

yay it built

parent 9c473c65
......@@ -55,6 +55,11 @@ typedef _Bool bool;
#define API_DISP_FRAMEBUFFER 0x29
#define API_DISP_BACKLIGHT 0x2a
#define API_DISP_PRINT_ADV 0x2b
#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
/* API_BATTERY_VOLTAGE 0x30 */
#define API_BATTERY_CURRENT 0x31
......@@ -106,6 +111,12 @@ typedef _Bool bool;
#define API_LIGHT_SENSOR_READ 0x83
#define API_BUTTONS_READ 0x90
#define API_BUTTONS_START 0x91
#define API_BUTTONS_STOP 0x92
#define API_BUTTONS_GET 0x93
#define API_BUTTONS_GET_MEMORY 0x94
#define API_BUTTONS_RESET_MEMORY 0x95
#define API_BUTTONS_SET_DISPLAY_WAKE_MASK 0x96
#define API_GPIO_SET_PIN_MODE 0xA0
#define API_GPIO_GET_PIN_MODE 0xA1
......@@ -137,6 +148,11 @@ typedef _Bool bool;
#define API_USB_STORAGE 0x111
#define API_USB_CDCACM 0x112
#define API_STATUS_START 0x120
#define API_STATUS_STOP 0x121
#define API_STATUS_GET_POWER_STATUS 0x122
#define API_STATUS_POWER_LED 0x123
/* clang-format on */
typedef uint32_t api_int_id_t;
......@@ -435,6 +451,14 @@ enum epic_button {
* :return: Returns nonzero value if unmasked buttons are pushed.
*/
API(API_BUTTONS_READ, uint8_t epic_buttons_read(uint8_t mask));
API(API_BUTTONS_START, void epic_buttons_start(void));
API(API_BUTTONS_STOP, void epic_buttons_stop(void));
API(API_BUTTONS_GET, uint8_t epic_buttons_get(uint8_t mask));
API(API_BUTTONS_GET_MEMORY, uint8_t epic_buttons_get_memory(uint8_t mask));
API(API_BUTTONS_RESET_MEMORY, void epic_buttons_reset_memory(void));
API(API_BUTTONS_SET_DISPLAY_WAKE_MASK, void epic_buttons_set_display_wake_mask(uint8_t mask));
/**
* Wristband GPIO
......@@ -1396,6 +1420,11 @@ API(API_DISP_FRAMEBUFFER, int epic_disp_framebuffer(union disp_framebuffer *fb))
*/
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_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));
/**
* Start continuous readout of the light sensor. Will read light level
......@@ -1770,4 +1799,9 @@ API(API_USB_STORAGE, int epic_usb_storage(void));
*/
API(API_USB_CDCACM, int epic_usb_cdcacm(void));
API(API_STATUS_START, void epic_status_start(void));
API(API_STATUS_STOP, void epic_status_stop(void));
API(API_STATUS_GET_POWER_STATUS, uint8_t epic_status_get_power_status(void));
API(API_STATUS_POWER_LED, void epic_status_power_led(bool onoff));
#endif /* _EPICARDIUM_H */
......@@ -80,11 +80,11 @@ void epic_buttons_set_display_wake_mask(uint8_t mask){
display_wake_mask = mask;
}
uint8_t epic_buttons_get(){
uint8_t epic_buttons_get(uint8_t mask){
if (!poll_timer || !xTimerIsTimerActive(poll_timer)) {
return -ENODATA;
}
return last;
return last & mask;
}
void epic_buttons_stop(){
......@@ -96,6 +96,6 @@ void epic_buttons_reset_memory(){
memory = 0;
}
uint8_t epic_buttons_get_memory(){
return memory;
uint8_t epic_buttons_get_memory(uint8_t mask){
return memory & mask;
}
......@@ -65,6 +65,10 @@ static void auto_backlight(){
epic_disp_backlight(lpf_light);
}
void epic_disp_set_timeout_cycles(int cycles){
timeout_cycles=cycles;
}
void epic_disp_wake(){
wake_event = true;
}
......@@ -91,7 +95,7 @@ void epic_disp_backlight_auto_stop()
xTimerStop(poll_timer, 0);
}
void epic_disp_backlight_auto(){
void epic_disp_backlight_auto_start(){
if(!poll_timer) {
poll_timer = xTimerCreateStatic(
"auto_backlight",
......
......@@ -13,12 +13,12 @@
#define PULSEWIDTH 2
#define PULSELENGTH 10
static uint8_t status = 0; // 0: discharging, 1: below 3.8V, 2: below 3.6V, 254: charging, 255: full and connected to charger (or error) (yeah i know bad collision) (i'll fix this)
static uint8_t power_status = 0; // 0: discharging, 1: below 3.8V, 2: below 3.6V, 254: charging, 255: full and connected to charger (or error) (yeah i know bad collision) (i'll fix this)
static float bat_volt = 0;
static float bat_cur = 0;
static float char_volt = 0;
static float char_cur = 0;
static bool led_on = true;
static bool power_led_on = true;
static TimerHandle_t poll_timer;
static StaticTimer_t poll_timer_buffer;
......@@ -31,22 +31,22 @@ static void get_power_status(){
if(char_volt > 4){
if(char_cur > 0.1){
status = 254;
power_status = 254;
} else {
status = 255;
power_status = 255;
}
} else if(bat_volt>3.8){
status = 0;
power_status = 0;
} else if(bat_volt>3.6){
status = 1;
power_status = 1;
} else {
status = 2;
power_status = 2;
}
}
static void update_led(){
static void update_power_led(){
static uint8_t counter = 0;
switch(status){
switch(power_status){
case 0:
case 1:
epic_leds_set(POWERLED,0,0,0);
......@@ -70,8 +70,8 @@ static void update_led(){
static void CALLBACK_led(){
get_power_status();
if(led_on){
update_led();
if(power_led_on){
update_power_led();
}
}
......@@ -88,11 +88,11 @@ void epic_status_start(){
}
}
uint8_t epic_status_get(){
uint8_t epic_status_get_power_status(){
if (!poll_timer || !xTimerIsTimerActive(poll_timer)) {
return -ENODATA;
}
return status;
return power_status;
}
void epic_status_stop(){
......@@ -100,6 +100,6 @@ void epic_status_stop(){
xTimerStop(poll_timer, 0);
}
void epic_status_led(bool onoff){
led_on = onoff;
void epic_status_power_led(bool onoff){
power_led_on = onoff;
}
Supports Markdown
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