-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trigger alerts based on settings values
- Loading branch information
Showing
14 changed files
with
153 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef K40_ALERTS_H | ||
#define K40_ALERTS_H | ||
|
||
enum AlertType { | ||
ALERT_TYPE_VOLTAGE = 0x01, | ||
ALERT_TYPE_COOLING = 0x02, | ||
ALERT_TYPE_LIDS = 0x04, | ||
ALERT_TYPE_FLAME_SENSOR = 0x08, | ||
}; | ||
|
||
void alerts_toggle_alert(AlertType type, bool enable); | ||
uint8_t alerts_get_current_alerts(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef UI_ALERTS_H | ||
#define UI_ALERTS_H | ||
|
||
#include <lvgl.h> | ||
|
||
void ui_overlay_init(); | ||
void ui_overlay_update(); | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include <freertos/FreeRTOS.h> | ||
#include <freertos/semphr.h> | ||
|
||
#include "K40/alerts.h" | ||
#include "queues.h" | ||
|
||
static uint8_t alerts_statuses = 0; | ||
static SemaphoreHandle_t alerts_statuses_mutex = xSemaphoreCreateMutex(); | ||
|
||
void alerts_toggle_alert(AlertType type, bool enable) { | ||
while (xSemaphoreTake(alerts_statuses_mutex, portMAX_DELAY) != pdPASS) | ||
; | ||
|
||
if (enable) { | ||
alerts_statuses |= type; | ||
} else { | ||
alerts_statuses &= ~type; | ||
} | ||
|
||
xSemaphoreGive(alerts_statuses_mutex); | ||
} | ||
|
||
uint8_t alerts_get_current_alerts() { | ||
while (xSemaphoreTake(alerts_statuses_mutex, portMAX_DELAY) != pdPASS) | ||
; | ||
|
||
uint8_t result = alerts_statuses; | ||
xSemaphoreGive(alerts_statuses_mutex); | ||
|
||
return result; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
#include <Arduino.h> | ||
#include <lvgl.h> | ||
|
||
#include "UI/images.h" | ||
#include "UI/overlay.h" | ||
#include "UI/screens/controls.h" | ||
#include "queues.h" | ||
|
||
static lv_obj_t *ui_overlay_laser_enabled_label; | ||
|
||
void ui_overlay_init() { | ||
ui_overlay_laser_enabled_label = lv_label_create(lv_layer_top()); | ||
lv_obj_set_width(ui_overlay_laser_enabled_label, LV_SIZE_CONTENT); | ||
lv_obj_set_height(ui_overlay_laser_enabled_label, LV_SIZE_CONTENT); | ||
lv_obj_set_align(ui_overlay_laser_enabled_label, LV_ALIGN_BOTTOM_RIGHT); | ||
lv_obj_set_x(ui_overlay_laser_enabled_label, -25); | ||
lv_obj_set_y(ui_overlay_laser_enabled_label, -20); | ||
lv_label_set_recolor(ui_overlay_laser_enabled_label, true); | ||
lv_label_set_text(ui_overlay_laser_enabled_label, "#FF0000 " LV_SYMBOL_WARNING "# Laser enabled"); | ||
lv_obj_set_style_text_color(ui_overlay_laser_enabled_label, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_text_font(ui_overlay_laser_enabled_label, &font_default_14, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_radius(ui_overlay_laser_enabled_label, 6, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_bg_color(ui_overlay_laser_enabled_label, lv_color_white(), LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_bg_opa(ui_overlay_laser_enabled_label, 255, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_pad_left(ui_overlay_laser_enabled_label, 10, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_pad_right(ui_overlay_laser_enabled_label, 10, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_pad_top(ui_overlay_laser_enabled_label, 6, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_pad_bottom(ui_overlay_laser_enabled_label, 6, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_border_color(ui_overlay_laser_enabled_label, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_border_opa(ui_overlay_laser_enabled_label, 25, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_border_width(ui_overlay_laser_enabled_label, 1, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_shadow_color(ui_overlay_laser_enabled_label, lv_color_black(), LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_shadow_opa(ui_overlay_laser_enabled_label, 15, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_shadow_width(ui_overlay_laser_enabled_label, 4, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_shadow_ofs_x(ui_overlay_laser_enabled_label, 0, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
lv_obj_set_style_shadow_ofs_y(ui_overlay_laser_enabled_label, 4, LV_PART_MAIN | LV_STATE_DEFAULT); | ||
} | ||
|
||
void ui_overlay_update() { | ||
if (lv_obj_has_state(ui_controls_laser_switch, LV_STATE_CHECKED)) { | ||
if (lv_obj_has_flag(ui_overlay_laser_enabled_label, LV_OBJ_FLAG_HIDDEN)) { | ||
lv_obj_clear_flag(ui_overlay_laser_enabled_label, LV_OBJ_FLAG_HIDDEN); | ||
} | ||
} else { | ||
if (!lv_obj_has_flag(ui_overlay_laser_enabled_label, LV_OBJ_FLAG_HIDDEN)) { | ||
lv_obj_add_flag(ui_overlay_laser_enabled_label, LV_OBJ_FLAG_HIDDEN); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters