Skip to content

Commit

Permalink
chore: typescript port
Browse files Browse the repository at this point in the history
  • Loading branch information
BravoMike99 committed Feb 4, 2025
1 parent c4e6300 commit 1238b19
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2097,10 +2097,11 @@ export abstract class FMCMainDisplay implements FmsDataInterface, FmsDisplayInte
}
}
if (tempString) {
const temp = parseInt(tempString.replace('M', '-'));
console.log('tS: ' + tempString);
console.log('ti: ' + temp);
let temp = parseInt(tempString);
if (isFinite(temp) && this.cruiseLevel) {
if (!tempString.startsWith('+') && !tempString.startsWith('-')) {
temp = -temp;
}
if (temp > -270 && temp < 100) {
this.cruiseTemperature = temp;
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,14 @@ export class CDUInitPage {
if (mcdu.cruiseLevel) {
cruiseFl.update('FL' + mcdu.cruiseLevel.toFixed(0).padStart(3, '0'), Column.cyan);
if (mcdu.cruiseTemperature) {
cruiseTemp.update(mcdu.cruiseTemperature.toFixed(0) + '°', Column.cyan);
cruiseTemp.update(CDUInitPage.formatTemperature(mcdu.cruiseTemperature), Column.cyan);
cruiseFlTempSeparator.updateAttributes(Column.cyan);
} else {
cruiseTemp.update(mcdu.tempCurve.evaluate(mcdu.cruiseLevel).toFixed(0) + '°', Column.cyan, Column.small);
cruiseTemp.update(
CDUInitPage.formatTemperature(Math.trunc(mcdu.tempCurve.evaluate(mcdu.cruiseLevel))),
Column.cyan,
Column.small,
);
cruiseFlTempSeparator.updateAttributes(Column.cyan, Column.small);
}
}
Expand Down Expand Up @@ -265,7 +269,7 @@ export class CDUInitPage {
const groundTemp = new Column(23, '---°', Column.right);
if (mcdu.groundTemp !== undefined) {
groundTemp.update(
mcdu.groundTemp.toFixed(0) + '°',
CDUInitPage.formatTemperature(mcdu.groundTemp),
Column.cyan,
mcdu.groundTempPilot !== undefined ? Column.big : Column.small,
);
Expand Down Expand Up @@ -785,4 +789,8 @@ export class CDUInitPage {
static formatWindComponent(tailwindComponent) {
return Math.round(Math.abs(tailwindComponent)).toFixed(0).padStart(3, '0');
}

static formatTemperature(temperature: number): string {
return (temperature > 0 ? '+' : '') + temperature.toFixed(0) + '°';
}
}

0 comments on commit 1238b19

Please sign in to comment.