bug fix ir Reading capability

This commit is contained in:
Shannon 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() void loop()
{ {
if (irReceive < millis() && irrecv.decode(&results)) { if (irReceive > millis() && irrecv.decode(&results)) {
irRead(&results); irRead(&results);
irrecv.resume(); irrecv.resume();
@ -45,7 +45,7 @@ void loop()
void decodeMessage() { void decodeMessage() {
int cmd = message[0]; 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) { if(com) {
uint8_t val[6]; uint8_t val[6];
@ -134,13 +134,13 @@ void sendRCTristate (uint8_t val[], int pin) {
triStateCode.toCharArray(triState, triStateCode.length() + 1); triStateCode.toCharArray(triState, triStateCode.length() + 1);
rc.sendTriState(triState); rc.sendTriState(triState);
Serial.println("RC-Tristate send!"); delay(500);
Serial.print("RC-Tristate send: ");
Serial.println(triState);
} }
void irRead(decode_results *results) { void irRead(decode_results *results) {
unsigned long codeValue;
int codeLen;
int codeType = results->decode_type; int codeType = results->decode_type;
if (codeType == UNKNOWN) { if (codeType == UNKNOWN) {
@ -155,9 +155,10 @@ void irRead(decode_results *results) {
} }
} }
codeValue = results->value; unsigned long codeValue = results->value;
codeLen = results->bits; int codeLen = results->bits;
String m = String(codeType + "::" + codeValue); char m[22];
Serial.println(String(m + "::" + codeLen)); 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 s = "0FFF0FFF000F";
var str = ""; var str = "";
for(i = 0; i < s.length; i+=2) { str += String.fromCharCode(parseInt(s.substr(i,2), 16)); } 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'); res.send('switch light');
}); });