GPC Developer Guides
...
Functions
Internal Functions

Device Functions

here we will cover a few functions available within your code, these functions function description get rtime returns the elapsed time between main iterations in milliseconds get slot returns the active slot number load slot loads a specified slot get ctrlbutton returns the identifier of the controller button vm tctrl sets the vm timeout for the next iteration set rgb sets the led on the zen to the supplied rgb color set hsb sets the led on the zen to the supplied hsb color get rtime get rtime returns the elapsed time between the current and previous iteration of the main function the value returned is in milliseconds you can see this function in action by using this counter script gpc int days; int hours; int minutes; int seconds; int milliseconds; main { milliseconds += get rtime(); if(milliseconds >= 1000) { // check if we have 1000 or more milliseconds passed milliseconds = 1000 // subtract 1000 from the milliseconds value, this ensures accuracy as the timing may not be precise seconds++; // increment the seconds counter } if(seconds == 60) { // check if 60 seconds has passed (1 minute) seconds = 0; // reset the seconds counter to 0 minutes++; // increment the minutes counter } if(minutes == 60) { // check if 60 minutes has passed (1 hour) minutes = 0; // reset the minutes counter to 0 hours++; // increment the hours counter } if(hours == 24) { // check if 24 hours has passed (1 day) hours = 0; // reset the hours counter to 0 days++; // increment the days counter } set val(trace 1, milliseconds); // output the milliseconds to trace 1 set val(trace 2, seconds); // output the seconds to trace 2 set val(trace 3, minutes); // output the minutes to trace 3 set val(trace 4, hours); // output the hours to trace 4 set val(trace 5, days); // output the days to trace 5 } 🔴 syntax get rtime(); ⚪ parameters none 🔵 returns the elapsed time, in milliseconds, since the last main iteration, default is 10ms but is dependant on the use of vm tctrl get slot get slot returns an int value representing the current active slot of the cronus device gpc int currentslot; init { currentslot = get slot(); } main { } 🔴 syntax get slot(); ⚪ parameters none 🔵 returns an int value represents the current active slot of the cronus device load slot load slot will attempt to load the slot number specified within its parameter if there is no script current stored in the specified slot, then it will unload the current slot and load slot 0 of the device gpc main { if(event press(xb1 rb)) // if rb / r2 is pressed load slot(5); // load slot 5 if(event press(xb1 lb)) // if lb / l2 is pressed load slot(0); // unload current slot and load slot 0 } 🔴 syntax load slot ( \<slot number> ); ⚪ parameters \<slot number> a value which represents a slot number to load with a range of 0 8 🔵 returns note any code after this statement will not be executed as the new slot is loaded immediately and any changes made by the current script will be kept during the first execution of the loaded slot get ctrlbutton get ctrlbutton returns the current control button the control button is set in the device tab of the zen studio this basically lets you know which button combo is configured to switch slots using the remote slot configuration gpc get ctrlbutton(); 🔴 syntax get ctrlbutton(); ⚪ parameters nothing 🔵 returns depending on the remote slot settings the value can be 0, 1 or 8 vm tctrl vm tctrl sets the virtual machine timeout for the next iteration by default, the virtual machine runs the main loop every 10 milliseconds as it aids stability you can however adjust how often each main iteration is run just be aware that changing this setting may cause instability within your script gpc main { vm tctrl( 5); // run the vm every 5ms } 🔴 syntax vm tctrl( \<timeout offset> ); ⚪ parameters \<timeout offset> numeric value to add to the virtual machine base time range 9 30 🔵 returns nothing set rgb set rgb sets the led colors on the zen eyes or a playstation controller based on the hue, saturation, and brightness gpc set rgb(255, 0, 0) // red set rgb(0, 255, 0)// green set rgb(0, 0, 255) // blue 🔴 syntax set rgb( \<red> , \<green> , \<blue> ); ⚪ parameters \<red> the amount of red to use with a range of 0 255 \<green> the amount of green to use with a range of 0 255 \<blue> the amount of blue to use with a range of 0 255 🔵 returns nothing set hsb set hsb sets the led colors on the zen eyes or a playstation controller based on the hue, saturation, and brightness gpc set hsb(300, 55, 70); 🔴 syntax set hsb( \<hue>, \<saturation>, \<brightness> ); ⚪ parameters \<hue> the hue (color on a 360 degree wheel) to use with a range of 0 359 \<saturation> the saturation (amount of color) to use with a range of 0 100 \<brightness> the brightness (amount of white) to use with a range of 0 100 🔵 returns nothing