From 663e04f6c8d2bd6a26c9876e9b76cfbba25346fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Mon, 30 Dec 2013 16:04:35 +0100 Subject: [PATCH] working basics --- hive/libhive/radioplugin/radioswitch.cpp | 14 ++++++-------- hive/server/hive_pi/radio/radioreciver.cpp | 9 ++++----- 2 files changed, 10 insertions(+), 13 deletions(-) diff --git a/hive/libhive/radioplugin/radioswitch.cpp b/hive/libhive/radioplugin/radioswitch.cpp index 1d0f7631..b354b240 100644 --- a/hive/libhive/radioplugin/radioswitch.cpp +++ b/hive/libhive/radioplugin/radioswitch.cpp @@ -66,9 +66,9 @@ bool RadioSwitch::isValid(QList rawData) QByteArray channelSettings; for(int i = 1; i < 10; i+=2){ if(m_binCode.at(i-1) == '0' && m_binCode.at(i) == '1'){ - channelSettings.append("0"); + channelSettings.append('0'); }else{ - channelSettings.append("1"); + channelSettings.append('1'); } } // get the button letter @@ -98,12 +98,10 @@ bool RadioSwitch::isValid(QList rawData) bool buttonStatus; if(byteList.last().toInt(0,2) == 1){ buttonStatus = true; - }else - if(byteList.last().toInt(0,2) == 4){ - buttonStatus = false; - }else{ - return false; - } + } + if(byteList.last().toInt(0,2) == 4){ + buttonStatus = false; + } qDebug() << "-----------------------------------------------------------"; qDebug() << "| REMOTE signal |"; diff --git a/hive/server/hive_pi/radio/radioreciver.cpp b/hive/server/hive_pi/radio/radioreciver.cpp index 8d3afc84..937e13b1 100644 --- a/hive/server/hive_pi/radio/radioreciver.cpp +++ b/hive/server/hive_pi/radio/radioreciver.cpp @@ -150,8 +150,8 @@ void RadioReciver::handleInterrupt() m_duration = currentTime - m_lastTime; // filter nois - if (m_duration > 5000 && m_timings[0] - 200 && m_duration < m_timings[0] + 200){ - //qDebug() << "dt " << m_duration; + if (m_duration > 5000 && m_duration > m_timings[0] - 200 && m_duration < m_timings[0] + 200){ + qDebug() << "dt " << m_duration; m_repeatCount++; m_changeCount--; @@ -160,14 +160,13 @@ void RadioReciver::handleInterrupt() // if we have a regular signal (1 bit sync + 48 bit data) if(m_changeCount == RC_MAX_CHANGES){ // write rawdata to a List and reset values to 0 + qDebug() << "detect protokol"; QList rawData; for(int i = 0; i < RC_MAX_CHANGES; i++ ){ rawData.append(m_timings[i]); m_timings[i] = 0; } detectProtocol(rawData); - }else{ - //qDebug() << "changes: " << m_changeCount; } m_repeatCount = 0; } @@ -177,7 +176,7 @@ void RadioReciver::handleInterrupt() m_changeCount = 0; } - if (m_changeCount >= RC_MAX_CHANGES) { + if (m_changeCount >= RC_MAX_CHANGES+1) { m_changeCount = 0; m_repeatCount = 0; }