Merge branch 'master' of git.luon.net:users/admar/stoptime and resolve conflicts

This commit is contained in:
Paul van Tilburg 2012-01-09 23:32:33 +01:00
commit ed042efaf2
3 changed files with 75 additions and 106 deletions

View File

@ -108,18 +108,25 @@ void selftest(void){
void displaytime_round(void)
{
int n;
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; }
@ -133,113 +140,42 @@ void displaytime_round(void)
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))
{
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))
if ((n > 2 * 60 + 30) && (n < 17 * 60 + 30))
{
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 ((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; }
// WriteLEDs();
}
void displaytime_floor(void)
@ -378,7 +314,7 @@ void displaytime_floor(void)
void displaytime()
{
#if (DISPLAYTIME == round)
#if (DISPLAYTIME_MODE == DISPLAYTIME_ROUND)
displaytime_round();
#else
displaytime_floor();

View File

@ -10,7 +10,7 @@
// set SKIPSELFTEST to 1 to skip selftest
#define SKIPSELFTEST 1
// DISPLAYTIME_MODE can either be displaytime_floor or displaytime_round:
// DISPLAYTIME_MODE can either be DISPLAYTIME_FLOOR or DISPLAYTIME_ROUND:
//
// * floor: floor() (or truncate) the time to chunks of 5 minutes and where the
// additional 4 leds indicate the number of minutes you have to add to get the
@ -22,7 +22,7 @@
// exact time. Thus, if you only look at the words, you have a maximum error
// of 2 minutes and 29 seconds.
//
#define DISPLAYTIME_MODE floor
#define DISPLAYTIME_MODE DISPLAYTIME_FLOOR
// set USELIGHTSENSOR to 1 to use ambient light sensor connected to ADC0 (pin
// 23)

View File

@ -5,6 +5,10 @@
#include <avr/io.h>
#include <math.h>
#include <pt.h>
#define DISPLAYTIME_FLOOR 1
#define DISPLAYTIME_ROUND 2
#include "settings.h"
// uncomment the following to speed up the timer for testing
@ -595,7 +599,7 @@ static int uart_thread(struct pt *pt)
case 'd':
// set day of week
// Sunday == 1, Saturday == 7
day_week = (arg2 - 0x30);
day_week = arg2 - 0x30;
Serial.print("S: d: ");
Serial.println(day_week);
break;
@ -644,6 +648,35 @@ static int uart_thread(struct pt *pt)
switch(arg1)
{
case 'T':
// get time
Serial.print("G: T: ");
Serial.print(year, DEC);
if (month < 10)
Serial.print("-0");
else
Serial.print("-");
Serial.print(month, DEC);
if (day < 10)
Serial.print("-0");
else
Serial.print("-");
Serial.print(day, DEC);
Serial.print(" ");
Serial.print(day_week, DEC);
Serial.print(" ");
Serial.print(hour, DEC);
if (minute < 10)
Serial.print(":0");
else
Serial.print(":");
Serial.print(minute, DEC);
if (second < 10)
Serial.print(":0");
else
Serial.print(":");
Serial.println(second, DEC);
break;
case 'Y':
// get year
Serial.print("G: Y: ");
@ -832,7 +865,7 @@ static int blink_thread(struct pt *pt)
PT_WAIT_UNTIL(pt, millisWillOverflow ? (millis() - msTick > 999) :
((millis() < 4294967295 - 998) && (millis() - msTick > 999)));
msTick=millis();
#if (PRINT_DEBUG_LEVEL <= 1)
#if (PRINT_DEBUG_LEVEL <= 0)
Serial.println("D: blink thread is alive");
#endif