Formatting cleanup
This commit is contained in:
parent
c7e286f51e
commit
5a1be3c2e4
50 changed files with 283 additions and 282 deletions
|
|
@ -59,28 +59,28 @@ bool parseArctechSelfLearning(uint8_t* bufStartP, uint8_t* bufEndP) { //start
|
|||
uint64_t data = 0;
|
||||
bool dimValuePresent;
|
||||
uint8_t b1,b2,b3,b4;
|
||||
|
||||
|
||||
//parse preamp
|
||||
|
||||
b1 = *bufStartP;
|
||||
stepBufferPointer(&bufStartP);
|
||||
b2 = *bufStartP;
|
||||
stepBufferPointer(&bufStartP);
|
||||
if(!IS_PREAMP(b1, b2)){
|
||||
if (!IS_PREAMP(b1, b2)){
|
||||
return false;
|
||||
}
|
||||
|
||||
//parse data
|
||||
|
||||
|
||||
uint16_t dataBitsInBuffer = (calculateBufferPointerDistance(bufStartP, bufEndP)-2) / 4; //each bit is representd by 4 high/low
|
||||
if (dataBitsInBuffer == 32) {
|
||||
dimValuePresent = false;
|
||||
}else if(dataBitsInBuffer == 36){
|
||||
} else if (dataBitsInBuffer == 36){
|
||||
dimValuePresent = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
for (uint8_t i = 0; i < dataBitsInBuffer; ++i) {
|
||||
b1 = *bufStartP; //no of high
|
||||
stepBufferPointer(&bufStartP);
|
||||
|
|
@ -103,7 +103,7 @@ bool parseArctechSelfLearning(uint8_t* bufStartP, uint8_t* bufEndP) { //start
|
|||
}
|
||||
|
||||
//data parsed - send event over serial
|
||||
|
||||
|
||||
Serial.print(F("+Wclass:command;protocol:arctech;model:selflearning;data:0x"));
|
||||
uint8_t hexToSend = (dimValuePresent ? 9 : 8);
|
||||
for (int8_t i = hexToSend - 1; i >= 0; --i) {
|
||||
|
|
|
|||
|
|
@ -17,29 +17,29 @@ void parseRadioRXBuffer() {
|
|||
bool parse = false;
|
||||
while (bufferReadP != bufferWriteP) { //stop if the read pointer is pointing to where the writing is currently performed
|
||||
uint8_t sampleCount = *bufferReadP;
|
||||
|
||||
|
||||
if ( (((uintptr_t)bufferReadP) & 0x1) == 1 ) { //buffer pointer is odd (stores highs)
|
||||
//Serial.print("high:"); Serial.println(sampleCount);
|
||||
if (prevValue >= SILENCE_LENGTH) {
|
||||
startDataP = bufferReadP; //some new data must start here since this is the first "high" after a silent period
|
||||
}
|
||||
|
||||
|
||||
//stream data to stream parsers
|
||||
parseOregonStream(HIGH, sampleCount);
|
||||
|
||||
|
||||
} else { //buffer pointer is even (stores lows)
|
||||
//Serial.print("low:"); Serial.println(sampleCount);
|
||||
if (sampleCount >= SILENCE_LENGTH) { //evaluate if it is time to parse the curernt data
|
||||
endDataP = bufferReadP; //this is a silient period and must be the end of a data
|
||||
if(startDataP != 0){
|
||||
if (startDataP != 0){
|
||||
parse = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//stream data to stream parsers
|
||||
parseOregonStream(LOW, sampleCount);
|
||||
|
||||
|
||||
}
|
||||
|
||||
//step the read pointer one step
|
||||
|
|
@ -74,11 +74,11 @@ void parseRadioRXBuffer() {
|
|||
//Let all available parsers parse the data set now.
|
||||
parseArctechSelfLearning(startDataP, endDataP);
|
||||
//TODO: add more parsers here
|
||||
|
||||
|
||||
//reset the data pointers since the data have been parsed at this point
|
||||
startDataP = 0;
|
||||
endDataP = 0;
|
||||
|
||||
|
||||
}; //end radioTask
|
||||
|
||||
void sendTCodedData(uint8_t* data, uint8_t T_long, uint8_t* timings, uint8_t repeat, uint8_t pause) {
|
||||
|
|
@ -88,7 +88,7 @@ void sendTCodedData(uint8_t* data, uint8_t T_long, uint8_t* timings, uint8_t rep
|
|||
for (int i = 0; i < T_long; ++i) {
|
||||
uint8_t timeIndex = (data[i / 4] >> (6 - (2 * (i % 4)))) & 0x03;
|
||||
if (timings[timeIndex] > 0 || i == T_long - 1) {
|
||||
if(nextPinState){
|
||||
if (nextPinState){
|
||||
TX_PIN_HIGH();
|
||||
}else{
|
||||
TX_PIN_LOW();
|
||||
|
|
@ -111,7 +111,7 @@ void sendSCodedData(uint8_t* data, uint8_t pulseCount, uint8_t repeat, uint8_t p
|
|||
bool nextPinState = HIGH;
|
||||
for (int i = 0; i < pulseCount; ++i) {
|
||||
if (data[i] > 0 || i == pulseCount - 1) {
|
||||
if(nextPinState){
|
||||
if (nextPinState){
|
||||
TX_PIN_HIGH();
|
||||
}else{
|
||||
TX_PIN_LOW();
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ void loop()
|
|||
|
||||
// Send power consumption
|
||||
#ifdef POWERCON_ENABLED
|
||||
if(timerMultiplier % POWER_TIMER_MULTIPLIER == 0)
|
||||
if (timerMultiplier % POWER_TIMER_MULTIPLIER == 0)
|
||||
{
|
||||
static PowerData powerData;
|
||||
powerSensor->read(powerData); // not needed, only here for future use
|
||||
|
|
@ -103,7 +103,7 @@ void loop()
|
|||
|
||||
// Handle temperature sensor
|
||||
#ifdef TEMPERATURE_ENABLED
|
||||
if(timerMultiplier % TEMPERATURE_TIMER_MULTIPLIER == 0)
|
||||
if (timerMultiplier % TEMPERATURE_TIMER_MULTIPLIER == 0)
|
||||
{
|
||||
static TemperatureData tempData;
|
||||
tempSensor->read(tempData);
|
||||
|
|
@ -114,7 +114,7 @@ void loop()
|
|||
|
||||
// Handle light sensor
|
||||
#ifdef LIGHT_ENABLED
|
||||
if(timerMultiplier % LIGHT_TIMER_MULTIPLIER == 0)
|
||||
if (timerMultiplier % LIGHT_TIMER_MULTIPLIER == 0)
|
||||
{
|
||||
static LightData lightData;
|
||||
lightSensor->read(lightData);
|
||||
|
|
|
|||
|
|
@ -83,14 +83,14 @@ inline void ProtocolOregon::setId(byte data[], byte id)
|
|||
*/
|
||||
inline void ProtocolOregon::setBatteryLevel(byte data[], bool level)
|
||||
{
|
||||
if(!level) data[4] = 0x0C;
|
||||
if (!level) data[4] = 0x0C;
|
||||
else data[4] = 0x00;
|
||||
}
|
||||
|
||||
inline void ProtocolOregon::setTemperature(byte data[], float temp)
|
||||
{
|
||||
// Set temperature sign
|
||||
if(temp < 0)
|
||||
if (temp < 0)
|
||||
{
|
||||
data[6] = 0x08;
|
||||
temp *= -1;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue