Merge branch 'working_calculator'
This commit is contained in:
commit
990ad0c87e
@ -393,7 +393,7 @@ list(APPEND SOURCE_FILES
|
|||||||
displayapp/screens/ApplicationList.cpp
|
displayapp/screens/ApplicationList.cpp
|
||||||
displayapp/screens/Notifications.cpp
|
displayapp/screens/Notifications.cpp
|
||||||
displayapp/screens/Twos.cpp
|
displayapp/screens/Twos.cpp
|
||||||
displayapp/screens/TestApp.cpp
|
displayapp/screens/Calculator.cpp
|
||||||
displayapp/screens/HeartRate.cpp
|
displayapp/screens/HeartRate.cpp
|
||||||
displayapp/screens/Motion.cpp
|
displayapp/screens/Motion.cpp
|
||||||
displayapp/screens/FlashLight.cpp
|
displayapp/screens/FlashLight.cpp
|
||||||
|
@ -38,7 +38,7 @@ namespace Pinetime {
|
|||||||
SettingShakeThreshold,
|
SettingShakeThreshold,
|
||||||
SettingBluetooth,
|
SettingBluetooth,
|
||||||
Error,
|
Error,
|
||||||
TestApp
|
Calculator
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@
|
|||||||
#include "displayapp/screens/Weather.h"
|
#include "displayapp/screens/Weather.h"
|
||||||
|
|
||||||
// My New Apps
|
// My New Apps
|
||||||
#include "displayapp/screens/TestApp.h"
|
#include "displayapp/screens/Calculator.h"
|
||||||
|
|
||||||
#include "drivers/Cst816s.h"
|
#include "drivers/Cst816s.h"
|
||||||
#include "drivers/St7789.h"
|
#include "drivers/St7789.h"
|
||||||
@ -555,8 +555,8 @@ void DisplayApp::LoadScreen(Apps app, DisplayApp::FullRefreshDirections directio
|
|||||||
currentScreen = std::make_unique<Screens::Steps>(motionController, settingsController);
|
currentScreen = std::make_unique<Screens::Steps>(motionController, settingsController);
|
||||||
break;
|
break;
|
||||||
// My Apps
|
// My Apps
|
||||||
case Apps::TestApp:
|
case Apps::Calculator:
|
||||||
currentScreen = std::make_unique<Screens::TestApp>();
|
currentScreen = std::make_unique<Screens::Calculator>();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
currentApp = app;
|
currentApp = app;
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"file": "FontAwesome5-Solid+Brands+Regular.woff",
|
"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,
|
"bpp": 1,
|
||||||
|
@ -55,7 +55,7 @@ namespace Pinetime {
|
|||||||
{"2", Apps::Twos, true},
|
{"2", Apps::Twos, true},
|
||||||
{Symbols::drum, Apps::Metronome, true},
|
{Symbols::drum, Apps::Metronome, true},
|
||||||
{Symbols::map, Apps::Navigation, Applications::Screens::Navigation::IsAvailable(filesystem)},
|
{Symbols::map, Apps::Navigation, Applications::Screens::Navigation::IsAvailable(filesystem)},
|
||||||
{"T", Apps::TestApp, true},
|
{Symbols::calculator, Apps::Calculator, true},
|
||||||
//{Symbols::none, Apps::None, false},
|
//{Symbols::none, Apps::None, false},
|
||||||
|
|
||||||
// {"M", Apps::Motion},
|
// {"M", Apps::Motion},
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <libraries/log/nrf_log.h>
|
#include <libraries/log/nrf_log.h>
|
||||||
#include "TestApp.h"
|
#include "Calculator.h"
|
||||||
#include "displayapp/InfiniTimeTheme.h"
|
#include "displayapp/InfiniTimeTheme.h"
|
||||||
#include "Symbols.h"
|
#include "Symbols.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
static void eventHandler(lv_obj_t* obj, lv_event_t event) {
|
static void eventHandler(lv_obj_t* obj, lv_event_t event) {
|
||||||
auto app = static_cast<TestApp*>(obj->user_data);
|
auto app = static_cast<Calculator*>(obj->user_data);
|
||||||
app->OnButtonEvent(obj, event);
|
app->OnButtonEvent(obj, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
TestApp::~TestApp() {
|
Calculator::~Calculator() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* buttonMap[] = {
|
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);
|
resultLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
lv_label_set_long_mode(resultLabel, LV_LABEL_LONG_CROP);
|
lv_label_set_long_mode(resultLabel, LV_LABEL_LONG_CROP);
|
||||||
lv_label_set_align(resultLabel, LV_LABEL_ALIGN_RIGHT);
|
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);
|
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)) {
|
if ((obj == buttonMatrix) && (event == LV_EVENT_PRESSED)) {
|
||||||
HandleInput();
|
HandleInput();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::HandleInput() {
|
void Calculator::HandleInput() {
|
||||||
const char* buttonText = lv_btnmatrix_get_active_btn_text(buttonMatrix);
|
const char* buttonText = lv_btnmatrix_get_active_btn_text(buttonMatrix);
|
||||||
|
|
||||||
if (buttonText == nullptr) {
|
if (buttonText == nullptr) {
|
||||||
@ -167,7 +167,7 @@ void TestApp::HandleInput() {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
// this is a little hacky because it matches only the first char
|
// this is a little hacky because it matches only the first char
|
||||||
case 'B':
|
case Symbols::backspace[0]:
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
// delete one value digit
|
// delete one value digit
|
||||||
if (offset < FIXED_POINT_OFFSET) {
|
if (offset < FIXED_POINT_OFFSET) {
|
||||||
@ -224,7 +224,7 @@ void TestApp::HandleInput() {
|
|||||||
UpdateResultLabel();
|
UpdateResultLabel();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::UpdateOperation() const {
|
void Calculator::UpdateOperation() const {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case '+':
|
case '+':
|
||||||
lv_obj_set_style_local_bg_grad_dir(buttonMatrix, LV_BTNMATRIX_PART_BTN, LV_STATE_CHECKED, LV_GRAD_DIR_HOR);
|
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;
|
value = 0;
|
||||||
offset = FIXED_POINT_OFFSET;
|
offset = FIXED_POINT_OFFSET;
|
||||||
operation = ' ';
|
operation = ' ';
|
||||||
@ -264,7 +264,7 @@ void TestApp::ResetInput() {
|
|||||||
error = Error::None;
|
error = Error::None;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::UpdateResultLabel() const {
|
void Calculator::UpdateResultLabel() const {
|
||||||
int64_t integer = result / FIXED_POINT_OFFSET;
|
int64_t integer = result / FIXED_POINT_OFFSET;
|
||||||
int64_t remainder = result % FIXED_POINT_OFFSET;
|
int64_t remainder = result % FIXED_POINT_OFFSET;
|
||||||
bool negative = (remainder < 0);
|
bool negative = (remainder < 0);
|
||||||
@ -293,7 +293,7 @@ void TestApp::UpdateResultLabel() const {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestApp::UpdateValueLabel() {
|
void Calculator::UpdateValueLabel() {
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case Error::TooLarge:
|
case Error::TooLarge:
|
||||||
lv_label_set_text_static(valueLabel, "too large");
|
lv_label_set_text_static(valueLabel, "too large");
|
||||||
@ -341,7 +341,7 @@ void TestApp::UpdateValueLabel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// update the result based on value and operation
|
// update the result based on value and operation
|
||||||
void TestApp::Eval() {
|
void Calculator::Eval() {
|
||||||
switch (operation) {
|
switch (operation) {
|
||||||
case ' ':
|
case ' ':
|
||||||
result = value;
|
result = value;
|
@ -16,11 +16,11 @@ namespace {
|
|||||||
namespace Pinetime {
|
namespace Pinetime {
|
||||||
namespace Applications {
|
namespace Applications {
|
||||||
namespace Screens {
|
namespace Screens {
|
||||||
class TestApp : public Screen {
|
class Calculator : public Screen {
|
||||||
public:
|
public:
|
||||||
~TestApp() override;
|
~Calculator() override;
|
||||||
|
|
||||||
TestApp();
|
Calculator();
|
||||||
|
|
||||||
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
void OnButtonEvent(lv_obj_t* obj, lv_event_t event);
|
||||||
|
|
@ -37,6 +37,10 @@ namespace Pinetime {
|
|||||||
static constexpr const char* eye = "\xEF\x81\xAE";
|
static constexpr const char* eye = "\xEF\x81\xAE";
|
||||||
static constexpr const char* home = "\xEF\x80\x95";
|
static constexpr const char* home = "\xEF\x80\x95";
|
||||||
static constexpr const char* sleep = "\xEE\xBD\x84";
|
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
|
// fontawesome_weathericons.c
|
||||||
// static constexpr const char* sun = "\xEF\x86\x85";
|
// static constexpr const char* sun = "\xEF\x86\x85";
|
||||||
|
Loading…
Reference in New Issue
Block a user