ColorLED.gph : Control the LED of your Controller / T2

Documentation, usage tips and configuration guides for Titan Two scripts and bytecodes published by the community users.

ColorLED.gph : Control the LED of your Controller / T2

Postby Scachi » Mon Dec 03, 2018 5:47 pm

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:
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);
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: ColorLED.gph : Control the LED of your Controller / T2

Postby UK_Wildcats » Thu Dec 06, 2018 9:52 pm

@J2Kbr - From a while back I thought that you were going to add the ColorLED function as a standard.
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: ColorLED.gph : Control the LED of your Controller / T2

Postby UK_Wildcats » Fri Aug 16, 2019 8:38 pm

I noticed that you updated the published file. What changes did you make?
User avatar
UK_Wildcats
Brigadier General
Brigadier General
 
Posts: 2243
Joined: Thu Jan 08, 2015 6:53 pm

Re: ColorLED.gph : Control the LED of your Controller / T2

Postby Scachi » Fri Aug 16, 2019 8:47 pm

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.
User avatar
Scachi
Brigadier General
Brigadier General
 
Posts: 3044
Joined: Wed May 11, 2016 6:25 am
Location: Germany

Re: ColorLED.gph : Control the LED of your Controller / T2

Postby rc419 » Wed Oct 02, 2019 8:12 pm

Are there any updates to this pack with the changes in the game? using XB1 controller
User avatar
rc419
Sergeant Major
Sergeant Major
 
Posts: 95
Joined: Thu Jun 28, 2018 6:04 pm


Return to User's Script Documentation

Who is online

Users browsing this forum: No registered users and 40 guests