|
|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
#include "main.h"
|
|
|
|
|
|
|
|
|
|
#define SOFTTIMERNUMS 4
|
|
|
|
|
volatile uint16_t timer1_acc;
|
|
|
|
|
uint16_t softtimer_last[SOFTTIMERNUMS];
|
|
|
|
|
|
|
|
|
|
void softtimer_reset(uint8_t timernum){
|
|
|
|
|
softtimer_last[SOFTTIMERNUMS] = timer1_acc;
|
|
|
|
|
softtimer_last[timernum] = timer1_acc;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint8_t softtimer(uint8_t timernum, uint16_t interval){
|
|
|
|
|
@ -16,6 +16,7 @@ uint8_t softtimer(uint8_t timernum, uint16_t interval){
|
|
|
|
|
return(0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// SOFTTIMER( <YOUR TIMER NUM>, <YOUR INTERVAL>);
|
|
|
|
|
#define SOFTTIMER(n,a) if(softtimer((n),(a*4)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -35,6 +36,9 @@ void hardinit() {
|
|
|
|
|
|
|
|
|
|
OCR1A = 15; // contrast
|
|
|
|
|
OCR1B = 50; // brightness
|
|
|
|
|
|
|
|
|
|
// enable softtimer isr
|
|
|
|
|
TIMSK1 |= _BV(TOIE1);
|
|
|
|
|
|
|
|
|
|
// init LCD:
|
|
|
|
|
lcd_init(1);
|
|
|
|
|
@ -51,27 +55,25 @@ void softinit() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int __attribute__((noreturn)) main(void) {
|
|
|
|
|
int i=0;
|
|
|
|
|
hardinit();
|
|
|
|
|
softinit();
|
|
|
|
|
usbInit();
|
|
|
|
|
|
|
|
|
|
display_puts("Hallo, Welt!\n\n");
|
|
|
|
|
display_update();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(;;){
|
|
|
|
|
usbPoll();
|
|
|
|
|
|
|
|
|
|
SOFTTIMER(1,100){
|
|
|
|
|
updateTemperature();
|
|
|
|
|
SOFTTIMER(2,500) {
|
|
|
|
|
thermoData[0]=thermoData[0]+5;
|
|
|
|
|
thermoData[1]=thermoData[1]+15;
|
|
|
|
|
thermoData[2]=thermoData[2]+7;
|
|
|
|
|
thermoData[3]=thermoData[3]+18;
|
|
|
|
|
newThermoData = 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SOFTTIMER(1,100) {
|
|
|
|
|
updateTemperature();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
thermoData[0]=thermoData[0]+5;
|
|
|
|
|
thermoData[1]=thermoData[1]+15;
|
|
|
|
|
thermoData[2]=thermoData[2]+7;
|
|
|
|
|
thermoData[3]=thermoData[3]+18;
|
|
|
|
|
i++; if(i%200 == 0) newThermoData = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -82,16 +84,18 @@ int __attribute__((noreturn)) main(void) {
|
|
|
|
|
asm volatile ("out %1, %0\n" : "=r" (sreg_store) : "I" (_SFR_IO_ADDR(SREG)));
|
|
|
|
|
reti();
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
ISR(TIMER1_OVF_vect,ISR_NOBLOCK){
|
|
|
|
|
uint16_t temp;
|
|
|
|
|
temp=timer1_acc;
|
|
|
|
|
temp++;
|
|
|
|
|
ATOMIC_BLOCK(ATOMIC_FORCEON){
|
|
|
|
|
timer1_acc=temp;
|
|
|
|
|
}
|
|
|
|
|
uint16_t tmp;
|
|
|
|
|
tmp=timer1_acc;
|
|
|
|
|
tmp++;
|
|
|
|
|
|
|
|
|
|
/* the ATOMIC is acutally only needed if timer1_acc is never read from an ISR, which
|
|
|
|
|
* is probably the case.
|
|
|
|
|
* ATOMIC_FORCEON: the ISR_NOBLOCK sets sei() a few cycles before.
|
|
|
|
|
*/
|
|
|
|
|
}
|
|
|
|
|
ATOMIC_BLOCK(ATOMIC_FORCEON){
|
|
|
|
|
timer1_acc=tmp;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|