@@ -189,10 +189,13 @@ gps.initialize = async function (callback) {
189
189
const lat = FC . GPS_DATA . lat / 10000000 ;
190
190
const lon = FC . GPS_DATA . lon / 10000000 ;
191
191
const url = `https://maps.google.com/?q=${ lat } ,${ lon } ` ;
192
- const imuHeading = FC . SENSOR_DATA . kinematics [ 2 ] ;
193
- const magHeading = hasMag ? Math . atan2 ( FC . SENSOR_DATA . magnetometer [ 1 ] , FC . SENSOR_DATA . magnetometer [ 0 ] ) : undefined ;
194
- const magHeadingDeg = magHeading === undefined ? 0 : magHeading * 180 / Math . PI ;
195
- const gpsHeading = FC . GPS_DATA . ground_course / 100 ;
192
+ const imuHeadingDegrees = FC . SENSOR_DATA . kinematics [ 2 ] ;
193
+ // Convert to radians and add 180 degrees to make icon point in the right direction
194
+ const imuHeadingRadians = ( imuHeadingDegrees + 180 ) * Math . PI / 180 ;
195
+ // These are not used, but could be used to show the heading from the magnetometer
196
+ // const magHeadingDegrees = hasMag ? Math.atan2(FC.SENSOR_DATA.magnetometer[1], FC.SENSOR_DATA.magnetometer[0]) : undefined;
197
+ // const magHeadingRadians = magHeadingDegrees === undefined ? 0 : magHeadingDegrees * Math.PI / 180;
198
+ const gpsHeading = FC . GPS_DATA . ground_course / 10 ;
196
199
const gnssArray = [ 'GPS' , 'SBAS' , 'Galileo' , 'BeiDou' , 'IMES' , 'QZSS' , 'Glonass' ] ;
197
200
const qualityArray = [ 'gnssQualityNoSignal' , 'gnssQualitySearching' , 'gnssQualityAcquired' , 'gnssQualityUnusable' , 'gnssQualityLocked' ,
198
201
'gnssQualityFullyLocked' , 'gnssQualityFullyLocked' , 'gnssQualityFullyLocked' ] ;
@@ -202,10 +205,10 @@ gps.initialize = async function (callback) {
202
205
$ ( '.GPS_info span.colorToggle' ) . text ( FC . GPS_DATA . fix ? i18n . getMessage ( 'gpsFixTrue' ) : i18n . getMessage ( 'gpsFixFalse' ) ) ;
203
206
$ ( '.GPS_info span.colorToggle' ) . toggleClass ( 'ready' , FC . GPS_DATA . fix != 0 ) ;
204
207
205
- const gspUnitText = i18n . getMessage ( 'gpsPositionUnit' ) ;
208
+ const gpsUnitText = i18n . getMessage ( 'gpsPositionUnit' ) ;
206
209
$ ( '.GPS_info td.alt' ) . text ( `${ alt } m` ) ;
207
- $ ( '.GPS_info td.latLon a' ) . prop ( 'href' , url ) . text ( `${ lat . toFixed ( 6 ) } / ${ lon . toFixed ( 6 ) } ${ gspUnitText } ` ) ;
208
- $ ( '.GPS_info td.heading' ) . text ( `${ imuHeading . toFixed ( 0 ) } / ${ gpsHeading . toFixed ( 0 ) } ${ gspUnitText } ` ) ;
210
+ $ ( '.GPS_info td.latLon a' ) . prop ( 'href' , url ) . text ( `${ lat . toFixed ( 6 ) } / ${ lon . toFixed ( 6 ) } ${ gpsUnitText } ` ) ;
211
+ $ ( '.GPS_info td.heading' ) . text ( `${ imuHeadingDegrees . toFixed ( 0 ) } / ${ gpsHeading . toFixed ( 0 ) } ${ gpsUnitText } ` ) ;
209
212
$ ( '.GPS_info td.speed' ) . text ( `${ FC . GPS_DATA . speed } cm/s` ) ;
210
213
$ ( '.GPS_info td.sats' ) . text ( FC . GPS_DATA . numSat ) ;
211
214
$ ( '.GPS_info td.distToHome' ) . text ( `${ FC . GPS_DATA . distanceToHome } m` ) ;
@@ -303,7 +306,7 @@ gps.initialize = async function (callback) {
303
306
action : 'center' ,
304
307
lat : lat ,
305
308
lon : lon ,
306
- heading : gpsHeading ,
309
+ heading : imuHeadingRadians ,
307
310
} ;
308
311
309
312
frame = document . getElementById ( 'map' ) ;
0 commit comments