add analog Read/Write and RCDecimal
This commit is contained in:
parent
f3d68c374e
commit
1afb6e6588
2 changed files with 37 additions and 9 deletions
|
@ -82,11 +82,11 @@ Followed by six byte long value
|
|||
- [x] 81 - Q - set pin mode
|
||||
- [x] 82 - R - digital write
|
||||
- [x] 83 - S - digital read
|
||||
- [ ] 84 - T - analog write
|
||||
- [ ] 85 - U - analog read
|
||||
- [ ] 86 - V - handle RC Decimal
|
||||
- [x] 84 - T - analog write
|
||||
- [x] 85 - U - analog read
|
||||
- [x] 86 - V - handle RC Decimal
|
||||
- [x] 87 - W - handle RC TriState
|
||||
- [ ] 88 - X - handle IR send
|
||||
- [x] 88 - X - handle IR send
|
||||
- [x] 89 - Y - handle IR read
|
||||
|
||||
## Special Command
|
||||
|
|
|
@ -56,8 +56,8 @@ void decodeMessage() {
|
|||
case 81: setMode(val[0], pin); break;
|
||||
case 82: digitalW(val[0], pin); break;
|
||||
case 83: digitalR(pin); break;
|
||||
//case 84: break;
|
||||
//case 85: break;
|
||||
case 84: analogW(pin, val) break;
|
||||
case 85: analogR(pin) break;
|
||||
//case 86: break;
|
||||
case 87: sendRCTristate(val, pin); break;
|
||||
//case 88: break;
|
||||
|
@ -115,6 +115,34 @@ 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,(256*val[0])+val[1]);
|
||||
|
||||
}
|
||||
|
||||
void analogR(int pin) {
|
||||
|
||||
if(p == -1) { Serial.println("badpin"); return; }
|
||||
pinMode(p, INPUT);
|
||||
int rval = analogRead(p);
|
||||
Serial.println(String(pin + "::" + rval));
|
||||
|
||||
}
|
||||
|
||||
void handleRCDecimal(uint8_t val[], int pin) {
|
||||
|
||||
if (p == -1) { Serial.println("badpin"); return; }
|
||||
unsigned int length =(val[0]*256)+val[1];
|
||||
unsigned long value =(val[2]*16777216)+(val[3]*65536)+(val[4]*256)+val[5];
|
||||
RCSwitch rc = RCSwitch();
|
||||
rc.enableTransmit(p);
|
||||
rc.send(value, length);
|
||||
|
||||
}
|
||||
|
||||
void sendRCTristate (uint8_t val[], int pin) {
|
||||
|
||||
if(pin == -1) { Serial.println("badpin"); return; }
|
||||
|
|
Reference in a new issue