summaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
authorRiku Isokoski <riksu9000@gmail.com>2021-10-05 12:45:03 +0300
committerRiku Isokoski <riksu9000@gmail.com>2021-10-05 12:45:03 +0300
commitf61e88b8425f9edcd38e47027df62dcc56c83adc (patch)
tree1faacaf82f085ce6ca718d598b13a4f509a8e0ff /src/components
parente468acc99e4d7e188dc902983640f5eb8e8ff31f (diff)
parent392c7ad2aceecd8fe976165b66d39f0ed2083911 (diff)
Merge branch 'develop' into update_touch_driver
Diffstat (limited to 'src/components')
-rw-r--r--src/components/battery/BatteryController.cpp10
-rw-r--r--src/components/battery/BatteryController.h5
-rw-r--r--src/components/ble/BatteryInformationService.cpp2
-rw-r--r--src/components/ble/NotificationManager.cpp8
-rw-r--r--src/components/ble/NotificationManager.h5
-rw-r--r--src/components/datetime/DateTimeController.cpp1
-rw-r--r--src/components/fs/FS.h2
-rw-r--r--src/components/motor/MotorController.cpp10
-rw-r--r--src/components/motor/MotorController.h5
-rw-r--r--src/components/settings/Settings.h14
10 files changed, 25 insertions, 37 deletions
diff --git a/src/components/battery/BatteryController.cpp b/src/components/battery/BatteryController.cpp
index 4ef20a24..b43b229f 100644
--- a/src/components/battery/BatteryController.cpp
+++ b/src/components/battery/BatteryController.cpp
@@ -17,6 +17,12 @@ void Battery::Update() {
isCharging = !nrf_gpio_pin_read(PinMap::Charging);
isPowerPresent = !nrf_gpio_pin_read(PinMap::PowerPresent);
+ if (isPowerPresent && !isCharging) {
+ isFull = true;
+ } else if (!isPowerPresent) {
+ isFull = false;
+ }
+
if (isReading) {
return;
}
@@ -63,12 +69,12 @@ void Battery::SaadcEventHandler(nrfx_saadc_evt_t const* p_event) {
// p_event->data.done.p_buffer[0] = (adc_voltage / reference_voltage) * 1024
voltage = p_event->data.done.p_buffer[0] * (8 * 600) / 1024;
- if (voltage > battery_max) {
+ if (isFull) {
percentRemaining = 100;
} else if (voltage < battery_min) {
percentRemaining = 0;
} else {
- percentRemaining = (voltage - battery_min) * 100 / (battery_max - battery_min);
+ percentRemaining = std::min((voltage - battery_min) * 100 / (battery_max - battery_min), isCharging ? 99 : 100);
}
nrfx_saadc_uninit();
diff --git a/src/components/battery/BatteryController.h b/src/components/battery/BatteryController.h
index 8af27ea8..c78ffb3f 100644
--- a/src/components/battery/BatteryController.h
+++ b/src/components/battery/BatteryController.h
@@ -22,7 +22,9 @@ namespace Pinetime {
}
bool IsCharging() const {
- return isCharging;
+ // isCharging will go up and down when fully charged
+ // isFull makes sure this returns false while fully charged.
+ return isCharging && !isFull;
}
bool IsPowerPresent() const {
@@ -37,6 +39,7 @@ namespace Pinetime {
uint16_t voltage = 0;
uint8_t percentRemaining = 0;
+ bool isFull = false;
bool isCharging = false;
bool isPowerPresent = false;
diff --git a/src/components/ble/BatteryInformationService.cpp b/src/components/ble/BatteryInformationService.cpp
index 7f176904..4ef02358 100644
--- a/src/components/ble/BatteryInformationService.cpp
+++ b/src/components/ble/BatteryInformationService.cpp
@@ -43,7 +43,7 @@ int BatteryInformationService::OnBatteryServiceRequested(uint16_t connectionHand
ble_gatt_access_ctxt* context) {
if (attributeHandle == batteryLevelHandle) {
NRF_LOG_INFO("BATTERY : handle = %d", batteryLevelHandle);
- static uint8_t batteryValue = batteryController.PercentRemaining();
+ uint8_t batteryValue = batteryController.PercentRemaining();
int res = os_mbuf_append(context->om, &batteryValue, 1);
return (res == 0) ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
}
diff --git a/src/components/ble/NotificationManager.cpp b/src/components/ble/NotificationManager.cpp
index b1b0e6b2..7ffed300 100644
--- a/src/components/ble/NotificationManager.cpp
+++ b/src/components/ble/NotificationManager.cpp
@@ -79,14 +79,6 @@ bool NotificationManager::AreNewNotificationsAvailable() {
return newNotification;
}
-bool NotificationManager::IsVibrationEnabled() {
- return vibrationEnabled;
-}
-
-void NotificationManager::ToggleVibrations() {
- vibrationEnabled = !vibrationEnabled;
-}
-
bool NotificationManager::ClearNewNotificationFlag() {
return newNotification.exchange(false);
}
diff --git a/src/components/ble/NotificationManager.h b/src/components/ble/NotificationManager.h
index d4072cc2..40f174ea 100644
--- a/src/components/ble/NotificationManager.h
+++ b/src/components/ble/NotificationManager.h
@@ -44,8 +44,6 @@ namespace Pinetime {
Notification GetPrevious(Notification::Id id);
bool ClearNewNotificationFlag();
bool AreNewNotificationsAvailable();
- bool IsVibrationEnabled();
- void ToggleVibrations();
static constexpr size_t MaximumMessageSize() {
return MessageSize;
@@ -60,7 +58,6 @@ namespace Pinetime {
uint8_t writeIndex = 0;
bool empty = true;
std::atomic<bool> newNotification {false};
- bool vibrationEnabled = true;
};
}
-} \ No newline at end of file
+}
diff --git a/src/components/datetime/DateTimeController.cpp b/src/components/datetime/DateTimeController.cpp
index 6e426825..0756d38d 100644
--- a/src/components/datetime/DateTimeController.cpp
+++ b/src/components/datetime/DateTimeController.cpp
@@ -7,6 +7,7 @@ using namespace Pinetime::Controllers;
void DateTime::SetCurrentTime(std::chrono::time_point<std::chrono::system_clock, std::chrono::nanoseconds> t) {
this->currentDateTime = t;
+ UpdateTime(previousSystickCounter); // Update internal state without updating the time
}
void DateTime::SetTime(
diff --git a/src/components/fs/FS.h b/src/components/fs/FS.h
index 1f2eb7e0..75ba16c8 100644
--- a/src/components/fs/FS.h
+++ b/src/components/fs/FS.h
@@ -53,7 +53,7 @@ namespace Pinetime {
*
*/
static constexpr size_t startAddress = 0x0B4000;
- static constexpr size_t size = 0x3C0000;
+ static constexpr size_t size = 0x34C000;
static constexpr size_t blockSize = 4096;
bool resourcesValid = false;
diff --git a/src/components/motor/MotorController.cpp b/src/components/motor/MotorController.cpp
index 42057a86..f596c718 100644
--- a/src/components/motor/MotorController.cpp
+++ b/src/components/motor/MotorController.cpp
@@ -9,9 +9,6 @@ APP_TIMER_DEF(longVibTimer);
using namespace Pinetime::Controllers;
-MotorController::MotorController(Controllers::Settings& settingsController) : settingsController {settingsController} {
-}
-
void MotorController::Init() {
nrf_gpio_cfg_output(PinMap::Motor);
nrf_gpio_pin_set(PinMap::Motor);
@@ -27,18 +24,11 @@ void MotorController::Ring(void* p_context) {
}
void MotorController::RunForDuration(uint8_t motorDuration) {
- if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
- return;
- }
-
nrf_gpio_pin_clear(PinMap::Motor);
app_timer_start(shortVibTimer, APP_TIMER_TICKS(motorDuration), nullptr);
}
void MotorController::StartRinging() {
- if (settingsController.GetVibrationStatus() == Controllers::Settings::Vibration::OFF) {
- return;
- }
Ring(this);
app_timer_start(longVibTimer, APP_TIMER_TICKS(1000), this);
}
diff --git a/src/components/motor/MotorController.h b/src/components/motor/MotorController.h
index cf78088e..c9326d57 100644
--- a/src/components/motor/MotorController.h
+++ b/src/components/motor/MotorController.h
@@ -1,14 +1,14 @@
#pragma once
#include <cstdint>
-#include "components/settings/Settings.h"
namespace Pinetime {
namespace Controllers {
class MotorController {
public:
- MotorController(Controllers::Settings& settingsController);
+ MotorController() = default;
+
void Init();
void RunForDuration(uint8_t motorDuration);
void StartRinging();
@@ -16,7 +16,6 @@ namespace Pinetime {
private:
static void Ring(void* p_context);
- Controllers::Settings& settingsController;
static void StopMotor(void* p_context);
};
}
diff --git a/src/components/settings/Settings.h b/src/components/settings/Settings.h
index a54ba976..871ff3b6 100644
--- a/src/components/settings/Settings.h
+++ b/src/components/settings/Settings.h
@@ -11,7 +11,7 @@ namespace Pinetime {
class Settings {
public:
enum class ClockType : uint8_t { H24, H12 };
- enum class Vibration : uint8_t { ON, OFF };
+ enum class Notification : uint8_t { ON, OFF };
enum class WakeUpMode : uint8_t {
SingleTap = 0,
DoubleTap = 1,
@@ -93,14 +93,14 @@ namespace Pinetime {
return settings.clockType;
};
- void SetVibrationStatus(Vibration status) {
- if (status != settings.vibrationStatus) {
+ void SetNotificationStatus(Notification status) {
+ if (status != settings.notificationStatus) {
settingsChanged = true;
}
- settings.vibrationStatus = status;
+ settings.notificationStatus = status;
};
- Vibration GetVibrationStatus() const {
- return settings.vibrationStatus;
+ Notification GetNotificationStatus() const {
+ return settings.notificationStatus;
};
void SetScreenTimeOut(uint32_t timeout) {
@@ -170,7 +170,7 @@ namespace Pinetime {
uint32_t screenTimeOut = 15000;
ClockType clockType = ClockType::H24;
- Vibration vibrationStatus = Vibration::ON;
+ Notification notificationStatus = Notification::ON;
uint8_t clockFace = 0;