Mega guide to converting your old scripts for Titan Two
Re: Mega guide to converting your old scripts for Titan Two
pablogroup wrote:FCB77 wrote:maybe you didnt define NOT_USE
- Code: Select all
#define NOT_USE 0;
This didn't work but the following code did! Thanks for the suggestion, it lead me in the right direction.
- Code: Select all
fix32 NOT_USE;
i just checked and i see the problem
if you use a ";" and the end of the define sentence, the compiler will throw an error
- Code: Select all
#define NOT_USE 0; //<--- error extra ";"
sensitivity(STICK_1_X, (fix32)NOT_USE, (fix32)0); //error
but if you remove the ";" from #define it will compile just fine.
- Code: Select all
#define NOT_USE 0
sensitivity(STICK_1_X, (fix32)NOT_USE, (fix32)0);
-
FCB77 - Command Sergeant Major
- Posts: 138
- Joined: Sun Feb 01, 2015 9:21 am
Re: Mega guide to converting your old scripts for Titan Two
Ah ok old habits die hard. I'm so used to GPC1.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
UK_Wildcats_Fans wrote:J2Kbr wrote:paname wrote:I prefer to keep a simple main {} with various function call but I noticed that in void functions() if i don't put a final 'return' statement at the end of each function , they behave oddly and the script may "freeze" randomly with cpu at 10% on the monitor instead of the usual 2/3% and if some combo was running it keep running..
EDIT: i traced the exact behaviour to my script starting working normally at 2/3% CPU then raising slowly even if i'm doing nothing and then "freeze" at 10% for that particular slot (test and debug or 1/2/3), other slot aren't unaffected , if i switch back to "freeze" slot and come back script is still freezed. it is as if some loop might be building up cpu usage..
I published the offending script causing this for debug purpose. (v1.05)
You possible found a bug. I have never experienced this because I always use return, even if the function returns void. Thanks for publishing the script. I will be debuging this after get back to my office (sept 20th).
EDIT: I added this bug to the GitHub issues tracker:
https://github.com/J2Kbr/GtunerIV/issues/2
For now, should we include a "return;" at the end of each function? See the below example.
- Code: Select all
void ColorLED(char Color) {
fix32 Color1, Color2, Color3, Color4;
int Blink;
Blink = 0; //mS
if(Color == 'B'){Color1 = LED_Intensity; Color2 = 0.0; Color3 = 0.0; Color4 = 0.0;}
if(Color == 'R'){Color1 = 0.0; Color2 = LED_Intensity; Color3 = 0.0; Color4 = 0.0;}
if(Color == 'G'){Color1 = 0.0; Color2 = 0.0; Color3 = LED_Intensity; Color4 = 0.0;}
if(Color == 'P'){Color1 = 0.0; Color2 = 0.0; Color3 = 0.0; Color4 = LED_Intensity;}
if(Color == 'C'){Color1 = LED_Intensity; Color2 = 0.0; Color3 = LED_Intensity; Color4 = 0.0;}
if(Color == 'Y'){Color1 = 0.0; Color2 = LED_Intensity; Color3 = LED_Intensity; Color4 = 0.0;}
if(Color == 'W'){Color1 = LED_Intensity; Color2 = LED_Intensity; Color3 = LED_Intensity; Color4 = LED_Intensity;}
led_set(LED_1,Color1,Blink);
led_set(LED_2,Color2,Blink);
led_set(LED_3,Color3,Blink);
led_set(LED_4,Color4,Blink);
return;
}
Alright, after some investigation on this issue it turned out that what is causing the non-responsiveness of the controller is not the lack of 'return', but the indiscriminately call of 'led_set', which generates a flood of reports to send to controller, compromising the ability of the controller to operate normally.
'led_set', as well as 'ffb_set', should only be called when there is actual change, not at every interaction of 'main' routine. The Titan Two VM runs in "free" mode, meaning the 'main' routine is called whenever is possible, which is many times per millisecond, if led_led is called every time it will generate a huge amount of data to send to the controller.
I suggest change the code to only call 'set_led' when it is required update the leds status.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Mega guide to converting your old scripts for Titan Two
That does explain a lot. I've had to refactor code a few times due to things freezing after a while. I had a feeling it was due to the nature of hitting it to often, but have always been able to move it, as suggested, to a spot where it was only called when necessary rather than every time. It didn't seem to be a bug as this is common in any application development. Thanks for confirming that I was on the right track!
-
The_Rabid_Taco - Major
- Posts: 1066
- Joined: Wed Mar 16, 2016 6:04 pm
- Location: Pensacola, FL
Re: Mega guide to converting your old scripts for Titan Two
Does anyone know the equivalent to the get_console() and get_controller() commands on the Titan Two? Any help is appreciated.
-
MaxRat08 - Sergeant Major
- Posts: 71
- Joined: Thu Jan 07, 2016 9:18 pm
Re: Mega guide to converting your old scripts for Titan Two
the controller/console info can be retried using the function port_status. I will publish an example showing how to use it.
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Mega guide to converting your old scripts for Titan Two
Is it possible to create user defined functions with the titan 2?
-
ytt42 - Private First Class
- Posts: 3
- Joined: Thu Aug 03, 2017 1:15 am
Re: Mega guide to converting your old scripts for Titan Two
ytt42 wrote:Is it possible to create user defined functions with the titan 2?
Yup but the format is slightly different. Check out a few code samples in the Online Resources section.
Setup: XIM Apex, T2, K780 keyboard, G Pro Wireless mouse, SteelSeries 4HD pad, DXRacer armrest, LucidSound LS30 headset, Netduma router, Ubiquiti UniFi AP LR
My R6 script: https://youtu.be/x-9NtxyySVM
My R6 script: https://youtu.be/x-9NtxyySVM
-
pablosscripts - Brigadier General
- Posts: 1976
- Joined: Tue Nov 24, 2015 6:27 am
Re: Mega guide to converting your old scripts for Titan Two
Any plans to make a CMD or a program that converts T1 gpc TO T2 gpc and vise versa ?
-
Kdtrey5 - Sergeant
- Posts: 6
- Joined: Sat Oct 21, 2017 10:11 pm
Re: Mega guide to converting your old scripts for Titan Two
Kdtrey5 wrote:Any plans to make a CMD or a program that converts T1 gpc TO T2 gpc and vise versa ?
Here look at this topic:
viewtopic.php?f=27&t=6515
You'll be able to quick and easy convert T1 to T2 but not T2 to T1..
- bonefisher
- Lieutenant General
- Posts: 5413
- Joined: Thu Jan 29, 2015 10:49 am
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 108 guests