From f4e1298a1a2ff16a8cd2cea90214956f273afa2e Mon Sep 17 00:00:00 2001 From: curt Date: Tue, 30 Jul 2002 02:56:42 +0000 Subject: [PATCH] Added formatted time to property tree for use by 'virtual' instruments. --- src/Cockpit/kr_87.cxx | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/src/Cockpit/kr_87.cxx b/src/Cockpit/kr_87.cxx index b3242099d..0cc2b4adf 100644 --- a/src/Cockpit/kr_87.cxx +++ b/src/Cockpit/kr_87.cxx @@ -397,7 +397,39 @@ void FGKR_87::update( double dt ) { et_ann = false; } - + // formatted timer + double time; + int hours, min, sec; + if ( timer_mode == 0 ) { + time = flight_timer; + } else { + time = elapsed_timer; + } + // cout << time << endl; + hours = (int)(time / 3600.0); + time -= hours * 3600.00; + min = (int)(time / 60.0); + time -= min * 60.0; + sec = (int)time; + int big, little; + if ( hours > 0 ) { + big = hours; + if ( big > 99 ) { + big = 99; + } + little = min; + } else { + big = min; + little = sec; + } + if ( big > 99 ) { + big = 99; + } + char formatted_timer[128]; + // cout << big << ":" << little << endl; + snprintf(formatted_timer, 6, "%02d:%02d", big, little); + fgSetString( "/radios/kr-87/outputs/timer-string", formatted_timer ); + while ( goal_needle_deg < 0.0 ) { goal_needle_deg += 360.0; } while ( goal_needle_deg >= 360.0 ) { goal_needle_deg -= 360.0; } -- 2.39.5