1 |   //***************************************************************************** |
2 |   // |
3 |   //  File  Name    :  'display.c' |
4 |   //  Title                :  Itronove  hodiny  |
5 |   #define  __PIC18F8720A__ |
6 |   //  Author              :  http://www.prochazka.zde.cz  -&rsaquo   hacesoft  2017 |
7 |   //  Created            :  05-05-2017,  15:03 |
8 |   //  Revised            :  12-05-2017,  15:03 |
9 |   //  Version            :  1.0 |
10 |   //  Target  MCU   :  PIC  18F8720 |
11 |   // |
12 |   //  This  code  is  distributed  under  the  GNU  Public  License |
13 |   //  Vsechny  informace  jsou  zahrnuty  pod  GPL  licenci,  pokud  není  explicitne  uveden  jiný  typ  licence. |
14 |   //  Pouzivání  techto  stránek  ke  komercním  úcelum  lze  jen  se  souhlasem  autora. |
15 |   //  Vsechna  práva  vyhrazena  (c)  1997  -  2017  hacesoft. |
16 |   // |
17 |   //***************************************************************************** |
18 |   |
19 |   #include  "display.h" |
20 |   #include &lsaquo xc.h&rsaquo |
21 |   #include &lsaquo string.h&rsaquo |
22 |   #include &lsaquo stdio.h&rsaquo |
23 |   #include &lsaquo stdlib.h&rsaquo |
24 |   #include &lsaquo stdint.h&rsaquo   //uint8_t,  uint16_t,  uint32_t |
25 |   #include  "i2c.h" |
26 |   |
27 |   |
28 |   void  _init_display  (void){ |
29 |        TTL_GLOW_Init(); |
30 |        TTL_HourHi_Init(); |
31 |        TTL_HourLo_Init(); |
32 |        TTL_MinitHi_Init(); |
33 |        TTL_MinitLo_Init(); |
34 |        TTL_SecondHi_Init(); |
35 |        TTL_SecondLo_Init(); |
36 |        TTL_GLOW_on(); |
37 |        _set_12_00_00(); |
38 |   } |
39 |   //***************************************************************************** |
40 |   void  _set_12_00_00(void){ |
41 |        SegmentHour  (12); |
42 |        SegmentMinut  (0); |
43 |        SegmentSecond  (0); |
44 |        |
45 |   } |
46 |   //***************************************************************************** |
47 |   /*void  _set_00_00_00(void){ |
48 |        SegmentHour  (0); |
49 |        SegmentMinut  (0); |
50 |        SegmentSecond  (0); |
51 |        |
52 |   }*/ |
53 |   //***************************************************************************** |
54 |   void  setRGB_PCA9633_HW_DT  (uint8_t  IO_adress,  uint8_t  value){ |
55 |        I2C_Start(_HW); |
56 |        I2C_Write(_HW,IO_adress);   //write  slave  address  ALL |
57 |        I2C_Write(_HW,0b00000010);  //pocatecni  adresa  PWM  registru  je  PWM0 |
58 |        I2C_Write(_HW,value); |
59 |        I2C_Stop(_HW); |
60 |   } |
61 |   //***************************************************************************** |
62 |   void  setRGB_PCA9633_SW_DT  (uint8_t  IO_adress,  uint8_t  value){ |
63 |        I2C_Start(_SW); |
64 |        I2C_Write(_SW,IO_adress);   //write  slave  address  ALL |
65 |        I2C_Write(_SW,0b00000010);  //pocatecni  adresa  PWM  registru  je  PWM1 |
66 |        I2C_Write(_SW,value); |
67 |        I2C_Stop(_SW);  |
68 |   } |
69 |   |
70 |   //***************************************************************************** |
71 |   void  _dtLeft_UP  (uint8_t  _status){ |
72 |        if  (_status  ==  _SET){ |
73 |            setRGB_PCA9633_HW_DT  (adress_LED_IC4,  255); |
74 |        } |
75 |        else{ |
76 |            setRGB_PCA9633_HW_DT  (adress_LED_IC4,  0); |
77 |        } |
78 |   } |
79 |   //***************************************************************************** |
80 |   void  _dtLeft_DOWN  (uint8_t  _status){ |
81 |        if  (_status  ==  _SET){ |
82 |            setRGB_PCA9633_HW_DT  (adress_LED_IC3,  255); |
83 |        } |
84 |        else{ |
85 |            setRGB_PCA9633_HW_DT  (adress_LED_IC3,  0); |
86 |        }     |
87 |   } |
88 |   //***************************************************************************** |
89 |   void  _dtRight_UP  (uint8_t  _status){ |
90 |        if  (_status  ==  _SET){ |
91 |            setRGB_PCA9633_SW_DT  (adress_LED_IC6,  255); |
92 |        } |
93 |        else{ |
94 |            setRGB_PCA9633_SW_DT  (adress_LED_IC6,  0); |
95 |        }     |
96 |   } |
97 |   //***************************************************************************** |
98 |   void  _dtRight_DOWN  (uint8_t  _status){ |
99 |        if  (_status  ==  _SET){ |
100 |            setRGB_PCA9633_HW_DT  (adress_LED_IC5,  255); |
101 |        } |
102 |        else{ |
103 |            setRGB_PCA9633_HW_DT  (adress_LED_IC5,  0); |
104 |        }     |
105 |   } |
106 |   //***************************************************************************** |
107 |   void  TTL_GLOW_Init  (void){ |
108 |        TTL_GLOW_PORT  =  0; |
109 |        TTL_GLOW_LAT  =  0; |
110 |        TTL_GLOW_ADCON1  =  0x0F; |
111 |        tTTL_GLOW  =  Output; |
112 |   /* |
113 |        CLRF  PORTA  ;  Initialize  PORTA  by |
114 |                                        ;  clearing  output |
115 |                                        ;  data  latches |
116 |        CLRF  LATA  ;  Alternate  method |
117 |                                        ;  to  clear  output |
118 |                                        ;  data  latches |
119 |        MOVLW  0x0F  ;  Configure  A/D |
120 |        MOVWF  ADCON1  ;  for  digital  inputs |
121 |        MOVLW  0xCF  ;  Value  used  to |
122 |                                        ;  initialize  data |
123 |                                        ;  direction |
124 |        MOVWF  TRISA  ;  Set  RA&lsaquo 3:0&rsaquo   as  inputs |
125 |                                        ;  RA&lsaquo 5:4&rsaquo   as  outputs |
126 |     */ |
127 |        //BitClear  (T0CON,T0CS); |
128 |        //BitClear  (T0CON,TMR0ON); |
129 |        //BitSet  (T0CON,T0SE); |
130 |     /*            |
131 |        bit  5  T0CS:  Timer0  Clock  Source  Select  bit |
132 |        1  =  Transition  on  T0CKI  pin |
133 |        0  =  Internal  instruction  cycle  clock  (CLKO)   |
134 |     */ |
135 |   } |
136 |   //***************************************************************************** |
137 |   void  TTL_HourHi_Init  (void){//HourHi |
138 |        TTL_HourHi_PORT  =  0; |
139 |        TTL_HourHi_LAT  =  0; |
140 |        tTTL_HourHi  =  Output; |
141 |   /* |
142 |        CLRF  PORTD  ;  Initialize  PORTD  by |
143 |                                        ;  clearing  output |
144 |                                        ;  data  latches |
145 |        CLRF  LATD  ;  Alternate  method |
146 |                                        ;  to  clear  output |
147 |                                        ;  data  latches |
148 |        MOVLW  0xCF  ;  Value  used  to |
149 |                                        ;  initialize  data |
150 |                                        ;  direction |
151 |        MOVWF  TRISD  ;  Set  RD&lsaquo 3:0&rsaquo   as  inputs |
152 |                                        ;  RD&lsaquo 5:4&rsaquo   as  outputs |
153 |   |
154 |     */ |
155 |   } |
156 |   //***************************************************************************** |
157 |   void  TTL_HourLo_Init  (void){//HourLo |
158 |        TTL_HourLo_PORT  =  0; |
159 |        TTL_HourLo_LAT  =  0; |
160 |        tTTL_HourLo  =  Output; |
161 |   /* |
162 |        CLRF  PORTE  ;  Initialize  PORTE  by |
163 |                                        ;  clearing  output |
164 |                                        ;  data  latches |
165 |        CLRF  LATE  ;  Alternate  method |
166 |                                        ;  to  clear  output |
167 |                                        ;  data  latches |
168 |        MOVLW  0x03  ;  Value  used  to |
169 |                                        ;  initialize  data |
170 |                                        ;  direction |
171 |        MOVWF  TRISE  ;  Set  RE1:RE0  as  inputs |
172 |                                        ;  RE7:RE2  as  outputs |
173 |     */ |
174 |   } |
175 |   //***************************************************************************** |
176 |   void  TTL_MinitHi_Init  (void){//MinitHi |
177 |        TTL_MinitHi_PORT  =  0; |
178 |        TTL_MinitHi_LAT  =  0; |
179 |        TTL_MinitHi_ADCON1  =  0x0F; |
180 |        tTTL_MinitHi  =  Output; |
181 |   /* |
182 |        CLRF  PORTH  ;  Initialize  PORTH  by |
183 |                                        ;  clearing  output |
184 |                                        ;  data  latches |
185 |        CLRF  LATH  ;  Alternate  method |
186 |                                        ;  to  clear  output |
187 |                                        ;  data  latches |
188 |        MOVLW  0Fh  ; |
189 |        MOVWF  ADCON1  ; |
190 |        MOVLW  0CFh  ;  Value  used  to |
191 |                                        ;  initialize  data |
192 |                                        ;  direction |
193 |        MOVWF  TRISH  ;  Set  RH3:RH0  as  inputs |
194 |                                        ;  RH5:RH4  as  outputs |
195 |                                        ;  RH7:RH6  as  inputs |
196 |     */ |
197 |   } |
198 |   //***************************************************************************** |
199 |   void  TTL_MinitLo_Init  (void){//MinitLo |
200 |        TTL_MinitLo_PORT  =  0; |
201 |        TTL_MinitLo_LAT  =  0; |
202 |        tTTL_MinitLo  =  Output; |
203 |   /* |
204 |        CLRF  PORTJ  ;  Initialize  PORTG  by |
205 |                                        ;  clearing  output |
206 |                                        ;  data  latches |
207 |        CLRF  LATJ  ;  Alternate  method |
208 |                                        ;  to  clear  output |
209 |                                        ;  data  latches |
210 |        MOVLW  0xCF  ;  Value  used  to |
211 |                                        ;  initialize  data |
212 |                                        ;  direction |
213 |        MOVWF  TRISJ  ;  Set  RJ3:RJ0  as  inputs |
214 |                                        ;  RJ5:RJ4  as  output |
215 |                                        ;  RJ7:RJ6  as  inputs |
216 |     */ |
217 |   } |
218 |   //***************************************************************************** |
219 |   void  TTL_SecondHi_Init  (void){//SecondHi |
220 |        TTL_SecondHi_PORT  =  0; |
221 |        TTL_SecondHi_LAT  =  0; |
222 |        TTL_SecondHi_ADCON1  =  0x0F; |
223 |        TTL_SecondHi_CMCON  =  0x7; |
224 |        tTTL_SecondHi  =  Output; |
225 |   /* |
226 |        CLRF  PORTF  ;  Initialize  PORTF  by |
227 |                                        ;  clearing  output |
228 |                                        ;  data  latches |
229 |        CLRF  LATF  ;  Alternate  method |
230 |                                        ;  to  clear  output |
231 |                                        ;  data  latches |
232 |        MOVLW  0x07  ; |
233 |        MOVWF  CMCON  ;  Turn  off  comparators |
234 |        MOVLW  0x0F  ; |
235 |        MOVWF  ADCON1  ;  Set  PORTF  as  digital  I/O |
236 |        MOVLW  0xCF  ;  Value  used  to |
237 |                                        ;  initialize  data |
238 |                                        ;  direction |
239 |        MOVWF  TRISF  ;  Set  RF3:RF0  as  inputs |
240 |                                        ;  RF5:RF4  as  outputs |
241 |     */ |
242 |   } |
243 |   //***************************************************************************** |
244 |   void  TTL_SecondLo_Init  (void){//SecondLo |
245 |        TTL_SecondLoG_PORT  =  0; |
246 |        TTL_SecondLoG_LAT  =  0; |
247 |        tTTL_SecondLoG  =  Output; |
248 |   /* |
249 |        CLRF  PORTG  ;  Initialize  PORTG  by |
250 |                                        ;  clearing  output |
251 |                                        ;  data  latches |
252 |        CLRF  LATG  ;  Alternate  method |
253 |                                        ;  to  clear  output |
254 |                                        ;  data  latches |
255 |        MOVLW  0x04  ;  Value  used  to |
256 |                                        ;  initialize  data |
257 |                                        ;  direction |
258 |        MOVWF  TRISG  ;  Set  RG1:RG0  as  outputs |
259 |                                        ;  RG2  as  input |
260 |                                        ;  RG4:RG3  as  inputs |
261 |     */ |
262 |            //bit  3-0  CCPxM3:CCPxM0:  CCP  Module  x  Mode  Select  bits |
263 |            //0000  =  Capture/Compare/PWM  disabled  (resets  CCPx  module) |
264 |   |
265 |            //ECCP1M&lsaquo 3:0&rsaquo :  ECCP1  Mode  Select  bits |
266 |                //0000  =  Capture/Compare/PWM  off  (resets  ECCP  module) |
267 |        //ECCP1CON  =  0; |
268 |            //bit  2  CCP1IE:  CCP1  Interrupt  Enable  bit |
269 |                //1  =  Enables  the  CCP1  interrupt |
270 |                //0  =  Disables  the  CCP1  interrupt |
271 |        //BitClear(PIE1,CCP1IE); |
272 |        //PIE1  =  0; |
273 |            //bit  1  TMR1CS:  Timer1  Clock  Source  Select  bit |
274 |                //1  =  External  clock  from  pin  RC0/T1OSO/T13CKI  (on  the  rising  edge) |
275 |                //0  =  Internal  clock  (FOSC/4)   |
276 |   //     BitClear(T1CON,TMR1CS); |
277 |            //bit  0  TMR1ON:  Timer1  On  bit |
278 |                //1  =  Enables  Timer1 |
279 |                //0  =  Stops  Timer1 |
280 |        //BitClear(T1CON,TMR1ON); |
281 |            //bit  2  T1SYNC:  Timer1  External  Clock  Input  Synchronization  Select  bit |
282 |                //When  TMR1CS  =  1: |
283 |                //1  =  Do  not  synchronize  external  clock  input |
284 |                //0  =  Synchronize  external  clock  input |
285 |                //When  TMR1CS  =  0: |
286 |                //This  bit  is  ignored.  Timer1  uses  the  internal  clock  when  TMR1CS  =  0. |
287 |        //BitSet(T1CON,  TMT1SYNC); |
288 |            //bit  3  T1OSCEN:  Timer1  Oscillator  Enable  bit |
289 |                //1  =  Timer1  oscillator  is  enabled |
290 |                //0  =  Timer1  oscillator  is  shut  off |
291 |                //The  oscillator  inverter  and  feedback  resistor  are  turned  off  to  eliminate  power  drain. |
292 |        //BitClear(T1CON,T1OSCEN); |
293 |      |
294 |        //--------------------- |
295 |            //bit  2  T3SYNC:  Timer3  External  Clock  Input  Synchronization  Control  bit |
296 |                //(Not  usable  if  the  system  clock  comes  from  Timer1/Timer3.) |
297 |                //When  TMR3CS  =  1: |
298 |                //1  =  Do  not  synchronize  external  clock  input |
299 |                //0  =  Synchronize  external  clock  input |
300 |                //When  TMR3CS  =  0: |
301 |                //This  bit  is  ignored.  Timer3  uses  the  internal  clock  when  TMR3CS  =  0. |
302 |     //    BitSet(T3CON,  T3SYNC); |
303 |           //  bit  1  TMR3CS:  Timer3  Clock  Source  Select  bit |
304 |                //1  =  External  clock  input  from  Timer1  oscillator  or  T13CKI  (on  the  rising  edge  after  the |
305 |                //first  falling  edge) |
306 |                //0  =  Internal  clock  (FOSC/4) |
307 |        //BitClear(T3CON,TMR3CS); |
308 |           //  bit  0  TMR3ON:  Timer3  On  bit |
309 |                //1  =  Enables  Timer3 |
310 |        //BitClear(T3CON,TMR3ON); |
311 |        //BitClear  (TTL_SecondLoC_PORT,TTL_Segment_SLF); |
312 |        //BitClear  (TTL_SecondLoC_PORT,TTL_Segment_SLG); |
313 |        //BitClear  (TTL_SecondLoC_PORT,TTL_Segment_SLT); |
314 |        BitClear  (TTL_SecondLoC_LAT,TTL_Segment_SLF); |
315 |        BitClear  (TTL_SecondLoC_LAT,TTL_Segment_SLG); |
316 |        BitClear  (TTL_SecondLoC_LAT,TTL_Segment_SLT); |
317 |        tTTL_SecondSLF  =  Output;              |
318 |        tTTL_SecondSLG  =  Output;              |
319 |        tTTL_SecondSLT  =  Output;   |
320 |   /* |
321 |        CLRF  PORTC  ;  Initialize  PORTC  by |
322 |                                        ;  clearing  output |
323 |                                        ;  data  latches |
324 |       CLRF  LATC  ;  Alternate  method |
325 |                                        ;  to  clear  output |
326 |                                        ;  data  latches |
327 |       MOVLW  0xCF  ;  Value  used  to |
328 |                                        ;  initialize  data |
329 |                                        ;  direction |
330 |       MOVWF  TRISC  ;  Set  RC&lsaquo 3:0&rsaquo   as  inputs |
331 |                                        ;  RC&lsaquo 5:4&rsaquo   as  outputs |
332 |                                        ;  RC&lsaquo 7:6&rsaquo   as  inputs |
333 |     */ |
334 |   } |
335 |   //***************************************************************************** |
336 |   |
337 |   void  TTL_GLOW_on  (void){//  zapne  zhaveni  itronu |
338 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_HH); |
339 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_HL); |
340 |        |
341 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_MH); |
342 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_ML); |
343 |        |
344 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_SH); |
345 |        BitSet(TTL_GLOW_LAT,  _TTL_GLOW_SL);   |
346 |   } |
347 |   //***************************************************************************** |
348 |   void  TTL_GLOW_off  (void){//  vypne  zhaveni  itronu |
349 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_HH); |
350 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_HL); |
351 |        |
352 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_MH); |
353 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_ML); |
354 |        |
355 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_SH); |
356 |        BitClear(TTL_GLOW_LAT,  _TTL_GLOW_SL);   |
357 |   } |
358 |   //***************************************************************************** |
359 |   void  SegmentHour  (uint8_t  nHour){ |
360 |        uint8_t  nBufferD  =  0; |
361 |        uint8_t  nBufferJ  =  0; |
362 |        if  (nHour  !=  0){ |
363 |            if  (nHour &rsaquo   9){ |
364 |                nBufferD  =  RadDesitky  (nHour); |
365 |            } |
366 |            nBufferJ  =  RadJednotky  (nHour,  nBufferD); |
367 |        } |
368 |        //if  (nBufferD  ==  0){nBufferD  =  15;}//prazdny  znak |
369 |        //_hour_raw  (decode_segment(1),  decode_segment(2)); |
370 |        _hour_raw  (decode_segment(nBufferD),  decode_segment(nBufferJ)); |
371 |   } |
372 |   //***************************************************************************** |
373 |   void  ShowErr  (void){ |
374 |        _hour_raw  (decode_segment(14),decode_segment(22));//show  empty  char |
375 |        _minut_raw  (decode_segment(22),decode_segment(21));//show  empty  char |
376 |        _second_raw  (decode_segment(21),decode_segment(21));//show  empty  char |
377 |   } |
378 |   //***************************************************************************** |
379 |   void  ClearDisplay  (void){ |
380 |        _hour_raw  (decode_segment(21),decode_segment(21));//show  empty  char |
381 |        _minut_raw  (decode_segment(21),decode_segment(21));//show  empty  char |
382 |        _second_raw  (decode_segment(21),decode_segment(21));//show  empty  char |
383 |   } |
384 |   //***************************************************************************** |
385 |   void  SegmentMinut  (uint8_t  nMinut){ |
386 |        uint8_t  nBufferD  =  0; |
387 |        uint8_t  nBufferJ  =  0; |
388 |        if  (nMinut  !=  0){ |
389 |            if  (nMinut &rsaquo   9){ |
390 |                nBufferD  =  RadDesitky  (nMinut); |
391 |            } |
392 |            nBufferJ  =  RadJednotky  (nMinut,  nBufferD); |
393 |        } |
394 |        _minut_raw  (decode_segment(nBufferD),  decode_segment(nBufferJ)); |
395 |   } |
396 |   //***************************************************************************** |
397 |   void  SegmentSecond  (uint8_t  nSecond){ |
398 |        uint8_t  nBufferD  =  0; |
399 |        uint8_t  nBufferJ  =  0; |
400 |            if  (nSecond  !=  0){ |
401 |            if  (nSecond &rsaquo   9){ |
402 |                nBufferD  =  RadDesitky  (nSecond); |
403 |            } |
404 |            nBufferJ  =  RadJednotky  (nSecond,  nBufferD); |
405 |        } |
406 |        _second_raw  (decode_segment(nBufferD),  decode_segment(nBufferJ)); |
407 |   } |
408 |   //***************************************************************************** |
409 |   unsigned  char  RadJednotky  (uint8_t  nBuffer,  uint8_t  nRadDesitky){ |
410 |       uint8_t  jednotky  =  0; |
411 |       jednotky  =  nBuffer  -  (unsigned)(nRadDesitky  *  10); |
412 |       return  jednotky; |
413 |   } |
414 |   //***************************************************************************** |
415 |   unsigned  char  RadDesitky  (uint8_t  nBuffer){ |
416 |        uint8_t  desitky  =  0; |
417 |        desitky  =  (unsigned)  nBuffer/10; |
418 |        return  desitky; |
419 |   } |
420 |   //***************************************************************************** |
421 |   void  PrintHex  (uint8_t  nSegment,  unsigned  int  nHex){ |
422 |        unsigned  int  nLo; |
423 |        unsigned  int  nHi; |
424 |        |
425 |        //nLo  =  0; |
426 |        //nHi  =  0; |
427 |        nLo  =  (nHex  and  0b00001111); |
428 |        nHi  =  (nHex  and  0b11110000)  ror  4; |
429 |        if  (nSegment  ==  1){ |
430 |            _hour_raw  (decode_segment(nHi),decode_segment(nLo)); |
431 |        } |
432 |        if  (nSegment  ==  2){ |
433 |            _minut_raw  (decode_segment(nHi),decode_segment(nLo)); |
434 |        } |
435 |        if  (nSegment  ==  3){ |
436 |            _second_raw  (decode_segment(nHi),decode_segment(nLo)); |
437 |        } |
438 |   } |
439 |   //***************************************************************************** |
440 |   void  PrintPomlcka  (uint8_t  nSegment){ |
441 |        if  (nSegment  ==  1){ |
442 |            _hour_raw  (decode_segment(16),decode_segment(16)); |
443 |        } |
444 |        if  (nSegment  ==  2){ |
445 |            _minut_raw  (decode_segment(16),decode_segment(16)); |
446 |        } |
447 |        if  (nSegment  ==  3){ |
448 |            _second_raw  (decode_segment(16),decode_segment(16)); |
449 |        } |
450 |        if  (nSegment  ==  _ALL){ |
451 |            _second_raw  (decode_segment(16),decode_segment(16)); |
452 |            _minut_raw   (decode_segment(16),decode_segment(16)); |
453 |            _hour_raw    (decode_segment(16),decode_segment(16)); |
454 |        } |
455 |   } |
456 |   //***************************************************************************** |
457 |   void  PrintSpace  (uint8_t  nSegment){ |
458 |        if  (nSegment  ==  1){ |
459 |            _hour_raw  (decode_segment(17),decode_segment(17)); |
460 |        } |
461 |        if  (nSegment  ==  2){ |
462 |            _minut_raw  (decode_segment(17),decode_segment(17)); |
463 |        } |
464 |        if  (nSegment  ==  3){ |
465 |            _second_raw  (decode_segment(17),decode_segment(17)); |
466 |        } |
467 |   } |
468 |   //***************************************************************************** |
469 |   uint8_t  decode_segment  (uint8_t  nSegment){//dekuduje  desitkove  cislo  na  segmetny  zobrazovace |
470 |        uint8_t  nBuffer  =  0; |
471 |        switch  (  nSegment  )  { |
472 |            case  0:  //znak  0           |
473 |                nBuffer  =  0b01111011; |
474 |            break; |
475 |            case  1:  //znak  1           |
476 |                nBuffer  =  0b01000001; |
477 |            break; |
478 |            case  2:  //znak  2          |
479 |                nBuffer  =  0b00110111; |
480 |            break; |
481 |            case  3:  //znak  3            |
482 |                nBuffer  =  0b01100111; |
483 |            break; |
484 |            case  4:  //znak  4             |
485 |                nBuffer  =  0b01001101; |
486 |            break; |
487 |            case  5:  //znak  5             |
488 |                nBuffer  =  0b01101110; |
489 |            break; |
490 |            case  6:  //znak  6             |
491 |                nBuffer  =  0b01111110; |
492 |            break; |
493 |            case  7:  //znak  7             |
494 |                nBuffer  =  0b01000011; |
495 |            break; |
496 |            case  8:  //znak  8            |
497 |                nBuffer  =  0b01111111; |
498 |            break; |
499 |            case  9:  //znak  9             |
500 |                nBuffer  =  0b01101111; |
501 |            break; |
502 |            case  10:  //znak  A             |
503 |                nBuffer  =  0b01011111; |
504 |            break; |
505 |            case  11:  //znak  B             |
506 |                nBuffer  =  0b01111100; |
507 |            break; |
508 |            case  12:  //znak  C             |
509 |                nBuffer  =  0b00111010; |
510 |            break; |
511 |            case  13:  //znak  D             |
512 |                nBuffer  =  0b01110101; |
513 |            break; |
514 |            case  14:  //znak  E             |
515 |                nBuffer  =  0b00111110; |
516 |            break; |
517 |            case  15:  //znak  F             |
518 |                nBuffer  =  0b00011110; |
519 |            break; |
520 |            case  16:  //zobrazi  minus           |
521 |                nBuffer  =  0b00000100; |
522 |            break; |
523 |            case  17:  //zobrazi  znas  u  ---space          |
524 |                nBuffer  =  0b01110000; |
525 |            break; |
526 |            case  20:  //znak  DT   (desetina  tecka)           |
527 |                nBuffer  =  0b10000000; |
528 |            break; |
529 |            case  21:  //zobrazi  prazdny  znak             |
530 |                nBuffer  =  0b00000000; |
531 |            break; |
532 |            case  22:  //znad  r             |
533 |                nBuffer  =  0b00101000; |
534 |            break; |
535 |        default:       //zobrazi  prazdny  znak       |
536 |            nBuffer  =  0b10000001; |
537 |        break; |
538 |      }    |
539 |        return  nBuffer; |
540 |   } |
541 |   //***************************************************************************** |
542 |   void  _hour_raw  (uint8_t  dRaw_hi,  uint8_t  dRaw_lo){//zobrazi  data  na  segmentovek  hodiny |
543 |        //_Hour_port_hi  =   dRaw_hi; |
544 |        //_Hour_port_lo  =   dRaw_lo; |
545 |        TTL_HourHi_LAT  =  dRaw_hi; |
546 |        TTL_HourLo_LAT  =  dRaw_lo; |
547 |   } |
548 |   //***************************************************************************** |
549 |   void  _minut_raw  (uint8_t  dRaw_hi,  uint8_t  dRaw_lo){//zobrazi  data  na  segmentovek  minuty |
550 |        //_Minut_port_hi  =   dRaw_hi; |
551 |       //  _Minut_port_lo  =   dRaw_lo; |
552 |        TTL_MinitHi_LAT  =  dRaw_hi; |
553 |        TTL_MinitLo_LAT  =  dRaw_lo; |
554 |   } |
555 |   //***************************************************************************** |
556 |   void  _second_raw  (uint8_t  dRaw_hi,  uint8_t  dRaw_lo){//zobrazi  data  na  segmentovek  sekundy |
557 |       //  _Second_port_hi  =  dRaw_hi; |
558 |      //   _Second_port_loh  =   dRaw_lo; |
559 |        TTL_SecondHi_LAT  =  dRaw_hi; |
560 |        TTL_SecondLoG_LAT  =  dRaw_lo; |
561 |        if  (BTFSC  (  dRaw_lo,  BIT_5))  |
562 |            {BitSet(TTL_SecondLoC_LAT,   _Second_lo_F);} |
563 |        else{BitClear(TTL_SecondLoC_LAT,  _Second_lo_F);} |
564 |     |
565 |        if  (BTFSC  (  dRaw_lo,  BIT_6)) |
566 |            {BitSet(TTL_SecondLoC_LAT,  _Second_lo_G);} |
567 |        else{BitClear(TTL_SecondLoC_LAT,  _Second_lo_G);} |
568 |        |
569 |        if  (BTFSC  (dRaw_lo,  BIT_7)) |
570 |            {BitSet(TTL_SecondLoC_LAT,  _Second_lo_DT);} |
571 |        else{BitClear(TTL_SecondLoC_LAT,  _Second_lo_DT);} |
572 |   } |
573 |   //***************************************************************************** |
574 |   /*void  Stopky10_setiny  (void){ |
575 |        for(;;)  { |
576 |            _set_00_00_00(); |
577 |            for  (uint8_t  a  =  0;  a&lsaquo   100;  a++){ |
578 |                for  (uint8_t  b  =  0;  b&lsaquo   100;  b++){ |
579 |                    for  (uint8_t  c  =  0;  c&lsaquo   100;  c++){ |
580 |                        SegmentSecond  (c); |
581 |                        __delay_ms(17); |
582 |                    } |
583 |                    SegmentMinut  (b); |
584 |                } |
585 |                SegmentHour  (a); |
586 |            }   |
587 |        } |
588 |   }*/ |
589 |   //***************************************************************************** |
590 |   /*void  Stopky60_setiny  (void){ |
591 |        for(;;)  { |
592 |            _set_00_00_00(); |
593 |            for  (uint8_t  a  =  0;  a&lsaquo   60;  a++){ |
594 |                for  (uint8_t  b  =  0;  b&lsaquo   60;  b++){ |
595 |                    for  (uint8_t  c  =  0;  c&lsaquo   60;  c++){ |
596 |                        SegmentSecond  (c); |
597 |                        __delay_ms(17); |
598 |                    } |
599 |                    SegmentMinut  (b); |
600 |                } |
601 |                SegmentHour  (a); |
602 |            }  |
603 |        } |
604 |   }*/ |
605 |   //***************************************************************************** |
606 |   /*void  Stopky60_sekundy  (void){ |
607 |        for(;;)  { |
608 |            _set_00_00_00(); |
609 |            for  (uint8_t  a  =  0;  a&lsaquo   24;  a++){ |
610 |                for  (uint8_t  b  =  0;  b&lsaquo   60;  b++){ |
611 |                    for  (uint8_t  c  =  0;  c&lsaquo   60;  c++){ |
612 |                        SegmentSecond  (c); |
613 |                        __delay_ms(700); |
614 |                    } |
615 |                    SegmentMinut  (b); |
616 |                } |
617 |                SegmentHour  (a); |
618 |            }  |
619 |        } |
620 |   } |
621 |   */ |