Previous Thread
Next Thread
Print Thread
Rate This Thread
Hop To
#3955204 - 05/18/14 08:31 PM LEDs on when Throttle Greater than 80%  
Joined: Nov 2004
Posts: 47
LoneStar Offline
Junior Member
LoneStar  Offline
Junior Member

Joined: Nov 2004
Posts: 47
San Antonio, Texas
Trying to get LEDs (LED0) to turn on when my throttle is at 80%. I using the script code below...

Code:
	ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0)); //set Throttle backlight power to 0

	
	KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(LIST(0, 80, 100),
									(PULSE+LED(&Throttle, LED_INTENSITY, 0)),
									(PULSE+LED(&Throttle, LED_INTENSITY, 255))));


When I start the script, the LEDs start in the ON state (255 intensity). If I move the throttle to 100% and back to 0% the LEDs turn off and then will work as programed, i.e. ON when throttle is pushed forward above 80% and OFF when throttle is pulled back below 80%.

I have switched the 0 and 255 values with the same result.

I thought the first line of the above code was supposed to initialize the LED power to level zero but it's not happening.

Can someone advise me on what I'm doing wrong?

Thanks for any help!

Inline advert (2nd and 3rd post)

#3955218 - 05/18/14 09:10 PM Re: LEDs on when Throttle Greater than 80% [Re: LoneStar]  
Joined: Nov 2004
Posts: 47
LoneStar Offline
Junior Member
LoneStar  Offline
Junior Member

Joined: Nov 2004
Posts: 47
San Antonio, Texas
Sorry, I forgot to switch the INTENSITY codes back after testing. Here's the code that needs help...

Code:
	ActKey(PULSE+KEYON+LED(&Throttle, LED_INTENSITY, 0)); //set Throttle backlight power to 0

	
	KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(LIST(0, 80, 100),
									(PULSE+LED(&Throttle, LED_INTENSITY, 255)),
									(PULSE+LED(&Throttle, LED_INTENSITY, 0))));


When the script starts, the LEDs turn on (should be off). If I push the throttle to 100% and then back to 0% the LEDs turn off. Then the LEDs will turn on when I push the throttle forward through 80% and will turn off when I pull the throttle back through 80%.

Thanks,

#3958617 - 05/27/14 08:43 AM Re: LEDs on when Throttle Greater than 80% [Re: LoneStar]  
Joined: Oct 2010
Posts: 83
Nicu Offline
Junior Member
Nicu  Offline
Junior Member

Joined: Oct 2010
Posts: 83
KeyAxis initialization generates some stray key presses, so a little delay is required to turn off the leds (I use DeferCall for this).
Also, you may not use LED_INTENSITY, which is global for all LEDSs, but use LED_ONOFF, which turn on and off each led (LED0 is the background light).

Code:
DeferCall(100, &ActKey, KEYON+LED(&Throttle, LED_ONOFF, 0)); // all LEDS off
KeyAxis(&Throttle, THR_LEFT, 0, AXMAP1(LIST(0, 80, 100),
				(PULSE+LED(&Throttle, LED_ONOFF, LED0)), // only LED0 (background) ON
				(PULSE+LED(&Throttle, LED_ONOFF, 0))));  // all LEDs off


Moderated by  RacerGT 

Quick Search
Recent Articles
Support SimHQ

If you shop on Amazon use this Amazon link to support SimHQ
.
Social


Recent Topics
Actors portraying US Presidents
by PanzerMeyer. 04/19/24 12:19 PM
Dickey Betts was 80
by Rick_Rawlings. 04/19/24 01:11 AM
Exodus
by RedOneAlpha. 04/18/24 05:46 PM
Grumman Wildcat unique landing gear
by Coot. 04/17/24 03:54 PM
Peter Higgs was 94
by Rick_Rawlings. 04/17/24 12:28 AM
Whitey Herzog was 92
by F4UDash4. 04/16/24 04:41 PM
Anyone can tell me what this is?
by NoFlyBoy. 04/16/24 04:10 PM
10 Years ago MV Sewol
by wormfood. 04/15/24 08:25 PM
Pride Of Jenni race win
by NoFlyBoy. 04/15/24 12:22 AM
Copyright 1997-2016, SimHQ Inc. All Rights Reserved.

Powered by UBB.threads™ PHP Forum Software 7.6.0