Subversion Repositories idreammicro-avr

Compare Revisions

Ignore whitespace Rev 24 → Rev 37

/trunk/projects/clock/SConscript
6,8 → 6,12
 
# Set libraries to use.
libraries = [
'deuligne',
'ds1307',
'mcp23008',
'adc',
'twi',
'usart'
]
/trunk/projects/clock/SConstruct
9,8 → 9,7
 
# Define environments to use (one environment per target).
environments = [
'env_arduino_uno',
'env_arduino_mega2560'
'env_arduino_uno'
]
 
# Browse environments.
/trunk/projects/clock/clock.c
28,7 → 28,9
* Header file inclusions.
******************************************************************************/
 
#include <deuligne/deuligne.h>
#include <ds1307/ds1307.h>
#include <twi/twi.h>
#include <usart/usart0.h>
#include <useful/datetime.h>
 
55,9 → 57,12
// Initialize USART0.
usart0__initialize(NULL);
 
// Enbale transmitter.
// Enable transmitter.
usart0__enable_transmitter();
 
// Initialize TWI.
twi__initialize(100000);
 
// Initialize RTC.
ds1307__initialize();
 
79,6 → 84,13
.year = 9
};
 
// Initialize Deuligne and configure display.
deuligne__initialize();
deuligne__set_display(true, true, true);
 
// Switch on backlight.
deuligne__switch_on_backlight();
 
// Set time and hour mode.
//ds1307__set_time(&time, hour_mode);
 
93,28 → 105,50
// Get RTC date.
ds1307__get_date(&date);
 
char str_datetime[] = "dd/mm/yy hh:mm:ss\n";
char str_date[] = "dd/mm/yy";
snprintf
(
str_date,
strlen(str_date) + 1,
"%02u/%02u/%02u",
date.date,
date.month,
date.year
);
 
snprintf
(
str_datetime,
strlen(str_datetime) + 1,
"%02u/%02u/%02u %02u:%02u:%02u\n",
date.date,
date.month,
date.year,
time.hours,
time.minutes,
time.seconds
);
char str_time[] = "hh:mm:ss";
snprintf
(
str_time,
strlen(str_time) + 1,
"%02u:%02u:%02u",
time.hours,
time.minutes,
time.seconds
);
 
char* p_str = str_datetime;
while (*p_str != '\0')
{
usart0__transmit_byte(*p_str);
p_str++;
}
char* p_date = &(str_date[0]);
while(*p_date != '\0')
{
usart0__transmit_byte(*p_date);
p_date++;
}
usart0__transmit_byte(' ');
 
char* p_time = &(str_time[0]);
while(*p_time != '\0')
{
usart0__transmit_byte(*p_time);
p_time++;
}
usart0__transmit_byte('\n');
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_1, 0);
deuligne__write_string(str_date);
 
deuligne__set_cursor_position(DEULIGNE__DISPLAY_LINE_2, 0);
deuligne__write_string(str_time);
 
_delay_ms(1000);
}