Setting LED's keeps crashing my T2
12 posts
• Page 1 of 2 • 1, 2
Setting LED's keeps crashing my T2
The following keeps freezing up my T2 after just a few seconds of play. Any ideas what I've done wrong?
- Code: Select all
main {
if(rappelling_flag || AutoReloadAction) {
ColorLED('W');
}
if(!rappelling_flag && !AutoReloadAction) {
ColorLED('B');
}
}
void ColorLED(char Color) {
fix32 Color1, Color2, Color3, Color4;
if(Color == 'B'){Color1 = 100.0; Color2 = 0.00; Color3 = 0.00; Color4 = 0.00;}
if(Color == 'R'){Color1 = 0.00; Color2 = 100.0; Color3 = 0.00; Color4 = 0.00;}
if(Color == 'G'){Color1 = 0.00; Color2 = 0.00; Color3 = 100.0; Color4 = 0.00;}
if(Color == 'P'){Color1 = 0.00; Color2 = 0.00; Color3 = 0.00; Color4 = 100.0;}
if(Color == 'C'){Color1 = 100.0; Color2 = 0.00; Color3 = 100.0; Color4 = 0.00;}
if(Color == 'A'){Color1 = 0.00; Color2 = 100.0; Color3 = 100.0; Color4 = 0.00;}
if(Color == 'W'){Color1 = 100.0; Color2 = 100.0; Color3 = 100.0; Color4 = 100.0;}
led_set(LED_1, Color1, 0);
led_set(LED_2, Color2, 0);
led_set(LED_3, Color3, 0);
led_set(LED_4, Color4, 0);
return;
}
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: Setting LED's keeps crashing my T2
I think your are flooding the usb with your second statement, always sending ColorLED('B');
Maybe you should at something like a "toggle" variable that remembers the last color state and only call the ColorLED function if the value of the toggle variable has changes to only send the color once then ?
Maybe you should at something like a "toggle" variable that remembers the last color state and only call the ColorLED function if the value of the toggle variable has changes to only send the color once then ?
-
Scachi - Brigadier General
- Posts: 3044
- Joined: Wed May 11, 2016 6:25 am
- Location: Germany
Re: Setting LED's keeps crashing my T2
Scachi wrote:I think your are flooding the usb with your second statement, always sending ColorLED('B');
Maybe you should at something like a "toggle" variable that remembers the last color state and only call the ColorLED function if the value of the toggle variable has changes to only send the color once then ?
Ah yes you're right ok I'll rework the code, thank you!
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: Setting LED's keeps crashing my T2
On your suggestion I've rewritten it, hopefully this works. I'll have to test it tonight when I get home:
- Code: Select all
int led_change_flag = 0;
if(rappelling_flag || AutoReloadAction) {
ColorLED('W');
led_change_flag = 0;
}
if((!rappelling_flag && !AutoReloadAction) && led_change_flag == 0) {
ColorLED('B');
led_change_flag = 1;
}
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: Setting LED's keeps crashing my T2
Ok the code above doesn't work:( It keeps freezing. Can anyone see what I've done wrong?
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: Setting LED's keeps crashing my T2
the best solution for this is call ColorLED in the same block you change the variables rappelling_flag and AutoReloadAction;
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Setting LED's keeps crashing my T2
J2Kbr wrote:the best solution for this is call ColorLED in the same block you change the variables rappelling_flag and AutoReloadAction;
The problem isn't with setting the LED's, it's reverting it back to the original colour. Setting it is never a problem, it's the revert that freezes my T2.
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: Setting LED's keeps crashing my T2
please post your full code (or pm me), so I can try find a good way to set/reset the LED color using ColorLED .
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
Re: Setting LED's keeps crashing my T2
Thanks! I've uploaded it to online resources. See lines 896, 936, or 1240 (original attempt at this, commented out).
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: Setting LED's keeps crashing my T2
I changed the LED logic logic a little bit:
- Code: Select all
if((rappelling_flag || AutoReloadAction) && !led_change_flag) {
ColorLED('W');
led_change_flag = 1;
} else if((!rappelling_flag && !AutoReloadAction) && led_change_flag) {
ColorLED('B');
led_change_flag = 0;
}
ConsoleTuner Support Team
-
J2Kbr - General of the Army
- Posts: 20323
- Joined: Tue Mar 18, 2014 1:39 pm
12 posts
• Page 1 of 2 • 1, 2
Return to GPC2 Script Programming
Who is online
Users browsing this forum: No registered users and 177 guests