feat: Add scientific operators page (trig, log, exp)

Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
2026-03-14 13:25:11 -06:00
committed by Tanner
parent 2400ebd145
commit 3c18e0326d
+100 -9
View File
@@ -59,6 +59,17 @@ if (process.env.HWVERSION!=1) {
operators.i = {grid: [0, 3], val: '1/x'}; operators.i = {grid: [0, 3], val: '1/x'};
} }
var scientificOperatorsGrid = [2, 4];
var scientificOperators = {
'sin': {grid: [0, 0], val: 'sin'},
'cos': {grid: [1, 0], val: 'cos'},
'tan': {grid: [0, 1], val: 'tan'},
'log': {grid: [1, 1], val: 'log'},
'tenpow': {grid: [0, 2], val: '10^x'},
'ln': {grid: [1, 2], val: 'ln'},
'epow': {grid: [0, 3], val: 'e^x'},
};
var specialsGrid = [2, 2]; var specialsGrid = [2, 2];
var specials = { var specials = {
'R': {grid: [0, 0], globalGrid: [0, 0], trbl: 'RN7R', val: 'AC'}, 'R': {grid: [0, 0], globalGrid: [0, 0], trbl: 'RN7R', val: 'AC'},
@@ -141,6 +152,11 @@ function drawOperators() {
screenColor =COLORS.OPERATOR; screenColor =COLORS.OPERATOR;
drawKeys(); drawKeys();
} }
function drawScientificOperators() {
screen = scientificOperators;
screenColor =COLORS.OPERATOR;
drawKeys();
}
function drawSpecials() { function drawSpecials() {
screen = specials; screen = specials;
screenColor = COLORS.SPECIAL; screenColor = COLORS.SPECIAL;
@@ -342,6 +358,76 @@ function buttonPress(val) {
} }
hasPressedNumber = false; hasPressedNumber = false;
break; break;
case 'sin':
if (results != null) {
results = Math.sin(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.sin(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'cos':
if (results != null) {
results = Math.cos(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.cos(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'tan':
if (results != null) {
results = Math.tan(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.tan(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'log':
if (results != null) {
results = Math.log10(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.log10(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'tenpow':
if (results != null) {
results = Math.pow(10, results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.pow(10, currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'ln':
if (results != null) {
results = Math.log(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.log(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'epow':
if (results != null) {
results = Math.exp(results);
displayOutput(results);
} else if (currNumber != null) {
currNumber = Math.exp(currNumber);
displayOutput(currNumber);
}
hasPressedNumber = false;
break;
case 'i': case 'i':
if (results != null) { if (results != null) {
results = divide(1, results); results = divide(1, results);
@@ -443,6 +529,7 @@ if (process.env.HWVERSION==1) {
swipeEnabled = true; swipeEnabled = true;
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT); prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
prepareScreen(operators, operatorsGrid, COLORS.OPERATOR); prepareScreen(operators, operatorsGrid, COLORS.OPERATOR);
prepareScreen(scientificOperators, scientificOperatorsGrid, COLORS.OPERATOR);
prepareScreen(specials, specialsGrid, COLORS.SPECIAL); prepareScreen(specials, specialsGrid, COLORS.SPECIAL);
drawNumbers(); drawNumbers();
@@ -460,17 +547,21 @@ if (process.env.HWVERSION==1) {
} }
}, },
swipe : (LR, UD) => { swipe : (LR, UD) => {
if (LR == 1) { // right if (UD !== 0) {
drawSpecials();
}
if (LR == -1) { // left
drawOperators();
}
if (UD == 1) { // down
drawNumbers(); drawNumbers();
return;
} }
if (UD == -1) { // up if (LR === 1) { // right
drawNumbers(); if (screen === scientificOperators) drawOperators();
else if (screen === operators) drawNumbers();
else if (screen === numbers) drawSpecials();
else if (screen === specials) drawNumbers();
}
if (LR === -1) { // left
if (screen === numbers) drawOperators();
else if (screen === operators) drawScientificOperators();
else if (screen === specials) drawNumbers();
else if (screen === scientificOperators) drawNumbers();
} }
} }
}); });