From bb0eec30039f02ceee0a1a6f1e59520b91ee2266 Mon Sep 17 00:00:00 2001 From: slughead Date: Sat, 2 Dec 2023 23:58:42 +0000 Subject: [PATCH] Added FA-18C Hornet backlight control --- TMHotasLEDSync.tmc | 7 +++--- a-10c_led_utils.tmh | 11 ++++----- fa-18c_hornet_led_utils.tmh | 46 +++++++++++++++++++++++++++++++++++++ led_utils.tmh | 9 ++++++-- 4 files changed, 61 insertions(+), 12 deletions(-) create mode 100644 fa-18c_hornet_led_utils.tmh diff --git a/TMHotasLEDSync.tmc b/TMHotasLEDSync.tmc index 72ceb42..6f8dd96 100644 --- a/TMHotasLEDSync.tmc +++ b/TMHotasLEDSync.tmc @@ -11,7 +11,7 @@ -- various lamps and console lighting of a variety of aircraft. -- -- Author: slughead - -- Date: 26/11/2023 + -- Date: 2/12/2023 -- ------------------------------------------------------------------------------*/ @@ -20,8 +20,9 @@ include "aircraft_utils.tmh" include "led_utils.tmh" include "a-10c_led_utils.tmh" include "f-16c_led_utils.tmh" +include "fa-18c_hornet_led_utils.tmh" -define VERSION "1.0.2" +define VERSION "1.0.3" define DEBUG 0 @@ -116,7 +117,7 @@ int TCPCallback(int buf, int size) if (aircraft == F_16C_50) set_f_16c_led_status( &packet ); if (aircraft == A_10C) set_a_10c_led_status( &packet ); if (aircraft == A_10C_2) set_a_10c_led_status( &packet ); - if (aircraft == FA_18C_HORNET) set_speed_brake_leds( char_to_int(packet[1]) ); + if (aircraft == FA_18C_HORNET) set_fa_18c_hornet_led_status( &packet ); if (aircraft == SU_25T) set_speed_brake_leds( char_to_int(packet[1]) ); if (aircraft == SU_33) set_speed_brake_leds( char_to_int(packet[1]) ); } diff --git a/a-10c_led_utils.tmh b/a-10c_led_utils.tmh index f7d44bb..0aa3993 100644 --- a/a-10c_led_utils.tmh +++ b/a-10c_led_utils.tmh @@ -8,7 +8,7 @@ -- on Thrustmaster Warthog Throttle. -- -- Author: slughead - -- Date: 26/11/2023 + -- Date: 2/12/2023 -- ------------------------------------------------------------------------------*/ @@ -23,7 +23,7 @@ int set_a_10c_led_status( alias led_states ) if (&Throttle != &joy0) { set_a_10c_speed_brake_leds( speed_brake_position ); - set_backlight(&Throttle, console_light); + set_a_10c_backlight( console_light) ; } } @@ -39,10 +39,7 @@ int set_a_10c_speed_brake_leds(int speed_brake_position) } } -int set_backlight(int device, int intensity) +int set_a_10c_backlight( int intensity ) { - if (device == &Throttle) - { - ActKey(PULSE+KEYON+LED(device, LED_INTENSITY, intensity * 51)); - } + set_backlight( intensity ); } \ No newline at end of file diff --git a/fa-18c_hornet_led_utils.tmh b/fa-18c_hornet_led_utils.tmh new file mode 100644 index 0000000..5d981cd --- /dev/null +++ b/fa-18c_hornet_led_utils.tmh @@ -0,0 +1,46 @@ +/*------------------------------------------------------------------------------- + -- + -- fa-18c_hornet_led_utils.tmh + -- + -- Use at own risk without warranty. + -- + -- F/A-18C Hornet specific utility functions to program the state of LEDs + -- on Thrustmaster Warthog Throttle. + -- + -- Author: slughead + -- Date: 2/12/2023 + -- + ------------------------------------------------------------------------------*/ + +//include "warthog_defines.tmh" +//include "warthog_utils.tmh" + +int set_fa_18c_hornet_led_status( alias led_states ) +{ + int speed_brake_position = char_to_int(led_states[1]); + int console_light = char_to_int(led_states[2]); + + if (&Throttle != &joy0) + { + set_fa_18c_speed_brake_leds( speed_brake_position ); + set_fa_18c_hornet_backlight( console_light) ; + } +} + +int set_fa_18c_speed_brake_leds(int speed_brake_position) +{ + if (&Throttle != &joy0) + { + set_led(&Throttle, get_tm_warthog_led_id( WH_LED1 ), (speed_brake_position >= 1)); + set_led(&Throttle, get_tm_warthog_led_id( WH_LED2 ), (speed_brake_position >= 2)); + set_led(&Throttle, get_tm_warthog_led_id( WH_LED3 ), (speed_brake_position >= 3)); + set_led(&Throttle, get_tm_warthog_led_id( WH_LED4 ), (speed_brake_position >= 4)); + set_led(&Throttle, get_tm_warthog_led_id( WH_LED5 ), (speed_brake_position >= 5)); + } +} + +int set_fa_18c_hornet_backlight( int intensity ) +{ + set_backlight( intensity ); + //ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, intensity * 51)); +} \ No newline at end of file diff --git a/led_utils.tmh b/led_utils.tmh index 71d6e1d..44804f9 100644 --- a/led_utils.tmh +++ b/led_utils.tmh @@ -8,7 +8,7 @@ -- and Warthog devices. -- -- Author: slughead - -- Date: 26/11/2023 + -- Date: 2/12/2023 -- ------------------------------------------------------------------------------*/ @@ -74,10 +74,15 @@ int reset_leds() set_led(&Throttle, get_tm_warthog_led_id( WH_LED4 ), LED_STATE_OFF); set_led(&Throttle, get_tm_warthog_led_id( WH_LED5 ), LED_STATE_OFF); - set_backlight(&Throttle, 3); + set_backlight( 3 ); } } +int set_backlight( int intensity ) +{ + ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, intensity * 51)); +} + int set_speed_brake_leds(int speed_brake_position) { if ( aircraft == FA_18C_HORNET |