From 748e31421dddf509339dd01ece80e3a7ac76e04d Mon Sep 17 00:00:00 2001 From: kieranc Date: Sun, 11 Jul 2021 17:48:16 +0200 Subject: [PATCH 1/4] Modify status text in BatteryInfo so it fits on screen (#437) * Modify status text in BatteryInfo so it fits on screen --- src/displayapp/screens/BatteryInfo.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/displayapp/screens/BatteryInfo.cpp b/src/displayapp/screens/BatteryInfo.cpp index 87c8b4bb..7e055762 100644 --- a/src/displayapp/screens/BatteryInfo.cpp +++ b/src/displayapp/screens/BatteryInfo.cpp @@ -102,16 +102,16 @@ void BatteryInfo::UpdateScreen() { if (batteryPercent >= 0) { if (batteryController.IsCharging() and batteryPercent < 100) { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_RED); - lv_label_set_text_static(status, "Battery charging"); + lv_label_set_text_static(status, "Charging"); } else if (batteryPercent == 100) { 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, "Battery is fully charged"); + lv_label_set_text_static(status, "Fully charged"); } else if (batteryPercent < 10) { 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 is low"); + lv_label_set_text_static(status, "Battery low"); } else { lv_obj_set_style_local_bg_color(charging_bar, LV_BAR_PART_INDIC, LV_STATE_DEFAULT, LV_COLOR_GREEN); - lv_label_set_text_static(status, "Battery discharging"); + lv_label_set_text_static(status, "Discharging"); } lv_label_set_text_fmt(percent, "%02i%%", batteryPercent); From 829b16a303fdf1d143e15ad53aa3a39251671fe0 Mon Sep 17 00:00:00 2001 From: Cameron Radmore Date: Sun, 11 Jul 2021 13:46:15 -0400 Subject: [PATCH 2/4] Add "metronome" to apps in readme (#479) --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 755f1905..bd23c867 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,7 @@ As of now, here is the list of achievements of this project: * Two (2048 clone game) * Stopwatch (with all the necessary functions such as play, pause, lap, stop) * Motion sensor and step counter (displays the number of steps and the state of the motion sensor in real-time) + * Metronome (vibrates to a given bpm with a customizable beats per bar) - User settings: * Display timeout * Wake-up condition From 7fee2c25894a3113a580d98c947048152af977d9 Mon Sep 17 00:00:00 2001 From: wilsonjwco <87050999+wilsonjwco@users.noreply.github.com> Date: Sun, 11 Jul 2021 11:47:24 -0600 Subject: [PATCH 3/4] Update buildAndProgram.md (#477) Corrected typo in example usage of cmake BUILD_DFU option. Changed from -BUILD_DFU=1 to -DBUILD_DFU=1 --- doc/buildAndProgram.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/buildAndProgram.md b/doc/buildAndProgram.md index afd526e0..5fe593ae 100644 --- a/doc/buildAndProgram.md +++ b/doc/buildAndProgram.md @@ -27,7 +27,7 @@ CMake configures the project according to variables you specify the command line **NRFJPROG**|Path to the NRFJProg executable. Used only if `USE_JLINK` is 1.|`-DNRFJPROG=/opt/nrfjprog/nrfjprog` **GDB_CLIENT_BIN_PATH**|Path to arm-none-eabi-gdb executable. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_BIN_PATH=/home/jf/nrf52/gcc-arm-none-eabi-9-2019-q4-major/bin/arm-none-eabi-gdb` **GDB_CLIENT_TARGET_REMOTE**|Target remote connection string. Used only if `USE_GDB_CLIENT` is 1.|`-DGDB_CLIENT_TARGET_REMOTE=/dev/ttyACM0` -**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-BUILD_DFU=1` +**BUILD_DFU (\*\*)**|Build DFU files while building (needs [adafruit-nrfutil](https://github.com/adafruit/Adafruit_nRF52_nrfutil)).|`-DBUILD_DFU=1` ####(**) Note about **CMAKE_BUILD_TYPE**: By default, this variable is set to *Release*. It compiles the code with size and speed optimizations. We use this value for all the binaries we publish when we [release](https://github.com/JF002/InfiniTime/releases) new versions of InfiniTime. From 4f378e8726fdcff72598aa6ed12eeaa6b3e61355 Mon Sep 17 00:00:00 2001 From: Jonathan Vander Mey Date: Sun, 11 Jul 2021 14:18:07 -0400 Subject: [PATCH 4/4] Refactor trig functions into LUT (#476) Replaced the use of the standard library trig functions with a LUT-based implementation instead. The standard library implementations produce more accurate results but the usage here doesn't need that. This ends up saving nearly 7kB of binary size. --- src/displayapp/screens/WatchFaceAnalog.cpp | 76 +++++++++++++--------- 1 file changed, 44 insertions(+), 32 deletions(-) diff --git a/src/displayapp/screens/WatchFaceAnalog.cpp b/src/displayapp/screens/WatchFaceAnalog.cpp index 0051408c..c589c320 100644 --- a/src/displayapp/screens/WatchFaceAnalog.cpp +++ b/src/displayapp/screens/WatchFaceAnalog.cpp @@ -5,27 +5,44 @@ #include "Symbols.h" #include "NotificationIcon.h" -#include - LV_IMG_DECLARE(bg_clock); using namespace Pinetime::Applications::Screens; -#define HOUR_LENGTH 70 -#define MINUTE_LENGTH 90 -#define SECOND_LENGTH 110 -#define PI 3.14159265358979323846 +namespace { -// ## -static int16_t coordinate_x_relocate(int16_t x) { - return ((x) + LV_HOR_RES / 2); +constexpr auto HOUR_LENGTH = 70; +constexpr auto MINUTE_LENGTH = 90; +constexpr auto SECOND_LENGTH = 110; + +// sin(90) = 1 so the value of _lv_trigo_sin(90) is the scaling factor +const auto LV_TRIG_SCALE = _lv_trigo_sin(90); + +int16_t cosine(int16_t angle) { + return _lv_trigo_sin(angle + 90); } -// ## -static int16_t coordinate_y_relocate(int16_t y) { - return (((y) -LV_HOR_RES / 2) < 0) ? (0 - ((y) -LV_HOR_RES / 2)) : ((y) -LV_HOR_RES / 2); +int16_t sine(int16_t angle) { + return _lv_trigo_sin(angle); } +int16_t coordinate_x_relocate(int16_t x) { + return (x + LV_HOR_RES / 2); +} + +int16_t coordinate_y_relocate(int16_t y) { + return std::abs(y - LV_HOR_RES / 2); +} + +lv_point_t coordinate_relocate(int16_t radius, int16_t angle) { + return lv_point_t{ + .x = coordinate_x_relocate(radius * static_cast(sine(angle)) / LV_TRIG_SCALE), + .y = coordinate_y_relocate(radius * static_cast(cosine(angle)) / LV_TRIG_SCALE) + }; +} + +} // namespace + WatchFaceAnalog::WatchFaceAnalog(Pinetime::Applications::DisplayApp* app, Controllers::DateTime& dateTimeController, Controllers::Battery& batteryController, @@ -123,15 +140,12 @@ void WatchFaceAnalog::UpdateClock() { second = dateTimeController.Seconds(); if (sMinute != minute) { - minute_point[0].x = coordinate_x_relocate(30 * sin(minute * 6 * PI / 180)); - minute_point[0].y = coordinate_y_relocate(30 * cos(minute * 6 * PI / 180)); - minute_point[1].x = coordinate_x_relocate(MINUTE_LENGTH * sin(minute * 6 * PI / 180)); - minute_point[1].y = coordinate_y_relocate(MINUTE_LENGTH * cos(minute * 6 * PI / 180)); + auto const angle = minute * 6; + minute_point[0] = coordinate_relocate(30, angle); + minute_point[1] = coordinate_relocate(MINUTE_LENGTH, angle); - minute_point_trace[0].x = coordinate_x_relocate(5 * sin(minute * 6 * PI / 180)); - minute_point_trace[0].y = coordinate_y_relocate(5 * cos(minute * 6 * PI / 180)); - minute_point_trace[1].x = coordinate_x_relocate(31 * sin(minute * 6 * PI / 180)); - minute_point_trace[1].y = coordinate_y_relocate(31 * cos(minute * 6 * PI / 180)); + minute_point_trace[0] = coordinate_relocate(5, angle); + minute_point_trace[1] = coordinate_relocate(31, angle); lv_line_set_points(minute_body, minute_point, 2); lv_line_set_points(minute_body_trace, minute_point_trace, 2); @@ -140,15 +154,13 @@ void WatchFaceAnalog::UpdateClock() { if (sHour != hour || sMinute != minute) { sHour = hour; sMinute = minute; - hour_point[0].x = coordinate_x_relocate(30 * sin((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point[0].y = coordinate_y_relocate(30 * cos((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point[1].x = coordinate_x_relocate(HOUR_LENGTH * sin((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point[1].y = coordinate_y_relocate(HOUR_LENGTH * cos((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); + auto const angle = (hour * 30 + minute / 2); - hour_point_trace[0].x = coordinate_x_relocate(5 * sin((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point_trace[0].y = coordinate_y_relocate(5 * cos((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point_trace[1].x = coordinate_x_relocate(31 * sin((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); - hour_point_trace[1].y = coordinate_y_relocate(31 * cos((((hour > 12 ? hour - 12 : hour) * 30) + (minute * 0.5)) * PI / 180)); + hour_point[0] = coordinate_relocate(30, angle); + hour_point[1] = coordinate_relocate(HOUR_LENGTH, angle); + + hour_point_trace[0] = coordinate_relocate(5, angle); + hour_point_trace[1] = coordinate_relocate(31, angle); lv_line_set_points(hour_body, hour_point, 2); lv_line_set_points(hour_body_trace, hour_point_trace, 2); @@ -156,10 +168,10 @@ void WatchFaceAnalog::UpdateClock() { if (sSecond != second) { sSecond = second; - second_point[0].x = coordinate_x_relocate(20 * sin((180 + second * 6) * PI / 180)); - second_point[0].y = coordinate_y_relocate(20 * cos((180 + second * 6) * PI / 180)); - second_point[1].x = coordinate_x_relocate(SECOND_LENGTH * sin(second * 6 * PI / 180)); - second_point[1].y = coordinate_y_relocate(SECOND_LENGTH * cos(second * 6 * PI / 180)); + auto const angle = second * 6; + + second_point[0] = coordinate_relocate(-20, angle); + second_point[1] = coordinate_relocate(SECOND_LENGTH, angle); lv_line_set_points(second_body, second_point, 2); } }