|
@@ -2,9 +2,6 @@
|
|
|
|
|
|
__C_task void main(void)
|
|
__C_task void main(void)
|
|
{
|
|
{
|
|
- uint8_t i;
|
|
|
|
- //uint8_t tmp8;
|
|
|
|
-
|
|
|
|
/* Disable comaparator */
|
|
/* Disable comaparator */
|
|
ACSR = 1<<ACD;
|
|
ACSR = 1<<ACD;
|
|
|
|
|
|
@@ -20,11 +17,7 @@ __C_task void main(void)
|
|
INDCTR_COMMON_DDR = INDCTR_COMMON_ALL; // common pins to output
|
|
INDCTR_COMMON_DDR = INDCTR_COMMON_ALL; // common pins to output
|
|
INDCTR_COMMON_PORT = ~INDCTR_COMMON_ALL; // off all indikators
|
|
INDCTR_COMMON_PORT = ~INDCTR_COMMON_ALL; // off all indikators
|
|
|
|
|
|
- for(i=0; i<INDCTR_NUMS; i++) {
|
|
|
|
- Display[i] = Sym_minus;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Flag.needDot = 0;
|
|
|
|
|
|
+ Flag2.needDot = 0;
|
|
|
|
|
|
/* Timer0 every 4 ms switch showing LED */
|
|
/* Timer0 every 4 ms switch showing LED */
|
|
TCCR0 = TIM0_PRESCALER;
|
|
TCCR0 = TIM0_PRESCALER;
|
|
@@ -36,6 +29,11 @@ __C_task void main(void)
|
|
// TCNT1 = 64536;
|
|
// TCNT1 = 64536;
|
|
// TIMSK |= 1<<TOIE1; // enable TIM1_OVF interrupt
|
|
// TIMSK |= 1<<TOIE1; // enable TIM1_OVF interrupt
|
|
|
|
|
|
|
|
+ /* Timer2 count 1 ms */
|
|
|
|
+ TCCR2 = TIM2_PRESCALER;
|
|
|
|
+ TCNT2 = TIM2_CNT; // load timer
|
|
|
|
+ TIMSK |= 1<<TOV2; // enable TIM2_OVF interrupt
|
|
|
|
+
|
|
/* ADC init */
|
|
/* ADC init */
|
|
resultADC = 0;
|
|
resultADC = 0;
|
|
ADMUX = (1<<REFS0) | (1<<ADLAR); // Vref = AVcc, channel ADC0, Left adjusted result
|
|
ADMUX = (1<<REFS0) | (1<<ADLAR); // Vref = AVcc, channel ADC0, Left adjusted result
|
|
@@ -46,111 +44,147 @@ __C_task void main(void)
|
|
|
|
|
|
__enable_interrupt();
|
|
__enable_interrupt();
|
|
|
|
|
|
- /* Init Scheduler and TDelay */
|
|
|
|
- RTOS_Init();
|
|
|
|
-
|
|
|
|
- // Tasks for sheduler
|
|
|
|
- RTOS_SetTask(startADC,0,50);
|
|
|
|
- RTOS_SetTask(getTime,4,500);
|
|
|
|
- RTOS_SetTask(showHHMM,8,500);
|
|
|
|
- RTOS_SetTask(ds18b20_StartMeasure,12,10000);
|
|
|
|
|
|
+ // Start tasks
|
|
|
|
+ counterADC = PERIOD_ADC; // every 50 ms start ADC measure
|
|
|
|
+ counterTWI = 4; // small delay
|
|
|
|
+ counterDS18B20s = 12; // small delay
|
|
|
|
|
|
State = show_HHMM;
|
|
State = show_HHMM;
|
|
|
|
|
|
while(1) {
|
|
while(1) {
|
|
|
|
|
|
/* check time */
|
|
/* check time */
|
|
|
|
+ if (1 == Flag.getTime) {
|
|
|
|
+ Flag.getTime = 0;
|
|
|
|
+ getTime();
|
|
|
|
+ } // end of Flag.getTime
|
|
|
|
+
|
|
if (1 == Flag.newTime) {
|
|
if (1 == Flag.newTime) {
|
|
Flag.newTime = 0;
|
|
Flag.newTime = 0;
|
|
|
|
|
|
- if (show_HHMM == State) {
|
|
|
|
|
|
+ switch (State) {
|
|
|
|
+ case show_HHMM:
|
|
// every 25 and 55 seconds shoe temperature for 5 seconds
|
|
// every 25 and 55 seconds shoe temperature for 5 seconds
|
|
if ((25 == Clock.seconds) || (55 == Clock.seconds)) {
|
|
if ((25 == Clock.seconds) || (55 == Clock.seconds)) {
|
|
- RTOS_SetTask(showHHMM,5000,500);
|
|
|
|
- RTOS_SetTask(showTEMP,0,1000);
|
|
|
|
|
|
+ State = show_TEMPt;
|
|
|
|
+ counterShowTemp = PERIOD_SHT;
|
|
|
|
+ showTEMP();
|
|
|
|
+ } else {
|
|
|
|
+ showHHMM();
|
|
}
|
|
}
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ case show_MMSS:
|
|
|
|
+ showMMSS();
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
|
|
+ } // end of Flag.newTime
|
|
|
|
+
|
|
|
|
+ /* Temperature */
|
|
|
|
+ if (1 == Flag.startDS18B20) {
|
|
|
|
+ Flag.startDS18B20 = 0;
|
|
|
|
+ ds18b20_StartMeasure();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (1 == Flag.readDS18B20) {
|
|
|
|
+ Flag.readDS18B20 = 0;
|
|
|
|
+ ds18b20_ReadTemperature();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if (1 == Flag.newTemp) {
|
|
|
|
+ Flag.newTemp = 0;
|
|
|
|
+ if ((show_TEMPt == State) || (show_TEMPp == State)) {
|
|
|
|
+ showTEMP();
|
|
|
|
+ }
|
|
|
|
+ } // end of Flag.newTemp
|
|
|
|
+
|
|
/* check buttons */
|
|
/* check buttons */
|
|
if (1 == Flag.newBTN) {
|
|
if (1 == Flag.newBTN) {
|
|
- uint8_t mm, hh;
|
|
|
|
-
|
|
|
|
Flag.newBTN = 0;
|
|
Flag.newBTN = 0;
|
|
|
|
+
|
|
|
|
+ uint8_t mm, hh;
|
|
|
|
|
|
btn_t btn = getBTN();
|
|
btn_t btn = getBTN();
|
|
switch (btn) {
|
|
switch (btn) {
|
|
case btn_1:
|
|
case btn_1:
|
|
// show HH:MM
|
|
// show HH:MM
|
|
State = show_HHMM;
|
|
State = show_HHMM;
|
|
- RTOS_SetTask(showTEMP,0,0);
|
|
|
|
- RTOS_SetTask(showMMSS,0,0);
|
|
|
|
- RTOS_SetTask(showHHMM,0,500);
|
|
|
|
|
|
+ counterShowTemp = 0;
|
|
|
|
+ showHHMM();
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_2:
|
|
case btn_2:
|
|
// show MM SS
|
|
// show MM SS
|
|
State = show_MMSS;
|
|
State = show_MMSS;
|
|
- Flag.needDot = 0;
|
|
|
|
- RTOS_SetTask(showHHMM,0,0);
|
|
|
|
- RTOS_SetTask(showTEMP,0,0);
|
|
|
|
- RTOS_SetTask(showMMSS,0,500);
|
|
|
|
|
|
+ Flag2.needDot = 1;
|
|
|
|
+ counterShowTemp = 0;
|
|
|
|
+ showMMSS();
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_3:
|
|
case btn_3:
|
|
// show temperature
|
|
// show temperature
|
|
- State = show_TEMP;
|
|
|
|
- Flag.needDot = 0;
|
|
|
|
- RTOS_SetTask(showMMSS,0,0);
|
|
|
|
- RTOS_SetTask(showHHMM,0,0);
|
|
|
|
- RTOS_SetTask(showTEMP,0,1000);
|
|
|
|
|
|
+ State = show_TEMPp;
|
|
|
|
+ Flag2.needDot = 0;
|
|
|
|
+ counterShowTemp = 0;
|
|
|
|
+ showTEMP();
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_4:
|
|
case btn_4:
|
|
// time --
|
|
// time --
|
|
- mm = bcd2bin(Clock.minutes);
|
|
|
|
- hh = bcd2bin(Clock.hours);
|
|
|
|
- if (mm > 0) {
|
|
|
|
- mm --;
|
|
|
|
- } else {
|
|
|
|
- mm = 59;
|
|
|
|
- if (hh > 0) {
|
|
|
|
- hh --;
|
|
|
|
|
|
+ if (Flag.setTime == 1) {
|
|
|
|
+ mm = bcd2bin(Clock.minutes);
|
|
|
|
+ hh = bcd2bin(Clock.hours);
|
|
|
|
+ if (mm > 0) {
|
|
|
|
+ mm --;
|
|
} else {
|
|
} else {
|
|
- hh = 23;
|
|
|
|
|
|
+ mm = 59;
|
|
|
|
+ if (hh > 0) {
|
|
|
|
+ hh --;
|
|
|
|
+ } else {
|
|
|
|
+ hh = 23;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ Clock.minutes = bin2bcd(mm);
|
|
|
|
+ Clock.hours = bin2bcd(hh);
|
|
}
|
|
}
|
|
- Clock.minutes = bin2bcd(mm);
|
|
|
|
- Clock.hours = bin2bcd(hh);
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_5:
|
|
case btn_5:
|
|
// time ++
|
|
// time ++
|
|
- mm = bcd2bin(Clock.minutes);
|
|
|
|
- hh = bcd2bin(Clock.hours);
|
|
|
|
- mm ++;
|
|
|
|
- if (mm > 59) {
|
|
|
|
- mm = 0;
|
|
|
|
- hh ++;
|
|
|
|
- if (hh > 23) {
|
|
|
|
- hh = 0;
|
|
|
|
|
|
+ if (Flag.setTime == 1) {
|
|
|
|
+ mm = bcd2bin(Clock.minutes);
|
|
|
|
+ hh = bcd2bin(Clock.hours);
|
|
|
|
+ mm ++;
|
|
|
|
+ if (mm > 59) {
|
|
|
|
+ mm = 0;
|
|
|
|
+ hh ++;
|
|
|
|
+ if (hh > 23) {
|
|
|
|
+ hh = 0;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
+ Clock.minutes = bin2bcd(mm);
|
|
|
|
+ Clock.hours = bin2bcd(hh);
|
|
}
|
|
}
|
|
- Clock.minutes = bin2bcd(mm);
|
|
|
|
- Clock.hours = bin2bcd(hh);
|
|
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_6:
|
|
case btn_6:
|
|
// save new time
|
|
// save new time
|
|
- Flag.blankIndktr = 0;
|
|
|
|
- setTime();
|
|
|
|
- RTOS_SetTask(getTime,4,500);
|
|
|
|
|
|
+ if (Flag.setTime == 1) {
|
|
|
|
+ Flag.setTime = 0;
|
|
|
|
+ Flag2.blankIndktr = 0;
|
|
|
|
+ setTime();
|
|
|
|
+ counterTWI = PERIOD_TWI;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
|
|
|
|
case btn_7:
|
|
case btn_7:
|
|
// time set
|
|
// time set
|
|
- Flag.blankIndktr = 1;
|
|
|
|
- RTOS_SetTask(getTime,0,0);
|
|
|
|
|
|
+ Flag.setTime = 1;
|
|
|
|
+ Flag2.blankIndktr = 1;
|
|
|
|
+ counterTWI = 0;
|
|
break;
|
|
break;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -159,8 +193,12 @@ __C_task void main(void)
|
|
|
|
|
|
} // end of new BTN
|
|
} // end of new BTN
|
|
|
|
|
|
- tdelay_ms(10); // sleep and rotate dispatcher
|
|
|
|
|
|
+ // делать нехрен -- спим, ждём прерывание
|
|
|
|
+ MCUCR = 1<<SE;
|
|
|
|
+ __sleep();
|
|
|
|
+
|
|
} // end of while(1)
|
|
} // end of while(1)
|
|
|
|
+
|
|
} // end of main()
|
|
} // end of main()
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -176,42 +214,37 @@ static uint8_t bin2bcd(uint8_t bin) {
|
|
|
|
|
|
static void showHHMM(void) {
|
|
static void showHHMM(void) {
|
|
State = show_HHMM;
|
|
State = show_HHMM;
|
|
- Display[0] = IndctrNums[(0x0F & (Clock.hours>>4))];
|
|
|
|
- Display[1] = IndctrNums[(0x0F & Clock.hours)];
|
|
|
|
- Display[2] = IndctrNums[(0x0F & (Clock.minutes>>4))];
|
|
|
|
- Display[3] = IndctrNums[(0x0F & Clock.minutes)];
|
|
|
|
|
|
+ Indicator1 = IndctrNums[(0x0F & (Clock.hours>>4))];
|
|
|
|
+ Indicator2 = IndctrNums[(0x0F & Clock.hours)];
|
|
|
|
+ Indicator3 = IndctrNums[(0x0F & (Clock.minutes>>4))];
|
|
|
|
+ Indicator4 = IndctrNums[(0x0F & Clock.minutes)];
|
|
}
|
|
}
|
|
|
|
|
|
static void showMMSS(void) {
|
|
static void showMMSS(void) {
|
|
- Display[0] = IndctrNums[(0x0F & (Clock.minutes>>4))];
|
|
|
|
- Display[1] = IndctrNums[(0x0F & Clock.minutes)];
|
|
|
|
- Display[2] = IndctrNums[(0x0F & (Clock.seconds>>4))];
|
|
|
|
- Display[3] = IndctrNums[(0x0F & Clock.seconds)];
|
|
|
|
|
|
+ Indicator1 = IndctrNums[(0x0F & (Clock.minutes>>4))];
|
|
|
|
+ Indicator2 = IndctrNums[(0x0F & Clock.minutes)];
|
|
|
|
+ Indicator3 = IndctrNums[(0x0F & (Clock.seconds>>4))];
|
|
|
|
+ Indicator4 = IndctrNums[(0x0F & Clock.seconds)];
|
|
}
|
|
}
|
|
|
|
|
|
static void showTEMP(void) {
|
|
static void showTEMP(void) {
|
|
int8_t t = Temperature;
|
|
int8_t t = Temperature;
|
|
|
|
|
|
if (t < 0) {
|
|
if (t < 0) {
|
|
- Display[0] = Sym_minus;
|
|
|
|
|
|
+ Indicator1 = Sym_minus;
|
|
t = -t;
|
|
t = -t;
|
|
} else {
|
|
} else {
|
|
- Display[0] = Sym_blank;
|
|
|
|
|
|
+ Indicator1 = Sym_blank;
|
|
}
|
|
}
|
|
|
|
|
|
// convert to BCD
|
|
// convert to BCD
|
|
t = bin2bcd(t);
|
|
t = bin2bcd(t);
|
|
|
|
|
|
- Display[1] = IndctrNums[(0x0F & (t>>4))];
|
|
|
|
- Display[2] = IndctrNums[(0x0F & t)];
|
|
|
|
- Display[3] = Sym_gradus;
|
|
|
|
|
|
+ Indicator2 = IndctrNums[(0x0F & (t>>4))];
|
|
|
|
+ Indicator3 = IndctrNums[(0x0F & t)];
|
|
|
|
+ Indicator4 = Sym_gradus;
|
|
|
|
|
|
- Flag.needDot = 0;
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-static void startADC(void) {
|
|
|
|
- // enable interrupt and start conversion
|
|
|
|
- ADCSR |= ((1<<ADSC) | (1<<ADIE));
|
|
|
|
|
|
+ Flag2.needDot = 0;
|
|
}
|
|
}
|
|
|
|
|
|
static btn_t getBTN(void) {
|
|
static btn_t getBTN(void) {
|
|
@@ -239,8 +272,8 @@ static void getTime(void) {
|
|
static uint8_t old_sec;
|
|
static uint8_t old_sec;
|
|
|
|
|
|
/* Sync with indicators */
|
|
/* Sync with indicators */
|
|
- Flag.waitIndktr = 1;
|
|
|
|
- while (Flag.waitIndktr == 1);
|
|
|
|
|
|
+ Flag2.waitIndktr = 1;
|
|
|
|
+ while (Flag2.waitIndktr == 1);
|
|
|
|
|
|
/*устанавливаем указатель DS1307 на нулевой адрес*/
|
|
/*устанавливаем указатель DS1307 на нулевой адрес*/
|
|
twi_buf[0] = (DS1307_ADR<<1)|0; //адресный пакет
|
|
twi_buf[0] = (DS1307_ADR<<1)|0; //адресный пакет
|
|
@@ -260,9 +293,9 @@ static void getTime(void) {
|
|
|
|
|
|
if (show_HHMM == State) {
|
|
if (show_HHMM == State) {
|
|
if (old_sec != Clock.seconds) {
|
|
if (old_sec != Clock.seconds) {
|
|
- Flag.needDot = 1;
|
|
|
|
|
|
+ Flag2.needDot = 1;
|
|
} else {
|
|
} else {
|
|
- Flag.needDot = 0;
|
|
|
|
|
|
+ Flag2.needDot = 0;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -272,8 +305,8 @@ static void getTime(void) {
|
|
|
|
|
|
static void setTime(void) {
|
|
static void setTime(void) {
|
|
/* Sync with indicators */
|
|
/* Sync with indicators */
|
|
- Flag.waitIndktr = 1;
|
|
|
|
- while (Flag.waitIndktr == 1);
|
|
|
|
|
|
+ Flag2.waitIndktr = 1;
|
|
|
|
+ while (Flag2.waitIndktr == 1);
|
|
|
|
|
|
/* prepare new time */
|
|
/* prepare new time */
|
|
twi_buf[0] = (DS1307_ADR<<1)|0; //адресный пакет
|
|
twi_buf[0] = (DS1307_ADR<<1)|0; //адресный пакет
|
|
@@ -296,14 +329,14 @@ static uint8_t ds18b20_Reset(void) {
|
|
|
|
|
|
//ds18b20_delay(us(480));
|
|
//ds18b20_delay(us(480));
|
|
TCNT1 = 0;
|
|
TCNT1 = 0;
|
|
- while (TCNT1 <= 500) {
|
|
|
|
|
|
+ while (TCNT1 <= 480) {
|
|
}
|
|
}
|
|
|
|
|
|
/* Release line and wait for 60uS */
|
|
/* Release line and wait for 60uS */
|
|
DS18B20_INPUT_MODE;
|
|
DS18B20_INPUT_MODE;
|
|
//ds18b20_delay(us(60));
|
|
//ds18b20_delay(us(60));
|
|
TCNT1 = 0;
|
|
TCNT1 = 0;
|
|
- while (TCNT1 <= 70) {
|
|
|
|
|
|
+ while (TCNT1 <= 60) {
|
|
}
|
|
}
|
|
|
|
|
|
/* Store line value and wait until the completion of 480uS period */
|
|
/* Store line value and wait until the completion of 480uS period */
|
|
@@ -311,7 +344,7 @@ static uint8_t ds18b20_Reset(void) {
|
|
//ds18b20_delay(us(420));
|
|
//ds18b20_delay(us(420));
|
|
//OCR1B = 420;
|
|
//OCR1B = 420;
|
|
TCNT1 = 0;
|
|
TCNT1 = 0;
|
|
- while (TCNT1 <= 430) {
|
|
|
|
|
|
+ while (TCNT1 <= 420) {
|
|
}
|
|
}
|
|
|
|
|
|
/* Return the value read from the presence pulse (0=OK, else=WRONG) */
|
|
/* Return the value read from the presence pulse (0=OK, else=WRONG) */
|
|
@@ -394,8 +427,8 @@ static void ds18b20_WriteByte(uint8_t byte) {
|
|
|
|
|
|
static void ds18b20_StartMeasure(void) {
|
|
static void ds18b20_StartMeasure(void) {
|
|
/* Sync with indicators */
|
|
/* Sync with indicators */
|
|
- Flag.waitIndktr = 1;
|
|
|
|
- while (Flag.waitIndktr == 1);
|
|
|
|
|
|
+ Flag2.waitIndktr = 1;
|
|
|
|
+ while (Flag2.waitIndktr == 1);
|
|
|
|
|
|
/* Reset, skip ROM and start temperature conversion */
|
|
/* Reset, skip ROM and start temperature conversion */
|
|
if (ds18b20_Reset() != 0) {
|
|
if (ds18b20_Reset() != 0) {
|
|
@@ -404,7 +437,7 @@ static void ds18b20_StartMeasure(void) {
|
|
} else {
|
|
} else {
|
|
ds18b20_WriteByte(DS18B20_CMD_SKIPROM);
|
|
ds18b20_WriteByte(DS18B20_CMD_SKIPROM);
|
|
ds18b20_WriteByte(DS18B20_CMD_CONVERTTEMP);
|
|
ds18b20_WriteByte(DS18B20_CMD_CONVERTTEMP);
|
|
- RTOS_SetTask(ds18b20_ReadTemperature, 800, 0);
|
|
|
|
|
|
+ counterDS18B20r = PERIOD_DS18B20r;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -413,8 +446,8 @@ static void ds18b20_ReadTemperature(void) {
|
|
uint8_t decimal;
|
|
uint8_t decimal;
|
|
|
|
|
|
/* Sync with indicators */
|
|
/* Sync with indicators */
|
|
- Flag.waitIndktr = 1;
|
|
|
|
- while (Flag.waitIndktr == 1);
|
|
|
|
|
|
+ Flag2.waitIndktr = 1;
|
|
|
|
+ while (Flag2.waitIndktr == 1);
|
|
|
|
|
|
/* Reset, skip ROM and send command to read Scratchpad */
|
|
/* Reset, skip ROM and send command to read Scratchpad */
|
|
if (ds18b20_Reset() != 0) {
|
|
if (ds18b20_Reset() != 0) {
|
|
@@ -463,12 +496,12 @@ __interrupt void TIMER0_OVF_ISR(void) {
|
|
|
|
|
|
INDCTR_COMMON_PORT &= ~INDCTR_COMMON_ALL; // off all indikators
|
|
INDCTR_COMMON_PORT &= ~INDCTR_COMMON_ALL; // off all indikators
|
|
|
|
|
|
- Flag.waitIndktr = 0;
|
|
|
|
|
|
+ Flag2.waitIndktr = 0;
|
|
|
|
|
|
- if (1 == Flag.blankIndktr) {
|
|
|
|
- if (blank_time <= 200) {
|
|
|
|
- blank_time ++;
|
|
|
|
|
|
+ if (1 == Flag2.blankIndktr) {
|
|
|
|
+ if (blank_time <= 150) {
|
|
flag = 1;
|
|
flag = 1;
|
|
|
|
+ blank_time ++;
|
|
} else if (blank_time <= 250) {
|
|
} else if (blank_time <= 250) {
|
|
blank_time ++;
|
|
blank_time ++;
|
|
flag = 0;
|
|
flag = 0;
|
|
@@ -481,29 +514,29 @@ __interrupt void TIMER0_OVF_ISR(void) {
|
|
if (1 == flag) {
|
|
if (1 == flag) {
|
|
switch (indicator) {
|
|
switch (indicator) {
|
|
case 0:
|
|
case 0:
|
|
- INDCTR_SEGMENT_PORT = Display[0];
|
|
|
|
|
|
+ INDCTR_SEGMENT_PORT = Indicator1;
|
|
INDCTR_COMMON_PORT |= 0x01;
|
|
INDCTR_COMMON_PORT |= 0x01;
|
|
indicator = 1;
|
|
indicator = 1;
|
|
break;
|
|
break;
|
|
|
|
|
|
case 1:
|
|
case 1:
|
|
- if (1 == Flag.needDot) {
|
|
|
|
- INDCTR_SEGMENT_PORT = Display[1] | Sym_dot;
|
|
|
|
|
|
+ if (1 == Flag2.needDot) {
|
|
|
|
+ INDCTR_SEGMENT_PORT = Indicator2 | Sym_dot;
|
|
} else {
|
|
} else {
|
|
- INDCTR_SEGMENT_PORT = Display[1];
|
|
|
|
|
|
+ INDCTR_SEGMENT_PORT = Indicator2;
|
|
}
|
|
}
|
|
INDCTR_COMMON_PORT |= 0x02;
|
|
INDCTR_COMMON_PORT |= 0x02;
|
|
indicator = 2;
|
|
indicator = 2;
|
|
break;
|
|
break;
|
|
|
|
|
|
case 2:
|
|
case 2:
|
|
- INDCTR_SEGMENT_PORT = Display[2];
|
|
|
|
|
|
+ INDCTR_SEGMENT_PORT = Indicator3;
|
|
INDCTR_COMMON_PORT |= 0x04;
|
|
INDCTR_COMMON_PORT |= 0x04;
|
|
indicator = 3;
|
|
indicator = 3;
|
|
break;
|
|
break;
|
|
|
|
|
|
case 3:
|
|
case 3:
|
|
- INDCTR_SEGMENT_PORT = Display[3];
|
|
|
|
|
|
+ INDCTR_SEGMENT_PORT = Indicator4;
|
|
INDCTR_COMMON_PORT |= 0x08;
|
|
INDCTR_COMMON_PORT |= 0x08;
|
|
|
|
|
|
default:
|
|
default:
|
|
@@ -523,7 +556,51 @@ __interrupt void TIMER1_COMPB_ISR(void) {
|
|
|
|
|
|
#pragma vector=TIMER1_OVF_vect
|
|
#pragma vector=TIMER1_OVF_vect
|
|
__interrupt void TIMER1_OVF_ISR(void) {
|
|
__interrupt void TIMER1_OVF_ISR(void) {
|
|
- Flag.T1OC = 1;
|
|
|
|
|
|
+// Flag.T1OC = 1;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+#pragma vector=TIMER2_OVF_vect
|
|
|
|
+__interrupt void TIMER2_OVF_ISR(void) {
|
|
|
|
+ TCNT2 = TIM2_CNT; // reload timer
|
|
|
|
+
|
|
|
|
+ if (counterADC > 0) {
|
|
|
|
+ counterADC --;
|
|
|
|
+ if (counterADC == 0) {
|
|
|
|
+ counterADC = PERIOD_ADC;
|
|
|
|
+ // enable interrupt and start conversion
|
|
|
|
+ ADCSR |= ((1<<ADSC) | (1<<ADIE));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (counterTWI > 0) {
|
|
|
|
+ counterTWI --;
|
|
|
|
+ if (counterTWI == 0) {
|
|
|
|
+ counterTWI = PERIOD_TWI;
|
|
|
|
+ Flag.getTime = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (counterShowTemp > 0) {
|
|
|
|
+ counterShowTemp --;
|
|
|
|
+ if (counterShowTemp == 0) {
|
|
|
|
+ State = show_HHMM;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (counterDS18B20s > 0) {
|
|
|
|
+ counterDS18B20s --;
|
|
|
|
+ if (counterDS18B20s == 0) {
|
|
|
|
+ counterDS18B20s = PERIOD_DS18B20s;
|
|
|
|
+ Flag.startDS18B20 = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (counterDS18B20r > 0) {
|
|
|
|
+ counterDS18B20r --;
|
|
|
|
+ if (counterDS18B20r == 0) {
|
|
|
|
+ Flag.readDS18B20 = 1;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
#pragma vector=ADC_vect
|
|
#pragma vector=ADC_vect
|