-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
159 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,104 +1,104 @@ | ||
/* | ||
Livolo.cpp - Library for Livolo wireless switches. | ||
Created by Sergey Chernov, October 25, 2013. | ||
Released into the public domain. | ||
01/12/2013 - code optimization, thanks Maarten! http://forum.arduino.cc/index.php?topic=153525.msg1489857#msg1489857 | ||
*/ | ||
|
||
#include "Arduino.h" | ||
#include "Livolo.h" | ||
|
||
Livolo::Livolo(byte pin) | ||
{ | ||
pinMode(pin, OUTPUT); | ||
txPin = pin; | ||
} | ||
|
||
// keycodes #1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106 | ||
// real remote IDs: 6400; 19303 | ||
// tested "virtual" remote IDs: 10550; 8500; 7400 | ||
// other IDs could work too, as long as they do not exceed 16 bit | ||
// known issue: not all 16 bit remote ID are valid | ||
// have not tested other buttons, but as there is dimmer control, some keycodes could be strictly system | ||
// use: sendButton(remoteID, keycode), see example blink.ino; | ||
|
||
|
||
void Livolo::sendButton(unsigned int remoteID, byte keycode) { | ||
|
||
for (pulse= 0; pulse <= 180; pulse = pulse+1) { // how many times to transmit a command | ||
sendPulse(1); // Start | ||
high = true; // first pulse is always high | ||
|
||
for (i = 16; i>0; i--) { // transmit remoteID | ||
byte txPulse=bitRead(remoteID, i-1); // read bits from remote ID | ||
selectPulse(txPulse); | ||
} | ||
|
||
for (i = 7; i>0; i--) { // transmit keycode | ||
byte txPulse=bitRead(keycode, i-1); // read bits from keycode | ||
selectPulse(txPulse); | ||
} | ||
} | ||
digitalWrite(txPin, LOW); | ||
} | ||
|
||
// build transmit sequence so that every high pulse is followed by low and vice versa | ||
|
||
void Livolo::selectPulse(byte inBit) { | ||
|
||
switch (inBit) { | ||
case 0: | ||
for (byte ii=1; ii<3; ii++) { | ||
if (high == true) { // if current pulse should be high, send High Zero | ||
sendPulse(2); | ||
} else { // else send Low Zero | ||
sendPulse(4); | ||
} | ||
high=!high; // invert next pulse | ||
} | ||
break; | ||
case 1: // if current pulse should be high, send High One | ||
if (high == true) { | ||
sendPulse(3); | ||
} else { // else send Low One | ||
sendPulse(5); | ||
} | ||
high=!high; // invert next pulse | ||
break; | ||
} | ||
} | ||
|
||
// transmit pulses | ||
// slightly corrected pulse length, use old (commented out) values if these not working for you | ||
|
||
void Livolo::sendPulse(byte txPulse) { | ||
|
||
switch(txPulse) { // transmit pulse | ||
case 1: // Start | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(500); // 550 | ||
// digitalWrite(txPin, LOW); | ||
break; | ||
case 2: // "High Zero" | ||
digitalWrite(txPin, LOW); | ||
delayMicroseconds(100); // 110 | ||
digitalWrite(txPin, HIGH); | ||
break; | ||
case 3: // "High One" | ||
digitalWrite(txPin, LOW); | ||
delayMicroseconds(300); // 303 | ||
digitalWrite(txPin, HIGH); | ||
break; | ||
case 4: // "Low Zero" | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(100); // 110 | ||
digitalWrite(txPin, LOW); | ||
break; | ||
case 5: // "Low One" | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(300); // 290 | ||
digitalWrite(txPin, LOW); | ||
break; | ||
} | ||
/* | ||
Livolo.cpp - Library for Livolo wireless switches. | ||
Created by Sergey Chernov, October 25, 2013. | ||
Released into the public domain. | ||
01/12/2013 - code optimization, thanks Maarten! http://forum.arduino.cc/index.php?topic=153525.msg1489857#msg1489857 | ||
*/ | ||
|
||
#include "Arduino.h" | ||
#include "Livolo.h" | ||
|
||
Livolo::Livolo(byte pin) | ||
{ | ||
pinMode(pin, OUTPUT); | ||
txPin = pin; | ||
} | ||
|
||
// keycodes #1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106 | ||
// real remote IDs: 6400; 19303 | ||
// tested "virtual" remote IDs: 10550; 8500; 7400 | ||
// other IDs could work too, as long as they do not exceed 16 bit | ||
// known issue: not all 16 bit remote ID are valid | ||
// have not tested other buttons, but as there is dimmer control, some keycodes could be strictly system | ||
// use: sendButton(remoteID, keycode), see example blink.ino; | ||
|
||
|
||
void Livolo::sendButton(unsigned int remoteID, byte keycode) { | ||
|
||
for (pulse= 0; pulse <= 180; pulse = pulse+1) { // how many times to transmit a command | ||
sendPulse(1); // Start | ||
high = true; // first pulse is always high | ||
|
||
for (i = 16; i>0; i--) { // transmit remoteID | ||
byte txPulse=bitRead(remoteID, i-1); // read bits from remote ID | ||
selectPulse(txPulse); | ||
} | ||
|
||
for (i = 7; i>0; i--) { // transmit keycode | ||
byte txPulse=bitRead(keycode, i-1); // read bits from keycode | ||
selectPulse(txPulse); | ||
} | ||
} | ||
digitalWrite(txPin, LOW); | ||
} | ||
|
||
// build transmit sequence so that every high pulse is followed by low and vice versa | ||
|
||
void Livolo::selectPulse(byte inBit) { | ||
|
||
switch (inBit) { | ||
case 0: | ||
for (byte ii=1; ii<3; ii++) { | ||
if (high == true) { // if current pulse should be high, send High Zero | ||
sendPulse(2); | ||
} else { // else send Low Zero | ||
sendPulse(4); | ||
} | ||
high=!high; // invert next pulse | ||
} | ||
break; | ||
case 1: // if current pulse should be high, send High One | ||
if (high == true) { | ||
sendPulse(3); | ||
} else { // else send Low One | ||
sendPulse(5); | ||
} | ||
high=!high; // invert next pulse | ||
break; | ||
} | ||
} | ||
|
||
// transmit pulses | ||
// slightly corrected pulse length, use old (commented out) values if these not working for you | ||
|
||
void Livolo::sendPulse(byte txPulse) { | ||
|
||
switch(txPulse) { // transmit pulse | ||
case 1: // Start | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(500); // 550 | ||
// digitalWrite(txPin, LOW); | ||
break; | ||
case 2: // "High Zero" | ||
digitalWrite(txPin, LOW); | ||
delayMicroseconds(100); // 110 | ||
digitalWrite(txPin, HIGH); | ||
break; | ||
case 3: // "High One" | ||
digitalWrite(txPin, LOW); | ||
delayMicroseconds(300); // 303 | ||
digitalWrite(txPin, HIGH); | ||
break; | ||
case 4: // "Low Zero" | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(100); // 110 | ||
digitalWrite(txPin, LOW); | ||
break; | ||
case 5: // "Low One" | ||
digitalWrite(txPin, HIGH); | ||
delayMicroseconds(300); // 290 | ||
digitalWrite(txPin, LOW); | ||
break; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
/* | ||
Morse.h - Library for Livolo wireless switches. | ||
Created by Sergey Chernov, October 25, 2013. | ||
Released into the public domain. | ||
*/ | ||
|
||
#ifndef Livolo_h | ||
#define Livolo_h | ||
|
||
#include "Arduino.h" | ||
|
||
class Livolo | ||
{ | ||
public: | ||
Livolo(byte pin); | ||
void sendButton(unsigned int remoteID, byte keycode); | ||
private: | ||
byte txPin; | ||
byte i; // just a counter | ||
byte pulse; // counter for command repeat | ||
boolean high; // pulse "sign" | ||
void selectPulse(byte inBit); | ||
void sendPulse(byte txPulse); | ||
}; | ||
|
||
/* | ||
Morse.h - Library for Livolo wireless switches. | ||
Created by Sergey Chernov, October 25, 2013. | ||
Released into the public domain. | ||
*/ | ||
|
||
#ifndef Livolo_h | ||
#define Livolo_h | ||
|
||
#include "Arduino.h" | ||
|
||
class Livolo | ||
{ | ||
public: | ||
Livolo(byte pin); | ||
void sendButton(unsigned int remoteID, byte keycode); | ||
private: | ||
byte txPin; | ||
byte i; // just a counter | ||
byte pulse; // counter for command repeat | ||
boolean high; // pulse "sign" | ||
void selectPulse(byte inBit); | ||
void sendPulse(byte txPulse); | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
This is a library to control Livolo branded wireless switches. | ||
Features: | ||
- emulates buttons 1 to 0 and ALL OFF of Livolo remote controller | ||
Usage: | ||
Basically you need two things to get it to work: | ||
1) Create Livolo instance | ||
2) Use sendButton (unsigned int remoteID, byte keycode) function to "push" the buttons | ||
sendButton function uses to arguments: remote ID and keycode. Typically, remote IDs are 16 bit unsigned values, but | ||
not all of them are valid (maybe there are some IDs reserved only for system use or there is something I don't know). | ||
Tested remote IDs: | ||
- read from real remote IDs: 6400; 19303 | ||
- "virtual" remote IDs: 10550; 8500; 7400 | ||
You can try and find new IDs as well: put your switch into learning mode and start sendButton with remote ID you wish to use. If | ||
it is a valid ID, switch will accept it. | ||
Keycodes read from real remote: | ||
#1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106 | ||
Keycodes are 7 bit values (actually I use 8 bit values, just skip most significant (leftmost) bit), but other keycodes | ||
could be reserved for system use (dimmer, for example). | ||
This is a library to control Livolo branded wireless switches. | ||
|
||
Features: | ||
|
||
- emulates buttons 1 to 0 and ALL OFF of Livolo remote controller | ||
|
||
Usage: | ||
|
||
Basically you need two things to get it to work: | ||
|
||
1) Create Livolo instance | ||
2) Use sendButton (unsigned int remoteID, byte keycode) function to "push" the buttons | ||
|
||
sendButton function uses to arguments: remote ID and keycode. Typically, remote IDs are 16 bit unsigned values, but | ||
not all of them are valid (maybe there are some IDs reserved only for system use or there is something I don't know). | ||
|
||
Tested remote IDs: | ||
|
||
- read from real remote IDs: 6400; 19303 | ||
- "virtual" remote IDs: 10550; 8500; 7400 | ||
|
||
You can try and find new IDs as well: put your switch into learning mode and start sendButton with remote ID you wish to use. If | ||
it is a valid ID, switch will accept it. | ||
|
||
Keycodes read from real remote: | ||
|
||
#1: 0, #2: 96, #3: 120, #4: 24, #5: 80, #6: 48, #7: 108, #8: 12, #9: 72; #10: 40, #OFF: 106 | ||
|
||
Keycodes are 7 bit values (actually I use 8 bit values, just skip most significant (leftmost) bit), but other keycodes | ||
could be reserved for system use (dimmer, for example). | ||
|
||
For an example sketch see blink.ino under examples folder. |