Subversion Repositories idreammicro-avr

Compare Revisions

Ignore whitespace Rev 37 → Rev 36

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