code formating changes

This commit is contained in:
2023-04-02 23:55:00 +02:00
parent 25b7258458
commit 99ab8cf36d
3 changed files with 18 additions and 15 deletions

View File

@ -113,7 +113,7 @@ void writeItemState(Serial* serial, Item* relay, uint8_t number)
void itemDispatch(SVector<Item, MAX_ITEMS>* items, Pwm16b* auxPwm, char* token, Serial* serial)
{
if( strcmp(token, "add") == 0 )
if(strcmp(token, "add") == 0)
{
token = strtok(NULL, " \n");
uint16_t id = strtol(token, nullptr, 2 );
@ -125,15 +125,17 @@ void itemDispatch(SVector<Item, MAX_ITEMS>* items, Pwm16b* auxPwm, char* token,
Item item;
item.id = id;
item.type = type;
if( token != NULL ) item.setName(token);
if( token != NULL )
item.setName(token);
items->push_back(item);
writeItemState(serial, &items->back(), items->count()-1);
}
else if(items->remainingCapacity() == 0) serial->write_p(PSTR("Relay storage full.\n"));
else serial->write_p(
PSTR("Usage: item add [id] [type] [name]\n [id] being a 16bit binary nummber and [name] an optional string\n"));
else if(items->remainingCapacity() == 0)
serial->write_p(PSTR("Relay storage full.\n"));
else
serial->write_p(PSTR("Usage: item add [id] [type] [name]\n [id] being a 16bit binary nummber and [name] an optional string\n"));
}
else if( strcmp(token, "delete") == 0 )
else if(strcmp(token, "delete") == 0)
{
token = strtok(NULL, " \n");
if(items->count() > 0)
@ -145,10 +147,10 @@ void itemDispatch(SVector<Item, MAX_ITEMS>* items, Pwm16b* auxPwm, char* token,
items->erase(index);
}
}
else if( strcmp(token, "on") == 0 )
else if(strcmp(token, "on") == 0)
{
char* token = strtok(NULL, " \n");
if( token != NULL)
if(token != NULL)
{
uint8_t selected = strtol(token, nullptr, 10);
if (selected < items->count())
@ -163,7 +165,7 @@ void itemDispatch(SVector<Item, MAX_ITEMS>* items, Pwm16b* auxPwm, char* token,
}
else serial->write_p(PSTR("Usage: item on [nn]\n"));
}
else if( strcmp(token, "off") == 0 )
else if(strcmp(token, "off") == 0)
{
char* token = strtok(NULL, " \n");
if( token != NULL)
@ -181,7 +183,7 @@ void itemDispatch(SVector<Item, MAX_ITEMS>* items, Pwm16b* auxPwm, char* token,
}
else serial->write_p(PSTR("Usage: item off [nn]\n"));
}
else if( strcmp(token, "resend") == 0 )
else if(strcmp(token, "resend") == 0)
{
char* token = strtok(NULL, " \n");
serial->write_p(PSTR("Resend every 30 min is "));
@ -455,8 +457,7 @@ int main()
W433DataReciver reciver(&PINC, PC0, &TCNT1, &TIFR1, &sensorPacketRecived, reinterpret_cast<void*>(&serial),
&reciverError);
W433DataTransmitter transmitter(&PORTB, PB5);
UvosItem::transmitter=&transmitter;
UvosItem::transmitter = &transmitter;
serial.write_p(PSTR("RGBController v1.5 starting\n"));

View File

@ -15,7 +15,8 @@ UvosItem::UvosItem(const Item& item)
void UvosItem::setValue(const uint8_t value)
{
const uint8_t paket[4] = {id >> 8, id & 0x00FF, 0, value};
if(transmitter)transmitter->send(paket, 4);
if(transmitter)
transmitter->send(paket, 4);
}
void UvosItem::resend()

View File

@ -2,7 +2,8 @@
#define WRITEPIN_H
#include <avr/io.h>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
inline void writePin(volatile unsigned char *port, const unsigned char pin, const bool state) //waste 2 cycles
{
*port &= ~(1 << pin);
@ -24,6 +25,6 @@ inline bool readPin( volatile unsigned char *inPort, const unsigned char pin)
{
return (bool) (*inPort & (1 << pin));
}
#pragma GCC diagnostic pop
#endif