bug fixing

This commit is contained in:
Shannon Sterz 2016-01-26 16:39:58 +01:00
parent b1552598ea
commit cb9e5fc361

View file

@ -53,18 +53,18 @@ void decodeMessage() {
switch (cmd) {
//case 80: break;
case 81: setMode(val[0], pin); break;
case 82: digitalW(val[0], pin); break;
case 83: digitalR(pin); break;
case 84: analogW(pin, val) break;
case 85: analogR(pin) break;
case 86: handleRCDecimal(val, pin) break;
case 87: sendRCTristate(val, pin); break;
case 88: irSend(val[0], val[1], lastFourToLong(val)) break;
case 81: setMode(val[0], pin); break;
case 82: digitalW(val[0], pin); break;
case 83: digitalR(pin); break;
case 84: analogW(val, pin); break;
case 85: analogR(pin); break;
case 86: handleRCDecimal(val, pin); break;
case 87: sendRCTristate(val, pin); break;
case 88: irSend(val[0], val[1], lastFourToLong(val)); break;
case 89: irrecv.enableIRIn();
irReceive = millis() + 10000;
break;
default: break;
default: break;
}
} else if(cmd == 90) {
@ -117,28 +117,28 @@ void digitalR(int pin) {
void analogW(uint8_t val[], int pin) {
if(p == -1) { if(debug) Serial.println("badpin"); return; }
pinMode(p, OUTPUT);
analogWrite(p,firsTwoToInt(val));
if(pin == -1) { Serial.println("badpin"); return; }
pinMode(pin, OUTPUT);
analogWrite(pin,firsTwoToInt(val));
}
void analogR(int pin) {
if(p == -1) { Serial.println("badpin"); return; }
pinMode(p, INPUT);
int rval = analogRead(p);
if(pin == -1) { Serial.println("badpin"); return; }
pinMode(pin, INPUT);
int rval = analogRead(pin);
Serial.println(String(pin + "::" + rval));
}
void handleRCDecimal(uint8_t val[], int pin) {
if (p == -1) { Serial.println("badpin"); return; }
if (pin == -1) { Serial.println("badpin"); return; }
unsigned int length = firsTwoToInt(val);
unsigned long value = lastFourToLong(val);
RCSwitch rc = RCSwitch();
rc.enableTransmit(p);
rc.enableTransmit(pin);
rc.send(value, length);
}