Cleanup changes

This commit is contained in:
2023-04-03 18:16:58 +02:00
parent e268d49c48
commit 1d75a5bc77

View File

@ -26,7 +26,7 @@
#define COMMAND_BUFFER_SIZE 64 #define COMMAND_BUFFER_SIZE 64
#define SNPRINTF_BUFFER_SIZE 96 #define SNPRINTF_BUFFER_SIZE 96
#define welcomeString "HELO SAS" #define welcomeString "HELOJANA"
static constexpr bool bdayMsg = false; static constexpr bool bdayMsg = false;
void buttonHandler(uint8_t index, uint8_t type, void* data); void buttonHandler(uint8_t index, uint8_t type, void* data);
@ -70,8 +70,10 @@ ISR(TIMER2_OVF_vect)
{ {
display.tick(); display.tick();
buttons.tick(); buttons.tick();
if(ringging && ((timer % 4 == 0 && timer < 128) || (timer > 128 && timer % 16 == 0)) ) writePin(&PORTD, PD4, true); if(ringging && ((timer % 4 == 0 && timer < 128) || (timer > 128 && timer % 16 == 0)))
else writePin(&PORTD, PD4, false); writePin(&PORTD, PD4, true);
else
writePin(&PORTD, PD4, false);
++timer; ++timer;
} }
@ -90,8 +92,15 @@ void buttonHandler(uint8_t index, uint8_t type, void* data)
} }
else if(index == 1 && type == Buttons::RELEASED ) else if(index == 1 && type == Buttons::RELEASED )
{ {
if(!ringging) if(++alm > 3) alm = 0; if(!ringging)
else ringging = false; {
if(++alm > 3)
alm = 0;
}
else
{
ringging = false;
}
} }
else if(index == 1 && type == Buttons::LONG_PRESSED ) else if(index == 1 && type == Buttons::LONG_PRESSED )
{ {
@ -339,7 +348,6 @@ int main()
TCCR1B = 1<<CS10; TCCR1B = 1<<CS10;
EICRA = 1<<ISC10; EICRA = 1<<ISC10;
EIMSK = 1<<INT1;
sei(); sei();
@ -352,34 +360,16 @@ int main()
alm = EEPROM_read_char(0); alm = EEPROM_read_char(0);
uint8_t oldAlm = alm; uint8_t oldAlm = alm;
#ifdef HAS_TRANSMITTER #ifdef HAS_TRANSMITTER
char name[] = "relay"; char name[] = "relay";
WirelessRelay relay(0b1011010001000000, name); WirelessRelay relay(0b1011010001000000, name);
#endif #endif
#ifdef HAS_DHT display.setString(welcomeString);
Dht11 sensor(&PORTD, &PIND, &DDRD, PD2); _delay_ms(1000);
#endif
if(time.day == 28 && time.month == 5)
{
if constexpr(bdayMsg)
{
display.setString("HAPPY ");
_delay_ms(1000);
display.setString("b-DAY ");
_delay_ms(1000);
display.setString("SASA ");
_delay_ms(1000);
}
}
else
{
display.setString(welcomeString);
_delay_ms(1000);
}
#ifdef HAS_DHT #ifdef HAS_DHT
Dht11 sensor(&PORTD, &PIND, &DDRD, PD2);
sensor.read(); sensor.read();
_delay_ms(1000); _delay_ms(1000);
sensor.read(); sensor.read();
@ -443,6 +433,7 @@ int main()
#else #else
displayItems(time, 0, 0); displayItems(time, 0, 0);
#endif #endif
if(time.hour == alarmA.hour && time.min == alarmA.min && time.sec == 0) if(time.hour == alarmA.hour && time.min == alarmA.min && time.sec == 0)
{ {
ringging = true; ringging = true;
@ -457,8 +448,8 @@ int main()
#endif #endif
} }
#ifdef HAS_RECIVER
serialDispatch(&serial, &sensors); serialDispatch(&serial, &sensors);
#ifdef HAS_RECIVER
if(deleteDate != time.day) if(deleteDate != time.day)
{ {
displaying = 0; displaying = 0;