Skip to content
Snippets Groups Projects
Commit a0fb5247 authored by Max Horn's avatar Max Horn
Browse files

Fix warnings

parent 59883d4d
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
#include "RCSwitch.h" #include "RCSwitch.h"
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
unsigned long RCSwitch::nReceivedValue = NULL; unsigned long RCSwitch::nReceivedValue = 0;
unsigned int RCSwitch::nReceivedBitlength = 0; unsigned int RCSwitch::nReceivedBitlength = 0;
unsigned int RCSwitch::nReceivedDelay = 0; unsigned int RCSwitch::nReceivedDelay = 0;
unsigned int RCSwitch::nReceivedProtocol = 0; unsigned int RCSwitch::nReceivedProtocol = 0;
...@@ -50,7 +50,7 @@ RCSwitch::RCSwitch() { ...@@ -50,7 +50,7 @@ RCSwitch::RCSwitch() {
#if not defined( RCSwitchDisableReceiving ) #if not defined( RCSwitchDisableReceiving )
this->nReceiverInterrupt = -1; this->nReceiverInterrupt = -1;
this->setReceiveTolerance(60); this->setReceiveTolerance(60);
RCSwitch::nReceivedValue = NULL; RCSwitch::nReceivedValue = 0;
#endif #endif
} }
...@@ -622,8 +622,8 @@ void RCSwitch::enableReceive(int interrupt) { ...@@ -622,8 +622,8 @@ void RCSwitch::enableReceive(int interrupt) {
void RCSwitch::enableReceive() { void RCSwitch::enableReceive() {
if (this->nReceiverInterrupt != -1) { if (this->nReceiverInterrupt != -1) {
RCSwitch::nReceivedValue = NULL; RCSwitch::nReceivedValue = 0;
RCSwitch::nReceivedBitlength = NULL; RCSwitch::nReceivedBitlength = 0;
attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE); attachInterrupt(this->nReceiverInterrupt, handleInterrupt, CHANGE);
} }
} }
...@@ -637,11 +637,11 @@ void RCSwitch::disableReceive() { ...@@ -637,11 +637,11 @@ void RCSwitch::disableReceive() {
} }
bool RCSwitch::available() { bool RCSwitch::available() {
return RCSwitch::nReceivedValue != NULL; return RCSwitch::nReceivedValue != 0;
} }
void RCSwitch::resetAvailable() { void RCSwitch::resetAvailable() {
RCSwitch::nReceivedValue = NULL; RCSwitch::nReceivedValue = 0;
} }
unsigned long RCSwitch::getReceivedValue() { unsigned long RCSwitch::getReceivedValue() {
...@@ -673,7 +673,7 @@ bool RCSwitch::receiveProtocol1(unsigned int changeCount){ ...@@ -673,7 +673,7 @@ bool RCSwitch::receiveProtocol1(unsigned int changeCount){
unsigned long delay = RCSwitch::timings[0] / 31; unsigned long delay = RCSwitch::timings[0] / 31;
unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01; unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01;
for (int i = 1; i<changeCount ; i=i+2) { for (unsigned int i = 1; i<changeCount ; i=i+2) {
if (RCSwitch::timings[i] > delay-delayTolerance && RCSwitch::timings[i] < delay+delayTolerance && RCSwitch::timings[i+1] > delay*3-delayTolerance && RCSwitch::timings[i+1] < delay*3+delayTolerance) { if (RCSwitch::timings[i] > delay-delayTolerance && RCSwitch::timings[i] < delay+delayTolerance && RCSwitch::timings[i+1] > delay*3-delayTolerance && RCSwitch::timings[i+1] < delay*3+delayTolerance) {
code = code << 1; code = code << 1;
...@@ -694,13 +694,7 @@ bool RCSwitch::receiveProtocol1(unsigned int changeCount){ ...@@ -694,13 +694,7 @@ bool RCSwitch::receiveProtocol1(unsigned int changeCount){
RCSwitch::nReceivedProtocol = 1; RCSwitch::nReceivedProtocol = 1;
} }
if (code == 0){ return code != 0;
return false;
}else if (code != 0){
return true;
}
} }
bool RCSwitch::receiveProtocol2(unsigned int changeCount){ bool RCSwitch::receiveProtocol2(unsigned int changeCount){
...@@ -709,7 +703,7 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){ ...@@ -709,7 +703,7 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){
unsigned long delay = RCSwitch::timings[0] / 10; unsigned long delay = RCSwitch::timings[0] / 10;
unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01; unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01;
for (int i = 1; i<changeCount ; i=i+2) { for (unsigned int i = 1; i<changeCount ; i=i+2) {
if (RCSwitch::timings[i] > delay-delayTolerance && RCSwitch::timings[i] < delay+delayTolerance && RCSwitch::timings[i+1] > delay*2-delayTolerance && RCSwitch::timings[i+1] < delay*2+delayTolerance) { if (RCSwitch::timings[i] > delay-delayTolerance && RCSwitch::timings[i] < delay+delayTolerance && RCSwitch::timings[i+1] > delay*2-delayTolerance && RCSwitch::timings[i+1] < delay*2+delayTolerance) {
code = code << 1; code = code << 1;
...@@ -730,12 +724,7 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){ ...@@ -730,12 +724,7 @@ bool RCSwitch::receiveProtocol2(unsigned int changeCount){
RCSwitch::nReceivedProtocol = 2; RCSwitch::nReceivedProtocol = 2;
} }
if (code == 0){ return code != 0;
return false;
}else if (code != 0){
return true;
}
} }
/** Protocol 3 is used by BL35P02. /** Protocol 3 is used by BL35P02.
...@@ -747,7 +736,7 @@ bool RCSwitch::receiveProtocol3(unsigned int changeCount){ ...@@ -747,7 +736,7 @@ bool RCSwitch::receiveProtocol3(unsigned int changeCount){
unsigned long delay = RCSwitch::timings[0] / PROTOCOL3_SYNC_FACTOR; unsigned long delay = RCSwitch::timings[0] / PROTOCOL3_SYNC_FACTOR;
unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01; unsigned long delayTolerance = delay * RCSwitch::nReceiveTolerance * 0.01;
for (int i = 1; i<changeCount ; i=i+2) { for (unsigned int i = 1; i<changeCount ; i=i+2) {
if (RCSwitch::timings[i] > delay*PROTOCOL3_0_HIGH_CYCLES - delayTolerance if (RCSwitch::timings[i] > delay*PROTOCOL3_0_HIGH_CYCLES - delayTolerance
&& RCSwitch::timings[i] < delay*PROTOCOL3_0_HIGH_CYCLES + delayTolerance && RCSwitch::timings[i] < delay*PROTOCOL3_0_HIGH_CYCLES + delayTolerance
...@@ -774,11 +763,7 @@ bool RCSwitch::receiveProtocol3(unsigned int changeCount){ ...@@ -774,11 +763,7 @@ bool RCSwitch::receiveProtocol3(unsigned int changeCount){
RCSwitch::nReceivedProtocol = 3; RCSwitch::nReceivedProtocol = 3;
} }
if (code == 0){ return code != 0;
return false;
}else if (code != 0){
return true;
}
} }
void RCSwitch::handleInterrupt() { void RCSwitch::handleInterrupt() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment