aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDimitri Sokolyuk <demon@dim13.org>2011-11-14 10:54:16 +0000
committerDimitri Sokolyuk <demon@dim13.org>2011-11-14 10:54:16 +0000
commit8627c34c0d7340df7b313ac87a14436d045b1d3f (patch)
tree4e34321293873462827a04e0a5580b942446d6d4
parent761cfcacd7cacbe1e290e8422ae99bc51398954d (diff)
fix off time bug
-rw-r--r--kernel/rgb.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/kernel/rgb.c b/kernel/rgb.c
index 87b1772..e5a6c90 100644
--- a/kernel/rgb.c
+++ b/kernel/rgb.c
@@ -52,6 +52,7 @@ pwm(void *arg)
{
struct pwmarg *a = (struct pwmarg *)arg;
uint32_t on, off;
+ uint8_t v;
DDRB |= _BV(a->pin);
PORTB &= ~_BV(a->pin);
@@ -62,17 +63,15 @@ pwm(void *arg)
for (;;) {
cli();
- on = SEC0(*a->value) / UINT8_MAX;
+ v = *a->value;
sei();
- if (on) {
+ if ((on = SEC2(v) / UINT8_MAX)) {
PORTB |= _BV(a->pin);
update(on, DL);
}
- off = SEC0(UINT8_MAX - on) / UINT8_MAX;
-
- if (off) {
+ if ((off = SEC2(UINT8_MAX - v) / UINT8_MAX)) {
PORTB &= ~_BV(a->pin);
update(off, DL);
}