Revert "added low battery message"

This reverts PR https://github.com/InfiniTimeOrg/InfiniTime/pull/1352
This commit is contained in:
Riku Isokoski 2022-12-31 09:56:03 +02:00
parent 3b084d74c3
commit fff0a00a4a
5 changed files with 1 additions and 31 deletions

View File

@ -81,20 +81,10 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
newPercent = std::min(approx.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100}); newPercent = std::min(approx.GetValue(voltage), isCharging ? uint8_t {99} : uint8_t {100});
} }
if (isPowerPresent) {
batteryLowNotified = false;
}
if ((isPowerPresent && newPercent > percentRemaining) || (!isPowerPresent && newPercent < percentRemaining) || firstMeasurement) { if ((isPowerPresent && newPercent > percentRemaining) || (!isPowerPresent && newPercent < percentRemaining) || firstMeasurement) {
firstMeasurement = false; firstMeasurement = false;
percentRemaining = newPercent; percentRemaining = newPercent;
systemTask->PushMessage(System::Messages::BatteryPercentageUpdated); systemTask->PushMessage(System::Messages::BatteryPercentageUpdated);
// warn about low battery when not charging and below threshold
if (BatteryIsLow() && !isPowerPresent && !batteryLowNotified) {
systemTask->PushMessage(System::Messages::LowBattery);
batteryLowNotified = true;
}
} }
nrfx_saadc_uninit(); nrfx_saadc_uninit();

View File

@ -18,10 +18,6 @@ namespace Pinetime {
return percentRemaining; return percentRemaining;
} }
bool BatteryIsLow() const {
return percentRemaining <= lowBatteryThreshold;
}
uint16_t Voltage() const { uint16_t Voltage() const {
return voltage; return voltage;
} }
@ -43,7 +39,6 @@ namespace Pinetime {
static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7; static constexpr nrf_saadc_input_t batteryVoltageAdcInput = NRF_SAADC_INPUT_AIN7;
uint16_t voltage = 0; uint16_t voltage = 0;
uint8_t percentRemaining = 0; uint8_t percentRemaining = 0;
bool batteryLowNotified = false;
bool isFull = false; bool isFull = false;
bool isCharging = false; bool isCharging = false;
@ -55,8 +50,6 @@ namespace Pinetime {
void SaadcEventHandler(nrfx_saadc_evt_t const* p_event); void SaadcEventHandler(nrfx_saadc_evt_t const* p_event);
static void AdcCallbackStatic(nrfx_saadc_evt_t const* event); static void AdcCallbackStatic(nrfx_saadc_evt_t const* event);
static constexpr uint8_t lowBatteryThreshold {15};
bool isReading = false; bool isReading = false;
Pinetime::System::SystemTask* systemTask = nullptr; Pinetime::System::SystemTask* systemTask = nullptr;

View File

@ -58,7 +58,7 @@ void BatteryInfo::Refresh() {
} else if (batteryPercent == 100) { } else if (batteryPercent == 100) {
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE); lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_BLUE);
lv_label_set_text_static(status, "Fully charged"); lv_label_set_text_static(status, "Fully charged");
} else if (batteryController.BatteryIsLow()) { } else if (batteryPercent < 10) {
lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW); lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_YELLOW);
lv_label_set_text_static(status, "Battery low"); lv_label_set_text_static(status, "Battery low");
} else { } else {

View File

@ -29,7 +29,6 @@ namespace Pinetime {
SetOffAlarm, SetOffAlarm,
MeasureBatteryTimerExpired, MeasureBatteryTimerExpired,
BatteryPercentageUpdated, BatteryPercentageUpdated,
LowBattery,
StartFileTransfer, StartFileTransfer,
StopFileTransfer, StopFileTransfer,
BleRadioEnableToggle BleRadioEnableToggle

View File

@ -18,8 +18,6 @@
#include "BootErrors.h" #include "BootErrors.h"
#include <memory> #include <memory>
#include <algorithm>
#include <cstring>
using namespace Pinetime::System; using namespace Pinetime::System;
@ -408,16 +406,6 @@ void SystemTask::Work() {
case Messages::BatteryPercentageUpdated: case Messages::BatteryPercentageUpdated:
nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining()); nimbleController.NotifyBatteryLevel(batteryController.PercentRemaining());
break; break;
case Messages::LowBattery: {
Pinetime::Controllers::NotificationManager::Notification notif;
constexpr char message[] = "Low Battery\0Charge your watch to prevent data loss.\0";
constexpr size_t messageSize = std::min(sizeof(message), Pinetime::Controllers::NotificationManager::MaximumMessageSize());
std::memcpy(notif.message.data(), message, messageSize);
notif.size = messageSize;
notif.category = Pinetime::Controllers::NotificationManager::Categories::SimpleAlert;
notificationManager.Push(std::move(notif));
PushMessage(Messages::OnNewNotification);
} break;
case Messages::OnPairing: case Messages::OnPairing:
if (state == SystemTaskState::Sleeping) { if (state == SystemTaskState::Sleeping) {
GoToRunning(); GoToRunning();