wordclock/wordclock/Dutch.h

324 lines
9.7 KiB
C

/**************************************************************************
* *
* W O R D C L O C K - A clock that tells the time using words. *
* *
* DUTCH 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 MTEN Display1=Display1 | (1<<1); //Serial.print("tien ");
#define HALF Display1=Display1 | (1<<2); //Serial.print("half ");
#define PAST Display1=Display1 | (1<<3); //Serial.print("over ");
#define THREE Display1=Display1 | (1<<4); //Serial.print("drie ");
#define ITIS Display1=Display1 | (1<<5); //Serial.print("het is ")
#define TO Display1=Display1 | (1<<7); //Serial.print("voor ");
#define TWO Display2=Display2 | (1<<0); //Serial.print("twee ");
#define SIX Display2=Display2 | (1<<1); //Serial.print("zes ");
#define TWELVE Display2=Display2 | (1<<2); //Serial.print("twaalf ");
#define HFIVE Display2=Display2 | (1<<3); //Serial.print("vijf ");
#define SEVEN Display2=Display2 | (1<<4); //Serial.print("zeven ");
#define HOUR Display2=Display2 | (1<<5); //Serial.print("uur ");
#define ONE Display2=Display2 | (1<<6); //Serial.print("een ");
#define QUARTER Display2=Display2 | (1<<7); //Serial.print("kwart ");
#define EIGHT Display3=Display3 | (1<<0); //Serial.print("acht ");
#define MFIVE Display3=Display3 | (1<<1); //Serial.print("vijf ");
#define ELEVEN Display3=Display3 | (1<<3); //Serial.print("elf ");
#define HTEN Display3=Display3 | (1<<4); //Serial.print("tien ");
#define NINE Display3=Display3 | (1<<5); //Serial.print("negen ");
#define FOUR 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 ")
/*#define LED1 digitalWrite(LED1PIN,HIGH)
#define LED2 digitalWrite(LED2PIN,HIGH)
#define LED3 digitalWrite(LED3PIN,HIGH)
#define LED4 digitalWrite(LED4PIN,HIGH)*/
void selftest(void){
Serial.print("Selftest started");
// start by clearing the display to a known state
ledsoff(); ITIS; delay(500);
ledsoff(); MFIVE; delay(500);
ledsoff(); MTEN; delay(500);
ledsoff(); QUARTER; delay(500);
ledsoff(); PAST; delay(500);
ledsoff(); TO; delay(500);
ledsoff(); HALF; delay(500);
ledsoff(); ONE; delay(500);
ledsoff(); TWO; delay(500);
ledsoff(); THREE; delay(500);
ledsoff(); FOUR; delay(500);
ledsoff(); HFIVE; delay(500);
ledsoff(); SIX; delay(500);
ledsoff(); SEVEN; delay(500);
ledsoff(); EIGHT; delay(500);
ledsoff(); NINE; delay(500);
ledsoff(); HTEN; delay(500);
ledsoff(); ELEVEN; ; delay(500);
ledsoff(); TWELVE; delay(500);
ledsoff(); HOUR; 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; LED1; LED2; LED3; LED4; delay(500);
ledsoff(); delay(500);
}
}
void displaytime_round(void)
{
int n, h = hour, m = minute;
// compute the number of seconds that we are in the hour
n = 60 * minute + second;
// compute the hour that we should display
if (n >= 17 * 60 + 30)
{
h = h + 1;
if (h >= 24)
h = 0;
}
// start by clearing the display to a known state
ledsoff();
// Now, turn on the "It is" leds
ITIS;
// now we display the appropriate minute counter
if ((n >= 2 * 60 + 30) && (n < 7 * 60 + 30)) { MFIVE; PAST; }
if ((n >= 7 * 60 + 30) && (n < 12 * 60 + 30)) { MTEN; PAST; }
if ((n >= 12 * 60 + 30) && (n < 17 * 60 + 30)) { QUARTER; PAST; }
if ((n >= 17 * 60 + 30) && (n < 22 * 60 + 30)) { MTEN; TO; HALF; }
if ((n >= 22 * 60 + 30) && (n < 27 * 60 + 30)) { MFIVE; TO; HALF; }
if ((n >= 27 * 60 + 30) && (n < 32 * 60 + 30)) { HALF; }
if ((n >= 32 * 60 + 30) && (n < 37 * 60 + 30)) { MFIVE; PAST; HALF; }
if ((n >= 37 * 60 + 30) && (n < 42 * 60 + 30)) { MTEN; PAST; HALF; }
if ((n >= 42 * 60 + 30) && (n < 47 * 60 + 30)) { QUARTER; TO; }
if ((n >= 47 * 60 + 30) && (n < 52 * 60 + 30)) { MTEN; TO; }
if ((n >= 52 * 60 + 30) && (n < 57 * 60 + 30)) { MFIVE; TO; }
switch (h) {
case 1:
case 13: ONE; break;
case 2:
case 14: TWO; break;
case 3:
case 15: THREE; break;
case 4:
case 16: FOUR; break;
case 5:
case 17: HFIVE; break;
case 6:
case 18: SIX; break;
case 7:
case 19: SEVEN; break;
case 8:
case 20: EIGHT; break;
case 9:
case 21: NINE; break;
case 10:
case 22: HTEN; break;
case 11:
case 23: ELEVEN; break;
case 0:
case 12:
case 24: TWELVE; break;
}
if ((n >= 57 * 60 + 30) || (n < 2 * 60 + 30))
HOUR;
// now we can illuminate the extra minute LEDs
if ((n+30-((n/(5*60))*(5*60))) / 60 == 1) { LED1; }
if ((n+30-((n/(5*60))*(5*60))) / 60 == 2) { LED1; LED2; }
if ((n+30-((n/(5*60))*(5*60))) / 60 == 3) { LED3; LED4; }
if ((n+30-((n/(5*60))*(5*60))) / 60 == 4) { LED4; }
}
void displaytime_floor(void)
{
// start by clearing the display to a known state
ledsoff();
// Now, turn on the "It is" leds
ITIS;
// now we display the appropriate minute counter
if ((minute>4) && (minute<10)) { MFIVE; PAST; }
if ((minute>9) && (minute<15)) { MTEN; PAST; }
if ((minute>14) && (minute<20)) { QUARTER; PAST; }
if ((minute>19) && (minute<25)) { MTEN; TO; HALF; }
if ((minute>24) && (minute<30)) { MFIVE; TO; HALF; }
if ((minute>29) && (minute<35)) { HALF; }
if ((minute>34) && (minute<40)) { MFIVE; PAST; HALF; }
if ((minute>39) && (minute<45)) { MTEN; PAST; HALF; }
if ((minute>44) && (minute<50)) { QUARTER; TO; }
if ((minute>49) && (minute<55)) { MTEN; TO; }
if (minute>54) { MFIVE; TO; }
if ((minute <5))
{
switch (hour) {
case 1:
case 13: ONE; break;
case 2:
case 14: TWO; break;
case 3:
case 15: THREE; break;
case 4:
case 16: FOUR; break;
case 5:
case 17: HFIVE; break;
case 6:
case 18: SIX; break;
case 7:
case 19: SEVEN; break;
case 8:
case 20: EIGHT; break;
case 9:
case 21: NINE; break;
case 10:
case 22: HTEN; break;
case 11:
case 23: ELEVEN; break;
case 0:
case 12:
case 24: TWELVE; break;
}
HOUR;
}
else
if ((minute < 20) && (minute >4))
{
switch (hour) {
case 1:
case 13: ONE; break;
case 2:
case 14: TWO; break;
case 3:
case 15: THREE; break;
case 4:
case 16: FOUR; break;
case 5:
case 17: HFIVE; break;
case 6:
case 18: SIX; break;
case 7:
case 19: SEVEN; break;
case 8:
case 20: EIGHT; break;
case 9:
case 21: NINE; break;
case 10:
case 22: HTEN; break;
case 11:
case 23: ELEVEN; break;
case 0:
case 12:
case 24: TWELVE; break;
}
}
else
{
// if we are greater than 34 minutes past the hour then display
// the next hour
switch (hour) {
case 1:
case 13: TWO; break;
case 14:
case 2: THREE; break;
case 15:
case 3: FOUR; break;
case 4:
case 16: HFIVE; break;
case 5:
case 17: SIX; break;
case 6:
case 18: SEVEN; break;
case 7:
case 19: EIGHT; break;
case 8:
case 20: NINE; break;
case 9:
case 21: HTEN; break;
case 10:
case 22: ELEVEN; break;
case 11:
case 23: TWELVE; 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();
}
void displaytime()
{
#if (DISPLAYTIME_MODE == DISPLAYTIME_ROUND)
displaytime_round();
#else
displaytime_floor();
#endif
}