Rev 1861 Rev 1942
Line 17... Line 17...
17 #define TL1 PIN_B3 // tlacitko S1 17 #define TL1 PIN_B3 // tlacitko S1
18 #define TL2 PIN_B2 // tlacitko S2 18 #define TL2 PIN_B2 // tlacitko S2
19 #define TL3 PIN_B1 // tlacitko S3 19 #define TL3 PIN_B1 // tlacitko S3
20 #define TL4 PIN_B0 // tlacitko S4 20 #define TL4 PIN_B0 // tlacitko S4
21   21  
-   22 #define POWER_T4 PIN_A6 // ovladani optotriaku T3
22 #define POWER_T4 PIN_A5 // ovladani optotriaku T4 23 #define POWER_T4 PIN_A5 // ovladani optotriaku T4
23 #define POWER_T5 PIN_A4 // ovladani optotriaku T5 24 #define POWER_T5 PIN_A4 // ovladani optotriaku T5
24   25  
25 #define ADC_PIN PIN_A0 //info, nelze menit - pin pouzit jako input analog 26 #define ADC_PIN PIN_A0 //info, nelze menit - pin pouzit jako input analog
26 #define ADC_PIN_NC PIN_A1 //info, nelze menit - pin pouzit jako input analog 27 #define ADC_PIN_NC PIN_A1 //info, nelze menit - pin pouzit jako input analog
Line 77... Line 78...
77 return (analog >> 5 ); // prumer = analog/32 78 return (analog >> 5 ); // prumer = analog/32
78 } 79 }
79   80  
80 int16 teplota(void) 81 int16 teplota(void)
81 { 82 {
-   83  
-   84 BYTE CONST TEMP_CALLIBRATION[20] = {0x90,0xb7,0x19,0x15,0x36,0x54,0x50,0xb5,0,0x24};
-   85  
-   86 int16 Temp;
-   87  
82 float32 Rpt; 88 /* float32 Rpt;
83 float32 Tpt; 89 float32 Tpt;
84   90  
85 Rpt = 1.0*adc()*2350.0/1024.0; //zapojeni OZ -> R=U/Iconst 91 Rpt = 1.0*adc()*2350.0/1024.0; //zapojeni OZ -> R=U/Iconst
86 92
87 #define A 3.90802e-3 93 #define A 3.90802e-3
88 #define B -5.802e-7 94 #define B -5.802e-7
89 95
90 Tpt = (-A + sqrt(A*A - 4*B*(1.0 - Rpt/1000.0)))/2.0/B; 96 Tpt = (-A + sqrt(A*A - 4*B*(1.0 - Rpt/1000.0)))/2.0/B;
-   97 */
91   98  
92 return (unsigned int16)Tpt; -  
93 } -  
94   99  
95 void baterie(void) -  
96 { 100  
97 static int8 stav=0; -  
98 switch (stav) -  
99 { -  
100 case 0: stav++; -  
101 lcd_define_char(0,LCD_CHAR_BAT0); -  
102 break; -  
103 case 1: stav++; -  
104 lcd_define_char(0,LCD_CHAR_BAT20); -  
105 break; -  
106 case 2: stav++; -  
107 lcd_define_char(0,LCD_CHAR_BAT40); -  
108 PowerOff(); -  
109 break; -  
110 case 3: stav++; -  
111 lcd_define_char(0,LCD_CHAR_BAT60); -  
112 break; 101 return Temp;
113 case 4: stav++; -  
114 lcd_define_char(0,LCD_CHAR_BAT80); -  
115 break; -  
116 case 5: stav=0; -  
117 lcd_define_char(0,LCD_CHAR_BAT100); -  
118 PowerOn(); -  
119 break; -  
120 default: stav=0; -  
121 } -  
122 } 102 }
123   103  
-   104  
124 #int_TIMER2 105 #int_TIMER2
125 void Rtc(void) //40ms 106 void Rtc(void) //40ms
126 { 107 {
127 static unsigned int8 ms40=0; 108 static unsigned int8 ms40=0;
128 struct time* time; 109 struct time* time;
Line 155... Line 136...
155   136  
156 // start 137 // start
157 void main() 138 void main()
158 { 139 {
159 int8 tmp; 140 int8 tmp;
160 -  
161 GeneralCpuInit(); 141 GeneralCpuInit();
162 -  
163 PowerOff(); 142 PowerOff();
164 143
165 lcd_init(); 144 lcd_init();
166 lcd_define_char(1,LCD_CHAR_STUPEN); 145 lcd_define_char(1,LCD_CHAR_STUPEN);
167 -  
168 printf(lcd_putc,"\fbatt: \20"); -  
169 146
170 nullcas(&cas); 147 nullcas(&cas);
171 148
172 for (;;){ 149 while(true)
-   150 {
173 delay_ms(300); 151 delay_ms(300);
174 152
175 if (cas.sec != tmp){ 153 if (cas.sec != tmp){
176 tmp=cas.sec; 154 tmp=cas.sec;
177 lcd_gotoxy(9,1); 155 lcd_gotoxy(9,1);
178 printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec); 156 printf(lcd_putc,"%2u:%02u:%02u",cas.hod,cas.min,cas.sec);
179 } 157 }
180 158
181 baterie(); -  
182 lcd_gotoxy(1,2); 159 lcd_gotoxy(1,2);
183 printf(lcd_putc,"teplota: %ld\21C ",teplota()); 160 printf(lcd_putc,"teplota: %ld\21C ",teplota());
184 } 161 }
185 } 162 }