slim down timer
This commit is contained in:
parent
db9413e118
commit
8c9020eec2
12
c/timer.c
12
c/timer.c
|
@ -32,12 +32,12 @@ struct settings {
|
||||||
.s = 0
|
.s = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
void timerdec(struct timer *t) { if (t->s != 0) t->s--; }
|
void timerdec(struct timer *t) { if (t->s) t->s--; }
|
||||||
void timerinc(struct timer *t) { t->s++; }
|
void timerinc(struct timer *t) { t->s++; }
|
||||||
void timerupdate(struct timer *t) { if(t->u != NULL) t->u(t); }
|
void timerupdate(struct timer *t) { if(t->u) t->u(t); }
|
||||||
|
|
||||||
int timerstate(int (*f)(struct timer *t), struct timer *t) {
|
int timerstate(int (*f)(struct timer *t), struct timer *t) {
|
||||||
if(f != NULL) {
|
if(f) {
|
||||||
if(f(t)) return 1;
|
if(f(t)) return 1;
|
||||||
else return 0;
|
else return 0;
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ int timerstop(struct timer *t) { return timerstate(t->c, t); }
|
||||||
int timerpause(struct timer *t) { return timerstate(t->p, t); }
|
int timerpause(struct timer *t) { return timerstate(t->p, t); }
|
||||||
|
|
||||||
int timerzero(struct timer *t) {
|
int timerzero(struct timer *t) {
|
||||||
if(t->s == 0) return 1;
|
if(!t->s) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,13 +68,13 @@ struct timer *timerinit(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int timerissettings(struct timer *t) {
|
int timerissettings(struct timer *t) {
|
||||||
if(t->s == 0) return 0;
|
if(!t->s) return 0;
|
||||||
if(s.s == t->s) return 1;
|
if(s.s == t->s) return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tomatotimer(struct timer *t) {
|
int tomatotimer(struct timer *t) {
|
||||||
if(t->s != 0) return 0;
|
if(t->s) return 0;
|
||||||
if(t->d % 2) t->s = s.s / 2;
|
if(t->d % 2) t->s = s.s / 2;
|
||||||
else t->s = s.s;
|
else t->s = s.s;
|
||||||
t->d++;
|
t->d++;
|
||||||
|
|
Loading…
Reference in New Issue