Skip to content

Commit 15fd085

Browse files
Merge pull request #2 from CypherNova1337/voidsec-hub/intelligent-ptolemy-vp3nah
Fix calculator equals and clarify missing weather
2 parents e7652ce + 19f6845 commit 15fd085

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

‎src/displayapp/screens/Calculator.cpp‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,13 @@ void Calculator::OnButtonEvent(lv_obj_t* obj, lv_event_t event) {
5959
}
6060

6161
void Calculator::HandleInput() {
62+
// A press between or outside the buttons leaves LVGL's "active" button on the previous key,
63+
// which would replay it. Only accept presses that actually landed on a button.
64+
const auto* ext = static_cast<lv_btnmatrix_ext_t*>(lv_obj_get_ext_attr(buttonMatrix));
65+
if (ext->btn_id_pr == LV_BTNMATRIX_BTN_NONE) {
66+
return;
67+
}
68+
6269
const char* buttonText = lv_btnmatrix_get_active_btn_text(buttonMatrix);
6370

6471
if (buttonText == nullptr) {
@@ -188,14 +195,15 @@ void Calculator::HandleInput() {
188195
break;
189196

190197
case '=':
191-
equalSignPressedBefore = true;
192198
Eval();
193-
// If the operation is ' ' then we move the value to the result.
194-
// We reset the input after this.
195-
// This seems more convenient.
196-
if (operation == ' ') {
197-
ResetInput();
199+
if (error == Error::None) {
200+
// Show the answer on the main line, like a regular calculator.
201+
// The next digit starts a new number, the next operator keeps working on the answer.
202+
value = result;
203+
operation = ' ';
204+
UpdateOperation();
198205
}
206+
equalSignPressedBefore = true;
199207
break;
200208
}
201209

‎src/displayapp/screens/WatchFaceNetRunner.cpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ void WatchFaceNetRunner::Refresh() {
296296
}
297297
lv_label_set_text_fmt(labelEnv, "#9d4edd ENV# %d°%c %s", temp, tempUnit, Symbols::GetSimpleCondition(optCurrentWeather->iconId));
298298
} else {
299-
lv_label_set_text_static(labelEnv, "#9d4edd ENV# NO SIGNAL");
299+
lv_label_set_text_static(labelEnv, "#9d4edd ENV# NO WEATHER");
300300
}
301301
}
302302
}

0 commit comments

Comments
 (0)