Ran clang-format
This commit is contained in:
parent
7310eb2c9a
commit
85e37de950
@ -4,13 +4,13 @@
|
||||
* Version 1.3
|
||||
*/
|
||||
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <avr/interrupt.h>
|
||||
|
||||
#include "usart/usart.h"
|
||||
#include "ds3231/systime.h"
|
||||
#include "usart/usart.h"
|
||||
|
||||
#include "clock.h"
|
||||
|
||||
@ -18,13 +18,12 @@ void setup()
|
||||
{
|
||||
USART0 &cSerial = USART0::inst();
|
||||
|
||||
if( SysTime::init() )
|
||||
{
|
||||
cSerial << "DS3231 detected!" << "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
cSerial << "ERROR - No RTC detected!" << "\r\n";
|
||||
if (SysTime::init()) {
|
||||
cSerial << "DS3231 detected!"
|
||||
<< "\r\n";
|
||||
} else {
|
||||
cSerial << "ERROR - No RTC detected!"
|
||||
<< "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,22 +36,30 @@ void setTime()
|
||||
constexpr auto BUFFER_SIZE = 32;
|
||||
char szBuffer[BUFFER_SIZE];
|
||||
|
||||
cSerial << "Set time:" << "\r\n" << "Year: ";
|
||||
cSerial << "Set time:"
|
||||
<< "\r\n"
|
||||
<< "Year: ";
|
||||
cSerial.receiveLine(szBuffer, BUFFER_SIZE, "\r");
|
||||
cSerial << szBuffer << "\r\n";
|
||||
sTime.tm_year = atoi(szBuffer) - 1900;
|
||||
|
||||
cSerial << "Set time:" << "\r\n" << "Month: ";
|
||||
cSerial << "Set time:"
|
||||
<< "\r\n"
|
||||
<< "Month: ";
|
||||
cSerial.receiveLine(szBuffer, BUFFER_SIZE, "\r");
|
||||
cSerial << szBuffer << "\r\n";
|
||||
sTime.tm_mon = atoi(szBuffer) - 1;
|
||||
|
||||
cSerial << "Set time:" << "\r\n" << "Day: ";
|
||||
cSerial << "Set time:"
|
||||
<< "\r\n"
|
||||
<< "Day: ";
|
||||
cSerial.receiveLine(szBuffer, BUFFER_SIZE, "\r");
|
||||
cSerial << szBuffer << "\r\n";
|
||||
sTime.tm_mday = atoi(szBuffer);
|
||||
|
||||
cSerial << "Set time:" << "\r\n" << "Hour: ";
|
||||
cSerial << "Set time:"
|
||||
<< "\r\n"
|
||||
<< "Hour: ";
|
||||
cSerial.receiveLine(szBuffer, BUFFER_SIZE, "\r");
|
||||
cSerial << szBuffer << "\r\n";
|
||||
sTime.tm_hour = atoi(szBuffer);
|
||||
@ -81,7 +88,9 @@ void setAlarm()
|
||||
constexpr auto BUFFER_SIZE = 32;
|
||||
char szBuffer[BUFFER_SIZE];
|
||||
|
||||
cSerial << "Set alarm:" << "\r\n" << "Hour: ";
|
||||
cSerial << "Set alarm:"
|
||||
<< "\r\n"
|
||||
<< "Hour: ";
|
||||
cSerial.receiveLine(szBuffer, BUFFER_SIZE, "\r");
|
||||
cSerial << szBuffer << "\r\n";
|
||||
tmAlarm->hour = atoi(szBuffer);
|
||||
@ -111,10 +120,8 @@ int main()
|
||||
constexpr auto BUFFER_SIZE = 32;
|
||||
char szBuffer[BUFFER_SIZE];
|
||||
|
||||
while( true )
|
||||
{
|
||||
if( !SysTime::checkSync() )
|
||||
{
|
||||
while (true) {
|
||||
if (!SysTime::checkSync()) {
|
||||
SysTime::syncSysTime();
|
||||
|
||||
time_t timeNow = time(nullptr);
|
||||
@ -124,26 +131,20 @@ int main()
|
||||
|
||||
cSerial << "Time: " << szBuffer << "\r\n";
|
||||
|
||||
if( rtc_check_alarm() )
|
||||
{
|
||||
cSerial << "ALARM!" << "\r\n";
|
||||
if (rtc_check_alarm()) {
|
||||
cSerial << "ALARM!"
|
||||
<< "\r\n";
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t ui8Cmd;
|
||||
|
||||
if( cSerial.receiveByte( ui8Cmd ) )
|
||||
{
|
||||
if( ui8Cmd == 's' )
|
||||
{
|
||||
if (cSerial.receiveByte(ui8Cmd)) {
|
||||
if (ui8Cmd == 's') {
|
||||
setTime();
|
||||
}
|
||||
else if( ui8Cmd == 'a' )
|
||||
{
|
||||
} else if (ui8Cmd == 'a') {
|
||||
setAlarm();
|
||||
}
|
||||
else if( ui8Cmd == 'p' )
|
||||
{
|
||||
} else if (ui8Cmd == 'p') {
|
||||
uint8_t ui8Hour;
|
||||
uint8_t ui8Minute;
|
||||
uint8_t ui8Second;
|
||||
@ -151,12 +152,11 @@ int main()
|
||||
rtc_get_alarm_s(&ui8Hour, &ui8Minute, &ui8Second);
|
||||
sprintf(szBuffer, "Alarm set to: %02d:%02d:%02d", ui8Hour, ui8Minute, ui8Second);
|
||||
cSerial << szBuffer << "\r\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cSerial << "Invalid char: '";
|
||||
cSerial.transmitByte(ui8Cmd);
|
||||
cSerial << "'" << "\r\n";
|
||||
cSerial << "'"
|
||||
<< "\r\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user