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:
@@ -59,6 +59,17 @@ if (process.env.HWVERSION!=1) {
|
||||
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 specials = {
|
||||
'R': {grid: [0, 0], globalGrid: [0, 0], trbl: 'RN7R', val: 'AC'},
|
||||
@@ -141,6 +152,11 @@ function drawOperators() {
|
||||
screenColor =COLORS.OPERATOR;
|
||||
drawKeys();
|
||||
}
|
||||
function drawScientificOperators() {
|
||||
screen = scientificOperators;
|
||||
screenColor =COLORS.OPERATOR;
|
||||
drawKeys();
|
||||
}
|
||||
function drawSpecials() {
|
||||
screen = specials;
|
||||
screenColor = COLORS.SPECIAL;
|
||||
@@ -342,6 +358,76 @@ function buttonPress(val) {
|
||||
}
|
||||
hasPressedNumber = false;
|
||||
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':
|
||||
if (results != null) {
|
||||
results = divide(1, results);
|
||||
@@ -443,6 +529,7 @@ if (process.env.HWVERSION==1) {
|
||||
swipeEnabled = true;
|
||||
prepareScreen(numbers, numbersGrid, COLORS.DEFAULT);
|
||||
prepareScreen(operators, operatorsGrid, COLORS.OPERATOR);
|
||||
prepareScreen(scientificOperators, scientificOperatorsGrid, COLORS.OPERATOR);
|
||||
prepareScreen(specials, specialsGrid, COLORS.SPECIAL);
|
||||
drawNumbers();
|
||||
|
||||
@@ -460,17 +547,21 @@ if (process.env.HWVERSION==1) {
|
||||
}
|
||||
},
|
||||
swipe : (LR, UD) => {
|
||||
if (LR == 1) { // right
|
||||
drawSpecials();
|
||||
}
|
||||
if (LR == -1) { // left
|
||||
drawOperators();
|
||||
}
|
||||
if (UD == 1) { // down
|
||||
if (UD !== 0) {
|
||||
drawNumbers();
|
||||
return;
|
||||
}
|
||||
if (UD == -1) { // up
|
||||
drawNumbers();
|
||||
if (LR === 1) { // right
|
||||
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();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user