ColorLED.gph : Control the LED of your Controller / T2
5 posts
• Page 1 of 1
ColorLED.gph : Control the LED of your Controller / T2
This code adds the function "ColorLED ( Color, BlinkOnTime, BlinkOffTime, BlinkCount, PostColor )"
to control the LED of your Controller / Titan Two.
Usage:
Download the Headerfile "ColorLED.gph" from the Online Resource.
Place this file into the same directory where your script file is.
Add this line to your script:
! Do not call this function on every interaction of main !
Only call it when you want to change the LED.
If you understand this you will have no trouble with the led, rumble or segment display control functions.
Correct:
Correct too:
Wrong:
Wrong too:
The color names / numbers:
Example function calls:
Blink in Color Green 200ms on / 200ms off, 2 times and reset the LED :
Blink in Color Purple 100ms on / 100ms off, 4 times and set the LED to Green :
Permanent Color Red:
to control the LED of your Controller / Titan Two.
Usage:
Download the Headerfile "ColorLED.gph" from the Online Resource.
Place this file into the same directory where your script file is.
Add this line to your script:
- Code: Select all
#include "ColorLED.gph"
! Do not call this function on every interaction of main !
Only call it when you want to change the LED.
If you understand this you will have no trouble with the led, rumble or segment display control functions.
Correct:
- Code: Select all
bool Toggle=FALSE;
main {
if (event_active(BUTTON_10)) ColorLED(CB,100,100,4); // blink 4x Blue, each with 100ms ON and 100ms OFF, after blinking it calls led_reset();
if (event_active(BUTTON_11)) { // toggle state change, this will only be run once on every change of the toggle state
Toggle=!Toggle;
if (Toggle) ColorLED(CG,200,200,2,CB); // blink 2x Green, each with 200ms ON and 200ms OFF, after blinking set it to Blue
else ColorLED(CR,200,200,2,CB); // blink 2x Green, each with 200ms ON and 200ms OFF, after blinking set it to Blue
}
if (Toggle) {
// put here the real code that should be run as long as the toggle is active
}
}
Correct too:
- Code: Select all
main {
if (event_active(BUTTON_5)) ColorLED(CR); // sets the color to red permanent/not blinking
}
Wrong:
- Code: Select all
bool Toggle=FALSE;
main {
// this part is still correct
if (event_active(BUTTON_10)) ColorLED(CB,100,100,4); // blink 4x Blue, each with 100ms ON and 100ms OFF, after blinking it calls led_reset();
if (event_active(BUTTON_11)) Toggle=!Toggle;
// this is where the bad things happen, ColorLED will be run all the time
if (Toggle) {
ColorLED(CG,200,200,2,CB); // WRONG: while TOGGLE is TRUE it will run the ColorLED function over and over again,
// crashing the T2 or resulting in disconnects of your controller
// put here the real code that should be run when the toggle is active
} else {
ColorLED(CR,200,200,2,CB); // WRONG: while TOGGLE is FALSE it will run the ColorLED function over and over again,
// crashing the T2 or resulting in disconnects of your controller
}
}
Wrong too:
- Code: Select all
main {
// bad, issue: sets the color to red permanent/not blinking each ms or faster as long as the button is pressed.
if (get_val(BUTTON_5)) ColorLED(CR);
}
The color names / numbers:
- Code: Select all
CB 1 // blue
CR 5 // red
CG 9 // green
CP 13 // purple
CC 17 // cyan
CA 21 // amber
CW 25 // white
Example function calls:
Blink in Color Green 200ms on / 200ms off, 2 times and reset the LED :
- Code: Select all
ColorLED(CG,200,200,2);
Blink in Color Purple 100ms on / 100ms off, 4 times and set the LED to Green :
- Code: Select all
ColorLED(CP,100,100,4,CG);
Permanent Color Red:
- Code: Select all
ColorLED(CR);
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: ColorLED.gph : Control the LED of your Controller / T2
@J2Kbr - From a while back I thought that you were going to add the ColorLED function as a standard.
-
UK_Wildcats - Brigadier General
- Posts: 2243
- Joined: Thu Jan 08, 2015 6:53 pm
Re: ColorLED.gph : Control the LED of your Controller / T2
I noticed that you updated the published file. What changes did you make?
-
UK_Wildcats - Brigadier General
- Posts: 2243
- Joined: Thu Jan 08, 2015 6:53 pm
Re: ColorLED.gph : Control the LED of your Controller / T2
UK_Wildcats_Fans wrote:I noticed that you updated the published file. What changes did you make?
I have removed the tags (renamed them for now) for the online resource information from my header files. It was overwriting the information of user script in some cases.
I hope j2kbr will add some tags for use in gph files that aren't getting parsed when submitting a script that uses a header file with online resource tags. https://github.com/J2Kbr/GtunerIV/issues/285
I prefer to have the information stored in my files instead of having to type them in the publish wizzard. This allows me to see my information without having to press the publish button first for files I have already submitted to the online resource.
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: ColorLED.gph : Control the LED of your Controller / T2
Are there any updates to this pack with the changes in the game? using XB1 controller
-
rc419 - Sergeant Major
- Posts: 95
- Joined: Thu Jun 28, 2018 6:04 pm
5 posts
• Page 1 of 1
Return to User's Script Documentation
Who is online
Users browsing this forum: No registered users and 67 guests