mirror of
https://github.com/InfiniTimeOrg/InfiniTime.git
synced 2024-10-22 23:21:53 +02:00
add backspace button
This commit is contained in:
parent
8c10adc890
commit
e46a1ca712
|
@ -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, 0xf201, 0xf06e, 0xf015, 0xf00c, 0xf1ec, 0xf743"
|
"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, 0xf201, 0xf06e, 0xf015, 0xf00c, 0xf1ec, 0xf743, 0xf55a"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"bpp": 1,
|
"bpp": 1,
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
#include "Calculator.h"
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
#include <libraries/log/nrf_log.h>
|
#include <libraries/log/nrf_log.h>
|
||||||
|
#include "Calculator.h"
|
||||||
|
#include "Symbols.h"
|
||||||
|
|
||||||
using namespace Pinetime::Applications::Screens;
|
using namespace Pinetime::Applications::Screens;
|
||||||
|
|
||||||
|
@ -14,7 +15,7 @@ Calculator::~Calculator() {
|
||||||
lv_obj_clean(lv_scr_act());
|
lv_obj_clean(lv_scr_act());
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char* buttonMap[] = {"7", "8", "9", "<", "\n", "4", "5", "6", "+-", "\n", "1", "2", "3", "*/", "\n", ".", "0", "=", "^", ""};
|
static const char* buttonMap[] = {"7", "8", "9", Symbols::backspace, "\n", "4", "5", "6", "+-", "\n", "1", "2", "3", "*/", "\n", ".", "0", "=", "^", ""};
|
||||||
|
|
||||||
Calculator::Calculator(DisplayApp* app) : Screen(app) {
|
Calculator::Calculator(DisplayApp* app) : Screen(app) {
|
||||||
resultLabel = lv_label_create(lv_scr_act(), nullptr);
|
resultLabel = lv_label_create(lv_scr_act(), nullptr);
|
||||||
|
@ -132,15 +133,38 @@ void Calculator::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
|
||||||
lv_label_refr_text(operationLabel);
|
lv_label_refr_text(operationLabel);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case '<':
|
// this is a little hacky because it matches only the first char
|
||||||
offset = FIXED_POINT_OFFSET;
|
case Symbols::backspace[0]:
|
||||||
if (value != 0) {
|
if (value != 0) {
|
||||||
value = 0;
|
// delete one value digit
|
||||||
|
|
||||||
|
if (offset < FIXED_POINT_OFFSET) {
|
||||||
|
if (offset == 0) {
|
||||||
|
offset = 1;
|
||||||
|
} else {
|
||||||
|
offset *= 10;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
value /= 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (offset < FIXED_POINT_OFFSET) {
|
||||||
|
value -= value % (10 * offset);
|
||||||
|
} else {
|
||||||
|
value -= value % offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateValueLabel();
|
||||||
} else {
|
} else {
|
||||||
|
// reset the result
|
||||||
|
|
||||||
result = 0;
|
result = 0;
|
||||||
UpdateResultLabel();
|
UpdateResultLabel();
|
||||||
}
|
}
|
||||||
UpdateValueLabel();
|
|
||||||
|
NRF_LOG_INFO(". offset: %" PRId64, offset);
|
||||||
|
NRF_LOG_INFO(". value: %" PRId64, value);
|
||||||
|
NRF_LOG_INFO(". result: %" PRId64, result);
|
||||||
|
|
||||||
*operation = ' ';
|
*operation = ' ';
|
||||||
lv_label_refr_text(operationLabel);
|
lv_label_refr_text(operationLabel);
|
||||||
|
|
|
@ -40,6 +40,7 @@ namespace Pinetime {
|
||||||
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* 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 a new issue