2021-08-02 11:15:24 +00:00
|
|
|
#include <furi.h>
|
2021-08-08 18:03:25 +00:00
|
|
|
#include <furi-hal.h>
|
2021-08-02 11:15:24 +00:00
|
|
|
#include <notification/notification-messages.h>
|
|
|
|
|
|
|
|
const NotificationMessage message_green_110 = {
|
|
|
|
.type = NotificationMessageTypeLedGreen,
|
|
|
|
.data.led.value = 110,
|
|
|
|
};
|
|
|
|
|
|
|
|
static const NotificationSequence sequence_overconsumption = {
|
|
|
|
&message_green_110,
|
|
|
|
&message_red_255,
|
|
|
|
&message_delay_100,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
2021-08-07 16:54:42 +00:00
|
|
|
int32_t power_observer_srv(void* p) {
|
2021-08-02 11:15:24 +00:00
|
|
|
NotificationApp* notifications = furi_record_open("notification");
|
|
|
|
|
|
|
|
const float overconsumption_limit = 0.03f;
|
|
|
|
|
|
|
|
while(true) {
|
2021-08-08 18:03:25 +00:00
|
|
|
float current = -furi_hal_power_get_battery_current(FuriHalPowerICFuelGauge);
|
2021-08-02 11:15:24 +00:00
|
|
|
|
|
|
|
if(current >= overconsumption_limit) {
|
|
|
|
notification_message_block(notifications, &sequence_overconsumption);
|
|
|
|
}
|
|
|
|
|
|
|
|
delay(1000);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|