Dolda2000 GitWeb
/
kokare.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
c773276
)
Cycle the display from the Timer2 interrupt.
author
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 2 Jul 2007 21:24:50 +0000
(21:24 +0000)
committer
Fredrik Tolf
<fredrik@dolda2000.com>
Mon, 2 Jul 2007 21:24:50 +0000
(21:24 +0000)
kokare.c
patch
|
blob
|
blame
|
history
diff --git
a/kokare.c
b/kokare.c
index
35e5a01
..
131015d
100644
(file)
--- a/
kokare.c
+++ b/
kokare.c
@@
-31,7
+31,6
@@
uint8_t font[16] = {
SEGA | SEGE | SEGF | SEGG,
};
/* LED */
SEGA | SEGE | SEGF | SEGG,
};
/* LED */
-#define LCDELAY 1000
uint8_t dsp[2] = {0, 0};
char leda = 0;
char ledc = 0;
uint8_t dsp[2] = {0, 0};
char leda = 0;
char ledc = 0;
@@
-67,8
+66,9
@@
volatile char trdelay = 0;
void init(void)
{
/* Timer init
void init(void)
{
/* Timer init
- * Timer 0 cycles t
iming sensitive subsystems
+ * Timer 0 cycles t
he Triac
* Timer 1 is used for global timing
* Timer 1 is used for global timing
+ * Timer 2 cycles the LED display
*/
OCR0A = 100;
TCCR0A = 2;
*/
OCR0A = 100;
TCCR0A = 2;
@@
-77,6
+77,10
@@
void init(void)
TCCR1A = 0;
TCCR1B = 1;
TIMSK1 = 1;
TCCR1A = 0;
TCCR1B = 1;
TIMSK1 = 1;
+ OCR2A = 16;
+ TCCR2A = 2;
+ TCCR2B = 4;
+ TIMSK2 = 2;
/*
* B0..2 = Pulse sensor
/*
* B0..2 = Pulse sensor
@@
-151,33
+155,27
@@
unsigned long getticks(void)
void ledcycle(void)
{
void ledcycle(void)
{
- static uint16_t last = 0;
uint8_t c, d, v;
uint8_t c, d, v;
- if(TCNT1 - last > LCDELAY) {
- last = TCNT1;
- if(++leda >= 8) {
- leda = 0;
- if(++ledc >= 2)
- ledc = 0;
- }
- if(dsp[ledc] & (1 << leda)) {
- if(leda < 6) {
- c = 1 << leda;
- d = 0;
- } else {
- c = 0;
- d = 0x10 << (leda - 6);
- }
- d |= ledc?0x40:0x80;
+ if(++leda >= 8) {
+ leda = 0;
+ if(++ledc >= 2)
+ ledc = 0;
+ }
+ if(dsp[ledc] & (1 << leda)) {
+ if(leda < 6) {
+ c = 1 << leda;
+ d = 0;
} else {
} else {
- c = d = 0;
+ c = 0;
+ d = 0x10 << (leda - 6);
}
}
- cli();
- PORTC = c;
- PORTD = (PORTD & 0x0f) | d;
- sei();
+ d |= ledc?0x40:0x80;
+ } else {
+ c = d = 0;
}
}
+ PORTC = c;
+ PORTD = (PORTD & 0x0f) | d;
}
void tempcycle(void)
}
void tempcycle(void)
@@
-268,7
+266,6
@@
int main(void)
while(1) {
mnow = getticks();
while(1) {
mnow = getticks();
- ledcycle();
tempcycle();
calcavg();
convcycle();
tempcycle();
calcavg();
convcycle();
@@
-453,6
+450,11
@@
ISR(SIG_OUTPUT_COMPARE0A)
}
}
}
}
+ISR(SIG_OUTPUT_COMPARE2A)
+{
+ ledcycle();
+}
+
ISR(SIG_OVERFLOW1)
{
of = 1;
ISR(SIG_OVERFLOW1)
{
of = 1;