diff --git a/CHANGELOG.md b/CHANGELOG.md index 7d9c8f76..0bf8fe09 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # CHANGELOG: Freeboard +### v2.3.1 + +- **Fixed**: Issue in autopilot display where +/- adjustment buttons were not sending data to Pypilot. + ### v2.3.0 - **Added**: Display a badge on menu icon when server has security enabled and client is not authenticated. diff --git a/helper/pypilot.ts b/helper/pypilot.ts index 3bddea7e..ae6d9f83 100644 --- a/helper/pypilot.ts +++ b/helper/pypilot.ts @@ -170,10 +170,10 @@ const initApiRoutes = () => { const v = req.body.value * (180 / Math.PI); let deg = apData.target + v; - if (deg > 359) { - deg = 359; - } else if (deg < -179) { - deg = -179; + if (deg > 360) { + deg = 360; + } else if (deg < -180) { + deg = -180; } const r = sendToPyPilot('target', deg); @@ -282,7 +282,7 @@ const initPyPilotListeners = () => { // Send values to pypilot const sendToPyPilot = (command: string, value: string | number | boolean) => { - server.debug(`command: ${command} = ${value}`); + server.debug(`sendToPyPilot: ${command} = ${value}`); let mode = ''; if (command === 'mode') { @@ -295,8 +295,8 @@ const sendToPyPilot = (command: string, value: string | number | boolean) => { mode = 'ap.enabled'; } } else if (command === 'target') { - if (typeof value === 'string') { - value = (180 / Math.PI) * parseFloat(value); // rad to deg + server.debug(`command: ${command}, value: ${value}, ${typeof value}`); + if (typeof value === 'number') { mode = 'ap.heading_command'; } } else { @@ -309,6 +309,7 @@ const sendToPyPilot = (command: string, value: string | number | boolean) => { } try { + server.debug(`out -> ${mode}=${JSON.stringify(value)}`); socket.emit('pypilot', mode + '=' + JSON.stringify(value)); return { state: 'COMPLETED', @@ -337,10 +338,13 @@ const handlePyPilotUpdateMsg = (data: any) => { }*/ if (typeof data['ap.heading_command'] !== 'undefined') { - const heading = + const h = data['ap.heading_command'] === false ? null : data['ap.heading_command']; - if (heading !== apData.heading_command) { - apData.target = heading; + if (h !== apData.heading_command) { + apData.target = h; + server.debug( + `in -> deg: ${apData.target}, rad: ${(Math.PI / 180) * apData.target}` + ); emitAPDelta('target' as Path, (Math.PI / 180) * apData.target); } } diff --git a/package.json b/package.json index f8cb3d56..f02581c6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@signalk/freeboard-sk", - "version": "2.3.0", + "version": "2.3.1", "description": "Openlayers chart plotter implementation for Signal K", "keywords": [ "signalk-webapp", diff --git a/src/app/app.info.ts b/src/app/app.info.ts index acb61f28..1f863424 100644 --- a/src/app/app.info.ts +++ b/src/app/app.info.ts @@ -268,7 +268,7 @@ export class AppInfo extends Info { this.name = 'Freeboard-SK'; this.shortName = 'Freeboard'; this.description = `Signal K Chart Plotter.`; - this.version = '2.3.0'; + this.version = '2.3.1'; this.url = 'https://github.com/signalk/freeboard-sk'; this.logo = './assets/img/app_logo.png'; diff --git a/src/app/lib/components/autopilot.component.ts b/src/app/lib/components/autopilot.component.ts index c553b808..c7ae7b69 100644 --- a/src/app/lib/components/autopilot.component.ts +++ b/src/app/lib/components/autopilot.component.ts @@ -244,7 +244,7 @@ export class AutopilotComponent { } formatTargetValue(value: number) { - if (value) { + if (typeof value === 'number') { return Convert.radiansToDegrees(value)?.toFixed(1); } else return '--'; }