bug fix ir Reading capability

This commit is contained in:
Stefan Sterz 2016-01-21 22:49:04 +01:00
parent d9527a5587
commit c34cba3176
2 changed files with 13 additions and 12 deletions

View File

@ -20,7 +20,7 @@ void setup()
void loop()
{
if (irReceive < millis() && irrecv.decode(&results)) {
if (irReceive > millis() && irrecv.decode(&results)) {
irRead(&results);
irrecv.resume();
@ -45,8 +45,8 @@ void loop()
void decodeMessage() {
int cmd = message[0];
int pin = (message[1] - 97 < 0 || message[1] - 97 > 19)? -1 : message[1] - 97 < 0;
int pin = (message[1] - 97 < 0 || message[1] - 97 > 19)? -1 : message[1] - 97 ;
if(com) {
uint8_t val[6];
memcpy(val, message + 2, 6);
@ -134,13 +134,13 @@ void sendRCTristate (uint8_t val[], int pin) {
triStateCode.toCharArray(triState, triStateCode.length() + 1);
rc.sendTriState(triState);
Serial.println("RC-Tristate send!");
delay(500);
Serial.print("RC-Tristate send: ");
Serial.println(triState);
}
void irRead(decode_results *results) {
unsigned long codeValue;
int codeLen;
int codeType = results->decode_type;
if (codeType == UNKNOWN) {
@ -155,9 +155,10 @@ void irRead(decode_results *results) {
}
}
codeValue = results->value;
codeLen = results->bits;
String m = String(codeType + "::" + codeValue);
Serial.println(String(m + "::" + codeLen));
unsigned long codeValue = results->value;
int codeLen = results->bits;
char m[22];
sprintf(m, "%04d::%04d::%09lu", codeType,codeLen,codeValue);
Serial.println(m);
}
}
}

View File

@ -14,7 +14,7 @@ router.get('/toggleLight', function (req, res) {
var s = "0FFF0FFF000F";
var str = "";
for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); }
arduino.write(new Buffer('Wa' + str,'ascii'));
arduino.write(new Buffer('Wl' + str,'ascii'));
res.send('switch light');
});