1
0
mirror of https://github.com/sbender9/signalk-raymarine-autopilot.git synced 2020-11-18 19:37:28 -08:00

fix: changing target heading or wind when going past 0 or 360 degrees

This commit is contained in:
Scott Bender 2018-07-09 10:39:22 -04:00
parent 8af3cb3b62
commit 23ca5265e9

View File

@ -105,20 +105,30 @@ function changeHeading(app, deviceid, command_json)
{
var current = app.getSelfPath(target_heading_path)
new_value = radsToDeg(current) + ammount
app.debug("new heading: " + new_value)
if ( new_value < 0 ) {
new_value = 360 + new_value
} else if ( new_value > 360 ) {
new_value = new_value - 360
}
app.debug(`current heading: ${radsToDeg(current)} new value: ${new_value}`)
command_format = heading_command
}
else if ( state == "wind" )
{
var current = app.getSelfPath(target_wind_path)
app.debug("current wind angle: " + current)
new_value = radsToDeg(current)
new_value = radsToDeg(current) + ammount
if ( new_value < 0 )
new_value = 360 + new_value
new_value += ammount
else if ( new_value > 360 )
new_value = new_value - 360
app.debug(`current wind angle: ${radsToDeg(current)} new value: ${new_value}`)
command_format = wind_direction_command
}
}
else
{
//error