@scubapics accordings to the docs, LED dim is OFF plus 5 levels of intensity. AFAIR the docs, you can’t set intensity per LED, it’s one value for all 5 LEDs . This is kind of sad because it would be cool to use one LED instead of four to reflect different states for e.g. LG/wheels state (50% dim for LG handle down, 100% as soon as wheels are locked on LED1 for example).
Until something properly done by scubapics, I’d try something like below for just the wheels and LG handle lighting up LED 1 to 4. It is based on scubapics original .tmc he posted above.
Notes on the changes I made:
Warthog LEDs call should be LED instead of LEDV. the LED syntax is slightly different. The second arg is either 0 (on/off/toggle mode) or 1 (brightness mode). The third argument can be a representation of “On”, “Off” or “Toggle” (i.e. LED_CURRENT+LEDn, LED_CURRENT-LEDn, LED_CURRENT^LEDn).
I’m unsure if LED needs multiple calls just like LEDV does to trigger so I left the while loop untouched.
I threw away the blink function to keep it short. I added “Throttle” instead of “ViperTQS” to the device list, renamed the function arguments accordingly. The SetLED() funtion uses LED instead of LEDV.
Don’t know if it works because I don’t own a Warthog Throttle and thus can’t test anything. Try it or ignore it until scubapics releases something that works and is included in his original. I’m just curious about if I got the basics right:
/*-------------------------------------------------------------------------------
--
-- ViperTQSLEDSync.tmc - MODIFIED FOR WARTHOG THROTTLE, DON'T USE
-- ON VIPERTQS
-- prototype based on the genius work of slughead/scubapics
-- if you want something that works properly, wait until someone with a clue
-- incorporates everything into the original code
------------------------------------------------------------------------------*/
include "target.tmh"
define LED_GEAR_NOSE LED1
define LED_GEAR_LEFT LED2
define LED_GEAR_RIGHT LED3
define LED_GEAR_WARNING LED4
define LED_RWR_SEARCH 14
define LED_RWR_A_POWER 15
define LED_RWR_LOW_ALT_RED 16
define LED_RWR_LOW_ALT_GREEN 17
define LED_RWR_SYSTEM_POWER 18
define LED_STATE_OFF 0
define LED_STATE_ON 1
// GEAR NOSE (OFF/GREEN/RED/YELLOW/BLUE/LBLUE/PURPLE/WHITE)
// GEAR LEFT (OFF/GREEN/RED/YELLOW/BLUE/LBLUE/PURPLE/WHITE)
// GEAR RIGHT (OFF/GREEN/RED/YELLOW/BLUE/LBLUE/PURPLE/WHITE)
// GEAR WARNING (OFF/RED)
// SEARCH (OFF/GREEN)
// A POWER (OFF/GREEN)
// LOW ALT (OFF/RED)
// LOW ALT (OFF/GREEN)
// SYSTEM POWER (OFF/GREEN)
int main()
{
Configure(&Throttle, MODE_KEEPENABLED);
Configure(&Joystick, MODE_EXCLUDED);
Configure(&JoystickF18, MODE_EXCLUDED);
Configure(&LMFD, MODE_EXCLUDED);
Configure(&RMFD, MODE_EXCLUDED);
Configure(&HCougar, MODE_EXCLUDED);
Configure(&T16000, MODE_EXCLUDED);
Configure(&T16000L, MODE_EXCLUDED);
Configure(&TWCSThrottle, MODE_EXCLUDED);
Configure(&TFRPRudder, MODE_EXCLUDED);
Configure(&TFRPHARudder, MODE_EXCLUDED);
Configure(&A320Pilot, MODE_EXCLUDED);
Configure(&A320Copilot, MODE_EXCLUDED);
Configure(&TCAQuadrant12, MODE_EXCLUDED);
Configure(&TCAQuadrant34, MODE_EXCLUDED);
Configure(&TCAQBoeing12, MODE_EXCLUDED);
Configure(&TCAQBoeing34, MODE_EXCLUDED);
Configure(&TCAYokeBoeing, MODE_EXCLUDED);
Configure(&ViperTQS, MODE_EXCLUDED);
//Configure(&ViperTQS, MODE_EXCLUDED);
Configure(&ViperBBox, MODE_EXCLUDED);
// TODO determine which Viper device is connected
// and set a device variable so that both can be
// supported without modifying the code.
Configure(&TCASidestickXPilot, MODE_EXCLUDED);
Configure(&TCASidestickXCopilot, MODE_EXCLUDED);
//Configure(&FarmStickRight, MODE_EXCLUDED);
//Configure(&FarmStickLeft, MODE_EXCLUDED);
if(Init(&EventHandle)) return 1;
RegisterGameCallback(2323, &TCPCallback); // attach TCPCallback procedure to TCP port 1000
SetKBRate(32, 50);
SetKBLayout(KB_ENG);
SetShiftButton(0, 0, 0, 0, 0, 0);
ResetLeds();
}
int EventHandle(int type, alias o, int x)
{
DefaultMapping(&o, x);
}
int TCPCallback(int buf, int size)
{
int i;
char packet;
Map(&packet, buf); Dim(&packet, size);
char packet_string;
Map(&packet_string, buf); Dim(&packet_string, size+1);
packet_string[size] = 0; // null terminate so can be printed
printf("%s : %d bytes received\xa", &packet_string, size);
if (size == 0) return 0;
if (packet[0] == 'q') // simulation exit
{
ResetLeds();
}
else if (packet[0] == 'm')
{
// read the aircraft type
// TODO for future expansion of other aircraft and throttle controllers
}
else if (packet[0] == 'u') // update status of lamps
{
SetLedStatus( packet[1] - '0',
packet[2] - '0',
packet[3] - '0',
packet[4] - '0',
packet[5] - '0',
packet[6] - '0',
packet[7] - '0',
packet[8] - '0',
packet[9] - '0',
packet[10] - '0' );
}
}
int ResetLeds()
{
// initially set LED brightness
SetLED(&Throttle, 1, 255); // 1 = LED_INTENSITY_MODE, 255 = full on
SetLED(&Throttle, LED_GEAR_NOSE, LED_STATE_OFF);
SetLED(&Throttle, LED_GEAR_LEFT, LED_STATE_OFF);
SetLED(&Throttle, LED_GEAR_RIGHT, LED_STATE_OFF);
SetLED(&Throttle, LED_GEAR_WARNING, LED_STATE_OFF);
}
int SetLedStatus
(
byte gear_nose_status,
byte gear_left_status,
byte gear_right_status,
byte gear_warning_status,
byte rwr_search_status,
byte rwr_activity_status,
byte rwr_a_power_status,
byte rwr_alt_low_status,
byte rwr_alt_status,
byte rwr_system_power_status
)
{
SetLED(&Throttle, LED_GEAR_NOSE, gear_nose_status);
SetLED(&Throttle, LED_GEAR_LEFT, gear_left_status);
SetLED(&Throttle, LED_GEAR_RIGHT, gear_right_status);
SetLED(&Throttle, LED_GEAR_WARNING, gear_warning_status);
}
int flash_led = 0;
int SetLED(alias dev, int led_index, int value)
{
int i;
int mode;
int switch_led;
if (value == 0) {
switch_led = LED_CURRENT-led_index;
mode = 0;
} else if (value == 1) {
switch_led = LED_CURRENT+led_index;
mode = 0;
} else if (value == 255) {
// 255 == set brightness for all leds
switch_led = value;
mode = 1;
}
i = 0; while (i<3)
{
ActKey(PULSE+KEYON+LED( &dev, mode, switch_led ));
i = i+1;
}
}