242 lines
7.6 KiB
C
242 lines
7.6 KiB
C
/**************************************************************************
|
|
* *
|
|
* W O R D C L O C K - A clock that tells the time using words. *
|
|
* *
|
|
* GERMAN Language Support Functions *
|
|
* *
|
|
* Copyright (C) 2009,2010,2011 Doug Jackson (doug@doughq.com) *
|
|
* *
|
|
***************************************************************************
|
|
* *
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
* it under the terms of the GNU General Public License as published by *
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
* (at your option) any later version. *
|
|
* *
|
|
* This program is distributed in the hope that it will be useful, *
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
|
* GNU General Public License for more details. *
|
|
* *
|
|
* You should have received a copy of the GNU General Public License *
|
|
* along with this program; if not, write to the Free Software *
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
|
|
* MA 02111-1307 USA *
|
|
* *
|
|
***************************************************************************
|
|
*
|
|
* Revision History
|
|
* 20110315 DRJ Split off from Wordclock.pde to simplify modifying
|
|
* code for multiple languages
|
|
*/
|
|
|
|
|
|
|
|
// Display output pin assignments
|
|
#define ZENH Display1=Display1 | (1<<1); Serial.print("zenh ");
|
|
#define HALB Display1=Display1 | (1<<2); Serial.print("halb ");
|
|
#define NACH Display1=Display1 | (1<<3); Serial.print("nach ");
|
|
#define DREI Display1=Display1 | (1<<4); Serial.print("drei ");
|
|
#define ESIST Display1=Display1 | (1<<5); Serial.print("Es ist ");
|
|
#define ZWANZIG Display1=Display1 | (1<<6); Serial.print("zwanzig ");
|
|
#define VOR Display1=Display1 | (1<<7); Serial.print("vor ");
|
|
|
|
#define ZWEI Display2=Display2 | (1<<0); Serial.print("zwei ");
|
|
#define SECHS Display2=Display2 | (1<<1); Serial.print("sechs ");
|
|
#define ZWOLF Display2=Display2 | (1<<2); Serial.print("zwolf ");
|
|
#define HFUNF Display2=Display2 | (1<<3); Serial.print("funf ");
|
|
#define SIEBEN Display2=Display2 | (1<<4); Serial.print("sieben ");
|
|
#define UHR Display2=Display2 | (1<<5); Serial.print("uhr ");
|
|
#define ONE Display2=Display2 | (1<<6); Serial.print("ein ");
|
|
#define VIERTEL Display2=Display2 | (1<<7); Serial.print("viertel ");
|
|
|
|
#define ACHT Display3=Display3 | (1<<0); Serial.print("acht ");
|
|
#define MFUNF Display3=Display3 | (1<<1); Serial.print("funf ");
|
|
#define ELEVEN Display3=Display3 | (1<<3); Serial.print("elf ");
|
|
#define HZENH Display3=Display3 | (1<<4); Serial.print("zenh ");
|
|
#define NEUN Display3=Display3 | (1<<5); Serial.print("neun ");
|
|
#define VIER Display3=Display3 | (1<<6); Serial.print("vier ");
|
|
|
|
#define LED1 Led1=1; Serial.print("MINLED 1 ")
|
|
#define LED2 Led2=1; Serial.print("2 ")
|
|
#define LED3 Led3=1; Serial.print("3 ")
|
|
#define LED4 Led4=1; Serial.print("4 ")
|
|
|
|
|
|
|
|
|
|
|
|
void selftest(void){
|
|
Serial.print("Selftest started ");
|
|
// start by clearing the display to a known state
|
|
ledsoff(); ESIST; delay(500);
|
|
ledsoff(); MFUNF; delay(500);
|
|
ledsoff(); ZENH; delay(500);
|
|
ledsoff(); VIERTEL; delay(500);
|
|
ledsoff(); ZWANZIG; delay(500);
|
|
ledsoff(); NACH; delay(500);
|
|
ledsoff(); VOR; delay(500);
|
|
ledsoff(); HALB; delay(500);
|
|
ledsoff(); ELEVEN; ; delay(500);
|
|
ledsoff(); HFUNF; delay(500);
|
|
ledsoff(); ZWEI; delay(500);
|
|
ledsoff(); ONE; delay(500);
|
|
ledsoff(); VIER; delay(500);
|
|
ledsoff(); HZENH; delay(500);
|
|
ledsoff(); ZWOLF; delay(500);
|
|
ledsoff(); DREI; delay(500);
|
|
ledsoff(); NEUN; delay(500);
|
|
ledsoff(); ACHT; delay(500);
|
|
ledsoff(); SECHS; delay(500);
|
|
ledsoff(); SIEBEN; delay(500);
|
|
ledsoff(); UHR; delay(500);
|
|
ledsoff(); LED1; delay(500);
|
|
ledsoff(); LED2; delay(500);
|
|
ledsoff(); LED3; delay(500);
|
|
ledsoff(); LED4; delay(500);
|
|
Serial.println(" .. ok");
|
|
|
|
for(int i=0; i<5; i++)
|
|
{
|
|
Display1=255; Display2=255; Display3=255; delay(500);
|
|
ledsoff(); delay(500);
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void displaytime(void){
|
|
|
|
// start by clearing the display to a known state
|
|
ledsoff();
|
|
|
|
// Now, turn on the "It is" leds
|
|
ESIST;
|
|
|
|
|
|
// now we display the appropriate minute counter
|
|
if ((minute>4) && (minute<10)) { MFUNF; NACH; }
|
|
if ((minute>9) && (minute<15)) { ZENH; NACH; }
|
|
if ((minute>14) && (minute<20)) { VIERTEL; NACH; }
|
|
if ((minute>19) && (minute<25)) { ZWANZIG; NACH; }
|
|
if ((minute>24) && (minute<30)) { MFUNF; VOR; HALB; }
|
|
if ((minute>29) && (minute<35)) { HALB;}
|
|
if ((minute>34) && (minute<40)) { MFUNF; NACH; HALB; }
|
|
if ((minute>39) && (minute<45)) { ZWANZIG; VOR; }
|
|
if ((minute>44) && (minute<50)) { VIERTEL; VOR; }
|
|
if ((minute>49) && (minute<55)) { ZENH; VOR; }
|
|
if (minute>54) { MFUNF; VOR; }
|
|
|
|
|
|
|
|
if ((minute <5))
|
|
{
|
|
switch (hour) {
|
|
case 1:
|
|
case 13: ONE; break;
|
|
case 2:
|
|
case 14: ZWEI; break;
|
|
case 3:
|
|
case 15: DREI; break;
|
|
case 4:
|
|
case 16: VIER; break;
|
|
case 5:
|
|
case 17: HFUNF; break;
|
|
case 6:
|
|
case 18: SECHS; break;
|
|
case 7:
|
|
case 19: SIEBEN; break;
|
|
case 8:
|
|
case 20: ACHT; break;
|
|
case 9:
|
|
case 21: NEUN; break;
|
|
case 10:
|
|
case 22: HZENH; break;
|
|
case 11:
|
|
case 23: ELEVEN; break;
|
|
case 0:
|
|
case 12:
|
|
case 24: ZWOLF; break;
|
|
}
|
|
UHR;
|
|
}
|
|
else
|
|
if ((minute < 25) && (minute >4))
|
|
{
|
|
switch (hour) {
|
|
case 1:
|
|
case 13: ONE; break;
|
|
case 2:
|
|
case 14: ZWEI; break;
|
|
case 3:
|
|
case 15: DREI; break;
|
|
case 4:
|
|
case 16: VIER; break;
|
|
case 5:
|
|
case 17: HFUNF; break;
|
|
case 6:
|
|
case 18: SECHS; break;
|
|
case 7:
|
|
case 19: SIEBEN; break;
|
|
case 8:
|
|
case 20: ACHT; break;
|
|
case 9:
|
|
case 21: NEUN; break;
|
|
case 10:
|
|
case 22: HZENH; break;
|
|
case 11:
|
|
case 23: ELEVEN; break;
|
|
case 0:
|
|
case 12:
|
|
case 24: ZWOLF; break;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
// if we are greater than 34 minutes NACH the hour then display
|
|
// the next hour
|
|
|
|
switch (hour) {
|
|
case 1:
|
|
case 13: ZWEI; break;
|
|
case 14:
|
|
case 2: DREI; break;
|
|
case 15:
|
|
case 3: VIER; break;
|
|
case 4:
|
|
case 16: HFUNF; break;
|
|
case 5:
|
|
case 17: SECHS; break;
|
|
case 6:
|
|
case 18: SIEBEN; break;
|
|
case 7:
|
|
case 19: ACHT; break;
|
|
case 8:
|
|
case 20: NEUN; break;
|
|
case 9:
|
|
case 21: HZENH; break;
|
|
case 10:
|
|
case 22: ELEVEN; break;
|
|
case 11:
|
|
case 23: ZWOLF; break;
|
|
case 0:
|
|
case 12:
|
|
case 24: ONE; break;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
// now we can illuminate the extra minute LEDs
|
|
|
|
if ((minute-(minute/5)*5)==1) { LED1; }
|
|
if ((minute-(minute/5)*5)==2) { LED1; LED2; }
|
|
if ((minute-(minute/5)*5)==3) { LED1; LED2; LED3; }
|
|
if ((minute-(minute/5)*5)==4) { LED1; LED2; LED3; LED4; }
|
|
|
|
// WriteLEDs();
|
|
|
|
}
|
|
|