point of sale - how to set more than one timer in verifone vx520 -
i want set timer inputting key , 1 timer turning light off use first timer set , can't set more 1 timer , second timer didn't work.
i use code below
int timer1, timer2; long events; timer1 = set_timer(8000, evt_timer); timer2 = set_timer(5000, evt_timer); while(1){ events = wait_event(); if(events & evt_kbd){ clr_timer(timer1); break; } else if (events & evt_timer) { printf("time_out"); break; } while(1){ events = wait_event(); if(events & evt_kbd){ clr_timer(timer2); break; } else if (events & evt_timer) { printf("time_out2"); break; } }
you need use different event mask (evt_timer) if want capture them different events. tricky thing need careful use because may trigger other actions. these events defined in svc.h
(note mask long
, long
defined being 32 bits, don't have left after standard events used).
the news set_timer
returns id (that's timer1
, timer2
in code). can use svc_ticks
api determine timer has expired. wrote wrapper called "timeremains" me that.
//first, define "timeremains" char timeremains(long* timer) { return svc_ticks(0, timer); } //here's code may like: if(!timeremains(&timer1)) { //timer1 has expired. whatever wanted when happens. //note: don't know state of timer2--it may have expired, // need deal } if(!timeremains(&timer2)) { //timer2 has expired. whatever wanted when happens. //note: though pretty sure timer1 has not yet expired, // can't forget it. if going exit polling loop, // sure clear first. }
Comments
Post a Comment