From 3b8c365b0fdc1451ad1321531534670648d1386a Mon Sep 17 00:00:00 2001 From: Gordon Williams Date: Thu, 23 Sep 2021 11:43:38 +0100 Subject: [PATCH] Update calculator - now shows currently active operation --- apps/calculator/ChangeLog | 1 + apps/calculator/app.js | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/calculator/ChangeLog b/apps/calculator/ChangeLog index c711731d7..6a3308c50 100644 --- a/apps/calculator/ChangeLog +++ b/apps/calculator/ChangeLog @@ -1,3 +1,4 @@ 0.01: New App! 0.02: fix precision rounding issue + no reset when equals pressed 0.03: Support for different screen sizes and touchscreen +0.04: Display current operation on LHS diff --git a/apps/calculator/app.js b/apps/calculator/app.js index 89520ab94..9f801cf22 100644 --- a/apps/calculator/app.js +++ b/apps/calculator/app.js @@ -199,8 +199,7 @@ function doMath(x, y, operator) { function displayOutput(num) { var len; var minusMarge = 0; - g.setColor(0); - g.fillRect(0, 0, g.getWidth(), RESULT_HEIGHT-1); + g.setBgColor(0).clearRect(0, 0, g.getWidth(), RESULT_HEIGHT-1); g.setColor(-1); if (num === Infinity || num === -Infinity || isNaN(num)) { // handle division by 0 @@ -244,6 +243,10 @@ function displayOutput(num) { } g.setFontAlign(1,0); g.drawString(num, g.getWidth()-20, RESULT_HEIGHT/2); + if (operator) { + g.setFont('Vector', 22).setFontAlign(1,0); + g.drawString(operator, g.getWidth()-1, RESULT_HEIGHT/2); + } } var wasPressedEquals = false; var hasPressedNumber = false;