diff options
Diffstat (limited to 'main.c.c')
-rw-r--r-- | main.c.c | 174 |
1 files changed, 0 insertions, 174 deletions
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(); - } -} |