diff --git a/hardware/adc/Makefile b/hardware/adc/Makefile index 7c5b968..d3e40fd 100644 --- a/hardware/adc/Makefile +++ b/hardware/adc/Makefile @@ -1,12 +1,12 @@ TOPDIR ?= ../.. include $(TOPDIR)/.config -$(ADC_SUPPORT)_ECMD_SRC += hardware/adc/adc.c +#$(ADC_SUPPORT)_ECMD_SRC += hardware/adc/adc.c $(HR20_TEMP_SUPPORT)_SRC += hardware/adc/hr20-temp.c -$(HR20_TEMP_SUPPORT)_ECMD_SRC += hardware/adc/hr20-temp-ecmd.c +#$(HR20_TEMP_SUPPORT)_ECMD_SRC += hardware/adc/hr20-temp-ecmd.c -$(NEED_TEMP2TEXT)_SRC += hardware/adc/temp2text.c +#$(NEED_TEMP2TEXT)_SRC += hardware/adc/temp2text.c ############################################################################## # generic fluff diff --git a/hardware/lcd/Makefile b/hardware/lcd/Makefile index b4a3104..2b71510 100644 --- a/hardware/lcd/Makefile +++ b/hardware/lcd/Makefile @@ -5,7 +5,7 @@ $(HD44780_SUPPORT)_SRC += hardware/lcd/hd44780.c $(HD44780_SUPPORT)_ECMD_SRC += hardware/lcd/ecmd.c $(HR20_LCD_SUPPORT)_SRC += hardware/lcd/hr20.c -$(HR20_LCD_SUPPORT)_ECMD_SRC += hardware/lcd/hr20-ecmd.c +#$(HR20_LCD_SUPPORT)_ECMD_SRC += hardware/lcd/hr20-ecmd.c ############################################################################## diff --git a/hardware/lcd/hr20-ecmd.c b/hardware/lcd/hr20-ecmd.c index 4dd7555..14e2912 100644 --- a/hardware/lcd/hr20-ecmd.c +++ b/hardware/lcd/hr20-ecmd.c @@ -36,7 +36,6 @@ int16_t parse_cmd_hr20_toggle(char *cmd, char *output, uint16_t len) return ECMD_FINAL_OK; } - int16_t parse_cmd_hr20_hourbar(char *cmd, char *output, uint16_t len) { /* skip leading extra spaces */ @@ -47,7 +46,7 @@ int16_t parse_cmd_hr20_hourbar(char *cmd, char *output, uint16_t len) *(ptr ++) = 0; uint8_t start = atoi(cmd); - uint8_t stop = atoi(ptr); + uint8_t stop = atoi(ptr); if (start > 24 || stop > 24) return ECMD_ERR_PARSE_ERROR; diff --git a/hardware/lcd/hr20.c b/hardware/lcd/hr20.c index 0f646c4..d8bfdd1 100644 --- a/hardware/lcd/hr20.c +++ b/hardware/lcd/hr20.c @@ -33,7 +33,7 @@ #include "config.h" #include "hardware/lcd/hr20.h" -#define HR20_LCD_INITIAL_CONTRAST 14 +#define HR20_LCD_INITIAL_CONTRAST 15 #include "hr20-charset.c" @@ -44,19 +44,40 @@ hr20_lcd_init (void) memset ((void *) &LCDDR0, 0xFF, 20); /* Set the initial LCD contrast level */ - LCDCCR = HR20_LCD_INITIAL_CONTRAST << LCDCC0; +// LCDCCR = HR20_LCD_INITIAL_CONTRAST << LCDCC0; + +/* Set the initial LCD contrast level + Nominal drive time = 300uS default */ + LCDCCR |= HR20_LCD_INITIAL_CONTRAST; /* LCD Control and Status Register B - clock source is TOSC1 pin - COM0:2 connected - SEG0:22 connected */ - LCDCRB = (1< 2048Hz - LCD Duty Cycle 1/3 (K=6) 2048Hz / 6 -> 341,33Hz - LCD Clock Divider (D=5) 341,33Hz / 7 -> 47,76Hz */ - LCDFRR = ((1< 1953.125Hz + - LCD Duty Cycle 1/3 (K=6) 1953.125Hz / 6 --> 325.52Hz + - LCD Clock Divider (D=5) 325.52Hz / 8 --> 40.69Hz */ + + LCDFRR = (1< 50){ + if (++ticks > 50){ /* Only clock here, when no crystal is connected */ #ifndef CLOCK_CRYSTAL_SUPPORT # /* Don't wait for a sync, if no sync source is enabled */ @@ -119,7 +121,7 @@ clock_set_time(uint32_t new_sync_timestamp) #ifdef CLOCK_NTP_ADJUST_SUPPORT /* The clock was synced */ if (sync_timestamp) { - int16_t delta = new_sync_timestamp - sync_timestamp; + delta = new_sync_timestamp - sync_timestamp; NTPADJDEBUG ("sync timestamp delta is %d\n", delta); if (delta < -300 || delta > 300) NTPADJDEBUG ("eeek, delta too large. " @@ -143,6 +145,8 @@ clock_set_time(uint32_t new_sync_timestamp) #endif /* CLOCK_NTP_ADJUST_SUPPORT */ sync_timestamp = new_sync_timestamp; + n_sync_timestamp = new_sync_timestamp; + n_sync_tick = TCNT2; /* Allow the clock to jump forward, but not to go backward * except the time difference is greater than 5 minutes */ @@ -171,6 +175,12 @@ clock_last_sync(void) return sync_timestamp; } +int32_t +clock_last_s_tick(void) +{ + return n_sync_tick; +} + #ifdef WHM_SUPPORT uint32_t clock_get_startup(void) diff --git a/services/clock/clock_ecmd.c b/services/clock/clock_ecmd.c index 8b70e44..b6d8ecd 100644 --- a/services/clock/clock_ecmd.c +++ b/services/clock/clock_ecmd.c @@ -31,23 +31,36 @@ int16_t parse_cmd_time(char *cmd, char *output, uint16_t len) { - return ECMD_FINAL(snprintf_P(output, len, PSTR("%lu"), clock_get_time())); -} + while (*cmd == ' ') + cmd++; -int16_t parse_cmd_date(char *cmd, char *output, uint16_t len) -{ - char *weekdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat"; - struct clock_datetime_t date; - clock_current_localtime(&date); + if (*cmd == '\0') + return ECMD_FINAL(snprintf_P(output, len, PSTR("%lu"), clock_get_time())); + else { + uint32_t newtime = strtoul(cmd, NULL, 10); - return ECMD_FINAL(snprintf_P(output, len, PSTR("%.2d:%.2d:%.2d %.2d.%.2d.%.2d %s"), - date.hour, date.min, date.sec, date.day, date.month, date.year % 100, - weekdays + date.dow * 4)); + if (!newtime) + return ECMD_ERR_PARSE_ERROR; + clock_set_time(newtime); + return ECMD_FINAL_OK; + } } + +//int16_t parse_cmd_date(char *cmd, char *output, uint16_t len) +//{ +// char *weekdays = "Sun\0Mon\0Tue\0Wed\0Thu\0Fri\0Sat"; +// struct clock_datetime_t date; +// clock_current_localtime(&date); +// +// return ECMD_FINAL(snprintf_P(output, len, PSTR("%.2d:%.2d:%.2d %.2d.%.2d.%.2d %s"), +// date.hour, date.min, date.sec, date.day, date.month, date.year % 100, +// weekdays + date.dow * 4)); +//} +// ecmd_feature(date, "date",, Display the current date.) + /* -- Ethersex META -- block(Clock) - ecmd_feature(time, "time",, Display the current time in seconds since January 1st 1970.) - ecmd_feature(date, "date",, Display the current date.) + ecmd_feature(time, "time",[UNIXTIME], Display/Set the current time in seconds since January 1st 1970.) */