Created
February 27, 2019 10:52
-
-
Save Misaka-0x447f/92eba67f11ab4ed73b59bc14ea6c9069 to your computer and use it in GitHub Desktop.
Light ctrl script for cronus
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* * | |
* GPC SCRIPT | |
* | |
* GPC is a scripting language with C-like syntax. | |
* To learn more access https://cronusmax.com/manual/cronus_instructions.htm | |
* *********************************************************** */ | |
int current = 0; | |
init { | |
light(current); | |
} | |
main { | |
// infinity loop | |
if(get_val(PS4_UP) && event_press(PS4_TRIANGLE)) { | |
current = (current + 1) % 8; | |
light(current); | |
} | |
if (get_val(PS4_UP) && event_press(PS4_CROSS)) { | |
current = 0; | |
light(current); | |
} | |
if (get_battery() <= 4 && get_battery() >= 2) { | |
combo_run(battery_low); | |
} else if (get_battery() < 3) { | |
combo_run(battery_critical); | |
} | |
} | |
combo battery_low { | |
light(4); | |
wait(100); | |
light(current); | |
wait(5000); | |
} | |
combo battery_critical { | |
light(1); | |
set_rumble(RUMBLE_B, 80); | |
wait(200); | |
set_rumble(RUMBLE_B, 0); | |
light(current); | |
wait(5000); | |
} | |
/* | |
0 0000 Off | |
1 0001 Pink | |
2 0010 Green | |
4 0100 Red | |
6 0110 Yellow | |
8 1000 Blue | |
a 1010 SkyBlue | |
f 1111 White | |
*/ | |
function light(c) { | |
c = c % 8; | |
if (c == 0) { | |
set_led(LED_1, 0); | |
set_led(LED_2, 0); | |
set_led(LED_3, 0); | |
set_led(LED_4, 0); | |
} | |
if (c == 1) { | |
set_led(LED_1, 0); | |
set_led(LED_2, 0); | |
set_led(LED_3, 0); | |
set_led(LED_4, 3); | |
} | |
if (c == 2) { | |
set_led(LED_1, 0); | |
set_led(LED_2, 0); | |
set_led(LED_3, 3); | |
set_led(LED_4, 0); | |
} | |
if (c == 3) { | |
set_led(LED_1, 0); | |
set_led(LED_2, 3); | |
set_led(LED_3, 0); | |
set_led(LED_4, 0); | |
} | |
if (c == 4) { | |
set_led(LED_1, 0); | |
set_led(LED_2, 3); | |
set_led(LED_3, 3); | |
set_led(LED_4, 0); | |
} | |
if (c == 5) { | |
set_led(LED_1, 3); | |
set_led(LED_2, 0); | |
set_led(LED_3, 0); | |
set_led(LED_4, 0); | |
} | |
if (c == 6) { | |
set_led(LED_1, 3); | |
set_led(LED_2, 0); | |
set_led(LED_3, 3); | |
set_led(LED_4, 0); | |
} | |
if (c == 7) { | |
set_led(LED_1, 3); | |
set_led(LED_2, 3); | |
set_led(LED_3, 3); | |
set_led(LED_4, 3); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment