@@ -103,6 +103,12 @@ import mavlink_store_get from '@/utils/mavlink'
103103import CPUUsage from ' @/widgets/CpuPie.vue'
104104import Networking from ' @/widgets/Networking.vue'
105105
106+ interface Orientation {
107+ roll: number
108+ pitch: number
109+ yaw: number
110+ }
111+
106112interface AppItem {
107113 icon? : string
108114 title? : string
@@ -128,6 +134,7 @@ export default Vue.extend({
128134 windowHeight: window .innerHeight ,
129135 windowWidth: window .innerWidth ,
130136 fetch_streams_task: new OneMoreTime ({ delay: 10000 , disposeWith: this }),
137+ lastOrientation: { roll: 0 , pitch: 0 , yaw: 0 } as Orientation ,
131138 }),
132139 computed: {
133140 apps(): AppItem [] {
@@ -232,11 +239,26 @@ export default Vue.extend({
232239 has_internet(): boolean {
233240 return helper .has_internet !== InternetConnectionState .OFFLINE
234241 },
242+ attitudeMessage(): Orientation | undefined {
243+ return mavlink_store_get (mavlink , ' ATTITUDE.messageData.message' ) as Orientation | undefined
244+ },
235245 orientation(): string {
236- const msg = mavlink_store_get (mavlink , ' ATTITUDE.messageData.message' ) as
237- { roll : number ; pitch : number ; yaw : number } | undefined
238- if (! msg ) return ' 0deg 0deg 0deg'
239- return ` ${msg .roll }rad ${- msg .pitch }rad ${- msg .yaw }rad `
246+ const { roll, pitch, yaw } = this .lastOrientation
247+ return ` ${roll }rad ${- pitch }rad ${- yaw }rad `
248+ },
249+ },
250+ watch: {
251+ attitudeMessage(msg : Orientation | undefined ): void {
252+ if (! msg ) return
253+ const { roll, pitch, yaw } = msg
254+ const last = this .lastOrientation
255+ // Only update if any axis changed by more than 3 degrees
256+ const threshold = 3 * (Math .PI / 180 )
257+ if (Math .abs (roll - last .roll ) > threshold
258+ || Math .abs (pitch - last .pitch ) > threshold
259+ || Math .abs (yaw - last .yaw ) > threshold ) {
260+ this .lastOrientation = { roll , pitch , yaw }
261+ }
240262 },
241263 },
242264 mounted() {
0 commit comments