mirror of https://github.com/espruino/BangleApps
Update app.js
Added default 'none' for when there is no tolerance value provided Added back missing code for using multiplied value from menu for generating colorspull/2757/head
parent
32c27fb918
commit
7cc763db1b
|
@ -83,7 +83,7 @@ function colorBandsToResistance(colorBands) {
|
|||
let firstBand = colorBands[0];
|
||||
let secondBand = colorBands[1];
|
||||
let multiplierBand = colorBands[2];
|
||||
let toleranceBand = colorBands[3];
|
||||
let toleranceBand = colorBands[3] || 'none'; // Add a default value for toleranceBand
|
||||
let significantDigits = colorData[firstBand].value * 10 + colorData[secondBand].value;
|
||||
let multiplier = colorData[multiplierBand].multiplier;
|
||||
let resistance = significantDigits * multiplier;
|
||||
|
@ -225,7 +225,7 @@ function drawResistance(resistance, tolerance) {
|
|||
tolerance = 20;
|
||||
}
|
||||
|
||||
var toleranceStr = "±" + tolerance + "%";
|
||||
var toleranceStr = "±" + tolerance + "%";
|
||||
var toleranceX = tolerance.toString().replace('.', '').length > 2 ? 10 : 14;
|
||||
g.drawString(toleranceStr.padEnd(4), 176 - toleranceX, y);
|
||||
}
|
||||
|
@ -419,9 +419,9 @@ function drawResistance(resistance, tolerance) {
|
|||
E.showMenu(toleranceMenu);
|
||||
}
|
||||
|
||||
function drawResistorAndResistance(resistance, tolerance) {
|
||||
function drawResistorAndResistance(resistance, tolerance, multipliedResistance) {
|
||||
console.log('Draw Resistor clicked');
|
||||
let colorBands = resistanceToColorBands((settings.resistance * settings.multiplier), settings.tolerance);
|
||||
let colorBands = resistanceToColorBands(multipliedResistance || resistance, tolerance);
|
||||
drawResistor(colorBands, tolerance);
|
||||
drawResistance(resistance, tolerance);
|
||||
resetSettings();
|
||||
|
@ -462,7 +462,7 @@ function drawResistance(resistance, tolerance) {
|
|||
let formattedResistance = formatResistance(multipliedValue);
|
||||
let resistanceString = `${formattedResistance.value}${formattedResistance.unit}`;
|
||||
if (settings.tolerance) {
|
||||
return `${resistanceString}, ± ${settings.tolerance}%`;
|
||||
return `${resistanceString}, ± ${settings.tolerance}%`;
|
||||
} else {
|
||||
return v ? `${resistanceString}` : '';
|
||||
}
|
||||
|
@ -508,4 +508,4 @@ function drawResistance(resistance, tolerance) {
|
|||
},
|
||||
};
|
||||
E.showMenu(mainMenu);
|
||||
})(load);
|
||||
})(load);
|
||||
|
|
Loading…
Reference in New Issue