From b0019da9ddbdbfcba546f9944ecc453759048125 Mon Sep 17 00:00:00 2001 From: tofasthacker Date: Sat, 23 Sep 2023 19:03:16 -0400 Subject: [PATCH 1/2] renamed calculator class and added calculator and backspace icon --- src/CMakeLists.txt | 2 +- src/displayapp/Apps.h | 2 +- src/displayapp/DisplayApp.cpp | 6 ++--- src/displayapp/fonts/fonts.json | 2 +- src/displayapp/screens/ApplicationList.h | 2 +- .../screens/{TestApp.cpp => Calculator.cpp} | 26 +++++++++---------- .../screens/{TestApp.h => Calculator.h} | 6 ++--- src/displayapp/screens/Symbols.h | 4 +++ 8 files changed, 27 insertions(+), 23 deletions(-) rename src/displayapp/screens/{TestApp.cpp => Calculator.cpp} (95%) rename src/displayapp/screens/{TestApp.h => Calculator.h} (94%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 822f67eb..a01311b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -393,7 +393,7 @@ list(APPEND SOURCE_FILES displayapp/screens/ApplicationList.cpp displayapp/screens/Notifications.cpp displayapp/screens/Twos.cpp - displayapp/screens/TestApp.cpp + displayapp/screens/Calculator.cpp displayapp/screens/HeartRate.cpp displayapp/screens/Motion.cpp displayapp/screens/FlashLight.cpp diff --git a/src/displayapp/Apps.h b/src/displayapp/Apps.h index 0ca6a989..c8a48228 100644 --- a/src/displayapp/Apps.h +++ b/src/displayapp/Apps.h @@ -38,7 +38,7 @@ namespace Pinetime { SettingShakeThreshold, SettingBluetooth, Error, - TestApp + Calculator }; } } diff --git a/src/displayapp/DisplayApp.cpp b/src/displayapp/DisplayApp.cpp index 66fea1ce..61cee716 100644 --- a/src/displayapp/DisplayApp.cpp +++ b/src/displayapp/DisplayApp.cpp @@ -32,7 +32,7 @@ #include "displayapp/screens/Weather.h" // My New Apps -#include "displayapp/screens/TestApp.h" +#include "displayapp/screens/Calculator.h" #include "drivers/Cst816s.h" #include "drivers/St7789.h" @@ -555,8 +555,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio currentScreen = std::make_unique(motionController, settingsController); break; // My Apps - case Apps::TestApp: - currentScreen = std::make_unique(); + case Apps::Calculator: + currentScreen = std::make_unique(); break; } currentApp = app; diff --git a/src/displayapp/fonts/fonts.json b/src/displayapp/fonts/fonts.json index bcfc365f..beac37ff 100644 --- a/src/displayapp/fonts/fonts.json +++ b/src/displayapp/fonts/fonts.json @@ -7,7 +7,7 @@ }, { "file": "FontAwesome5-Solid+Brands+Regular.woff", - "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c" + "range": "0xf294, 0xf242, 0xf54b, 0xf21e, 0xf1e6, 0xf017, 0xf129, 0xf03a, 0xf185, 0xf560, 0xf001, 0xf3fd, 0xf1fc, 0xf45d, 0xf59f, 0xf5a0, 0xf027, 0xf028, 0xf6a9, 0xf04b, 0xf04c, 0xf048, 0xf051, 0xf095, 0xf3dd, 0xf04d, 0xf2f2, 0xf024, 0xf252, 0xf569, 0xf06e, 0xf015, 0xf00c, 0xf1ec, 0xf55a" } ], "bpp": 1, diff --git a/src/displayapp/screens/ApplicationList.h b/src/displayapp/screens/ApplicationList.h index 7475f092..31ad64b9 100644 --- a/src/displayapp/screens/ApplicationList.h +++ b/src/displayapp/screens/ApplicationList.h @@ -55,7 +55,7 @@ namespace Pinetime { {"2", Apps::Twos, true}, {Symbols::drum, Apps::Metronome, true}, {Symbols::map, Apps::Navigation, Applications::Screens::Navigation::IsAvailable(filesystem)}, - {"T", Apps::TestApp, true}, + {Symbols::calculator, Apps::Calculator, true}, //{Symbols::none, Apps::None, false}, // {"M", Apps::Motion}, diff --git a/src/displayapp/screens/TestApp.cpp b/src/displayapp/screens/Calculator.cpp similarity index 95% rename from src/displayapp/screens/TestApp.cpp rename to src/displayapp/screens/Calculator.cpp index 11b385e0..e5d38810 100644 --- a/src/displayapp/screens/TestApp.cpp +++ b/src/displayapp/screens/Calculator.cpp @@ -1,25 +1,25 @@ #include #include #include -#include "TestApp.h" +#include "Calculator.h" #include "displayapp/InfiniTimeTheme.h" #include "Symbols.h" using namespace Pinetime::Applications::Screens; static void eventHandler(lv_obj_t* obj, lv_event_t event) { - auto app = static_cast(obj->user_data); + auto app = static_cast(obj->user_data); app->OnButtonEvent(obj, event); } -TestApp::~TestApp() { +Calculator::~Calculator() { lv_obj_clean(lv_scr_act()); } static const char* buttonMap[] = { - "7", "8", "9", "B"/*Symbols::backspace*/, "\n", "4", "5", "6", "+ -", "\n", "1", "2", "3", "* /", "\n", "0", ".", "(-)", "=", ""}; + "7", "8", "9", Symbols::backspace, "\n", "4", "5", "6", "+ -", "\n", "1", "2", "3", "* /", "\n", "0", ".", "(-)", "=", ""}; -TestApp::TestApp() { +Calculator::Calculator() { resultLabel = lv_label_create(lv_scr_act(), nullptr); lv_label_set_long_mode(resultLabel, LV_LABEL_LONG_CROP); lv_label_set_align(resultLabel, LV_LABEL_ALIGN_RIGHT); @@ -53,13 +53,13 @@ TestApp::TestApp() { lv_obj_set_style_local_bg_main_stop(buttonMatrix, LV_BTNMATRIX_PART_BTN, LV_STATE_CHECKED, 128); } -void TestApp::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { +void Calculator::OnButtonEvent(lv_obj_t* obj, lv_event_t event) { if ((obj == buttonMatrix) && (event == LV_EVENT_PRESSED)) { HandleInput(); } } -void TestApp::HandleInput() { +void Calculator::HandleInput() { const char* buttonText = lv_btnmatrix_get_active_btn_text(buttonMatrix); if (buttonText == nullptr) { @@ -167,7 +167,7 @@ void TestApp::HandleInput() { break; // this is a little hacky because it matches only the first char - case 'B': + case Symbols::backspace[0]: if (value != 0) { // delete one value digit if (offset < FIXED_POINT_OFFSET) { @@ -224,7 +224,7 @@ void TestApp::HandleInput() { UpdateResultLabel(); } -void TestApp::UpdateOperation() const { +void Calculator::UpdateOperation() const { switch (operation) { case '+': lv_obj_set_style_local_bg_grad_dir(buttonMatrix, LV_BTNMATRIX_PART_BTN, LV_STATE_CHECKED, LV_GRAD_DIR_HOR); @@ -256,7 +256,7 @@ void TestApp::UpdateOperation() const { } } -void TestApp::ResetInput() { +void Calculator::ResetInput() { value = 0; offset = FIXED_POINT_OFFSET; operation = ' '; @@ -264,7 +264,7 @@ void TestApp::ResetInput() { error = Error::None; } -void TestApp::UpdateResultLabel() const { +void Calculator::UpdateResultLabel() const { int64_t integer = result / FIXED_POINT_OFFSET; int64_t remainder = result % FIXED_POINT_OFFSET; bool negative = (remainder < 0); @@ -293,7 +293,7 @@ void TestApp::UpdateResultLabel() const { } } -void TestApp::UpdateValueLabel() { +void Calculator::UpdateValueLabel() { switch (error) { case Error::TooLarge: lv_label_set_text_static(valueLabel, "too large"); @@ -341,7 +341,7 @@ void TestApp::UpdateValueLabel() { } // update the result based on value and operation -void TestApp::Eval() { +void Calculator::Eval() { switch (operation) { case ' ': result = value; diff --git a/src/displayapp/screens/TestApp.h b/src/displayapp/screens/Calculator.h similarity index 94% rename from src/displayapp/screens/TestApp.h rename to src/displayapp/screens/Calculator.h index 91b94f9b..17513861 100644 --- a/src/displayapp/screens/TestApp.h +++ b/src/displayapp/screens/Calculator.h @@ -16,11 +16,11 @@ namespace { namespace Pinetime { namespace Applications { namespace Screens { - class TestApp : public Screen { + class Calculator : public Screen { public: - ~TestApp() override; + ~Calculator() override; - TestApp(); + Calculator(); void OnButtonEvent(lv_obj_t* obj, lv_event_t event); diff --git a/src/displayapp/screens/Symbols.h b/src/displayapp/screens/Symbols.h index 7154ff44..b4dadfb2 100644 --- a/src/displayapp/screens/Symbols.h +++ b/src/displayapp/screens/Symbols.h @@ -37,6 +37,10 @@ namespace Pinetime { static constexpr const char* eye = "\xEF\x81\xAE"; static constexpr const char* home = "\xEF\x80\x95"; static constexpr const char* sleep = "\xEE\xBD\x84"; + static constexpr const char* calculator = "\xEF\x87\xAC"; + static constexpr const char* backspace = "\xEF\x95\x9A"; + + // fontawesome_weathericons.c // static constexpr const char* sun = "\xEF\x86\x85"; From 5fc831542fba0f27e1ea126b0db07d6192d1a588 Mon Sep 17 00:00:00 2001 From: tofasthacker Date: Sat, 23 Sep 2023 19:39:53 -0400 Subject: [PATCH 2/2] fixed terminal $ --- src/displayapp/screens/WatchFaceTerminal.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/displayapp/screens/WatchFaceTerminal.cpp b/src/displayapp/screens/WatchFaceTerminal.cpp index ac00f5a3..bd0a9f17 100644 --- a/src/displayapp/screens/WatchFaceTerminal.cpp +++ b/src/displayapp/screens/WatchFaceTerminal.cpp @@ -51,7 +51,7 @@ WatchFaceTerminal::WatchFaceTerminal(Controllers::DateTime& dateTimeController, lv_label_set_text_static(label_prompt_1, "user@watch:~ #00ff00 $# now"); label_prompt_2 = lv_label_create(lv_scr_act(), nullptr); - lv_label_set_recolor(label_prompt_1, true); + lv_label_set_recolor(label_prompt_2, true); lv_obj_align(label_prompt_2, lv_scr_act(), LV_ALIGN_IN_LEFT_MID, 0, 60); lv_label_set_text_static(label_prompt_2, "user@watch:~ #00ff00 $#");