Relay dispatch now waits for reciver to finish reciving packet
This commit is contained in:
@ -242,9 +242,9 @@ CMAKE_CACHEFILE_DIR:INTERNAL=/home/philipp/Programming/avr/RGBcontroller
|
|||||||
//Major version of cmake used to create the current loaded cache
|
//Major version of cmake used to create the current loaded cache
|
||||||
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
|
||||||
//Minor version of cmake used to create the current loaded cache
|
//Minor version of cmake used to create the current loaded cache
|
||||||
CMAKE_CACHE_MINOR_VERSION:INTERNAL=14
|
CMAKE_CACHE_MINOR_VERSION:INTERNAL=15
|
||||||
//Patch version of cmake used to create the current loaded cache
|
//Patch version of cmake used to create the current loaded cache
|
||||||
CMAKE_CACHE_PATCH_VERSION:INTERNAL=4
|
CMAKE_CACHE_PATCH_VERSION:INTERNAL=5
|
||||||
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
|
||||||
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
|
||||||
//Path to CMake executable.
|
//Path to CMake executable.
|
||||||
@ -343,7 +343,7 @@ CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
|
|||||||
//ADVANCED property for variable: CMAKE_RANLIB
|
//ADVANCED property for variable: CMAKE_RANLIB
|
||||||
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
CMAKE_RANLIB-ADVANCED:INTERNAL=1
|
||||||
//Path to CMake installation.
|
//Path to CMake installation.
|
||||||
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.14
|
CMAKE_ROOT:INTERNAL=/usr/share/cmake-3.15
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
|
||||||
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
|
||||||
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
|
||||||
|
@ -31,7 +31,7 @@ set(CMAKE_LINKER /usr/bin/avr-ld)
|
|||||||
|
|
||||||
# Compiler flags
|
# Compiler flags
|
||||||
add_definitions(-mmcu=${MCU} -DF_CPU=${CPU_SPEED})
|
add_definitions(-mmcu=${MCU} -DF_CPU=${CPU_SPEED})
|
||||||
add_definitions(-s -c -g -Os -flto -Wall -std=c++17 )
|
add_definitions(-s -c -g -Os -flto -Wall -std=c++17 -fno-strict-aliasing)
|
||||||
add_definitions(-fno-exceptions -ffunction-sections -fdata-sections)
|
add_definitions(-fno-exceptions -ffunction-sections -fdata-sections)
|
||||||
|
|
||||||
# Linker flags
|
# Linker flags
|
||||||
|
@ -48,6 +48,11 @@ int8_t W433DataReciver::reciveBit(uint8_t index)
|
|||||||
else return -1;
|
else return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void W433DataReciver::waitForReciveIdle(const uint16_t timeoutMs)
|
||||||
|
{
|
||||||
|
for(uint16_t i = 0; i < timeoutMs && state != LOOKING_FOR_SYNC; ++i ) _delay_ms(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
bool W433DataReciver::isTime(int16_t input, const uint16_t time, const bool state, const uint16_t tollerance)
|
bool W433DataReciver::isTime(int16_t input, const uint16_t time, const bool state, const uint16_t tollerance)
|
||||||
{
|
{
|
||||||
|
@ -86,6 +86,7 @@ public:
|
|||||||
~W433DataReciver();
|
~W433DataReciver();
|
||||||
static void initTimer();
|
static void initTimer();
|
||||||
static void staticInterrupt();
|
static void staticInterrupt();
|
||||||
|
void waitForReciveIdle(const uint16_t timeoutMs = 2000);
|
||||||
void interrupt();
|
void interrupt();
|
||||||
#ifdef USE_RINGBUFFER
|
#ifdef USE_RINGBUFFER
|
||||||
RingBuffer<RINGBUFFER_LENGTH, uint8_t>* getRingBuffer();
|
RingBuffer<RINGBUFFER_LENGTH, uint8_t>* getRingBuffer();
|
||||||
|
8
main.cpp
8
main.cpp
@ -298,7 +298,7 @@ void auxDispatch(Pwm16b* auxPwm, char* token, Serial* serial)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void serialDispatch(Serial* serial, SVector<WirelessRelay, MAX_RELAYS>* relays, RgbLed* rgbled, Pwm16b* auxPwm)
|
void serialDispatch(Serial* serial, SVector<WirelessRelay, MAX_RELAYS>* relays, RgbLed* rgbled, Pwm16b* auxPwm, W433DataReciver* reciver)
|
||||||
{
|
{
|
||||||
|
|
||||||
if(serial->dataIsWaiting())
|
if(serial->dataIsWaiting())
|
||||||
@ -315,6 +315,7 @@ void serialDispatch(Serial* serial, SVector<WirelessRelay, MAX_RELAYS>* relays,
|
|||||||
}
|
}
|
||||||
else if(strcmp(token, "rgb") == 0)
|
else if(strcmp(token, "rgb") == 0)
|
||||||
{
|
{
|
||||||
|
reciver->waitForReciveIdle();
|
||||||
rgbDispatch(rgbled, strtok(NULL, " \n"), serial);
|
rgbDispatch(rgbled, strtok(NULL, " \n"), serial);
|
||||||
}
|
}
|
||||||
else if(strcmp(token, "aux") == 0)
|
else if(strcmp(token, "aux") == 0)
|
||||||
@ -440,13 +441,13 @@ int main()
|
|||||||
setBit(&PCMSK1, PCINT8, true);
|
setBit(&PCMSK1, PCINT8, true);
|
||||||
W433DataReciver reciver(&PINC, PC0, &TCNT1, &TIFR1, &sensorPacketRecived, reinterpret_cast<void*>(&serial), &reciverError);
|
W433DataReciver reciver(&PINC, PC0, &TCNT1, &TIFR1, &sensorPacketRecived, reinterpret_cast<void*>(&serial), &reciverError);
|
||||||
|
|
||||||
serial.write_p(PSTR("RGBController v1.0 starting\n"));
|
serial.write_p(PSTR("RGBController v1.1 starting\n"));
|
||||||
|
|
||||||
load();
|
load();
|
||||||
|
|
||||||
while(true)
|
while(true)
|
||||||
{
|
{
|
||||||
serialDispatch(&serial, &relays, &rgbled, &pwmTc1);
|
serialDispatch(&serial, &relays, &rgbled, &pwmTc1, &reciver);
|
||||||
rgbled.logic();
|
rgbled.logic();
|
||||||
|
|
||||||
if(doorOne != readPin(&PINB, PB3) && !sensorsPaused)
|
if(doorOne != readPin(&PINB, PB3) && !sensorsPaused)
|
||||||
@ -486,6 +487,7 @@ int main()
|
|||||||
{
|
{
|
||||||
for(uint16_t i = 0; i < relays.count(); i++)
|
for(uint16_t i = 0; i < relays.count(); i++)
|
||||||
{
|
{
|
||||||
|
reciver.waitForReciveIdle();
|
||||||
relays[i].resend();
|
relays[i].resend();
|
||||||
_delay_ms(100);
|
_delay_ms(100);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user