mirror of
https://github.com/DarkFlippers/unleashed-firmware
synced 2024-11-23 21:13:16 +00:00
[FL-1625] Overcurrent monitoring. Cli command for external 3.3v dcdc control. (#615)
* Apps: power observer for overcurrent monitoring * Power: cli command for enable\disable externat 3.3v dcdc Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
parent
35c441f031
commit
95f44f4d33
4 changed files with 56 additions and 0 deletions
|
@ -39,6 +39,7 @@ int32_t lfrfid_debug_app(void* p);
|
|||
int32_t storage_app(void* p);
|
||||
int32_t storage_app_test(void* p);
|
||||
int32_t dialogs_app(void* p);
|
||||
int32_t power_observer(void* p);
|
||||
|
||||
// On system start hooks declaration
|
||||
void irda_cli_init();
|
||||
|
@ -91,6 +92,10 @@ const FlipperApplication FLIPPER_SERVICES[] = {
|
|||
{.app = power_task, .name = "power_task", .stack_size = 1024, .icon = &A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef SRV_POWER_OBSERVER
|
||||
{.app = power_observer, .name = "power_observer", .stack_size = 1024, .icon = &A_Plugins_14},
|
||||
#endif
|
||||
|
||||
#ifdef SRV_BT
|
||||
{.app = bt_task, .name = "bt_task", .stack_size = 1024, .icon = &A_Plugins_14},
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@ SRV_DOLPHIN = 1
|
|||
SRV_NOTIFICATION = 1
|
||||
SRV_STORAGE = 1
|
||||
SRV_DIALOGS = 1
|
||||
SRV_POWER_OBSERVER = 1
|
||||
|
||||
# Main Apps
|
||||
APP_IRDA = 1
|
||||
|
@ -59,6 +60,12 @@ SRV_CLI = 1
|
|||
CFLAGS += -DSRV_POWER
|
||||
endif
|
||||
|
||||
SRV_POWER_OBSERVER ?= 0
|
||||
ifeq ($(SRV_POWER_OBSERVER), 1)
|
||||
SRV_POWER = 1
|
||||
CFLAGS += -DSRV_POWER_OBSERVER
|
||||
endif
|
||||
|
||||
SRV_BT ?= 0
|
||||
ifeq ($(SRV_BT), 1)
|
||||
SRV_CLI = 1
|
||||
|
|
33
applications/power-observer/power-observer.c
Normal file
33
applications/power-observer/power-observer.c
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include <furi.h>
|
||||
#include <api-hal.h>
|
||||
#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,
|
||||
};
|
||||
|
||||
int32_t power_observer(void* p) {
|
||||
NotificationApp* notifications = furi_record_open("notification");
|
||||
|
||||
const float overconsumption_limit = 0.03f;
|
||||
|
||||
while(true) {
|
||||
float current = -api_hal_power_get_battery_current(ApiHalPowerICFuelGauge);
|
||||
|
||||
if(current >= overconsumption_limit) {
|
||||
notification_message_block(notifications, &sequence_overconsumption);
|
||||
}
|
||||
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -43,6 +43,16 @@ void power_cli_otg(Cli* cli, string_t args, void* context) {
|
|||
}
|
||||
}
|
||||
|
||||
void power_cli_ext(Cli* cli, string_t args, void* context) {
|
||||
if(!string_cmp(args, "0")) {
|
||||
api_hal_power_disable_external_3_3v();
|
||||
} else if(!string_cmp(args, "1")) {
|
||||
api_hal_power_enable_external_3_3v();
|
||||
} else {
|
||||
cli_print_usage("power_ext", "<1|0>", string_get_cstr(args));
|
||||
}
|
||||
}
|
||||
|
||||
void power_cli_init(Cli* cli, Power* power) {
|
||||
cli_add_command(cli, "poweroff", CliCommandFlagParallelSafe, power_cli_poweroff, power);
|
||||
cli_add_command(cli, "reboot", CliCommandFlagParallelSafe, power_cli_reboot, power);
|
||||
|
@ -51,4 +61,5 @@ void power_cli_init(Cli* cli, Power* power) {
|
|||
cli_add_command(cli, "dfu", CliCommandFlagParallelSafe, power_cli_dfu, power);
|
||||
cli_add_command(cli, "power_info", CliCommandFlagParallelSafe, power_cli_info, power);
|
||||
cli_add_command(cli, "power_otg", CliCommandFlagParallelSafe, power_cli_otg, power);
|
||||
cli_add_command(cli, "power_ext", CliCommandFlagParallelSafe, power_cli_ext, power);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue