summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefanie Eckner <stefanie@eckner.net>2020-10-30 10:31:40 +0100
committerStefanie Eckner <stefanie@eckner.net>2020-10-30 10:31:40 +0100
commit24a0a1fc40b006a8673606afbc895b0abdcbbed4 (patch)
treec38184ec6b04db0c92fb958aa778ebf140593100
parent992af39d0775345631bea73bfc60156345a707fb (diff)
downloadUhr-24a0a1fc40b006a8673606afbc895b0abdcbbed4.tar.xz
BCD- und Mengenlehreuhr für P16f872
-rw-r--r--ERICH_VER_0.1.ASM645
-rw-r--r--ERICH_VER_0.1_BCD.HEX51
-rw-r--r--ERICH_VER_0.1_MEN.HEX62
-rw-r--r--binTime.h330
-rw-r--r--main.c.c174
-rw-r--r--setTime.h505
6 files changed, 758 insertions, 1009 deletions
diff --git a/ERICH_VER_0.1.ASM b/ERICH_VER_0.1.ASM
new file mode 100644
index 0000000..1ae2a7b
--- /dev/null
+++ b/ERICH_VER_0.1.ASM
@@ -0,0 +1,645 @@
+; #define Mengenlehreuhr
+
+#include <P16f872.INC>
+
+ __CONFIG 0x3B39
+
+Stunde Equ 0x20 ; aktuelle Stunde
+Minute Equ 0x21 ; aktuelle Minute
+Sekunde Equ 0x22 ; aktuelle Sekunde
+dreiMSL Equ 0x23 ; 3ms-Zaehler (eigtl. 10/3 ms) low-Teil
+dreiMSH Equ 0x24 ; 3ms-Zaehler (eigtl. 10/3 ms) high-Teil
+weiterDML Equ 0x25 ; Sollwert fuer 3ms-Zaehler beim Warten low-Teil
+weiterDMH Equ 0x26 ; Sollwert fuer 3ms-Zaehler beim Warten high-Teil
+weiterT1L Equ 0x27 ; Sollwert fuer Timer1Zaehler beim Warten low-Teil
+weiterT1H Equ 0x28 ; Sollwert fuer Timer1Zaehler beim Warten high-Teil
+tara Equ 0x29 ; zum Tarieren der Zeitkonstante
+dZFlL Equ 0x2A ; 3ms-Zaehlerstand bei letzter Flanke low-Teil
+dZFlH Equ 0x2B ; 3ms-Zaehlerstand bei letzter Flanke high-Teil
+Stati Equ 0x2C ; 0: letzter/aktueller Pegel der DCF77-Empfängers
+ ; 1: Fehler innerhalb der letzten Funkminute
+ ; 2: MEZ/MESZ-Umstellung am Ende der Stunde
+ ; 3: MESZ?
+ ; 4: Schaltsekunde am Ende der Stunde
+ ; 6: letzte Minute kam per Funk
+ ; 7: letzte Stunde kam per Funk
+tmpL Equ 0x2D ; temporaerer Speicher
+tmpH Equ 0x2E ; temporaerer Speicher
+Spalten Equ 0x2F ; zu aktivierende Spalten
+Zeilen Equ 0x30 ; zu aktivierende Zeile(n)
+dat0 Equ 0x31 ; Funkdaten, Bit 0..7
+dat1 Equ 0x32 ; Funkdaten, Bit 8..15
+dat2 Equ 0x33 ; Funkdaten, Bit 16..23
+dat3 Equ 0x34 ; Funkdaten, Bit 24..31
+dat4 Equ 0x35 ; Funkdaten, Bit 32..39
+dat5 Equ 0x36 ; Funkdaten, Bit 40..47
+dat6 Equ 0x37 ; Funkdaten, Bit 48..55
+dat7 Equ 0x38 ; Funkdaten, Bit 56..58 bzw. 63
+
+ GOTO Anfang
+ RETFIE
+
+Anfang ; nach den Interrupts
+
+ BCF STATUS, RP0
+ BCF STATUS, RP1 ; Bank0
+
+ CLRF Stunde ; eigene Variablen initialisieren
+ CLRF Minute
+ CLRF Sekunde
+ MOVLW 0x12
+ MOVWF Stunde
+ MOVLW 0x34
+ MOVWF Minute
+ MOVLW 0x56
+ MOVWF Sekunde
+
+ CLRF dat0
+ CLRF dat1
+ CLRF dat2
+ CLRF dat3
+ CLRF dat4
+ CLRF dat5
+ CLRF dat6
+ CLRF dat7
+
+ CLRF dreiMSH
+ CLRF dreiMSL
+ MOVLW 0x2C
+ MOVWF weiterDML
+ MOVLW 0x01
+ MOVWF weiterDMH
+ CLRF weiterT1L
+ CLRF weiterT1H
+ CLRF Stati
+ BSF Stati, 1
+ MOVLW 0x85
+ MOVWF tara ; eigentlich 5 1/3 (die 0x80 entspricht einer Null!)
+
+ CLRF PORTA ; I/O initialisieren
+ CLRF PORTB
+ CLRF PORTC
+
+ BSF STATUS, RP0 ; Bank 1
+
+ MOVLW 0x06 ; Port-A digital
+ MOVWF ADCON1
+ MOVLW 0x38 ; alles Ausgaenge bis auf A3, A4 und A5
+ MOVWF TRISA
+ CLRF TRISB ; alles Ausgaenge
+ CLRF TRISC ; alles Ausgaenge
+
+ BCF PIE1, TMR1IE ; Interrupt für Timer deaktivieren
+
+ BCF STATUS, RP0 ; Bank 0
+
+ MOVLW 0x01 ; Timer1 initialisieren
+ MOVWF T1CON
+; MOVLW 0xC0
+; MOVWF INTCON
+
+Multiplex
+
+#ifdef Mengenlehreuhr
+ MOVF Minute, 0
+ CALL BCD2Un
+ MOVWF Spalten
+ SWAPF Spalten, 1
+ MOVF Minute, 0
+ CALL BCD2Un5H
+ IORWF Spalten, 1 ; anzuzeigende Minutenteile
+
+; BTFSC Stati, 1 ; Funkfehler?
+; GOTO SekTaktAnzeigen
+
+ MOVF Stati, 0
+ MOVWF tmpL
+ RRF Stati, 0
+ ANDWF tmpL, 1 ; tmpL<6> = Stati<6> & Stati<7> (Funk korrekt?)
+ BTFSC Stati, 1
+ BCF tmpL, 6 ; tmpL<6> = Stati<6> & Stati<7> & NOT Stati<1> (Funk korrekt?)
+ RLF PORTA, 0
+ XORWF tmpL, 1 ; tmpL<6> = (Stati<6> & Stati<7> & NOT Stati<1>) XOR PORTA<5>
+ BTFSC tmpL, 6 ; Funksignal auf Sekunden-LED geben
+; BTFSC PORTA, 5
+ BSF Spalten, 3
+ GOTO ErsteZeileSetzen
+SekTaktAnzeigen
+ BTFSC Sekunde, 0 ; Sekunde auf Sekunden-LED geben
+ BSF Spalten, 3
+ErsteZeileSetzen
+#else
+ MOVF Sekunde, 0 ; Sekunde als nächstes anzeigen
+ MOVWF Spalten
+#endif
+ MOVLW 0x4
+ MOVWF Zeilen
+ CALL Wait
+
+#ifdef Mengenlehreuhr
+ MOVF Minute, 0
+ CALL BCD2Un5L
+ MOVWF Spalten
+#else
+ MOVF Minute, 0
+ MOVWF Spalten ; Minute als nächstes anzeigen
+#endif
+ MOVLW 0x2
+ MOVWF Zeilen
+ CALL Wait
+
+#ifdef Mengenlehreuhr
+ MOVF Stunde, 0
+ CALL BCD2Un5L
+ ANDLW 0xF0
+ MOVWF Spalten
+ MOVF Stunde, 0
+ CALL BCD2Un
+ IORWF Spalten, 1
+#else
+ MOVF Stunde, 0
+ ANDLW 0x3F
+ MOVWF Spalten ; Stunde als nächstes anzeigen
+ MOVF Stati, 0
+ MOVWF tmpL
+ RRF Stati, 0
+ ANDWF tmpL, 1
+ RLF PORTA, 0
+ XORWF tmpL, 1
+ BTFSC tmpL, 6
+ BSF Spalten, 6 ; Funksignal auf ZusatzLED geben
+#endif
+ MOVLW 0x1
+ MOVWF Zeilen
+ CALL Wait
+
+ GOTO Multiplex
+
+; Unterprogramme
+
+Sek ; Sekunde eins weiter stellen
+
+ BTFSC PORTA, 3 ; Tastendruck?
+ CALL Std
+ BTFSC PORTA, 4
+ CALL Min
+
+ INCF Sekunde, 1
+ MOVLW 0x0F ; 0x0F-Teil von Sekunde anschauen
+ ANDWF Sekunde, 0
+ SUBLW 0x0A ; = A ?
+ BTFSC STATUS, Z
+ GOTO Sek10 ; neue 10Sek!
+
+ RETURN ; Sek erfolgreich erhöht
+
+Sek10
+ MOVLW 0x10 ; Sekundenzehner weiter stellen
+ ADDWF Sekunde, 1
+ MOVLW 0xF0 ; Sekundeneiner löschen
+ ANDWF Sekunde, 1
+ MOVLW 0x60 ; = 60 ?
+ SUBWF Sekunde, 0
+ BTFSC STATUS, Z
+ GOTO Min ; neue Minute!
+
+ RETURN ; erfolgreiche neue 10Sek
+
+Min ; Minute eins weiter stellen
+ MOVLW 0x3F
+ ANDWF Stati, 1 ; Funkmin. & Funkstd. zurücksetzen
+ CLRF Sekunde
+ INCF Minute, 1
+ MOVLW 0x0F ; 0x0F-Teil von Minute anschauen
+ ANDWF Minute, 0
+ SUBLW 0x0A ; = A ?
+ BTFSC STATUS, Z
+ GOTO Min10 ; neue 10Min!
+
+ RETURN ; Min erfolgreich erhöht
+
+Min10
+ MOVLW 0x10 ; Minutenzehner weiter stellen
+ ADDWF Minute, 1
+ MOVLW 0xF0 ; Minuteneiner löschen
+ ANDWF Minute, 1
+ MOVLW 0x60 ; = 60 ?
+ SUBWF Minute, 0
+ BTFSC STATUS, Z
+ GOTO Std ; neue Stunde!
+
+ RETURN ; erfolgreiche neue 10Min
+
+Std ; Stunde eins weiter stellen
+ BTFSC Stati, 4 ; Schaltsekunde?
+ INCF Sekunde, 1
+ BCF Stati, 4 ; und rücksetzen
+
+ BTFSS Stati, 2 ; ME(S)Z-Umstellung?
+ GOTO keineSZUmstellung
+ BCF Stati, 2 ; rücksetzen
+ MOVLW 0x08
+ XORWF Stati, 1 ; ME(S)Z-Merker umschalten
+ BTFSC Stati, 3
+ INCF Stunde, 1 ; etwas rabiat, sollte bei einer Umstellung zwischen
+ ; 2 und 3 Uhr aber funktionieren
+ BTFSS Stati, 3
+ DECF Stunde, 1 ; dito
+
+keineSZUmstellung
+
+ CLRF Minute
+ INCF Stunde, 1
+ MOVLW 0x0F ; 0x0F-Teil von Stunde anschauen
+ ANDWF Stunde, 0
+ SUBLW 0x0A ; = A ?
+ BTFSC STATUS, Z
+ GOTO Std10 ; neue 10Std!
+
+ MOVLW 0x24 ; = 24 ?
+ SUBWF Stunde, 0
+ BTFSC STATUS, Z
+ CLRF Stunde ; neuer Tag
+
+ RETURN ; Std erfolgreich erhöht
+
+Std10
+ MOVLW 0x10 ; Stundenzehner weiter stellen
+ ADDWF Stunde, 1
+ MOVLW 0xF0 ; Stundeneiner löschen
+ ANDWF Stunde, 1
+
+ RETURN ; erfolgreiche neue 10Std
+
+Wait
+ MOVF tara, 0
+ ADDWF weiterT1L, 1 ; + (0x00;tara)
+ BTFSC STATUS, C
+ INCF weiterT1H, 1
+
+ MOVLW 0x80
+ ADDWF weiterT1L, 1 ; + (0x00;0x80)
+ BTFSC STATUS, C
+ INCF weiterT1H, 1
+
+ MOVLW 0x0C ; + (0x0C;0x00)
+ ADDWF weiterT1H, 1 ; Solltimerstand setzen (für 300Hz)
+
+WLoop
+ MOVF weiterT1H, 0
+ MOVWF tmpL
+
+ MOVF TMR1L, 0
+ SUBWF weiterT1L, 0
+ BTFSS STATUS, C
+ DECF tmpL, 1
+ MOVF TMR1H, 0
+ SUBWF tmpL, 1
+ BTFSS tmpL, 7 ; weiterT1 - TMR1 >= 0x8000 ("<0"), dann skippen
+
+ GOTO WLoop
+
+ MOVLW 0xF8
+ ANDWF PORTA, 1
+ MOVF Spalten, 0
+ MOVWF PORTB
+ MOVF Zeilen, 0
+ IORWF PORTA, 1
+
+ MOVLW 0xFF
+ BTFSS PORTA, 5
+ MOVLW 0x00
+ XORWF Stati, 0
+ ANDLW 0x01
+ BTFSS STATUS, Z
+ CALL FlankeGefunden
+
+ INCF dreiMSL, 1 ; 3MS zählen
+ BTFSC STATUS, Z
+ INCF dreiMSH, 1 ; 3*256MS zählen
+
+ MOVF weiterDMH, 0 ; weiterDM = dreiMS ?
+ SUBWF dreiMSH, 0
+ BTFSS STATUS, Z
+ RETURN ; nein !
+
+ MOVF weiterDML, 0
+ SUBWF dreiMSL, 0
+ BTFSS STATUS, Z
+ RETURN ; nein !
+ ; ja !
+ CALL setzeWeiterDM ; neue Marke setzen
+ CALL Sek ; neue Sekunde
+
+ RETURN ; Wait
+
+FlankeGefunden
+ MOVF dZFlH, 0
+ SUBWF dreiMSH, 0
+ MOVWF tmpH
+ MOVF dZFlL, 0
+ SUBWF dreiMSL, 0
+ BTFSS STATUS, C
+ DECF tmpH, 1
+ MOVWF tmpL ; tmp:= dreiMS - dzFl
+ BTFSS Stati, 0
+ GOTO warLow
+ BCF Stati, 0 ; war High-Pegel
+ MOVF tmpH, 0
+ BTFSS STATUS, Z ; tmp >= 0x0100 ?
+ GOTO periodenFehler ; Fehler!
+ MOVF tmpL, 0
+ SUBLW 0x4B ; tmp > 75? (entspricht 250 ms)
+ BTFSS STATUS, C
+ GOTO periodenFehler ; Fehler!
+ MOVLW 0x0A ; tmp < 10? (entspricht 33 ms)
+ SUBWF tmpL, 0
+ BTFSS STATUS, C
+ GOTO periodenFehler ; Fehler!
+ MOVLW 0x28
+ SUBWF tmpL, 0 ; tmp >= 40? (entspricht 133 ms) -> empfangenes Bit
+ RRF dat0, 1
+ RRF dat1, 1
+ RRF dat2, 1
+ RRF dat3, 1
+ RRF dat4, 1
+ RRF dat5, 1
+ RRF dat6, 1
+ RRF dat7, 1
+ ; die Pegellänge interessiert bei low nicht
+ RETURN
+warLow
+ BSF Stati, 0 ; war Low-Pegel
+
+ MOVF tmpH, 0
+ BTFSC STATUS, Z ; tmp <= 0x00FF ? (= 0,85 s)
+ GOTO keineNeueFunkMinute
+ SUBLW 0x02
+ BTFSS STATUS, C ; tmp > 0x02FF ? (= 2,56 s)
+ GOTO periodenFehler ; Fehler!
+
+ BTFSS tmpH, 1 ; tmp <= 0x01FF ? (= 1,70 s)
+ GOTO keineNeueFunkMinute
+
+ BTFSS Stati, 1 ; wenn kein Fehler, dann
+ CALL neueFunkMinute
+ CLRF dat0 ; Funk-Werte initialisieren
+ CLRF dat1
+ CLRF dat2
+ CLRF dat3
+ CLRF dat4
+ CLRF dat5
+ CLRF dat6
+ CLRF dat7
+ BSF dat0, 7
+ BCF Stati, 1 ; Fehler zurücksetzen
+keineNeueFunkMinute
+
+ MOVF dreiMSH, 0 ; Überprüfung, ob neue Sekunde eingeleitet werden muss
+ SUBWF weiterDMH, 0
+ MOVWF tmpH
+ MOVF dreiMSL, 0
+ SUBWF weiterDML, 0
+ BTFSS STATUS, C
+ DECF tmpH, 1
+ MOVWF tmpL ; tmp := weiterDM - dreiMS
+
+ MOVF tmpH, 0
+ BTFSS STATUS, Z ; wenn tmp >= 0x0100
+ GOTO keineExtraSek ; dann gab's schon 'ne neue Sekunde vom Quarz
+ MOVF tmpL, 0
+ SUBLW 0x96
+ BTFSS STATUS, C ; wenn tmp >= 0x0096 (= 150)
+ GOTO keineExtraSek ; dann gab's schon 'ne neue Sekunde vom Quarz
+
+ BTFSS Stati,1 ; wenn der Funk spinnt, wird nicht an der Zeit gespielt!
+ CALL Sek
+keineExtraSek
+ BTFSS Stati,1 ; wenn der Funk spinnt, wird nicht an der Zeit gespielt!
+ CALL setzeWeiterDM ; neue Marke setzen
+ GOTO FlankenZeitSpeichern
+
+periodenFehler ; wenn die Pegelperiode nicht stimmt, muss
+ ; trotzdem mindestens die Zeitmarke gesetzt werden
+ BSF Stati, 1
+FlankenZeitSpeichern
+ MOVF dreiMSL, 0
+ MOVWF dZFlL
+ MOVF dreiMSH, 0
+ MOVWF dZFlH
+ RETURN ; FlankeGefunden
+
+neueFunkMinute
+ MOVLW 0x10 ; dat7, 5 ist das 0. Bit in Wikipediazählweise
+ XORWF dat7, 0
+ ANDLW 0x3F
+ BTFSS STATUS, Z ; Anfang nicht korrekt durchgeschoben?
+ RETURN
+
+ BTFSS dat4, 1 ; 20. Bit sollte immer 1 sein!
+ RETURN
+
+ BCF Stati, 2
+ BTFSC dat5, 5 ; 16. Bit (MEZ/MESZ-Umstellung)
+ BSF Stati, 2
+
+ MOVLW 0xC0
+ ANDWF dat5, 0
+ XORLW 0x40
+ BTFSC STATUS, Z ; 17. & 18. Bit -> Sommerzeit!
+ BSF Stati, 3
+ XORLW 0xC0
+ BTFSC STATUS, Z ; 17. & 18. Bit -> keine Sommerzeit!
+ BCF Stati, 3 ; Im Falle von Fehlern werden diese Bits ignoriert!
+
+ BCF Stati, 4
+ BTFSC dat4, 0 ; 19. Bit -> Schaltsekunde am Ende der Stunde?
+ BSF Stati, 4
+
+ RRF dat3, 0
+ MOVWF tmpH
+ RRF dat4, 0
+ MOVWF tmpL ; (dat3;dat4) eins verschoben merken
+ RRF tmpH, 1
+ RRF tmpL, 1 ; noch eins verschieben
+ MOVF tmpL, 0 ; -> bit21..bit28 (Minute mit Parität)
+ MOVWF tmpH ; Parität prüfen:
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; benachbarte Bits XORen
+ MOVF tmpH, 0
+ RRF tmpH, 1
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; Übernächste Nachbarn XORen
+ MOVF tmpH, 0
+ RRF tmpH, 1
+ RRF tmpH, 1
+ RRF tmpH, 1
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; üüübernächste Nachbarn XORen
+ BTFSC tmpH, 0 ; gerade Parität!
+ GOTO Funkminutenfehler
+ MOVF tmpL, 0
+ ANDLW 0x0F
+ SUBLW 0x09
+ BTFSS STATUS, C ; Minuteneiner >9 ?
+ GOTO Funkminutenfehler
+ MOVF tmpL, 0
+ ANDLW 0x70
+ SUBLW 0x50
+ BTFSS STATUS, C ; Minutenzehner >5 ?
+ GOTO Funkminutenfehler
+ MOVF tmpL, 0
+ ANDLW 0x7F ; Parität löschen
+ MOVWF Minute ; Minute setzen
+ CLRF Sekunde ; Sekunde auf 0
+ CALL setzeWeiterDM ; Sekunde auf ,0
+ BSF Stati, 6
+Funkminutenfehler
+
+ RRF dat2, 0
+ RRF dat3, 0
+ MOVWF tmpL ; (dat3;dat4) eins verschoben merken
+ RRF tmpL, 0 ; noch eins verschieben
+ ANDLW 0x7F ; falsche Bits löschen
+ MOVWF tmpL ; -> bit29..bit25 (Stunde mit Parität)
+ MOVWF tmpH ; Parität prüfen:
+ MOVWF tmpH
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; benachbarte Bits XORen
+ MOVF tmpH, 0
+ RRF tmpH, 1
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; Übernächste Nachbarn XORen
+ MOVF tmpH, 0
+ RRF tmpH, 1
+ RRF tmpH, 1
+ RRF tmpH, 1
+ RRF tmpH, 1
+ XORWF tmpH, 1 ; üüübernächste Nachbarn XORen
+ BTFSC tmpH, 0 ; gerade Parität!
+ GOTO Funkstundenfehler
+ MOVF tmpL, 0
+ ANDLW 0x0F
+ SUBLW 0x09
+ BTFSS STATUS, C ; Stundeneiner >9 ?
+ GOTO Funkstundenfehler
+ MOVF tmpL, 0
+ ANDLW 0x30
+ SUBLW 0x20
+ BTFSS STATUS, C ; Stundenzehner >2 ?
+ GOTO Funkstundenfehler
+ MOVF tmpL, 0
+ ANDLW 0x3F
+ SUBLW 0x23
+ BTFSS STATUS, C ; Stunde >23 ? (ohne Einerüberprüfung!)
+ GOTO Funkstundenfehler
+ MOVF tmpL, 0
+ ANDLW 0x3F
+ MOVWF Stunde ; Stunde setzen
+ BSF Stati, 7
+Funkstundenfehler
+
+ RETURN ; neueFunkMinute
+
+setzeWeiterDM ; setzt weiterDM-Zähler auf nächste 1/300s-Zeit
+ MOVLW 0x01
+ ADDWF dreiMSH, 0
+ MOVWF weiterDMH ; high-Teil + 1
+ MOVLW 0x2C
+ ADDWF dreiMSL, 0 ; low-Teil + 44
+ BTFSC STATUS, C
+ INCF weiterDMH, 1 ; Übertrag
+ MOVWF weiterDML
+ ; -> /300
+
+ RETURN ; setzeWeiterDM
+
+#ifdef Mengenlehreuhr
+BCD2Un5L ; bcd zu unär (5er, low-teil)
+ SUBLW 0x09
+ SUBLW 0x04
+ BTFSC STATUS, DC ; 5er an?
+ GOTO BCD2Un5LUng
+ ADDLW 0x05
+ ANDLW 0xF0
+ BTFSC STATUS, Z ; =0 ?
+ RETLW 0x00
+ XORLW 0x10
+ BTFSC STATUS, Z ; =10 ?
+ RETLW 0xC0
+ XORLW 0x30
+ BTFSC STATUS, Z ; =20 ?
+ RETLW 0xF0
+ XORLW 0x10
+ BTFSC STATUS, Z ; =30 ?
+ RETLW 0xFC
+ RETLW 0xFF ; >=40
+BCD2Un5LUng ; 5er muss gesetzt werden
+ ANDLW 0xF0
+ BTFSC STATUS, Z ; =5 ?
+ RETLW 0x80
+ XORLW 0x10
+ BTFSC STATUS, Z ; =15 ?
+ RETLW 0xE0
+ XORLW 0x30
+ BTFSC STATUS, Z ; =25 ?
+ RETLW 0xF8
+ XORLW 0x10
+ BTFSC STATUS, Z ; =35 ?
+ RETLW 0xFE
+ RETLW 0xFF ; >=40
+
+BCD2Un5H ; bcd zu unär (5er, high-teil)
+ SUBLW 0x09
+ SUBLW 0x04
+ BTFSC STATUS, DC ; 5er an?
+ GOTO BCD2Un5HUng
+ ADDLW 0x05
+ ANDLW 0xF0
+ XORLW 0x50
+ BTFSC STATUS, Z ; =50 ?
+ RETLW 0x06
+ RETLW 0x00 ; <=40
+BCD2Un5HUng ; 5er muss gesetzt werden
+ ANDLW 0xF0
+ XORLW 0x40
+ BTFSC STATUS, Z ; =45 ?
+ RETLW 0x04
+ XORLW 0x10
+ BTFSC STATUS, Z ; =55 ?
+ RETLW 0x07
+ RETLW 0x00 ; <=40
+
+BCD2Un ; bcd zu unär (1er)
+ ANDLW 0x0F
+ BTFSC STATUS, Z ; =0 ?
+ RETLW 0x00
+ XORLW 0x01
+ BTFSC STATUS, Z ; =1 ?
+ RETLW 0x08
+ XORLW 0x03
+ BTFSC STATUS, Z ; =2 ?
+ RETLW 0x0C
+ XORLW 0x01
+ BTFSC STATUS, Z ; =3 ?
+ RETLW 0x0E
+ XORLW 0x07
+ BTFSC STATUS, Z ; =4 ?
+ RETLW 0x0F
+ XORLW 0x01
+ BTFSC STATUS, Z ; =5 ?
+ RETLW 0x00
+ XORLW 0x03
+ BTFSC STATUS, Z ; =6 ?
+ RETLW 0x08
+ XORLW 0x01
+ BTFSC STATUS, Z ; =7 ?
+ RETLW 0x0C
+ XORLW 0x0F
+ BTFSC STATUS, Z ; =8 ?
+ RETLW 0x0E
+ RETLW 0x0F
+
+#endif
+
+ END
diff --git a/ERICH_VER_0.1_BCD.HEX b/ERICH_VER_0.1_BCD.HEX
new file mode 100644
index 0000000..ae2fbbb
--- /dev/null
+++ b/ERICH_VER_0.1_BCD.HEX
@@ -0,0 +1,51 @@
+:020000040000FA
+:100000000228090083120313A001A101A2011230EA
+:10001000A0003430A1005630A200B101B201B301FA
+:10002000B401B501B601B701B801A401A3012C3098
+:10003000A5000130A600A701A801AC01AC148530D1
+:10004000A900850186018701831606309F0038309C
+:100050008500860187010C10831201309000220870
+:10006000AF000430B0008C202108AF000230B00097
+:100070008C2020083F39AF002C08AD002C0CAD05BA
+:10008000050DAD062D1B2F170130B0008C202F2839
+:1000900085196F20051A5C20A20A0F3022050A3C40
+:1000A0000319532808001030A207F030A205603071
+:1000B000220203195C2808003F30AC05A201A10A06
+:1000C0000F3021050A3C0319662808001030A107EB
+:1000D000F030A1056030210203196F2808002C1AA6
+:1000E000A20A2C122C1D7B282C110830AC06AC194E
+:1000F000A00AAC1DA003A101A00A0F3020050A3CF4
+:1001000003198728243020020319A00108001030A9
+:10011000A007F030A00508002908A7070318A80ABF
+:100120008030A7070318A80A0C30A8072808AD00DC
+:100130000E082702031CAD030F08AD02AD1F962861
+:10014000F83085052F08860030088504FF30851EAD
+:1001500000302C060139031DBB20A30A0319A40A91
+:1001600026082402031D080025082302031D080099
+:100170007021482008002B082402AE002A08230220
+:10018000031CAE03AD002C1CDC282C102E08031D14
+:1001900005292D084B3C031C05290A302D02031CA0
+:1001A000052928302D02B10CB20CB30CB40CB50CDF
+:1001B000B60CB70CB80C08002C142E080319F12843
+:1001C000023C031C0529AE1CF128AC1C0B21B1011B
+:1001D000B201B301B401B501B601B701B801B1175D
+:1001E000AC1024082602AE0023082502031CAE032F
+:1001F000AD002E08031D02292D08963C031C022980
+:10020000AC1C4820AC1C70210629AC142308AA00A1
+:100210002408AB000800103038063F39031D0800E1
+:10022000B51C08002C11B61A2C15C0303605403A02
+:100230000319AC15C03A0319AC112C1235182C1641
+:10024000340CAE00350CAD00AE0CAD0C2D08AE007C
+:10025000AE0CAE062E08AE0CAE0CAE062E08AE0CE2
+:10026000AE0CAE0CAE0CAE062E1846292D080F397A
+:10027000093C031C46292D087039503C031C4629B3
+:100280002D087F39A100A20170212C17330C340CEA
+:10029000AD002D0C7F39AD00AE00AE00AE0CAE0649
+:1002A0002E08AE0CAE0CAE062E08AE0CAE0CAE0C8C
+:1002B000AE0CAE062E186F292D080F39093C031C11
+:1002C0006F292D083039203C031C6F292D083F3938
+:1002D000233C031C6F292D083F39A000AC170800F0
+:1002E00001302407A6002C3023070318A60AA50016
+:0202F000080004
+:02400E00393B3C
+:00000001FF
diff --git a/ERICH_VER_0.1_MEN.HEX b/ERICH_VER_0.1_MEN.HEX
new file mode 100644
index 0000000..eda9f9f
--- /dev/null
+++ b/ERICH_VER_0.1_MEN.HEX
@@ -0,0 +1,62 @@
+:020000040000FA
+:100000000228090083120313A001A101A2011230EA
+:10001000A0003430A1005630A200B101B201B301FA
+:10002000B401B501B601B701B801A401A3012C3098
+:10003000A5000130A600A701A801AC01AC148530D1
+:10004000A900850186018701831606309F0038309C
+:100050008500860187010C10831201309000210871
+:10006000B921AF00AF0E2108A721AF042C08AD00C5
+:100070002C0CAD05AC182D13050DAD062D1BAF15C1
+:1000800043282218AF150430B0009B202108882196
+:10009000AF000230B0009B2020088821F039AF006B
+:1000A0002008B921AF040130B0009B202F2885190A
+:1000B0007E20051A6B20A20A0F3022050A3C031984
+:1000C000622808001030A207F030A205603022023A
+:1000D00003196B2808003F30AC05A201A10A0F30BC
+:1000E00021050A3C0319752808001030A107F030DB
+:1000F000A1056030210203197E2808002C1AA20AEB
+:100100002C122C1D8A282C110830AC06AC19A00A20
+:10011000AC1DA003A101A00A0F3020050A3C031961
+:100120009628243020020319A00108001030A007EF
+:10013000F030A00508002908A7070318A80A803096
+:10014000A7070318A80A0C30A8072808AD000E0856
+:100150002702031CAD030F08AD02AD1FA528F83020
+:1001600085052F08860030088504FF30851E003085
+:100170002C060139031DCA20A30A0319A40A260864
+:100180002402031D080025082302031D08007F2107
+:10019000572008002B082402AE002A082302031C63
+:1001A000AE03AD002C1CEB282C102E08031D1429C7
+:1001B0002D084B3C031C14290A302D02031C142962
+:1001C00028302D02B10CB20CB30CB40CB50CB60C2B
+:1001D000B70CB80C08002C142E0803190029023C97
+:1001E000031C1429AE1C0029AC1C1A21B101B20158
+:1001F000B301B401B501B601B701B801B117AC1034
+:1002000024082602AE0023082502031CAE03AD001D
+:100210002E08031D11292D08963C031C1129AC1C26
+:100220005720AC1C7F211529AC142308AA002408F0
+:10023000AB000800103038063F39031D0800B51C1C
+:1002400008002C11B61A2C15C0303605403A031997
+:10025000AC15C03A0319AC112C1235182C16340CFD
+:10026000AE00350CAD00AE0CAD0C2D08AE00AE0CE2
+:10027000AE062E08AE0CAE0CAE062E08AE0CAE0CC2
+:10028000AE0CAE0CAE062E1855292D080F39093CC0
+:10029000031C55292D087039503C031C55292D0885
+:1002A0007F39A100A2017F212C17330C340CAD0043
+:1002B0002D0C7F39AD00AE00AE00AE0CAE062E08A0
+:1002C000AE0CAE0CAE062E08AE0CAE0CAE0CAE0CE8
+:1002D000AE062E187E292D080F39093C031C7E29F5
+:1002E0002D083039203C031C7E292D083F39233C42
+:1002F000031C7E292D083F39A000AC1708000130EF
+:100300002407A6002C3023070318A60AA50008001E
+:10031000093C043C83189A29053EF039031900343E
+:10032000103A0319C034303A0319F034103A031963
+:10033000FC34FF34F03903198034103A0319E034E7
+:10034000303A0319F834103A0319FE34FF34093CEB
+:10035000043C8318B129053EF039503A031906349C
+:100360000034F039403A03190434103A03190734C1
+:1003700000340F3903190034013A03190834033AE1
+:1003800003190C34013A03190E34073A03190F34D8
+:10039000013A03190034033A03190834013A0319E6
+:0A03A0000C340F3A03190E340F3429
+:02400E00393B3C
+:00000001FF
diff --git a/binTime.h b/binTime.h
deleted file mode 100644
index 36a0128..0000000
--- a/binTime.h
+++ /dev/null
@@ -1,330 +0,0 @@
-/*****************************************************/
-/* Bausatz BIN_Hourglass ver.1.0 *********************/
-/* binTime.h *****************************************/
-/* Pollin Electronic GmbH ****************************/
-/* 85104 Pförring ************************************/
-/* www.pollin.de *************************************/
-/*****************************************************/
-/* Author: Leonhard Hesse ****************************/
-/*****************************************************/
-
-#ifndef BINTIME_H_
-#define BINTIME_H_
-
-#include <avr/io.h>
-#include <util/delay.h>
-
-
-void Time0() {
- PORTB |= (1 << PB0);
- PORTB |= (1 << PB1);
- PORTB |= (1 << PB2);
- PORTB |= (1 << PB3);
- PORTB |= (1 << PB4);
- PORTB |= (1 << PB5);
- PORTB |= (1 << PB6);
- PORTB |= (1 << PB7);
-}
-void Time1() {
- PORTB &= ~(1 << PB0);
-}
-void Time2() {
- PORTB &= ~(1 << PB1);
-}
-void Time3() {
- PORTB &= ~(1 << PB0);
- PORTB &= ~(1 << PB1);
-}
-void Time4() {
- PORTB &= ~(1 << PB2);
-}
-void Time5() {
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time6() {
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time7() {
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time8() {
- PORTB &= ~(1 << PB3);
-}
-void Time9() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB0);
-}
-void Time10() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
-}
-void Time11() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time12() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
-}
-void Time13() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time14() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time15() {
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-
-void Time16() {
- PORTB &= ~(1 << PB4);
-}
-void Time17() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB0);
-}
-void Time18() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB1);
-}
-void Time19() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time20() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
-}
-void Time21() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time22() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time23() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time24() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
-}
-void Time25() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB0);
-}
-void Time26() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
-}
-void Time27() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time28() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
-}
-void Time29() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time30() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time31() {
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time32() {
- PORTB &= ~(1 << PB5);
-}
-void Time33() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB0);
-}
-void Time34() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB1);
-}
-void Time35() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time36() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB2);
-}
-void Time37() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time38() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time39() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time40() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
-}
-void Time41() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB0);
-}
-void Time42() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
-}
-void Time43() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time44() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
-}
-void Time45() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time46() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time47() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time48() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
-}
-void Time49() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB0);
-}
-void Time50() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB1);
-}
-void Time51() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time52() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
-}
-void Time53() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB0);
-}
-void Time54() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
-}
-void Time55() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time56() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
-}
-void Time57() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB0);
-}
-void Time58() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
-}
-void Time59() {
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB0);
-}
-void Time255() {
- PORTB &= ~(1 << PB0);
- PORTB &= ~(1 << PB1);
- PORTB &= ~(1 << PB2);
- PORTB &= ~(1 << PB3);
- PORTB &= ~(1 << PB4);
- PORTB &= ~(1 << PB5);
- PORTB &= ~(1 << PB6);
- PORTB &= ~(1 << PB7);
-}
-
-#endif /* BINTIME_H_ */
diff --git a/main.c.c b/main.c.c
deleted file mode 100644
index 9ab0d74..0000000
--- a/main.c.c
+++ /dev/null
@@ -1,174 +0,0 @@
-/****************************************************************************/
-/* Bausatz BIN-Hourglass ver.1.0 ********************************************/
-/* main.c *******************************************************************/
-/* Pollin Electronic GmbH ***************************************************/
-/* 85104 Pförring ***********************************************************/
-/* www.pollin.de ************************************************************/
-/****************************************************************************/
-/* Author: Leonhard Hesse ***************************************************/
-/****************************************************************************/
-
-#define F_CPU 2000000UL
-
-#include <avr/io.h>
-#include <avr/sleep.h>
-#include <avr/interrupt.h>
-#include <util/delay.h>
-#include "binTime.h"
-#include "setTime.h"
-
-volatile uint8_t tasterZaeler = 4;
-volatile uint16_t clockDelay = 0;
-
-/****************************************************************************/
-/* interrupt routine user button 1 ******************************************/
-/****************************************************************************/
-
-ISR(INT0_vect) {
- if (tasterZaeler >= 2) {
- tasterZaeler = 1;
- hour++;
- clockDelay = 0;
- _delay_ms(200);
- }
-}
-
-/****************************************************************************/
-/* interrupt routine user button 2 ******************************************/
-/****************************************************************************/
-
-ISR(INT1_vect) {
- if (tasterZaeler >= 2) {
- tasterZaeler = 1;
- minute++;
- clockDelay = 0;
- _delay_ms(200);
- }
-}
-
-/****************************************************************************/
-/* interrupt routine for 16-Bit-Timer to count seconds **********************/
-/****************************************************************************/
-
-ISR (TIMER1_COMPA_vect) {
- second++;
-}
-
-/****************************************************************************/
-/* implement methods to light the LEDs for ca. 0,1 ms ***********************/
-/****************************************************************************/
-
-void showHour() {
- for (int i = 0; i < 200; i++) {
- hourOn();
- }
- hourOff();
-}
-void showMinute() {
- for (int i = 0; i < 200; i++) {
- minuteOn();
- }
- minuteOff();
-}
-void showSecond() {
- for (int i = 0; i < 200; i++) {
- secondOn();
- }
- secondOff();
-}
-void showTime() {
- showHour();
- showMinute();
- showSecond();
-}
-
-/****************************************************************************/
-/* implement methods to switch off the LEDs for ca. 0,1 ms ******************/
-/****************************************************************************/
-void hideHour() {
- for (int i = 0; i < 200; i++) {
- hourOff();
- }
-}
-void hideMinute() {
- for (int i = 0; i < 200; i++) {
- minuteOff();
- }
-}
-void hideSecond() {
- for (int i = 0; i < 200; i++) {
- secondOff();
- }
-}
-void hideTime() {
- hideHour();
- hideMinute();
- hideSecond();
-}
-
-int main(void) {
-
- /************************************************************************/
- /* initialize ports and external interrupts *****************************/
- /************************************************************************/
-
- DDRB |= (1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4)
- | (1 << PB5) | (1 << PB6) | (1 << PB7);
- DDRD |= (1 << PD4) | (1 << PD5) | (1 << PD6);
- DDRD &= ~((1 << PD0) | (1 << PD1));
- PORTD |= (1 << PD2) | (1 << PD3);
- GIMSK |= (1 << INT0) | (1 << INT1);
- MCUCR |= (1 << ISC11) | (1 << ISC10);
- sei();
-
- PORTB |= (1 << PD4) | (1 << PD5) | (1 << PD6);
- PORTB |= ((1 << PB0) | (1 << PB1) | (1 << PB2) | (1 << PB3) | (1 << PB4)
- | (1 << PB5) | (1 << PB6) | (1 << PB7));
-
- for (;;) {
-
- /********************************************************************/
- /* show default time for ca. 0,5s and switch off LEDs for ca. 0,5s **/
- /********************************************************************/
-
- if (tasterZaeler == 4) {
- defaultTime();
- for (int t = 0; t < 200; t++) {
- showTime();
- }
- for (int t = 0; t < 200; t++) {
- hideTime();
- }
- }
-
- /********************************************************************/
- /* start clock after 10s without user input *************************/
- /* if there is an user input stop clock and reset second ************/
- /********************************************************************/
-
- if (tasterZaeler >= 1) {
- if (tasterZaeler <= 2) {
- clockDelay++;
- second = 0;
- TIMSK &= ~(1 << OCIE1A);
- tasterZaeler = 2;
- }
- }
- if (clockDelay == 4000) {
- TCCR1B = ((1 << WGM12) | (1 << CS10) | (1 << CS11));
- TIMSK = (1 << OCIE1A);
- OCR1A = 31250;
- clockDelay = 0;
- tasterZaeler = 3;
- }
- resetTime();
- setSecond();
- showSecond();
- resetTime();
- setMinute();
- showMinute();
- resetTime();
- setHour();
- showHour();
- }
-}
diff --git a/setTime.h b/setTime.h
deleted file mode 100644
index b237259..0000000
--- a/setTime.h
+++ /dev/null
@@ -1,505 +0,0 @@
-/*****************************************************/
-/* Bausatz BIN_Hourglass ver.1.0 *********************/
-/* setTime.h *****************************************/
-/* Pollin Electronic GmbH ****************************/
-/* 85104 Pförring ************************************/
-/* www.pollin.de *************************************/
-/*****************************************************/
-/* Author: Leonhard Hesse ****************************/
-/*****************************************************/
-
-#ifndef SETTIME_H_
-#define SETTIME_H_
-
-#include <avr/io.h>
-#include <util/delay.h>
-#include "binTime.h"
-
-volatile uint8_t hour = 0;
-volatile uint8_t minute = 0;
-volatile uint8_t second = 0;
-
-void hourOn() {
- PORTD &= ~(1 << PD4);
-}
-void hourOff() {
- PORTD |= (1 << PD4);
-}
-void minuteOn() {
- PORTD &= ~(1 << PD5);
-}
-void minuteOff() {
- PORTD |= (1 << PD5);
-}
-void secondOn() {
- PORTD &= ~(1 << PD6);
-}
-void secondOff() {
- PORTD |= (1 << PD6);
-}
-void resetTime() {
- Time0();
-}
-void defaultTime() {
- Time255();
-}
-
-void setHour() {
- switch (hour) {
- case 0:
- Time0();
- break;
- case 1:
- Time1();
- break;
- case 2:
- Time2();
- break;
- case 3:
- Time3();
- break;
- case 4:
- Time4();
- break;
- case 5:
- Time5();
- break;
- case 6:
- Time6();
- break;
- case 7:
- Time7();
- break;
- case 8:
- Time8();
- break;
- case 9:
- Time9();
- break;
- case 10:
- Time10();
- break;
- case 11:
- Time11();
- break;
- case 12:
- Time12();
- break;
- case 13:
- Time13();
- break;
- case 14:
- Time14();
- break;
- case 15:
- Time15();
- break;
- case 16:
- Time16();
- break;
- case 17:
- Time17();
- break;
- case 18:
- Time18();
- break;
- case 19:
- Time19();
- break;
- case 20:
- Time20();
- break;
- case 21:
- Time21();
- break;
- case 22:
- Time22();
- break;
- case 23:
- Time23();
- break;
- }
- if (hour > 23) {
- hour = 0;
- }
-}
-
-void setMinute() {
- switch (minute) {
- case 0:
- Time0();
- break;
- case 1:
- Time1();
- break;
- case 2:
- Time2();
- break;
- case 3:
- Time3();
- break;
- case 4:
- Time4();
- break;
- case 5:
- Time5();
- break;
- case 6:
- Time6();
- break;
- case 7:
- Time7();
- break;
- case 8:
- Time8();
- break;
- case 9:
- Time9();
- break;
- case 10:
- Time10();
- break;
- case 11:
- Time11();
- break;
- case 12:
- Time12();
- break;
- case 13:
- Time13();
- break;
- case 14:
- Time14();
- break;
- case 15:
- Time15();
- break;
- case 16:
- Time16();
- break;
- case 17:
- Time17();
- break;
- case 18:
- Time18();
- break;
- case 19:
- Time19();
- break;
- case 20:
- Time20();
- break;
- case 21:
- Time21();
- break;
- case 22:
- Time22();
- break;
- case 23:
- Time23();
- break;
- case 24:
- Time24();
- break;
- case 25:
- Time25();
- break;
- case 26:
- Time26();
- break;
- case 27:
- Time27();
- break;
- case 28:
- Time28();
- break;
- case 29:
- Time29();
- break;
- case 30:
- Time30();
- break;
- case 31:
- Time31();
- break;
- case 32:
- Time32();
- break;
- case 33:
- Time33();
- break;
- case 34:
- Time34();
- break;
- case 35:
- Time35();
- break;
- case 36:
- Time36();
- break;
- case 37:
- Time37();
- break;
- case 38:
- Time38();
- break;
- case 39:
- Time39();
- break;
- case 40:
- Time40();
- break;
- case 41:
- Time41();
- break;
- case 42:
- Time42();
- break;
- case 43:
- Time43();
- break;
- case 44:
- Time44();
- break;
- case 45:
- Time45();
- break;
- case 46:
- Time46();
- break;
- case 47:
- Time47();
- break;
- case 48:
- Time48();
- break;
- case 49:
- Time49();
- break;
- case 50:
- Time50();
- break;
- case 51:
- Time51();
- break;
- case 52:
- Time52();
- break;
- case 53:
- Time53();
- break;
- case 54:
- Time54();
- break;
- case 55:
- Time55();
- break;
- case 56:
- Time56();
- break;
- case 57:
- Time57();
- break;
- case 58:
- Time58();
- break;
- case 59:
- Time59();
- break;
- }
- if (minute > 59){
- hour++;
- minute = 0;
- }
-}
-
-void setSecond() {
- switch (second) {
- case 0:
- Time0();
- break;
- case 1:
- Time1();
- break;
- case 2:
- Time2();
- break;
- case 3:
- Time3();
- break;
- case 4:
- Time4();
- break;
- case 5:
- Time5();
- break;
- case 6:
- Time6();
- break;
- case 7:
- Time7();
- break;
- case 8:
- Time8();
- break;
- case 9:
- Time9();
- break;
- case 10:
- Time10();
- break;
- case 11:
- Time11();
- break;
- case 12:
- Time12();
- break;
- case 13:
- Time13();
- break;
- case 14:
- Time14();
- break;
- case 15:
- Time15();
- break;
- case 16:
- Time16();
- break;
- case 17:
- Time17();
- break;
- case 18:
- Time18();
- break;
- case 19:
- Time19();
- break;
- case 20:
- Time20();
- break;
- case 21:
- Time21();
- break;
- case 22:
- Time22();
- break;
- case 23:
- Time23();
- break;
- case 24:
- Time24();
- break;
- case 25:
- Time25();
- break;
- case 26:
- Time26();
- break;
- case 27:
- Time27();
- break;
- case 28:
- Time28();
- break;
- case 29:
- Time29();
- break;
- case 30:
- Time30();
- break;
- case 31:
- Time31();
- break;
- case 32:
- Time32();
- break;
- case 33:
- Time33();
- break;
- case 34:
- Time34();
- break;
- case 35:
- Time35();
- break;
- case 36:
- Time36();
- break;
- case 37:
- Time37();
- break;
- case 38:
- Time38();
- break;
- case 39:
- Time39();
- break;
- case 40:
- Time40();
- break;
- case 41:
- Time41();
- break;
- case 42:
- Time42();
- break;
- case 43:
- Time43();
- break;
- case 44:
- Time44();
- break;
- case 45:
- Time45();
- break;
- case 46:
- Time46();
- break;
- case 47:
- Time47();
- break;
- case 48:
- Time48();
- break;
- case 49:
- Time49();
- break;
- case 50:
- Time50();
- break;
- case 51:
- Time51();
- break;
- case 52:
- Time52();
- break;
- case 53:
- Time53();
- break;
- case 54:
- Time54();
- break;
- case 55:
- Time55();
- break;
- case 56:
- Time56();
- break;
- case 57:
- Time57();
- break;
- case 58:
- Time58();
- break;
- case 59:
- Time59();
- break;
- }
- if (second > 59){
- minute++;
- second = 0;
- }
-}
-
-#endif /* SETTIME_H_ */