Analog face constexpr fix

This commit is contained in:
mark9064 2024-10-17 23:13:38 +01:00
parent b3f4831e54
commit c1b9967d92

View file

@ -1,5 +1,6 @@
#include "displayapp/screens/WatchFaceAnalog.h" #include "displayapp/screens/WatchFaceAnalog.h"
#include <cmath> #include <cmath>
#include <limits>
#include <lvgl/lvgl.h> #include <lvgl/lvgl.h>
#include "displayapp/screens/BatteryIcon.h" #include "displayapp/screens/BatteryIcon.h"
#include "displayapp/screens/BleIcon.h" #include "displayapp/screens/BleIcon.h"
@ -15,8 +16,10 @@ namespace {
constexpr int16_t MinuteLength = 90; constexpr int16_t MinuteLength = 90;
constexpr int16_t SecondLength = 110; constexpr int16_t SecondLength = 110;
// LVGL sin isn't constexpr (though it could be if it were C++) so fix size here
// All the types are hardcoded anyway and would need changing if the size changed
// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor // sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor
const auto LV_TRIG_SCALE = _lv_trigo_sin(90); constexpr int16_t LV_TRIG_SCALE = std::numeric_limits<int16_t>::max(); // = _lv_trigo_sin(90)
int16_t Cosine(int16_t angle) { int16_t Cosine(int16_t angle) {
return _lv_trigo_sin(angle + 90); return _lv_trigo_sin(angle + 90);