Button(s) hold time / average
2 posts
• Page 1 of 1
Button(s) hold time / average
Single button hold time (button_5);
Button 1-21 hold time;
Button average hold time based on 10 presses (Dont@Me);
- Code: Select all
main {
if(event_release(BUTTON_5)) {
printf("Held for %.2f secs",(fix32)time_active(BUTTON_5)/1000.0);
}
}
Button 1-21 hold time;
- Code: Select all
main {
int8 i = 0;
do {
if(event_release(i)) {
printf("BUTTON_%i held for %.3f Secs", i+1, (fix32)time_active(i)/1000f);
}
}
while(++i!=STICK_1_X);
}
Button average hold time based on 10 presses (Dont@Me);
- Code: Select all
uint16 io_time_actives[210];
uint8 io_release[20];
uint32 sum;
main {
int8 i = 0;
do {
if(event_release(i)) {
++io_release[i] %= 10;
io_time_actives[(i*10)+io_release[i]] = time_active(i);
if(!io_release[i]){
int8 n = 0;
do{
sum += io_time_actives[(i*10)+n];
}while(++n<10);
printf("BUTTON_%d average hold time: %.3f secs", i-1, (fix32)(sum/10)/1000f);
}
}
}while(++i!=BUTTON_21);
}
ConsoleTuner Support Team || ConsoleTuner Discord || InputSense Discord
- Mad
- Major General
- Posts: 4536
- Joined: Wed May 22, 2019 5:39 am
2 posts
• Page 1 of 1
Return to GPC2 Script Programming
Who is online
Users browsing this forum: Google [Bot] and 88 guests