├── .gitignore ├── pics ├── cc1101_1.png ├── cc1101_2.png ├── cc1101_3.jpg ├── cc1101_4.jpg ├── cc1101_5.JPG ├── cc1101_6.JPG └── cc1101_7.JPG ├── ESPboy_Sub1GHzInspector.ino.d1_mini.bin ├── lib ├── SmartRC-CC1101-Driver-Lib-master │ ├── img │ │ ├── MEGA_CC1101.png │ │ ├── Nano_CC1101.png │ │ ├── Esp32_CC1101.png │ │ ├── Esp8266_CC1101.png │ │ ├── Wiring_CC1101.png │ │ └── TXS0108E_CC1101.png │ ├── examples │ │ ├── Rc-Switch examples cc1101 │ │ │ ├── Receive_Send_Decimal_Demo_Simple │ │ │ │ ├── RX-TX_WIRING ESP32.png │ │ │ │ ├── RX-TX_WIRING ESP8266.png │ │ │ │ ├── RX-TX_WIRING NANO_UNO.png │ │ │ │ └── Receive_Send_Decimal_Demo_Simple.ino │ │ │ ├── ReceiveDemo_Advanced_cc1101 │ │ │ │ ├── ReceiveDemo_Advanced_cc1101.ino │ │ │ │ └── output.ino │ │ │ ├── ReceiveDemo_Simple_cc1101 │ │ │ │ └── ReceiveDemo_Simple_cc1101.ino │ │ │ ├── ReceiveDemo_Simple_with_RSSI_cc1101 │ │ │ │ └── ReceiveDemo_Simple_with_RSSI_cc1101.ino │ │ │ ├── TypeD_REV_cc1101 │ │ │ │ └── TypeD_REV_cc1101.ino │ │ │ ├── TypeC_Intertechno_cc1101 │ │ │ │ └── TypeC_Intertechno_cc1101.ino │ │ │ ├── TypeA_WithDIPSwitches_cc1101 │ │ │ │ └── TypeA_WithDIPSwitches_cc1101.ino │ │ │ ├── TypeB_WithRotaryOrSlidingSwitches_cc1101 │ │ │ │ └── TypeB_WithRotaryOrSlidingSwitches_cc1101.ino │ │ │ ├── SendDemo_cc1101 │ │ │ │ └── SendDemo_cc1101.ino │ │ │ ├── Repeater_cc1101 │ │ │ │ └── Repeater_cc1101.ino │ │ │ └── ProtocolAnalyzeDemo_cc1101 │ │ │ │ └── ProtocolAnalyzeDemo_cc1101.ino │ │ ├── ESPiLight examples cc1101 │ │ │ ├── Transmit_cc1101 │ │ │ │ └── Transmit_cc1101.ino │ │ │ ├── Transmit_Raw_cc1101 │ │ │ │ └── Transmit_Raw_cc1101.ino │ │ │ ├── Receive_Raw_cc1101 │ │ │ │ └── Receive_Raw_cc1101.ino │ │ │ ├── pilight_raw_cc1101 │ │ │ │ └── pilight_raw_cc1101.ino │ │ │ ├── Receive_cc1101 │ │ │ │ └── Receive_cc1101.ino │ │ │ └── pilight_debug_cc1101 │ │ │ │ └── pilight_debug_cc1101.ino │ │ ├── RemoteSensor examples cc1101 │ │ │ ├── ThermoHygroTransmitter_cc1101 │ │ │ │ └── ThermoHygroTransmitter_cc1101.ino │ │ │ ├── ThermoHygroReceiver_cc1101 │ │ │ │ └── ThermoHygroReceiver_cc1101.ino │ │ │ └── Repeater_cc1101 │ │ │ │ └── Repeater_cc1101.ino │ │ ├── CC1101 default examples │ │ │ ├── New_Method_without_GDO │ │ │ │ ├── cc1101_New_Transmitt_method_Serial_minimal │ │ │ │ │ └── cc1101_New_Transmitt_method_Serial_minimal.ino │ │ │ │ ├── cc1101_New_Receive_method_minimal │ │ │ │ │ └── cc1101_New_Receive_method_minimal.ino │ │ │ │ ├── cc1101_New_Transmitt_method_Hello_World_minimal │ │ │ │ │ └── cc1101_New_Transmitt_method_Hello_World_minimal.ino │ │ │ │ ├── cc1101_New_Transmitt_method_Serial_advanced │ │ │ │ │ └── cc1101_New_Transmitt_method_Serial_advanced.ino │ │ │ │ ├── cc1101_New_Transmitt_method_Hello_World_advanced │ │ │ │ │ └── cc1101_New_Transmitt_method_Hello_World_advanced.ino │ │ │ │ └── cc1101_New_Receive_method_advanced │ │ │ │ │ └── cc1101_New_Receive_method_advanced.ino │ │ │ └── Old_Method_with_GDO │ │ │ │ ├── cc1101_Receive_minimal │ │ │ │ └── cc1101_Receive_minimal.ino │ │ │ │ ├── cc1101_Transmitt_Serial_minimal │ │ │ │ └── cc1101_Transmitt_Serial_minimal.ino │ │ │ │ ├── cc1101_Transmitt_Hello_World_minimal │ │ │ │ └── cc1101_Transmitt_Hello_World_minimal.ino │ │ │ │ ├── cc1101_Transmitt_Serial_advanced │ │ │ │ └── cc1101_Transmitt_Serial_advanced.ino │ │ │ │ ├── cc1101_Transmitt_Hello_World_advanced │ │ │ │ └── cc1101_Transmitt_Hello_World_advanced.ino │ │ │ │ └── cc1101_Receive_advanced │ │ │ │ └── cc1101_Receive_advanced.ino │ │ └── NewRemoteSwitch examples cc1101 │ │ │ ├── ShowReceivedCode_cc1101 │ │ │ └── ShowReceivedCode_cc1101.ino │ │ │ ├── LightShow_cc1101 │ │ │ └── LightShow_cc1101.ino │ │ │ ├── Retransmitter_cc1101 │ │ │ └── Retransmitter_cc1101.ino │ │ │ ├── LearnCode_cc1101 │ │ │ └── LearnCode_cc1101.ino │ │ │ └── NewRemoteRepeater │ │ │ └── NewRemoteRepeater.ino │ ├── library.properties │ ├── library.json │ ├── keywords.txt │ ├── LICENSE.txt │ └── ELECHOUSE_CC1101_SRC_DRV.h ├── RC-switch_mod │ ├── library.properties │ ├── README.md │ ├── library.json │ ├── examples │ │ ├── ReceiveDemo_Advanced │ │ │ ├── ReceiveDemo_Advanced.ino │ │ │ └── output.ino │ │ ├── ReceiveDemo_Simple │ │ │ └── ReceiveDemo_Simple.ino │ │ ├── TypeD_REV │ │ │ └── TypeD_REV.ino │ │ ├── TypeC_Intertechno │ │ │ └── TypeC_Intertechno.ino │ │ ├── TypeA_WithDIPSwitches │ │ │ └── TypeA_WithDIPSwitches.ino │ │ ├── TypeB_WithRotaryOrSlidingSwitches │ │ │ └── TypeB_WithRotaryOrSlidingSwitches.ino │ │ ├── TypeA_WithDIPSwitches_Lightweight │ │ │ └── TypeA_WithDIPSwitches_Lightweight.ino │ │ ├── SendDemo │ │ │ └── SendDemo.ino │ │ └── Webserver │ │ │ └── Webserver.ino │ ├── keywords.txt │ ├── platformio.ini │ └── src │ │ └── RCSwitch.h ├── ESPboyLED.h ├── ESPboyMCP.h ├── ESPboyInit.h ├── ESPboyInit.cpp ├── ESPboyMenuGUI.h ├── ESPboyTerminalGUI.h ├── ESPboyMCP.cpp ├── ESPboyLED.cpp ├── ESPboyLogo.h ├── ESPboyMenuGUI.cpp └── ESPboyTerminalGUI.cpp └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | .DS_Store 3 | -------------------------------------------------------------------------------- /pics/cc1101_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_1.png -------------------------------------------------------------------------------- /pics/cc1101_2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_2.png -------------------------------------------------------------------------------- /pics/cc1101_3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_3.jpg -------------------------------------------------------------------------------- /pics/cc1101_4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_4.jpg -------------------------------------------------------------------------------- /pics/cc1101_5.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_5.JPG -------------------------------------------------------------------------------- /pics/cc1101_6.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_6.JPG -------------------------------------------------------------------------------- /pics/cc1101_7.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/pics/cc1101_7.JPG -------------------------------------------------------------------------------- /ESPboy_Sub1GHzInspector.ino.d1_mini.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/ESPboy_Sub1GHzInspector.ino.d1_mini.bin -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/MEGA_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/MEGA_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/Nano_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/Nano_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/Esp32_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/Esp32_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/Esp8266_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/Esp8266_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/Wiring_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/Wiring_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/img/TXS0108E_CC1101.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/img/TXS0108E_CC1101.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP32.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP8266.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING ESP8266.png -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING NANO_UNO.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ESPboy-edu/ESPboy_Sub1GHzInspector/HEAD/lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/RX-TX_WIRING NANO_UNO.png -------------------------------------------------------------------------------- /lib/RC-switch_mod/library.properties: -------------------------------------------------------------------------------- 1 | name=rc-switch 2 | version=1.0.0 3 | author=@sui77 @1technophile and more 4 | maintainer=Theo Arends 5 | sentence=Operate 433/315Mhz devices. 6 | paragraph=Use ESP8266/ESP32 to operate remote radio controlled devices. 7 | category=Device Control 8 | url=https://github.com/arendst/Tasmota 9 | architectures=esp8266,esp32 10 | includes=RCSwitch.h 11 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/README.md: -------------------------------------------------------------------------------- 1 | **Modified Tasmota Fork of RC-SWITCH by @sui77 and @1technophile** 2 | 3 | ## Info 4 | 5 | This will most likely work with all popular low cost power outlet sockets. 6 | 7 | All you need is a 315/433MHz AM transmitter and one 8 | or more devices with one of the supported chipsets: 9 | 10 | - SC5262 / SC5272 11 | - HX2262 / HX2272 12 | - PT2262 / PT2272 13 | - EV1527 / RT1527 / FP1527 / HS1527 14 | - Intertechno outlets 15 | - HT6P20X 16 | 17 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "rc-switch", 3 | "description": "Use ESP8266/ESP32 to operate remote radio controlled devices", 4 | "keywords": "rf, radio, wireless", 5 | "authors": 6 | { 7 | "name": "Theo Arends" 8 | }, 9 | "repository": 10 | { 11 | "type": "git", 12 | "url": "https://github.com/arendst/Tasmota.git" 13 | }, 14 | "version": "1.0.0", 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "platforms": "*" 19 | } 20 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/library.properties: -------------------------------------------------------------------------------- 1 | name=SmartRC-CC1101-Driver-Lib 2 | version=2.5.2 3 | author=LSatan 4 | maintainer=LSatan 5 | sentence=Driver for cc1101. 6 | paragraph=This driver library can be used for many libraries that use a simple RF ASK module,with the advantages of the cc1101 module.It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly. 7 | category=Device Control 8 | url=https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 9 | architectures=avr,esp8266,esp32 10 | includes=ELECHOUSE_CC1101_SRC_DRV.h 11 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/library.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "SmartRC-CC1101-Driver-Lib", 3 | "description": "This driver library can be used for many libraries that use a simple RF ASK module, with the advantages of the cc1101 module.It offers many direct setting options as in SmartRF Studio and calculates settings such as MHz directly.", 4 | "keywords": "rf, radio, wireless, cc1101", 5 | "authors": 6 | { 7 | "name": "Little Satan" 8 | }, 9 | "repository": 10 | { 11 | "type": "git", 12 | "url": "https://github.com/LSatan/SmartRC-CC1101-Driver-Lib" 13 | }, 14 | "version": "2.5.2", 15 | "frameworks": [ 16 | "arduino" 17 | ], 18 | "platforms": "*" 19 | } 20 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/ReceiveDemo_Advanced/ReceiveDemo_Advanced.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | If you want to visualize a telegram copy the raw data and 7 | paste it into http://test.sui.li/oszi/ 8 | */ 9 | 10 | #include 11 | 12 | RCSwitch mySwitch = RCSwitch(); 13 | 14 | void setup() { 15 | Serial.begin(9600); 16 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 17 | } 18 | 19 | void loop() { 20 | if (mySwitch.available()) { 21 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 22 | mySwitch.resetAvailable(); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/ReceiveDemo_Simple/ReceiveDemo_Simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | Serial.begin(9600); 13 | mySwitch.enableReceive(0); // Receiver on interrupt 0 => that is pin #2 14 | } 15 | 16 | void loop() { 17 | if (mySwitch.available()) { 18 | 19 | Serial.print("Received "); 20 | Serial.print( mySwitch.getReceivedValue() ); 21 | Serial.print(" / "); 22 | Serial.print( mySwitch.getReceivedBitlength() ); 23 | Serial.print("bit "); 24 | Serial.print("Protocol: "); 25 | Serial.println( mySwitch.getReceivedProtocol() ); 26 | 27 | mySwitch.resetAvailable(); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /lib/ESPboyLED.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy LED class 3 | for www.ESPboy.com project by RomanS 4 | */ 5 | #pragma once 6 | 7 | #include 8 | #include "ESPboyMCP.h" //to control LED lock 9 | 10 | #ifndef ESPboy_LED 11 | #define ESPboy_LED 12 | 13 | #define LEDPIN D4 14 | #define LEDLOCK 9 15 | 16 | class ESPboyLED{ 17 | private: 18 | ESPboyMCP *mcp; 19 | uint8_t LEDr, LEDg, LEDb, LEDflagOnOff; 20 | void ledset(uint8_t rled, uint8_t gled, uint8_t bled); 21 | 22 | public: 23 | void begin(ESPboyMCP *mcpGUI); 24 | void off(); 25 | void on(); 26 | uint8_t getState(); 27 | 28 | void setRGB (uint8_t red, uint8_t green, uint8_t blue); 29 | void setR (uint8_t red); 30 | void setG (uint8_t green); 31 | void setB (uint8_t blue); 32 | 33 | uint32_t getRGB(); 34 | uint8_t getR(); 35 | uint8_t getG(); 36 | uint8_t getB(); 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/TypeD_REV/TypeD_REV.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for REV outlets (e.g. 8342L) 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | Need help? http://forum.ardumote.com 7 | */ 8 | 9 | #include 10 | 11 | RCSwitch mySwitch = RCSwitch(); 12 | 13 | void setup() { 14 | 15 | // Transmitter is connected to Arduino Pin #10 16 | mySwitch.enableTransmit(10); 17 | 18 | // set pulse length. 19 | mySwitch.setPulseLength(360); 20 | 21 | } 22 | 23 | void loop() { 24 | 25 | // Switch on: 26 | // The first parameter represents the channel (a, b, c, d) 27 | // The second parameter represents the device number 28 | // 29 | // In this example it's family 'd', device #2 30 | mySwitch.switchOn('d', 2); 31 | 32 | // Wait a second 33 | delay(1000); 34 | 35 | // Switch off 36 | mySwitch.switchOff('d', 2); 37 | 38 | // Wait another second 39 | delay(1000); 40 | 41 | } 42 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/TypeC_Intertechno/TypeC_Intertechno.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for Intertechno outlets 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the familycode (a, b, c, ... f) 25 | // The second parameter represents the group number 26 | // The third parameter represents the device number 27 | // 28 | // In this example it's family 'b', group #3, device #2 29 | mySwitch.switchOn('b', 3, 2); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff('b', 3, 2); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/TypeA_WithDIPSwitches/TypeA_WithDIPSwitches.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with a 10 pole DIP switch. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first 5 DIP switches. 25 | // In this example it's ON-ON-OFF-OFF-ON. 26 | // 27 | // The second parameter represents the setting of the last 5 DIP switches. 28 | // In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF. 29 | mySwitch.switchOn("11001", "01010"); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff("11001", "01010"); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/TypeB_WithRotaryOrSlidingSwitches/TypeB_WithRotaryOrSlidingSwitches.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with two rotary/sliding switches. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | 9 | RCSwitch mySwitch = RCSwitch(); 10 | 11 | void setup() { 12 | 13 | // Transmitter is connected to Arduino Pin #10 14 | mySwitch.enableTransmit(10); 15 | 16 | // Optional set pulse length. 17 | // mySwitch.setPulseLength(320); 18 | 19 | } 20 | 21 | void loop() { 22 | 23 | // Switch on: 24 | // The first parameter represents the setting of the first rotary switch. 25 | // In this example it's switched to "1" or "A" or "I". 26 | // 27 | // The second parameter represents the setting of the second rotary switch. 28 | // In this example it's switched to "4" or "D" or "IV". 29 | mySwitch.switchOn(1, 4); 30 | 31 | // Wait a second 32 | delay(1000); 33 | 34 | // Switch off 35 | mySwitch.switchOff(1, 4); 36 | 37 | // Wait another second 38 | delay(1000); 39 | 40 | } 41 | -------------------------------------------------------------------------------- /lib/ESPboyMCP.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboyMCP class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | #ifndef ESPboy_MCP 9 | #define ESPboy_MCP 10 | 11 | #include 12 | #include 13 | 14 | 15 | #define MCP23017address 0x20 // actually it's 0x20 but in lib there is (x|0x20) :) 16 | #define MCP4725address 0x60 17 | 18 | class ESPboyMCP{ 19 | 20 | protected: 21 | bool detectedDAC = false; 22 | bool readyDAC(); 23 | uint8_t readRegister (const uint8_t address, uint8_t addr); 24 | uint8_t writeRegisterMode (const uint8_t address, uint16_t value, uint8_t reg); 25 | void writeRegister (const uint8_t address, uint8_t regAddr, uint8_t regValue); 26 | void updateRegisterBit (const uint8_t address, uint8_t pin, uint8_t pValue, uint8_t portAaddr, uint8_t portBaddr); 27 | public: 28 | void begin(); 29 | int8_t writeDAC(uint16_t value, const bool eeprom); 30 | void pinMode(uint8_t p, uint8_t d); 31 | void pullUp(uint8_t p, uint8_t d); 32 | void digitalWrite(uint8_t pin, uint8_t d); 33 | uint16_t readGPIOAB(); 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/keywords.txt: -------------------------------------------------------------------------------- 1 | ELECHOUSE_CC1101_SRC_DRV KEYWORD1 2 | ELECHOUSE_cc1101 KEYWORD1 3 | Init KEYWORD2 4 | SpiReadStatus KEYWORD2 5 | SpiStrobe KEYWORD2 6 | SpiWriteReg KEYWORD2 7 | SpiWriteBurstReg KEYWORD2 8 | SpiReadReg KEYWORD2 9 | SpiReadBurstReg KEYWORD2 10 | setSpiPin KEYWORD2 11 | setGDO KEYWORD2 12 | setCCMode KEYWORD2 13 | setModulation KEYWORD2 14 | setPA KEYWORD2 15 | setMHZ KEYWORD2 16 | setRxBW KEYWORD2 17 | setChannel KEYWORD2 18 | SetTx KEYWORD2 19 | SetRx KEYWORD2 20 | getRssi KEYWORD2 21 | getLqi KEYWORD2 22 | setSres KEYWORD2 23 | SendData KEYWORD2 24 | CheckReceiveFlag KEYWORD2 25 | CheckRxFifo KEYWORD2 26 | CheckCRC KEYWORD2 27 | ReceiveData KEYWORD2 28 | setClb KEYWORD2 29 | setChsp KEYWORD2 30 | setDRate KEYWORD2 31 | setDeviation KEYWORD2 32 | setSyncMode KEYWORD2 33 | setAdrChk KEYWORD2 34 | setAddr KEYWORD2 35 | setWhiteData KEYWORD2 36 | setPktFormat KEYWORD2 37 | setLengthConfig KEYWORD2 38 | setPacketLength KEYWORD2 39 | setCrc KEYWORD2 40 | setCRC_AF KEYWORD2 41 | setDcFilterOff KEYWORD2 42 | setManchester KEYWORD2 43 | setFEC KEYWORD2 44 | setPQT KEYWORD2 45 | setAppendStatus KEYWORD2 -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/LICENSE.txt: -------------------------------------------------------------------------------- 1 | ---------------------------------------------------------------------------------------------------------------- 2 | cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE). 3 | ---------------------------------------------------------------------------------------------------------------- 4 | 5 | 6 | ELECHOUSE_CC1101.cpp - CC1101 module library 7 | Copyright (c) 2010 Michael. 8 | Author: Michael, 9 | Version: November 12, 2010 10 | 11 | This library is designed to use CC1101/CC1100 module on Arduino platform. 12 | CC1101/CC1100 module is an useful wireless module.Using the functions of the 13 | library, you can easily send and receive data by the CC1101/CC1100 module. 14 | Just have fun! 15 | For the details, please refer to the datasheet of CC1100/CC1101. 16 | 17 | notes: The whole stuff that is not directly related to Rc_Switch, 18 | NewRemoteSwitch or Elechouse_cc1101 Lib is Copyright (c) 2018 - 2020 by Little Satan. 19 | Example calculator codes in the driver lib. 20 | And so on... 21 | You can freely use, edit or distribute it with reference to the source. 22 | For everything else, the rights of the respective owners apply! -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/TypeA_WithDIPSwitches_Lightweight/TypeA_WithDIPSwitches_Lightweight.ino: -------------------------------------------------------------------------------- 1 | /* 2 | This is a minimal sketch without using the library at all but only works for 3 | the 10 pole dip switch sockets. It saves a lot of memory and thus might be 4 | very useful to use with ATTinys :) 5 | 6 | https://github.com/sui77/rc-switch/ 7 | */ 8 | 9 | int RCLpin = 7; 10 | 11 | void setup() { 12 | pinMode(RCLpin, OUTPUT); 13 | } 14 | 15 | void loop() { 16 | RCLswitch(0b010001000001); // DIPs an Steckdose: 0100010000 An:01 17 | delay(2000); 18 | 19 | RCLswitch(0b010001000010); // DIPs an Steckdose: 0100010000 Aus:10 20 | delay(2000); 21 | } 22 | 23 | void RCLswitch(uint16_t code) { 24 | for (int nRepeat=0; nRepeat<6; nRepeat++) { 25 | for (int i=4; i<16; i++) { 26 | RCLtransmit(1,3); 27 | if (((code << (i-4)) & 2048) > 0) { 28 | RCLtransmit(1,3); 29 | } else { 30 | RCLtransmit(3,1); 31 | } 32 | } 33 | RCLtransmit(1,31); 34 | } 35 | } 36 | 37 | void RCLtransmit(int nHighPulses, int nLowPulses) { 38 | digitalWrite(RCLpin, HIGH); 39 | delayMicroseconds( 350 * nHighPulses); 40 | digitalWrite(RCLpin, LOW); 41 | delayMicroseconds( 350 * nLowPulses); 42 | } 43 | 44 | -------------------------------------------------------------------------------- /lib/ESPboyInit.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy_Init class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | #ifndef ESPboy_Init 9 | #define ESPboy_Init 10 | 11 | #include 12 | #include "ESPboyMCP.h" 13 | #include "ESPboyMCP.cpp" 14 | #include "ESPboyLED.h" 15 | #include "ESPboyLED.cpp" 16 | #include "ESPboylogo.h" 17 | 18 | #include 19 | 20 | #include //to control WiFi 21 | 22 | #include 23 | using fs::FS; 24 | 25 | #define MCP4725address 0x60 26 | #define CSTFTPIN 8 //Chip Select pin for LCD (it's on the MCP23017 GPIO expander GPIO8) 27 | 28 | #define LEDPIN D4 29 | #define SOUNDPIN D3 30 | 31 | #define PAD_LEFT 0x01 32 | #define PAD_UP 0x02 33 | #define PAD_DOWN 0x04 34 | #define PAD_RIGHT 0x08 35 | #define PAD_ACT 0x10 36 | #define PAD_ESC 0x20 37 | #define PAD_LFT 0x40 38 | #define PAD_RGT 0x80 39 | #define PAD_ANY 0xff 40 | 41 | 42 | class ESPboyInit{ 43 | 44 | public: 45 | ESPboyMCP mcp; 46 | TFT_eSPI tft; 47 | ESPboyLED myLED; 48 | 49 | 50 | ESPboyInit(); 51 | void begin(const char *appName); 52 | 53 | uint8_t getKeys(); 54 | void playTone(uint16_t frq, uint16_t dur); 55 | void playTone(uint16_t frq); 56 | void noPlayTone(); 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/keywords.txt: -------------------------------------------------------------------------------- 1 | ####################################### 2 | # Syntax Coloring Map For RCSwitch 3 | ####################################### 4 | 5 | ####################################### 6 | # Datatypes (KEYWORD1) 7 | ####################################### 8 | 9 | RCSwitch KEYWORD1 10 | 11 | ####################################### 12 | # Methods and Functions (KEYWORD2) 13 | ####################################### 14 | 15 | ########## 16 | #SENDS Begin 17 | ########## 18 | switchOn KEYWORD2 19 | switchOff KEYWORD2 20 | sendTriState KEYWORD2 21 | send KEYWORD2 22 | ########## 23 | #SENDS End 24 | ########## 25 | 26 | ########## 27 | #RECEIVE Begin 28 | ########## 29 | enableReceive KEYWORD2 30 | disableReceive KEYWORD2 31 | available KEYWORD2 32 | resetAvailable KEYWORD2 33 | setReceiveTolerance KEYWORD2 34 | getReceivedValue KEYWORD2 35 | getReceivedBitlength KEYWORD2 36 | getReceivedDelay KEYWORD2 37 | getReceivedProtocol KEYWORD2 38 | getReceivedRawdata KEYWORD2 39 | ########## 40 | #RECEIVE End 41 | ########## 42 | 43 | ########## 44 | #OTHERS Begin 45 | ########## 46 | enableTransmit KEYWORD2 47 | disableTransmit KEYWORD2 48 | setPulseLength KEYWORD2 49 | setProtocol KEYWORD2 50 | setRepeatTransmit KEYWORD2 51 | ########## 52 | #OTHERS End 53 | ########## 54 | 55 | ####################################### 56 | # Constants (LITERAL1) 57 | ####################################### 58 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/SendDemo/SendDemo.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | https://github.com/sui77/rc-switch/ 5 | 6 | */ 7 | 8 | #include 9 | 10 | RCSwitch mySwitch = RCSwitch(); 11 | 12 | void setup() { 13 | 14 | Serial.begin(9600); 15 | 16 | // Transmitter is connected to Arduino Pin #10 17 | mySwitch.enableTransmit(10); 18 | 19 | // Optional set protocol (default is 1, will work for most outlets) 20 | // mySwitch.setProtocol(2); 21 | 22 | // Optional set pulse length. 23 | // mySwitch.setPulseLength(320); 24 | 25 | // Optional set number of transmission repetitions. 26 | // mySwitch.setRepeatTransmit(15); 27 | 28 | } 29 | 30 | void loop() { 31 | 32 | /* See Example: TypeA_WithDIPSwitches */ 33 | mySwitch.switchOn("11111", "00010"); 34 | delay(1000); 35 | mySwitch.switchOff("11111", "00010"); 36 | delay(1000); 37 | 38 | /* Same switch as above, but using decimal code */ 39 | mySwitch.send(5393, 24); 40 | delay(1000); 41 | mySwitch.send(5396, 24); 42 | delay(1000); 43 | 44 | /* Same switch as above, but using binary code */ 45 | mySwitch.send("000000000001010100010001"); 46 | delay(1000); 47 | mySwitch.send("000000000001010100010100"); 48 | delay(1000); 49 | 50 | /* Same switch as above, but tri-state code */ 51 | mySwitch.sendTriState("00000FFF0F0F"); 52 | delay(1000); 53 | mySwitch.sendTriState("00000FFF0FF0"); 54 | delay(1000); 55 | 56 | delay(20000); 57 | } 58 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/ESPiLight examples cc1101/Transmit_cc1101/Transmit_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic ESPiLight transmit example 3 | 4 | https://github.com/puuu/espilight 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int TRANSMITTER_PIN; 14 | 15 | void setup() { 16 | Serial.begin(115200); 17 | 18 | #ifdef ESP32 19 | TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2. 20 | #elif ESP8266 21 | TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1. 22 | #else 23 | TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6. 24 | #endif 25 | 26 | //CC1101 Settings: (Settings with "//" are optional!) 27 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 28 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 29 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 30 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 31 | ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on 32 | } 33 | 34 | // Toggle state of elro 800 switch evrey 2 s 35 | void loop() { 36 | ESPiLight rf(TRANSMITTER_PIN); 37 | rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"on\":1}"); 38 | delay(2000); 39 | rf.send("elro_800_switch", "{\"systemcode\":17,\"unitcode\":1,\"off\":1}"); 40 | delay(2000); 41 | } 42 | -------------------------------------------------------------------------------- /lib/ESPboyInit.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy_Init class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | #ifndef ESPboy_Init_cpp 9 | #define ESPboy_Init_cpp 10 | 11 | #include "ESPboyInit.h" 12 | 13 | ESPboyInit::ESPboyInit(){}; 14 | 15 | void ESPboyInit::begin(const char *appName) { 16 | //Serial.begin(115200); //serial init 17 | WiFi.mode(WIFI_OFF); // to safe battery power 18 | 19 | 20 | //mcp23017 init for buttons, LED LOCK and TFT Chip Select pins 21 | mcp.begin(); 22 | delay(100); 23 | for (int i=0;i<8;i++){ 24 | mcp.pinMode(i, INPUT); 25 | mcp.pullUp(i, HIGH);} 26 | 27 | //DAC init and backlit off 28 | mcp.writeDAC(0, false); 29 | 30 | //LED init 31 | myLED.begin(&this->mcp); 32 | myLED.setRGB(0,0,0); 33 | 34 | //sound init and test 35 | pinMode(SOUNDPIN, OUTPUT); 36 | //playTone(200, 100); 37 | //delay(100); 38 | //playTone(100, 100); 39 | //delay(100); 40 | //noPlayTone(); 41 | 42 | //LCD TFT init 43 | mcp.pinMode(CSTFTPIN, OUTPUT); 44 | mcp.digitalWrite(CSTFTPIN, LOW); 45 | tft.begin(); 46 | tft.setSwapBytes(true); 47 | delay(100); 48 | //tft.setRotation(0); 49 | tft.fillScreen(TFT_BLACK); 50 | 51 | //draw ESPboylogo 52 | tft.drawXBitmap(30, 24, ESPboyLogo, 68, 64, TFT_YELLOW); 53 | tft.setTextSize(1); 54 | tft.setTextColor(TFT_YELLOW); 55 | tft.drawString (appName, (128-(strlen(appName)*6))/2, 102); 56 | 57 | //LCD backlit fading on 58 | for (uint16_t bcklt=300; bcklt<2500; bcklt+=30){ 59 | mcp.writeDAC(bcklt, false); 60 | delay(10);} 61 | 62 | delay(1000); 63 | 64 | //clear TFT and backlit on high 65 | mcp.writeDAC(4095, true); 66 | tft.fillScreen(TFT_BLACK); 67 | }; 68 | 69 | 70 | void ESPboyInit::playTone(uint16_t frq, uint16_t dur) { tone(SOUNDPIN, frq, dur); } 71 | void ESPboyInit::playTone(uint16_t frq) { tone(SOUNDPIN, frq); } 72 | 73 | void ESPboyInit::noPlayTone() { noTone(SOUNDPIN); } 74 | 75 | uint8_t ESPboyInit::getKeys() { return (~mcp.readGPIOAB() & 255); } 76 | 77 | #endif -------------------------------------------------------------------------------- /lib/ESPboyMenuGUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy_MenuGUI class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | 9 | //!!!!!!!!!!!!!!!!! 10 | //#define U8g2_MENU //if defined then using font 4x6, if commented using font 6x8 11 | #define buttonclicks //if defined - button are clicking but it takes more than 1kb RAM, if commented - no clicks and more free RAM 12 | ////!!!!!!!!!!!!!!!!! 13 | 14 | 15 | #ifndef ESPboy_MenuGUI 16 | #define ESPboy_MenuGUI 17 | 18 | #include "ESPboyInit.h" 19 | #include "ESPboyInit.cpp" 20 | 21 | #include 22 | using fs::FS; 23 | 24 | 25 | #ifdef U8g2_MENU 26 | #include "U8g2_for_TFT_eSPI.h" 27 | #endif 28 | 29 | #ifdef U8g2_MENU 30 | #define GUI_FONT_WIDTH_MENU 4 31 | #define GUI_FONT_HEIGHT_MENU 6 32 | #else 33 | #define GUI_FONT_WIDTH_MENU 6 34 | #define GUI_FONT_HEIGHT_MENU 8 35 | #endif 36 | 37 | #define MENU_SPACE_BETWEEN_LINES (GUI_FONT_HEIGHT_MENU+3) 38 | #define MENU_MAX_LINES_ONSCREEN (128/MENU_SPACE_BETWEEN_LINES) 39 | 40 | #define MenuGUI_PAD_LEFT 0x01 41 | #define MenuGUI_PAD_UP 0x02 42 | #define MenuGUI_PAD_DOWN 0x04 43 | #define MenuGUI_PAD_RIGHT 0x08 44 | #define MenuGUI_PAD_ACT 0x10 45 | #define MenuGUI_PAD_ESC 0x20 46 | #define MenuGUI_PAD_LFT 0x40 47 | #define MenuGUI_PAD_RGT 0x80 48 | #define MenuGUI_PAD_ANY 0xff 49 | 50 | 51 | class ESPboyMenuGUI{ 52 | 53 | private: 54 | ESPboyInit *myESPboy; 55 | #ifdef U8g2_MENU 56 | U8g2_for_TFT_eSPI *u8f; 57 | #endif 58 | 59 | struct menuStruct{ 60 | const char **menuLine; 61 | uint16_t menuOffset; 62 | uint16_t menuItemsQuantity; 63 | uint16_t menuLineColor; 64 | uint16_t menuUnselectedLineColor; 65 | uint16_t menuSelectionColor; 66 | uint16_t menuCurrent; 67 | } menuList; 68 | 69 | void menuDraw(); 70 | 71 | public: 72 | ESPboyMenuGUI(ESPboyInit *myESPboyPointer); 73 | uint16_t menuInit(const char** menuLinesF, uint16_t menuLineColorF, uint16_t menuUnselectedLineColorF, uint16_t menuSelectionColorF); 74 | }; 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/ReceiveDemo_Advanced/output.ino: -------------------------------------------------------------------------------- 1 | static const char* bin2tristate(const char* bin); 2 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength); 3 | 4 | void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { 5 | 6 | const char* b = dec2binWzerofill(decimal, length); 7 | Serial.print("Decimal: "); 8 | Serial.print(decimal); 9 | Serial.print(" ("); 10 | Serial.print( length ); 11 | Serial.print("Bit) Binary: "); 12 | Serial.print( b ); 13 | Serial.print(" Tri-State: "); 14 | Serial.print( bin2tristate( b) ); 15 | Serial.print(" PulseLength: "); 16 | Serial.print(delay); 17 | Serial.print(" microseconds"); 18 | Serial.print(" Protocol: "); 19 | Serial.println(protocol); 20 | 21 | Serial.print("Raw data: "); 22 | for (unsigned int i=0; i<= length*2; i++) { 23 | Serial.print(raw[i]); 24 | Serial.print(","); 25 | } 26 | Serial.println(); 27 | Serial.println(); 28 | } 29 | 30 | static const char* bin2tristate(const char* bin) { 31 | static char returnValue[50]; 32 | int pos = 0; 33 | int pos2 = 0; 34 | while (bin[pos]!='\0' && bin[pos+1]!='\0') { 35 | if (bin[pos]=='0' && bin[pos+1]=='0') { 36 | returnValue[pos2] = '0'; 37 | } else if (bin[pos]=='1' && bin[pos+1]=='1') { 38 | returnValue[pos2] = '1'; 39 | } else if (bin[pos]=='0' && bin[pos+1]=='1') { 40 | returnValue[pos2] = 'F'; 41 | } else { 42 | return "not applicable"; 43 | } 44 | pos = pos+2; 45 | pos2++; 46 | } 47 | returnValue[pos2] = '\0'; 48 | return returnValue; 49 | } 50 | 51 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { 52 | static char bin[64]; 53 | unsigned int i=0; 54 | 55 | while (Dec > 0) { 56 | bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0'; 57 | Dec = Dec >> 1; 58 | } 59 | 60 | for (unsigned int j = 0; j< bitLength; j++) { 61 | if (j >= bitLength - i) { 62 | bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; 63 | } else { 64 | bin[j] = '0'; 65 | } 66 | } 67 | bin[bitLength] = '\0'; 68 | 69 | return bin; 70 | } 71 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ESPboy_Sub1GHzInspector 2 | 3 | [Demo video](https://youtu.be/BxWNkIO8hpA) 4 | 5 | The ESPboy CC1101 chip module allows you to inspect Sub1Ghz signals (300-348MHz, 387-464MHz, 779-928MHz). 6 | Scan, decode, store to open garage doors, barriers, IoT sensors... 7 | 8 | You can buy this module ready-made or make it yourself. 9 | 10 | ![1](pics/cc1101_5.JPG) 11 | 12 | ![2](pics/cc1101_6.JPG) 13 | 14 | ![3](pics/cc1101_7.JPG) 15 | 16 | 17 | ## 1. Buy CC1101 18 | 19 | - Blue with antenna [link to buy](https://aliexpress.ru/item/2055139086.html?sku_id=50596123696&spm=a2g2w.productlist.0.0.4b09bf65eOzht2) 20 | 21 | ![BLUE](pics/cc1101_2.png) 22 | 23 | - Green with antenna [link to buy](https://aliexpress.ru/item/32858516951.html?sku_id=65340950183&spm=a2g2w.productlist.0.0.24475f0432NP99) 24 | 25 | ![GREEN](pics/cc1101_1.png) 26 | 27 | 28 | ## 2. Connect CC1101 to ESPboy 29 | 30 | for blue CC1101 version 31 | 32 | - 1 >> GND 33 | - 2 >> VCC 34 | - 3 >> D4, GPIO2 35 | - 4 >> D8, GPIO15, SS 36 | - 5 >> D5, GPIO14, SCK 37 | - 6 >> D7, GPIO13, MOSI 38 | - 7 >> D6, GPIO12, MISO 39 | - 8 >> RX, GPIO3, RX 40 | 41 | for green CC1101 version 42 | 43 | - GND >> GND 44 | - 3V3 >> VCC 45 | - G0D0 >> D4, GPIO 2 46 | - CSN >> D8, GPIO15, SS 47 | - SCK >> D5, GPIO14, SCK 48 | - MOSI >> D7, GPIO13, MOSI 49 | - MISO >> D6, GPIO12, MISO 50 | - GD02 >> RX, GPIO3, RX 51 | 52 | 53 | ## 3. Upload this firmware 54 | 55 | NOTE: Before compilation, set Arduino IDE settings 56 | 57 | - Board: ESP8266 WeMos D1 mini 58 | - CPU frequency: 160Mhz 59 | 60 | ## 4. Useful links 61 | 62 | - [Buy ESPboy](https://www.tindie.com/products/23910/) 63 | - [DIY ESPboy](https://easyeda.com/ESPboy) 64 | - [Main Web site](https://www.espboy.com) 65 | - [YouTube channel](https://www.youtube.com/c/ESPboy) 66 | - [Community](https://community.espboy.com) 67 | - [Discord chat](https://discord.gg/kXfDQpX) 68 | - [Twitter](https://twitter.com/ESPboy_edu) 69 | - [Software](https://github.com/ESPboy-edu) 70 | - [Contact: espboy.edu@gmail.com](mailto:espboy.edu@gmail.com) 71 | 72 | 73 | 74 | [Check the description here](https://community.espboy.com/t/espboy-sub1ghz-inspector-cc1101-module/70/7) 75 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/ReceiveDemo_Advanced_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | If you want to visualize a telegram copy the raw data and 7 | paste it into http://test.sui.li/oszi/ 8 | ---------------------------------------------------------- 9 | Mod by Little Satan. Have Fun! 10 | ---------------------------------------------------------- 11 | */ 12 | #include 13 | #include 14 | 15 | int pin; // int for Receive pin. 16 | 17 | RCSwitch mySwitch = RCSwitch(); 18 | 19 | void setup() { 20 | Serial.begin(9600); 21 | 22 | #ifdef ESP32 23 | pin = 4; // for esp32! Receiver on GPIO pin 4. 24 | #elif ESP8266 25 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 26 | #else 27 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 28 | #endif 29 | 30 | 31 | //CC1101 Settings: (Settings with "//" are optional!) 32 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 33 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 34 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 35 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 36 | 37 | mySwitch.enableReceive(pin); // Receiver on interrupt 0 => that is pin #2 38 | 39 | ELECHOUSE_cc1101.SetRx(); // set Receive on 40 | } 41 | 42 | void loop() { 43 | if (mySwitch.available()) { 44 | output(mySwitch.getReceivedValue(), mySwitch.getReceivedBitlength(), mySwitch.getReceivedDelay(), mySwitch.getReceivedRawdata(),mySwitch.getReceivedProtocol()); 45 | mySwitch.resetAvailable(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/ReceiveDemo_Advanced_cc1101/output.ino: -------------------------------------------------------------------------------- 1 | static const char* bin2tristate(const char* bin); 2 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength); 3 | 4 | void output(unsigned long decimal, unsigned int length, unsigned int delay, unsigned int* raw, unsigned int protocol) { 5 | 6 | const char* b = dec2binWzerofill(decimal, length); 7 | Serial.print("Decimal: "); 8 | Serial.print(decimal); 9 | Serial.print(" ("); 10 | Serial.print( length ); 11 | Serial.print("Bit) Binary: "); 12 | Serial.print( b ); 13 | Serial.print(" Tri-State: "); 14 | Serial.print( bin2tristate( b) ); 15 | Serial.print(" PulseLength: "); 16 | Serial.print(delay); 17 | Serial.print(" microseconds"); 18 | Serial.print(" Protocol: "); 19 | Serial.println(protocol); 20 | 21 | Serial.print("Raw data: "); 22 | for (unsigned int i=0; i<= length*2; i++) { 23 | Serial.print(raw[i]); 24 | Serial.print(","); 25 | } 26 | Serial.println(); 27 | Serial.println(); 28 | } 29 | 30 | static const char* bin2tristate(const char* bin) { 31 | static char returnValue[50]; 32 | int pos = 0; 33 | int pos2 = 0; 34 | while (bin[pos]!='\0' && bin[pos+1]!='\0') { 35 | if (bin[pos]=='0' && bin[pos+1]=='0') { 36 | returnValue[pos2] = '0'; 37 | } else if (bin[pos]=='1' && bin[pos+1]=='1') { 38 | returnValue[pos2] = '1'; 39 | } else if (bin[pos]=='0' && bin[pos+1]=='1') { 40 | returnValue[pos2] = 'F'; 41 | } else { 42 | return "not applicable"; 43 | } 44 | pos = pos+2; 45 | pos2++; 46 | } 47 | returnValue[pos2] = '\0'; 48 | return returnValue; 49 | } 50 | 51 | static char * dec2binWzerofill(unsigned long Dec, unsigned int bitLength) { 52 | static char bin[64]; 53 | unsigned int i=0; 54 | 55 | while (Dec > 0) { 56 | bin[32+i++] = ((Dec & 1) > 0) ? '1' : '0'; 57 | Dec = Dec >> 1; 58 | } 59 | 60 | for (unsigned int j = 0; j< bitLength; j++) { 61 | if (j >= bitLength - i) { 62 | bin[j] = bin[ 31 + i - (j - (bitLength - i)) ]; 63 | } else { 64 | bin[j] = '0'; 65 | } 66 | } 67 | bin[bitLength] = '\0'; 68 | 69 | return bin; 70 | } 71 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_cc1101/ReceiveDemo_Simple_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for receiving 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pin; // int for Receive pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 4; // for esp32! Receiver on GPIO pin 4. 22 | #elif ESP8266 23 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 24 | #else 25 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | 35 | mySwitch.enableReceive(pin); // Receiver on 36 | 37 | ELECHOUSE_cc1101.SetRx(); // set Receive on 38 | 39 | } 40 | void loop() { 41 | 42 | if (mySwitch.available()){ 43 | 44 | Serial.print("Received "); 45 | Serial.print( mySwitch.getReceivedValue() ); 46 | Serial.print(" / "); 47 | Serial.print( mySwitch.getReceivedBitlength() ); 48 | Serial.print("bit "); 49 | Serial.print("Protocol: "); 50 | Serial.println( mySwitch.getReceivedProtocol() ); 51 | 52 | mySwitch.resetAvailable(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/ESPiLight examples cc1101/Transmit_Raw_cc1101/Transmit_Raw_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic ESPiLight transmit RAW signal example 3 | 4 | https://github.com/puuu/espilight 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int TRANSMITTER_PIN; 14 | 15 | 16 | void setup() { 17 | Serial.begin(115200); 18 | 19 | #ifdef ESP32 20 | TRANSMITTER_PIN = 2; // for esp32! Transmit on GPIO pin 2. 21 | #elif ESP8266 22 | TRANSMITTER_PIN = 5; // for esp8266! Transmit on pin 5 = D1. 23 | #else 24 | TRANSMITTER_PIN = 6; // for Arduino! Transmit on pin 6. 25 | #endif 26 | 27 | //CC1101 Settings: (Settings with "//" are optional!) 28 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 29 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 30 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 31 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 32 | ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on 33 | 34 | ESPiLight rf(TRANSMITTER_PIN); 35 | 36 | int length = 0; 37 | uint16_t codes[MAXPULSESTREAMLENGTH]; 38 | 39 | // get pulse train from string (format see: pilight USB Nano) 40 | length = rf.stringToPulseTrain( 41 | "c:102020202020202020220202020020202200202200202020202020220020202203;p:" 42 | "279,2511,1395,9486@", 43 | codes, MAXPULSESTREAMLENGTH); 44 | 45 | // transmit the pulse train 46 | rf.sendPulseTrain(codes, length); 47 | } 48 | 49 | // Toggle state of elro 800 switch evrey 2 s 50 | void loop() { 51 | // stop 52 | } 53 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/ReceiveDemo_Simple_with_RSSI_cc1101/ReceiveDemo_Simple_with_RSSI_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for receiving with Rssi output. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pin; // int for Receive pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 4; // for esp32! Receiver on GPIO pin 4. 22 | #elif ESP8266 23 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 24 | #else 25 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | mySwitch.enableReceive(pin); // Receiver on 35 | 36 | ELECHOUSE_cc1101.SetRx(); // set Receive on 37 | 38 | } 39 | void loop() { 40 | 41 | if (mySwitch.available()){ 42 | 43 | Serial.print("Received "); 44 | Serial.print( mySwitch.getReceivedValue() ); 45 | Serial.print(" / "); 46 | Serial.print( mySwitch.getReceivedBitlength() ); 47 | Serial.print("bit "); 48 | Serial.print("Protocol: "); 49 | Serial.println( mySwitch.getReceivedProtocol() ); 50 | 51 | Serial.print("RSSI: "); 52 | Serial.println(ELECHOUSE_cc1101.getRssi()); 53 | 54 | mySwitch.resetAvailable(); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/TypeD_REV_cc1101/TypeD_REV_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for REV outlets (e.g. 8342L) 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | 7 | Need help? http://forum.ardumote.com 8 | ---------------------------------------------------------- 9 | Mod by Little Satan. Have Fun! 10 | ---------------------------------------------------------- 11 | */ 12 | #include 13 | #include 14 | 15 | int pin; // int for Transmit pin. 16 | 17 | RCSwitch mySwitch = RCSwitch(); 18 | 19 | void setup() { 20 | Serial.begin(9600); 21 | 22 | #ifdef ESP32 23 | pin = 2; // for esp32! Transmit on GPIO pin 2. 24 | #elif ESP8266 25 | pin = 5; // for esp8266! Transmit on pin 5 = D1 26 | #else 27 | pin = 6; // for Arduino! Transmit on pin 6. 28 | #endif 29 | 30 | //CC1101 Settings: (Settings with "//" are optional!) 31 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 32 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 33 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 34 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 35 | 36 | // Transmitter on 37 | mySwitch.enableTransmit(pin); 38 | 39 | // cc1101 set Transmit on 40 | ELECHOUSE_cc1101.SetTx(); 41 | 42 | // set pulse length. 43 | mySwitch.setPulseLength(360); 44 | 45 | } 46 | 47 | void loop() { 48 | 49 | // Switch on: 50 | // The first parameter represents the channel (a, b, c, d) 51 | // The second parameter represents the device number 52 | // 53 | // In this example it's family 'd', device #2 54 | mySwitch.switchOn('d', 2); 55 | 56 | // Wait a second 57 | delay(1000); 58 | 59 | // Switch off 60 | mySwitch.switchOff('d', 2); 61 | 62 | // Wait another second 63 | delay(1000); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/RemoteSensor examples cc1101/ThermoHygroTransmitter_cc1101/ThermoHygroTransmitter_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch sends (bogus) thermo / hygro data to a remote weather sensors made by Cresta. 3 | * 4 | * Setup: 5 | * - connect transmitter input of a 433MHz transmitter to digital pin 11 6 | * - On the weather station, activate the "scan" function for channel 1. 7 | * 8 | * Library: 9 | * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor 10 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 11 | * 12 | */ 13 | #include 14 | #include 15 | 16 | int pin; 17 | 18 | void setup() { 19 | 20 | #ifdef ESP32 21 | pin = 2; // for esp32! Transmit on GPIO pin 2. 22 | #elif ESP8266 23 | pin = 5; // for esp8266! Transmit on pin 5 = D1 24 | #else 25 | pin = 6; // for Arduino! Transmit on pin 6. 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | ELECHOUSE_cc1101.SetTx(); // Transmitt on 34 | } 35 | 36 | void loop() { 37 | // Initializes a ThermoHygroTransmitter on pin 11, with "random" ID 0, on channel 1. 38 | ThermoHygroTransmitter transmitter(pin, 0, 1); 39 | 40 | // Displays temperatures from -10 degrees Celsius to +20, 41 | // and humidity from 10% REL to 40% REL, with increments of 2 42 | for (int i = -10; i<=20; i+=2) { 43 | // Temperatures are passed at 10 times the real value, 44 | // to avoid using floating point math. 45 | transmitter.sendTempHumi(i * 10, i + 20); 46 | 47 | // Wait two seconds before sending next. 48 | delay(2000); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/TypeC_Intertechno_cc1101/TypeC_Intertechno_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for Intertechno outlets 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pin; // int for Transmit pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 2; // for esp32! Transmit on GPIO pin 2. 22 | #elif ESP8266 23 | pin = 5; // for esp8266! Transmit on pin 5 = D1 24 | #else 25 | pin = 6; // for Arduino! Transmit on pin 6. 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | // Transmitter on 35 | mySwitch.enableTransmit(pin); 36 | 37 | // cc1101 set Transmit on 38 | ELECHOUSE_cc1101.SetTx(); 39 | 40 | // Optional set pulse length. 41 | // mySwitch.setPulseLength(320); 42 | 43 | } 44 | 45 | void loop() { 46 | 47 | // Switch on: 48 | // The first parameter represents the familycode (a, b, c, ... f) 49 | // The second parameter represents the group number 50 | // The third parameter represents the device number 51 | // 52 | // In this example it's family 'b', group #3, device #2 53 | mySwitch.switchOn('b', 3, 2); 54 | 55 | // Wait a second 56 | delay(1000); 57 | 58 | // Switch off 59 | mySwitch.switchOff('b', 3, 2); 60 | 61 | // Wait another second 62 | delay(1000); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_minimal/cc1101_New_Transmitt_method_Serial_minimal.ino: -------------------------------------------------------------------------------- 1 | //New transmission method. 2 | //In addition, the gdo0 and gdo2 pin are not required. 3 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 4 | //by Little_S@tan 5 | 6 | #include 7 | 8 | const int n = 61; 9 | byte buffer[n] = ""; 10 | 11 | void setup() { 12 | 13 | Serial.begin(9600); 14 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 15 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 16 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 17 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 18 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 19 | // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 20 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 21 | 22 | Serial.println("Tx Mode"); 23 | } 24 | 25 | void loop() { 26 | 27 | //When sending, we give a little time to completely transmit the message (time in millis). 28 | //You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning. 29 | 30 | if (Serial.available()) { 31 | int len = Serial.readBytesUntil('\n', buffer, n); 32 | buffer[len] = '\0'; 33 | Serial.println((char *)buffer); 34 | ELECHOUSE_cc1101.SendData(buffer, len, 100); 35 | Serial.print("Buffer: "); 36 | for (int i = 0; i 7 | 8 | void setup(){ 9 | 10 | Serial.begin(9600); 11 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 12 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 13 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 14 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 15 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 16 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 17 | 18 | Serial.println("Rx Mode"); 19 | } 20 | byte buffer[61] = {0}; 21 | 22 | void loop(){ 23 | 24 | //Checks whether something has been received. 25 | //When something is received we give some time to receive the message in full.(time in millis) 26 | if (ELECHOUSE_cc1101.CheckRxFifo(100)){ 27 | 28 | if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK! 29 | Serial.print("Rssi: "); 30 | Serial.println(ELECHOUSE_cc1101.getRssi()); 31 | Serial.print("LQI: "); 32 | Serial.println(ELECHOUSE_cc1101.getLqi()); 33 | 34 | int len = ELECHOUSE_cc1101.ReceiveData(buffer); 35 | buffer[len] = '\0'; 36 | Serial.println((char *) buffer); 37 | for (int i = 0; i 11 | #include 12 | 13 | int pin; // int for Transmit pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 2; // for esp32! Transmit on GPIO pin 2. 22 | #elif ESP8266 23 | pin = 5; // for esp8266! Transmit on pin 5 = D1 24 | #else 25 | pin = 6; // for Arduino! Transmit on pin 6. 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | // Transmitter on 35 | mySwitch.enableTransmit(pin); 36 | 37 | // cc1101 set Transmit on 38 | ELECHOUSE_cc1101.SetTx(); 39 | 40 | 41 | // Optional set pulse length. 42 | // mySwitch.setPulseLength(320); 43 | 44 | } 45 | 46 | void loop() { 47 | 48 | // Switch on: 49 | // The first parameter represents the setting of the first 5 DIP switches. 50 | // In this example it's ON-ON-OFF-OFF-ON. 51 | // 52 | // The second parameter represents the setting of the last 5 DIP switches. 53 | // In this example the last 5 DIP switches are OFF-ON-OFF-ON-OFF. 54 | mySwitch.switchOn("11001", "01010"); 55 | 56 | // Wait a second 57 | delay(1000); 58 | 59 | // Switch off 60 | mySwitch.switchOff("11001", "01010"); 61 | 62 | // Wait another second 63 | delay(1000); 64 | 65 | } 66 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101/TypeB_WithRotaryOrSlidingSwitches_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for outlets which are configured with two rotary/sliding switches. 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pin; // int for Transmit pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 2; // for esp32! Transmit on GPIO pin 2. 22 | #elif ESP8266 23 | pin = 5; // for esp8266! Transmit on pin 5 = D1 24 | #else 25 | pin = 6; // for Arduino! Transmit on pin 6. 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | // Transmitter on 35 | mySwitch.enableTransmit(pin); 36 | 37 | // cc1101 set Transmit on 38 | ELECHOUSE_cc1101.SetTx(); 39 | 40 | // Optional set pulse length. 41 | // mySwitch.setPulseLength(320); 42 | 43 | } 44 | 45 | void loop() { 46 | 47 | // Switch on: 48 | // The first parameter represents the setting of the first rotary switch. 49 | // In this example it's switched to "1" or "A" or "I". 50 | // 51 | // The second parameter represents the setting of the second rotary switch. 52 | // In this example it's switched to "4" or "D" or "IV". 53 | mySwitch.switchOn(1, 4); 54 | 55 | // Wait a second 56 | delay(1000); 57 | 58 | // Switch off 59 | mySwitch.switchOff(1, 4); 60 | 61 | // Wait another second 62 | delay(1000); 63 | 64 | } 65 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Receive_minimal/cc1101_Receive_minimal.ino: -------------------------------------------------------------------------------- 1 | // These examples are from the Electronics Cookbook by Simon Monk 2 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 3 | // mod by Little_S@tan 4 | #include 5 | 6 | int gdo0; 7 | 8 | void setup(){ 9 | 10 | #ifdef ESP32 11 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 12 | #elif ESP8266 13 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 14 | #else 15 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 16 | #endif 17 | 18 | Serial.begin(9600); 19 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 20 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 21 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 22 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 23 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 24 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 25 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 26 | 27 | Serial.println("Rx Mode"); 28 | } 29 | byte buffer[61] = {0}; 30 | 31 | void loop(){ 32 | 33 | if (ELECHOUSE_cc1101.CheckReceiveFlag()){ 34 | 35 | if (ELECHOUSE_cc1101.CheckCRC()){ //CRC Check. If "setCrc(false)" crc returns always OK! 36 | Serial.print("Rssi: "); 37 | Serial.println(ELECHOUSE_cc1101.getRssi()); 38 | Serial.print("LQI: "); 39 | Serial.println(ELECHOUSE_cc1101.getLqi()); 40 | 41 | int len = ELECHOUSE_cc1101.ReceiveData(buffer); 42 | buffer[len] = '\0'; 43 | Serial.println((char *) buffer); 44 | for (int i = 0; i 6 | 7 | byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100}; 8 | char *transmitt_char = "Hello World"; 9 | 10 | void setup() { 11 | 12 | Serial.begin(9600); 13 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 14 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 15 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 16 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 17 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 18 | // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 19 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 20 | 21 | Serial.println("Tx Mode"); 22 | } 23 | 24 | void loop() { 25 | 26 | //3 different methods to send data without gdo 27 | //When sending, we give a little time to completely transmit the message (time in millis). 28 | //You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning. 29 | 30 | //Transmitt "Hello World" from byte format. 31 | ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100); 32 | delay(2000); 33 | 34 | //Transmitt "Hello World" from char format. 35 | ELECHOUSE_cc1101.SendData(transmitt_char, 100); 36 | delay(2000); 37 | 38 | //Transmitt "Hello World" from char format directly. 39 | ELECHOUSE_cc1101.SendData("Hello World", 100); 40 | delay(2000); 41 | } 42 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_minimal/cc1101_Transmitt_Serial_minimal.ino: -------------------------------------------------------------------------------- 1 | // These examples are from the Electronics Cookbook by Simon Monk 2 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 3 | // mod by Little_S@tan 4 | 5 | #include 6 | 7 | int gdo0; 8 | 9 | const int n = 61; 10 | byte buffer[n] = ""; 11 | 12 | void setup() { 13 | 14 | #ifdef ESP32 15 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 16 | #elif ESP8266 17 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 18 | #else 19 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 20 | #endif 21 | 22 | Serial.begin(9600); 23 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 24 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 25 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 26 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 27 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 28 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 29 | // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 30 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 31 | Serial.println("Tx Mode"); 32 | } 33 | 34 | void loop() { 35 | 36 | if (Serial.available()) { 37 | int len = Serial.readBytesUntil('\n', buffer, n); 38 | buffer[len] = '\0'; 39 | Serial.println((char *)buffer); 40 | ELECHOUSE_cc1101.SendData(buffer, len); 41 | Serial.print("Buffer: "); 42 | for (int i = 0; i 7 | #include 8 | 9 | int RECEIVER_PIN; // any intterupt able pin 10 | int TRANSMITTER_PIN; 11 | 12 | ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter 13 | 14 | // callback function. It is called on successfully received and parsed rc signal 15 | void rfRawCallback(const uint16_t* codes, size_t length) { 16 | // print pulse lengths 17 | Serial.print("RAW signal: "); 18 | for (unsigned int i = 0; i < length; i++) { 19 | Serial.print(codes[i]); 20 | Serial.print(' '); 21 | } 22 | Serial.println(); 23 | 24 | // format of pilight USB Nano 25 | String data = rf.pulseTrainToString(codes, length); 26 | Serial.print("string format: "); 27 | Serial.print(data); 28 | Serial.println(); 29 | } 30 | 31 | void setup() { 32 | Serial.begin(115200); 33 | 34 | #ifdef ESP32 35 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 36 | #elif ESP8266 37 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 38 | #else 39 | RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 40 | #endif 41 | 42 | //CC1101 Settings: (Settings with "//" are optional!) 43 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 44 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 45 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 46 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 47 | ELECHOUSE_cc1101.SetRx(); // set Receive on 48 | 49 | // set callback funktion for raw messages 50 | rf.setPulseTrainCallBack(rfRawCallback); 51 | // inittilize receiver 52 | rf.initReceiver(RECEIVER_PIN); 53 | } 54 | 55 | void loop() { 56 | // process input queue and may fire calllback 57 | rf.loop(); 58 | delay(10); 59 | } 60 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Hello_World_minimal/cc1101_Transmitt_Hello_World_minimal.ino: -------------------------------------------------------------------------------- 1 | // These examples are from the Electronics Cookbook by Simon Monk 2 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 3 | // mod by Little_S@tan 4 | #include 5 | 6 | int gdo0; 7 | 8 | byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100}; 9 | char *transmitt_char = "Hello World"; 10 | 11 | void setup() { 12 | 13 | #ifdef ESP32 14 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 15 | #elif ESP8266 16 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 17 | #else 18 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 19 | #endif 20 | 21 | Serial.begin(9600); 22 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 23 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 24 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 25 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 26 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 27 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 28 | // ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 29 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 30 | Serial.println("Tx Mode"); 31 | } 32 | 33 | void loop() { 34 | 35 | //3 different methods to send data 36 | 37 | //Transmitt "Hello World" from byte format. 38 | ELECHOUSE_cc1101.SendData(transmitt_byte, 11); 39 | delay(2000); 40 | 41 | //Transmitt "Hello World" from char format. 42 | ELECHOUSE_cc1101.SendData(transmitt_char); 43 | delay(2000); 44 | 45 | //Transmitt "Hello World" from char format directly. 46 | ELECHOUSE_cc1101.SendData("Hello World"); 47 | delay(2000); 48 | } 49 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/ESPiLight examples cc1101/pilight_raw_cc1101/pilight_raw_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic ESPiLight pilight_raw example 3 | 4 | This example mimic the output of the piligh_raw tool. 5 | 6 | https://github.com/puuu/espilight 7 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 8 | ---------------------------------------------------------- 9 | Mod by Little Satan. Have Fun! 10 | ---------------------------------------------------------- 11 | */ 12 | #include 13 | #include 14 | 15 | int RECEIVER_PIN; // any intterupt able pin 16 | int TRANSMITTER_PIN; 17 | 18 | ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter 19 | 20 | // callback function. It is called on successfully received and parsed rc signal 21 | void rfRawCallback(const uint16_t* pulses, size_t length) { 22 | Serial.print("ESPiLight:"); 23 | for (unsigned int i = 0; i < length; i++) { 24 | Serial.print(" "); 25 | Serial.print(pulses[i]); 26 | if (pulses[i] > 5100) { 27 | Serial.printf(" -# "); 28 | Serial.println(i); 29 | } 30 | } 31 | } 32 | 33 | void setup() { 34 | Serial.begin(115200); 35 | 36 | #ifdef ESP32 37 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 38 | #elif ESP8266 39 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 40 | #else 41 | RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 42 | #endif 43 | 44 | //CC1101 Settings: (Settings with "//" are optional!) 45 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 46 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 47 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 48 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 49 | ELECHOUSE_cc1101.SetRx(); // set Receive on 50 | 51 | // set callback funktion for raw messages 52 | rf.setPulseTrainCallBack(rfRawCallback); 53 | // inittilize receiver 54 | rf.initReceiver(RECEIVER_PIN); 55 | } 56 | 57 | void loop() { 58 | // process input queue and may fire calllback 59 | rf.loop(); 60 | delay(10); 61 | } 62 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/NewRemoteSwitch examples cc1101/ShowReceivedCode_cc1101/ShowReceivedCode_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo for RF remote switch receiver. 3 | * For details, see RemoteReceiver.h! 4 | * 5 | * This sketch shows the received signals on the serial port. 6 | * Connect the receiver to digital pin 2 on arduino and digital pin 1 on ESP8266. 7 | * 8 | * 9 | *Detected codes example: 10 | code: 8233372 Period: 273 11 | unit: 1 12 | groupBit: 0 13 | switchType: 0 14 | * 15 | * https://github.com/1technophile/NewRemoteSwitch 16 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 17 | * ---------------------------------------------------------- 18 | * Mod by Little Satan. Have Fun! 19 | * ---------------------------------------------------------- 20 | * 21 | */ 22 | #include 23 | #include 24 | 25 | int pin; // int for Receive pin. 26 | 27 | void setup() { 28 | Serial.begin(115200); 29 | 30 | #ifdef ESP32 31 | pin = 4; // for esp32! Receiver on GPIO pin 4. 32 | #elif ESP8266 33 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 34 | #else 35 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 36 | #endif 37 | 38 | //CC1101 Settings: (Settings with "//" are optional!) 39 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 40 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 41 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 42 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 43 | 44 | ELECHOUSE_cc1101.SetRx(); // set Receive on 45 | 46 | NewRemoteReceiver::init(pin, 2, showCode); 47 | Serial.println("Receiver initialized"); 48 | } 49 | 50 | void loop() { 51 | 52 | } 53 | 54 | // Callback function is called only when a valid code is received. 55 | void showCode(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType) { 56 | 57 | // Print the received code. 58 | Serial.print("Code: "); 59 | Serial.print(address); 60 | Serial.print(" Period: "); 61 | Serial.println(period); 62 | Serial.print(" unit: "); 63 | Serial.println(unit); 64 | Serial.print(" groupBit: "); 65 | Serial.println(groupBit); 66 | Serial.print(" switchType: "); 67 | Serial.println(switchType); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/SendDemo_cc1101/SendDemo_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for different sending methods 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pin; // int for Transmit pin. 14 | 15 | RCSwitch mySwitch = RCSwitch(); 16 | 17 | void setup() { 18 | Serial.begin(9600); 19 | 20 | #ifdef ESP32 21 | pin = 2; // for esp32! Transmit on GPIO pin 2. 22 | #elif ESP8266 23 | pin = 5; // for esp8266! Transmit on pin 5 = D1 24 | #else 25 | pin = 6; // for Arduino! Transmit on pin 6. 26 | #endif 27 | 28 | //CC1101 Settings: (Settings with "//" are optional!) 29 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 30 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 32 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 33 | 34 | // Transmitter on 35 | mySwitch.enableTransmit(pin); 36 | 37 | // cc1101 set Transmit on 38 | ELECHOUSE_cc1101.SetTx(); 39 | 40 | // Optional set protocol (default is 1, will work for most outlets) 41 | // mySwitch.setProtocol(2); 42 | 43 | // Optional set pulse length. 44 | // mySwitch.setPulseLength(320); 45 | 46 | // Optional set number of transmission repetitions. 47 | // mySwitch.setRepeatTransmit(15); 48 | 49 | } 50 | 51 | void loop() { 52 | 53 | /* See Example: TypeA_WithDIPSwitches */ 54 | mySwitch.switchOn("11111", "00010"); 55 | delay(1000); 56 | mySwitch.switchOff("11111", "00010"); 57 | delay(1000); 58 | 59 | /* Same switch as above, but using decimal code */ 60 | mySwitch.send(5393, 24); 61 | delay(1000); 62 | mySwitch.send(5396, 24); 63 | delay(1000); 64 | 65 | /* Same switch as above, but using binary code */ 66 | mySwitch.send("000000000001010100010001"); 67 | delay(1000); 68 | mySwitch.send("000000000001010100010100"); 69 | delay(1000); 70 | 71 | /* Same switch as above, but tri-state code */ 72 | mySwitch.sendTriState("00000FFF0F0F"); 73 | delay(1000); 74 | mySwitch.sendTriState("00000FFF0FF0"); 75 | delay(1000); 76 | 77 | delay(20000); 78 | } 79 | -------------------------------------------------------------------------------- /lib/ESPboyTerminalGUI.h: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboyTerminalGUI class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v2.1 6 | */ 7 | 8 | //!!!!!!!!!!!!!!!!! 9 | #define U8g2 //if defined then using font 4x6, if commented using font 6x8 10 | //#define buttonclicks //if defined - button are clicking but it takes more than 1kb RAM, if commented - no clicks and more free RAM 11 | //!!!!!!!!!!!!!!!!! 12 | 13 | #ifndef ESPboy_TerminalGUI 14 | #define ESPboy_TerminalGUI 15 | 16 | #include "ESPboyMCP.h" 17 | #include 18 | 19 | 20 | #include 21 | using fs::FS; 22 | 23 | #ifdef U8g2 24 | #include "U8g2_for_TFT_eSPI.h" 25 | #endif 26 | 27 | #ifdef U8g2 28 | #define GUI_FONT_WIDTH 4 29 | #define GUI_FONT_HEIGHT 6 30 | #else 31 | #define GUI_FONT_WIDTH 6 32 | #define GUI_FONT_HEIGHT 8 33 | #endif 34 | 35 | #define GUI_MAX_CONSOLE_STRINGS 100 36 | #define GUI_MAX_STRINGS_ONSCREEN_FULL ((128-2)/GUI_FONT_HEIGHT) 37 | #define GUI_MAX_STRINGS_ONSCREEN_SMALL ((128-44)/GUI_FONT_HEIGHT) 38 | #define GUI_MAX_TYPING_CHARS 60 39 | #define GUI_KEY_UNPRESSED_TIMEOUT 700 40 | #define GUI_KEY_PRESSED_DELAY_TO_SEND 500 41 | #define GUI_CURSOR_BLINKING_PERIOD 500 42 | #define GUI_KEYB_CALL_DELAY 150 //auto repeat 43 | 44 | #define GUI_PAD_LEFT 0x01 45 | #define GUI_PAD_UP 0x02 46 | #define GUI_PAD_DOWN 0x04 47 | #define GUI_PAD_RIGHT 0x08 48 | #define GUI_PAD_ACT 0x10 49 | #define GUI_PAD_ESC 0x20 50 | #define GUI_PAD_LFT 0x40 51 | #define GUI_PAD_RGT 0x80 52 | #define GUI_PAD_ANY 0xff 53 | 54 | 55 | class ESPboyTerminalGUI{ 56 | 57 | private: 58 | ESPboyMCP *mcp; 59 | TFT_eSPI *tft; 60 | #ifdef U8g2 61 | U8g2_for_TFT_eSPI *u8f; 62 | #endif 63 | 64 | 65 | struct consoleStringS { 66 | String consoleString; 67 | uint16_t consoleStringColor; 68 | }; 69 | 70 | std::vector consoleStringsVector; 71 | 72 | struct keyboardParameters{ 73 | int16_t renderLine; 74 | uint8_t displayMode; 75 | uint8_t shiftOn; 76 | int8_t selX; 77 | int8_t selY; 78 | String typing; 79 | }keybParam; 80 | 81 | const static uint8_t keybOnscr[2][3][21] PROGMEM; 82 | 83 | uint8_t keysAction(); 84 | void drawConsole(uint8_t onlyLastLine); 85 | void drawKeyboard(uint8_t slX, uint8_t slY, uint8_t onlySelected); 86 | void drawBlinkingCursor(); 87 | void drawTyping(uint8_t); 88 | 89 | public: 90 | ESPboyTerminalGUI(TFT_eSPI *tftGUI, ESPboyMCP *mcpGUI); 91 | void SetKeybParamTyping(String str); 92 | uint8_t getKeys(); 93 | uint32_t waitKeyUnpressed(); 94 | void printConsole(String bfrstr, uint16_t color, uint8_t ln, uint8_t noAddLine); 95 | String getUserInput(); 96 | void doScroll(); 97 | void toggleDisplayMode(uint8_t mode); 98 | void drawOwnTypingLine(String typingLine, uint16_t colorLine); 99 | }; 100 | 101 | #endif 102 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/RemoteSensor examples cc1101/ThermoHygroReceiver_cc1101/ThermoHygroReceiver_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch receives and decodes data from a 433MHz thermo/hygro weather sensor. 3 | * The received data (temperature, humidity, channel) is echo 4 | * 5 | * Setup: 6 | * - Connect digital output of a 433MHz receiver to digital pin 2 of Arduino 7 | * - Enable the serial monitor at 115200 baud. 8 | * 9 | * Need library: 10 | * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor 11 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 12 | * 13 | */ 14 | #include 15 | #include 16 | 17 | int pin; 18 | 19 | void setup() { 20 | Serial.begin(115200); 21 | 22 | #ifdef ESP32 23 | pin = 4; // for esp32! Receiver on GPIO pin 4. 24 | #elif ESP8266 25 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 26 | #else 27 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 28 | #endif 29 | 30 | //CC1101 Settings: (Settings with "//" are optional!) 31 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 32 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 33 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 34 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 35 | ELECHOUSE_cc1101.SetRx(); // set Receive on 36 | 37 | // Init the receiver on interrupt pin 0 (digital pin 2). 38 | // Set the callback to function "showTempHumi", which is called 39 | // whenever valid sensor data has been received. 40 | SensorReceiver::init(pin, showTempHumi); 41 | } 42 | 43 | void loop() { 44 | // Empty! However, you can do other stuff here if you like. 45 | } 46 | 47 | void showTempHumi(byte *data) { 48 | // is data a ThermoHygro-device? 49 | if ((data[3] & 0x1f) == 0x1e) { 50 | // Yes! 51 | 52 | byte channel, randomId; 53 | int temp; 54 | byte humidity; 55 | 56 | // Decode the data 57 | SensorReceiver::decodeThermoHygro(data, channel, randomId, temp, humidity); 58 | 59 | // Print temperature. Note: temp is 10x the actual temperature! 60 | Serial.print("Temperature: "); 61 | Serial.print(temp / 10); // units 62 | Serial.print('.'); 63 | Serial.print(temp % 10); // decimal 64 | 65 | // Print humidity 66 | Serial.print(" deg, Humidity: "); 67 | Serial.print(humidity); 68 | Serial.print("% REL"); 69 | 70 | // Print channel 71 | Serial.print(", Channel: "); 72 | Serial.println(channel, DEC); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /lib/ESPboyMCP.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboyMCP class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | 9 | void ESPboyMCP::begin() { 10 | Wire.begin(); 11 | Wire.setClock(400000); 12 | writeRegister(MCP23017address, 0x00,0xff); 13 | writeRegister(MCP23017address, 0x01,0xff); 14 | Wire.beginTransmission(MCP4725address); 15 | detectedDAC = !Wire.endTransmission(); 16 | } 17 | 18 | 19 | bool ESPboyMCP::readyDAC(){ 20 | yield(); 21 | uint8_t readed = readRegister(MCP4725address, 1); 22 | return ((readed & 0x80) > 0); 23 | } 24 | 25 | 26 | int8_t ESPboyMCP::writeDAC(uint16_t value, const bool eeprom = 0) { 27 | if(!detectedDAC) return 0; 28 | if(eeprom && !readyDAC()) return -1; 29 | if (value > 4095) value = 4095; 30 | if (value < 0) value = 0; 31 | writeRegisterMode(MCP4725address, value, eeprom ? 0x60 : 0x40); 32 | return 1; 33 | } 34 | 35 | uint8_t ESPboyMCP::writeRegisterMode(const uint8_t address, uint16_t value, uint8_t reg){ 36 | uint8_t h = (value / 16); 37 | uint8_t l = (value & 0x0F) << 4; 38 | Wire.beginTransmission(address); 39 | Wire.write(reg); 40 | Wire.write(h); 41 | Wire.write(l); 42 | return Wire.endTransmission(); 43 | } 44 | 45 | 46 | uint8_t ESPboyMCP::readRegister(const uint8_t address, uint8_t addr){ 47 | Wire.beginTransmission(address); 48 | Wire.write(addr); 49 | Wire.endTransmission(); 50 | Wire.requestFrom(address, (const uint8_t)1); 51 | return Wire.read(); 52 | } 53 | 54 | 55 | void ESPboyMCP::writeRegister(const uint8_t address, uint8_t regAddr, uint8_t regValue){ 56 | // Write the register 57 | Wire.beginTransmission(address); 58 | Wire.write(regAddr); 59 | Wire.write(regValue); 60 | Wire.endTransmission(); 61 | } 62 | 63 | void ESPboyMCP::updateRegisterBit(const uint8_t address, uint8_t pin, uint8_t pValue, uint8_t portAaddr, uint8_t portBaddr){ 64 | uint8_t regValue; 65 | uint8_t regAddr=(pin<8)?portAaddr:portBaddr; 66 | uint8_t bit=pin%8; 67 | regValue = readRegister(address, regAddr); 68 | bitWrite(regValue,bit,pValue); 69 | writeRegister(address, regAddr,regValue); 70 | } 71 | 72 | void ESPboyMCP::pinMode(uint8_t p, uint8_t d) { 73 | updateRegisterBit(MCP23017address, p,(d==INPUT), 0x00, 0x01); 74 | } 75 | 76 | void ESPboyMCP::pullUp(uint8_t p, uint8_t d) { 77 | updateRegisterBit(MCP23017address, p, d, 0x0C, 0x0D); 78 | } 79 | 80 | void ESPboyMCP::digitalWrite(uint8_t pin, uint8_t d) { 81 | uint8_t gpio; 82 | uint8_t bit=pin%8; 83 | uint8_t regAddr=(pin<8)?0x14:0x15; 84 | gpio = readRegister(MCP23017address, regAddr); 85 | bitWrite(gpio,bit,d); 86 | regAddr=(pin<8)?0x12:0x13; 87 | writeRegister(MCP23017address, regAddr, gpio); 88 | } 89 | 90 | uint16_t ESPboyMCP::readGPIOAB() { 91 | uint16_t ba = 0; 92 | uint8_t a; 93 | Wire.beginTransmission(MCP23017address); 94 | Wire.write(0x12); 95 | Wire.endTransmission(); 96 | Wire.requestFrom(MCP23017address, 2); 97 | a = Wire.read(); 98 | ba = Wire.read(); 99 | ba <<= 8; 100 | ba |= a; 101 | return ba; 102 | } 103 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/NewRemoteSwitch examples cc1101/LightShow_cc1101/LightShow_cc1101.ino: -------------------------------------------------------------------------------- 1 | /** 2 | * Demo for RF remote switch receiver. 3 | * For details, see NewRemoteReceiver.h! 4 | * 5 | * Connect the transmitter to digital pin 6. 6 | * 7 | * This sketch demonstrates the use of the NewRemoteTransmitter class. 8 | * 9 | * When run, this sketch switches some pre-defined devices on and off in a loop. 10 | * 11 | * NOTE: the actual receivers have the address and group numbers in this example 12 | * are only for demonstration! If you want to duplicate an existing remote, please 13 | * try the "retransmitter"-example instead. 14 | * 15 | * To use this actual example, you'd need to "learn" the used code in the receivers 16 | * This sketch is unsuited for that. 17 | * 18 | * 19 | * https://github.com/1technophile/NewRemoteSwitch 20 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 21 | * ---------------------------------------------------------- 22 | * Mod by Little Satan. Have Fun! 23 | * ---------------------------------------------------------- 24 | * 25 | */ 26 | #include 27 | #include 28 | 29 | int pin; // int for Transmit pin. 30 | 31 | void setup() { 32 | 33 | #ifdef ESP32 34 | pin = 2; // for esp32! Transmit on GPIO pin 2. 35 | #elif ESP8266 36 | pin = 5; // for esp8266! Transmit on pin 5 = D1 37 | #else 38 | pin = 6; // for Arduino! Transmit on pin 6. 39 | #endif 40 | 41 | //CC1101 Settings: (Settings with "//" are optional!) 42 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 43 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 44 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 45 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 46 | 47 | ELECHOUSE_cc1101.SetTx(); // cc1101 set Transmit on 48 | } 49 | 50 | void loop() { 51 | 52 | // Create a transmitter on address 123, using digital pin 6 to transmit, 53 | // with a period duration of 260ms (default), repeating the transmitted 54 | // code 2^3=8 times. 55 | NewRemoteTransmitter transmitter(123, pin, 260, 3); 56 | 57 | // Switch unit 2 off 58 | transmitter.sendUnit(2, false); 59 | 60 | // Switch all devices in the group off 61 | transmitter.sendGroup(false); 62 | 63 | // Set unit 1 to dim-level 3 (range 0-15) 64 | transmitter.sendDim(1, 3); 65 | 66 | // Wait 5 seconds 67 | delay(5000); 68 | 69 | 70 | // Switch unit 2 on 71 | transmitter.sendUnit(2, true); 72 | 73 | // Switch all devices in the group on 74 | transmitter.sendGroup(true); 75 | 76 | // Set unit 1 to dim-level 15, full brightness. 77 | transmitter.sendDim(1, 15); 78 | 79 | // Wait 5 seconds 80 | delay(5000); 81 | } 82 | -------------------------------------------------------------------------------- /lib/ESPboyLED.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy LED class 3 | for www.ESPboy.com project by RomanS 4 | */ 5 | 6 | #include "ESPboyLED.h" 7 | 8 | 9 | void ESPboyLED::begin(ESPboyMCP *mcpGUI){ 10 | mcp = mcpGUI; 11 | pinMode(LEDPIN, OUTPUT); 12 | mcp->pinMode(LEDLOCK, OUTPUT); 13 | LEDflagOnOff = 1; 14 | LEDr = 0; 15 | LEDg = 0; 16 | LEDb = 0; 17 | delay(100); 18 | ledset(1, 1, 1); 19 | delay(100); 20 | ledset(0, 0, 0); 21 | } 22 | 23 | 24 | void ESPboyLED::off(){ 25 | LEDflagOnOff = 0; 26 | ledset(0, 0, 0); 27 | } 28 | 29 | 30 | void ESPboyLED::on(){ 31 | LEDflagOnOff = 1; 32 | ledset(LEDr, LEDg, LEDb); 33 | } 34 | 35 | 36 | uint8_t ESPboyLED::getState(){ 37 | return (LEDflagOnOff); 38 | } 39 | 40 | void ESPboyLED::setRGB (uint8_t red, uint8_t green, uint8_t blue){ 41 | LEDr = red; 42 | LEDg = green; 43 | LEDb = blue; 44 | if (LEDflagOnOff) ledset(LEDr, LEDg, LEDb); 45 | } 46 | 47 | 48 | void ESPboyLED::setR (uint8_t red){ 49 | LEDr = red; 50 | if (LEDflagOnOff) ledset(LEDr, LEDg, LEDb); 51 | } 52 | 53 | 54 | void ESPboyLED::setG (uint8_t green){ 55 | LEDg = green; 56 | if (LEDflagOnOff) ledset(LEDr, LEDg, LEDb); 57 | } 58 | 59 | 60 | void ESPboyLED::setB (uint8_t blue){ 61 | LEDb = blue; 62 | if (LEDflagOnOff) ledset(LEDr, LEDg, LEDb); 63 | } 64 | 65 | 66 | uint32_t ESPboyLED::getRGB(){ 67 | return (((uint32_t)LEDb<<16) + ((uint32_t)LEDg<<8) + ((uint32_t)LEDr) ); 68 | } 69 | 70 | 71 | uint8_t ESPboyLED::getR(){ 72 | return (LEDr); 73 | } 74 | 75 | 76 | uint8_t ESPboyLED::getG(){ 77 | return (LEDg); 78 | } 79 | 80 | 81 | uint8_t ESPboyLED::getB(){ 82 | return (LEDb); 83 | } 84 | 85 | 86 | 87 | 88 | 89 | #define t0h (26*(F_CPU/80000000)) // 0.4us 90 | #define t1h (t0h*2) // 0.8us 91 | #define ttot (t0h*3.125) // 1.25us 92 | 93 | 94 | void ICACHE_RAM_ATTR ESPboyLED::ledset(uint8_t rled, uint8_t gled, uint8_t bled) { 95 | static uint8_t rstore=0xFF, gstore=0xFF, bstore=0xFF; 96 | static uint_fast32_t i, t, c, startTime, pixel, mask; 97 | static uint8_t cpuFreq; 98 | static const uint32_t pinMask = 1<digitalWrite(LEDLOCK, HIGH); 108 | 109 | pixel = (gled<<16) + (rled<<8) + bled; 110 | mask = 0x800000; 111 | startTime = 0; 112 | os_intr_lock(); 113 | for (i=0; i<24; i++){ 114 | if (pixel & mask) t = t1h; 115 | else t = t0h; 116 | while (((c=ESP.getCycleCount()) - startTime) < ttot);// Wait for the previous bit to finish 117 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); // digitalWrite HIGH 118 | startTime = c; 119 | while (((c=ESP.getCycleCount()) - startTime) < t); // Wait for high time to finish 120 | GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, pinMask); // digitalWrite LOW 121 | mask>>=1; 122 | } 123 | while((ESP.getCycleCount() - startTime) < ttot); 124 | os_intr_unlock(); 125 | GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, pinMask); 126 | mcp->digitalWrite(LEDLOCK, LOW); 127 | } 128 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/NewRemoteSwitch examples cc1101/Retransmitter_cc1101/Retransmitter_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo for RF remote switch receiver. 3 | * For details, see NewRemoteReceiver.h! 4 | * 5 | * 6 | * When run, this sketch waits for a valid code from a new-style the receiver, 7 | * decodes it, and retransmits it after 5 seconds. 8 | * 9 | * Notes: Arduino only!!! 10 | * 11 | * https://github.com/1technophile/NewRemoteSwitch 12 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 13 | * ---------------------------------------------------------- 14 | * Mod by Little Satan. Have Fun! 15 | * ---------------------------------------------------------- 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | void setup() { 23 | 24 | //CC1101 Settings: (Settings with "//" are optional!) 25 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 26 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 27 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 28 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 29 | 30 | ELECHOUSE_cc1101.SetRx(); // set Receive on 31 | 32 | // See example ShowReceivedCode for info on this 33 | NewRemoteReceiver::init(0, 2, retransmitter); 34 | } 35 | 36 | void loop() { 37 | } 38 | 39 | void retransmitter(NewRemoteCode receivedCode) { 40 | // Disable the receiver; otherwise it might pick up the retransmit as well. 41 | NewRemoteReceiver::disable(); 42 | 43 | // Need interrupts for delay() 44 | interrupts(); 45 | 46 | // Wait 5 seconds before sending. 47 | delay(5000); 48 | 49 | // Create a new transmitter with the received address and period, use digital pin as output pin 50 | 51 | ELECHOUSE_cc1101.SetTx(); // set Transmit on 52 | NewRemoteTransmitter transmitter(receivedCode.address, 6, receivedCode.period); 53 | 54 | if (receivedCode.switchType == NewRemoteCode::dim || 55 | (receivedCode.switchType == NewRemoteCode::on && receivedCode.dimLevelPresent)) { 56 | // Dimmer signal received 57 | 58 | if (receivedCode.groupBit) { 59 | transmitter.sendGroupDim(receivedCode.dimLevel); 60 | } 61 | else { 62 | transmitter.sendDim(receivedCode.unit, receivedCode.dimLevel); 63 | } 64 | } 65 | else { 66 | // On/Off signal received 67 | bool isOn = receivedCode.switchType == NewRemoteCode::on; 68 | 69 | if (receivedCode.groupBit) { 70 | // Send to the group 71 | transmitter.sendGroup(isOn); 72 | } 73 | else { 74 | // Send to a single unit 75 | transmitter.sendUnit(receivedCode.unit, isOn); 76 | } 77 | } 78 | ELECHOUSE_cc1101.SetRx(); // set Receive on 79 | NewRemoteReceiver::enable(); 80 | } 81 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/ESPiLight examples cc1101/Receive_cc1101/Receive_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic ESPilight receive example 3 | 4 | https://github.com/puuu/espilight 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int RECEIVER_PIN; // any intterupt able pin 14 | int TRANSMITTER_PIN; 15 | 16 | ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter 17 | 18 | // callback function. It is called on successfully received and parsed rc signal 19 | void rfCallback(const String &protocol, const String &message, int status, 20 | size_t repeats, const String &deviceID) { 21 | Serial.print("RF signal arrived ["); 22 | Serial.print(protocol); // protocoll used to parse 23 | Serial.print("]["); 24 | Serial.print(deviceID); // value of id key in json message 25 | Serial.print("] ("); 26 | Serial.print(status); // status of message, depending on repeat, either: 27 | // FIRST - first message of this protocoll within the 28 | // last 0.5 s 29 | // INVALID - message repeat is not equal to the 30 | // previous message 31 | // VALID - message is equal to the previous message 32 | // KNOWN - repeat of a already valid message 33 | Serial.print(") "); 34 | Serial.print(message); // message in json format 35 | Serial.println(); 36 | 37 | // check if message is valid and process it 38 | if (status == VALID) { 39 | Serial.print("Valid message: ["); 40 | Serial.print(protocol); 41 | Serial.print("] "); 42 | Serial.print(message); 43 | Serial.println(); 44 | } 45 | } 46 | 47 | void setup() { 48 | Serial.begin(115200); 49 | 50 | #ifdef ESP32 51 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 52 | #elif ESP8266 53 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 54 | #else 55 | RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 56 | #endif 57 | 58 | //CC1101 Settings: (Settings with "//" are optional!) 59 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 60 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 61 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 62 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 63 | ELECHOUSE_cc1101.SetRx(); // set Receive on 64 | 65 | // set callback funktion 66 | rf.setCallback(rfCallback); 67 | // inittilize receiver 68 | rf.initReceiver(RECEIVER_PIN); 69 | } 70 | 71 | void loop() { 72 | // process input queue and may fire calllback 73 | rf.loop(); 74 | delay(10); 75 | } 76 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/NewRemoteSwitch examples cc1101/LearnCode_cc1101/LearnCode_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo for RF remote switch receiver. 3 | * This example is for the new KaKu / Home Easy type of remotes! 4 | * 5 | * For details, see NewRemoteReceiver.h! 6 | * 7 | * With this sketch you can control a LED connected to digital pin 4, 8 | * after the sketch learned the code. After start, the LED starts to blink, 9 | * until a valid code has been received. The led stops blinking. Now you 10 | * can control the LED with the remote. 11 | * 12 | * Note: only unit-switches are supported in this sketch, no group or dim. 13 | * 14 | * Arduino only! 15 | * 16 | * https://github.com/1technophile/NewRemoteSwitch 17 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 18 | * ---------------------------------------------------------- 19 | * Mod by Little Satan. Have Fun! 20 | * ---------------------------------------------------------- 21 | * 22 | */ 23 | #include 24 | #include 25 | 26 | 27 | int pin = 0; // int for Receive pin. 28 | int led = 4; // pin for Led. 29 | 30 | boolean codeLearned = false; 31 | unsigned long learnedAddress; 32 | byte learnedUnit; 33 | 34 | void setup() { 35 | 36 | 37 | //CC1101 Settings: (Settings with "//" are optional!) 38 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 39 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 40 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 41 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 42 | 43 | ELECHOUSE_cc1101.SetRx(); // set Receive on 44 | 45 | // LED-pin as output 46 | pinMode(led, OUTPUT); 47 | 48 | // Init a new receiver on interrupt pin 0, minimal 2 identical repeats, and callback set to processCode. 49 | NewRemoteReceiver::init(pin, 2, processCode); 50 | } 51 | 52 | void loop() { 53 | // Blink led until a code has been learned 54 | if (!codeLearned) { 55 | digitalWrite(13, HIGH); 56 | delay(500); 57 | digitalWrite(13, LOW); 58 | delay(500); 59 | } 60 | } 61 | 62 | // Callback function is called only when a valid code is received. 63 | void processCode(NewRemoteCode receivedCode) { 64 | // A code has been received. 65 | // Do we already know the code? 66 | if (!codeLearned) { 67 | // No! Let's learn the received code. 68 | learnedAddress = receivedCode.address; 69 | learnedUnit = receivedCode.unit; 70 | codeLearned = true; 71 | } else { 72 | // Yes! 73 | // Is the received code identical to the learned code? 74 | if (receivedCode.address == learnedAddress && receivedCode.unit == learnedUnit) { 75 | // Yes! 76 | // Switch the LED off if the received code was "off". 77 | // Anything else (on, dim, on_with_dim) will switch the LED on. 78 | if (receivedCode.switchType == NewRemoteCode::off) { 79 | digitalWrite(13, LOW); 80 | } else { 81 | digitalWrite(13, HIGH); 82 | } 83 | } 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/RemoteSensor examples cc1101/Repeater_cc1101/Repeater_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * This sketch simply repeats data received from remote weather sensors made by Cresta. 3 | * 4 | * Setup: 5 | * - connect digital output of a 433MHz receiver to digital pin 2 of Arduino. 6 | * - connect transmitter input of a 433MHz transmitter to digital pin 11 7 | * - An LED on pin 13 will tell you if and when a signal has been received and transmitted. 8 | * 9 | * Library: 10 | * https://github.com/mattwire/arduino-dev/tree/master/libraries/RemoteSensor 11 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 12 | * 13 | */ 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | int LED_PIN; 20 | int pinRx; // int for Receive pin. 21 | int pinTx; // int for Transmit pin. 22 | 23 | void setup() { 24 | 25 | #ifdef ESP32 26 | pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 27 | LED_PIN = 32; // set led on GPIO pin 32. 28 | #elif ESP8266 29 | pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 30 | LED_PIN = 16; // set led on pin 16 = D0. 31 | #else 32 | pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 33 | LED_PIN = 4; // set led on pin D4. 34 | #endif 35 | 36 | //CC1101 Settings: (Settings with "//" are optional!) 37 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 38 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 39 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 40 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 41 | 42 | pinMode(LED_PIN, OUTPUT); 43 | 44 | // Since we're not instantiating SensorTransmitter, but only use the static methods of SensorTransmitter, 45 | // the pin mode must be set manually. 46 | pinMode(pinTx, OUTPUT); 47 | 48 | // When no signal has been received, the LED is lit. 49 | digitalWrite(LED_PIN, HIGH); 50 | 51 | // Init the receiver on interrupt pin 0 (digital pin 2). 52 | // Set the callback to function "retransmit", which is called 53 | // whenever valid sensor data has been received. 54 | ELECHOUSE_cc1101.SetRx(); // set Receive on 55 | SensorReceiver::init(pinRx, retransmit); 56 | } 57 | 58 | void loop() { 59 | } 60 | 61 | void retransmit(byte *data) { 62 | // Data received 63 | 64 | // Wait a second after a receiving. There's little point for decoding and sending the same signal multiple times. 65 | SensorReceiver::disable(); 66 | interrupts(); // delay() requires that interrupts are enabled 67 | delay(1000); 68 | 69 | // Flash LED when transmitting. 70 | digitalWrite(LED_PIN, HIGH); 71 | 72 | // Transmit signal. Note: this is a static method, no object required! 73 | ELECHOUSE_cc1101.SetTx(); // set Transmit on 74 | SensorTransmitter::sendPackage(pinTx, data); 75 | 76 | digitalWrite(LED_PIN, LOW); 77 | 78 | noInterrupts(); 79 | ELECHOUSE_cc1101.SetRx(); // set Receive on 80 | SensorReceiver::enable(); 81 | } 82 | -------------------------------------------------------------------------------- /lib/ESPboyLogo.h: -------------------------------------------------------------------------------- 1 | const uint8_t ESPboyLogo[] PROGMEM = { 2 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 3 | 0x01, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x03, 0x00, 0xFC, 4 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x83, 0x1F, 0xFC, 0x00, 0x00, 0x00, 5 | 0x00, 0x00, 0xD0, 0xC3, 0x3F, 0xF4, 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 6 | 0xE3, 0x7F, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xE1, 0x7F, 0x78, 7 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x7F, 0x00, 0x00, 0x00, 0x00, 8 | 0x00, 0x00, 0x00, 0xA0, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 9 | 0xA0, 0x7F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x7F, 0x00, 10 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x41, 0x3E, 0x78, 0x00, 0x00, 0x00, 11 | 0x00, 0x00, 0xF0, 0x83, 0x1F, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 12 | 0x03, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x03, 0x00, 0xF4, 13 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xB0, 0x03, 0x0F, 0xEC, 0x00, 0x00, 0x00, 14 | 0x00, 0x00, 0xE0, 0x81, 0x1F, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 15 | 0x80, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1E, 0x00, 16 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1D, 0x00, 0x00, 0x00, 0x00, 17 | 0x00, 0x00, 0xE0, 0x01, 0x0F, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 18 | 0x03, 0x00, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF0, 0x03, 0x00, 0xFC, 19 | 0x00, 0x00, 0x00, 0x00, 0x00, 0xD0, 0x03, 0x0F, 0xF4, 0x00, 0x00, 0x00, 20 | 0x00, 0x00, 0xB0, 0x83, 0x1F, 0xEC, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 21 | 0x81, 0x1F, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1E, 0x00, 22 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x1D, 0x00, 0x00, 0x00, 0x00, 23 | 0x00, 0x00, 0x00, 0x00, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 24 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 25 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 26 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 27 | 0x1E, 0x80, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x0F, 28 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0xC0, 0x0F, 0x00, 0x00, 0x00, 29 | 0x00, 0x00, 0x00, 0x3D, 0x40, 0x0F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 30 | 0x3B, 0xC0, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1E, 0x80, 0x07, 31 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 32 | 0x00, 0x00, 0x80, 0x07, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 33 | 0x0F, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x0F, 0x00, 0x7E, 34 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x0F, 0x00, 0x7A, 0x00, 0x00, 0x00, 35 | 0x00, 0x00, 0xC0, 0x0E, 0x00, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 36 | 0x07, 0x00, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 37 | 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 38 | 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0xFF, 0xFF, 39 | 0xFF, 0xFF, 0xFF, 0xFF, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 40 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 41 | 0x00, 0xE0, 0xE7, 0xF7, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0xF7, 42 | 0xF7, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0xE0, 0x30, 0x30, 0xF6, 0xF1, 43 | 0xCC, 0x00, 0x00, 0x00, 0xE0, 0xF3, 0x31, 0xF6, 0xFB, 0xCD, 0x00, 0x00, 44 | 0x00, 0xE0, 0xE3, 0xF3, 0x37, 0x9B, 0xCD, 0x00, 0x00, 0x00, 0xE0, 0xC0, 45 | 0xF7, 0x33, 0x9B, 0xCD, 0x00, 0x00, 0x00, 0xE0, 0x00, 0x36, 0x30, 0x9B, 46 | 0xCD, 0x00, 0x00, 0x00, 0xE0, 0xF7, 0x37, 0xF0, 0xFB, 0xFD, 0x00, 0x00, 47 | 0x00, 0xE0, 0xF7, 0x33, 0xF0, 0xF1, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 48 | 0x00, 0x00, 0x00, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 49 | 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 50 | }; 51 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/platformio.ini: -------------------------------------------------------------------------------- 1 | ; PlatformIO Project Configuration File 2 | ; 3 | ; Build options: build flags, source filter 4 | ; Upload options: custom upload port, speed and extra flags 5 | ; Library options: dependencies, extra library storages 6 | ; Advanced options: extra scripting 7 | ; 8 | ; Please visit documentation for the other options and examples 9 | ; https://docs.platformio.org/page/projectconf.html 10 | 11 | [platformio] 12 | src_dir = examples/ReceiveDemo_Advanced 13 | 14 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 15 | ; ENVIRONMENT CHOICE ; 16 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 17 | ;Uncomment the env line corresponding to your board and modules required, ; 18 | ;you can also adapt the modules by removing the corresponding lines in the env detail ; 19 | ; if you go to the build flag section of your env you will see that some user_config.h ; 20 | ; parameters can be overwritten here, for example the gateway name. ; 21 | ; If you want to avoid the lost of your environments at each update you can put them ; 22 | ; into a separate file called prod_env.ini, it will be automatically read by pio ; 23 | ; an example (prod_env.ini.example) is available into the same folder as this file. ; 24 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 25 | 26 | ;default_envs = sonoff-basic-rfr3 27 | ;default_envs = esp32dev-rf 28 | ;default_envs = nodemcuv2-rf 29 | ;default_envs = rf-wifi-gateway 30 | ;default_envs = uno-rf 31 | 32 | 33 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 34 | ; ENVIRONMENTS PARAMETERS ; 35 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 36 | ;Libraries and parameters shared accross environements ; 37 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 38 | 39 | 40 | 41 | [env] 42 | lib_extra_dirs = . 43 | framework = arduino 44 | build_flags = 45 | -w ; supress all warnings 46 | monitor_speed = 115200 47 | 48 | [com] 49 | esp8266_platform = espressif8266@2.2.3 50 | esp32_platform = espressif32@1.11.1 51 | atmelavr_platform = atmelavr@1.13.0 52 | 53 | [com-esp] 54 | build_flags = 55 | ${env.build_flags} 56 | 57 | [com-arduino] 58 | build_flags = 59 | ${env.build_flags} 60 | 61 | [com-arduino-low-memory] 62 | build_flags = 63 | ${env.build_flags} 64 | 65 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 66 | ; ENVIRONMENTS LIST ; 67 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 68 | ;List of environments that can be build ; 69 | ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 70 | 71 | [env:esp32dev-rf] 72 | platform = ${com.esp32_platform} 73 | board = esp32dev 74 | build_flags = 75 | ${com-esp.build_flags} 76 | 77 | [env:nodemcuv2-rf] 78 | platform = ${com.esp8266_platform} 79 | board = nodemcuv2 80 | build_flags = 81 | ${com-esp.build_flags} 82 | board_build.flash_mode = dout 83 | 84 | [env:rf-wifi-gateway] 85 | platform = ${com.esp8266_platform} 86 | board = nodemcuv2 87 | build_flags = 88 | ${com-esp.build_flags} 89 | board_build.flash_mode = dout 90 | 91 | 92 | [env:sonoff-basic-rfr3] 93 | platform = ${com.esp8266_platform} 94 | board = esp8285 95 | build_flags = 96 | ${com-esp.build_flags} 97 | board_build.flash_mode = dout 98 | 99 | [env:uno-rf] 100 | platform = ${com.atmelavr_platform} 101 | board = uno 102 | build_flags = 103 | ${com-arduino-low-memory.build_flags} 104 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/ESPiLight examples cc1101/pilight_debug_cc1101/pilight_debug_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Basic ESPiLight pilight_debug example 3 | 4 | This example mimic the output of the piligh_debug tool. 5 | 6 | https://github.com/puuu/espilight 7 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 8 | ---------------------------------------------------------- 9 | Mod by Little Satan. Have Fun! 10 | ---------------------------------------------------------- 11 | */ 12 | #include 13 | #include 14 | 15 | #define PULSE_DIV 34 16 | 17 | int RECEIVER_PIN; // any intterupt able pin 18 | int TRANSMITTER_PIN; 19 | 20 | ESPiLight rf(TRANSMITTER_PIN); // use -1 to disable transmitter 21 | 22 | unsigned int normalize(unsigned int i, unsigned int pulselen) { 23 | double x; 24 | x = (double)i / pulselen; 25 | 26 | return (unsigned int)(round(x)); 27 | } 28 | 29 | // callback function. It is called on successfully received and parsed rc signal 30 | void rfRawCallback(const uint16_t* pulses, size_t length) { 31 | uint16_t pulse; 32 | uint16_t pulselen = pulses[length - 1] / PULSE_DIV; 33 | if (pulselen > 25) { 34 | for (unsigned int i = 3; i < length; i++) { 35 | if ((pulses[i] / pulselen) >= 2) { 36 | pulse = pulses[i]; 37 | break; 38 | } 39 | } 40 | if (normalize(pulse, pulselen) > 0 && length > 25) { 41 | /* Print everything */ 42 | Serial.println("--[RESULTS]--"); 43 | Serial.println(); 44 | Serial.print("time:\t\t"); 45 | Serial.print(millis()); 46 | Serial.println(" ms"); 47 | Serial.println("hardware:\tESPiLight"); 48 | Serial.print("pulse:\t\t"); 49 | Serial.println(normalize(pulse, pulselen)); 50 | Serial.print("rawlen:\t\t"); 51 | Serial.println(length); 52 | Serial.printf("pulselen:\t"); 53 | Serial.println(pulselen); 54 | Serial.println(); 55 | Serial.println("Raw code:"); 56 | for (unsigned int i = 0; i < length; i++) { 57 | Serial.print(pulses[i]); 58 | Serial.print(" "); 59 | } 60 | Serial.println(); 61 | } 62 | } 63 | } 64 | 65 | void setup() { 66 | Serial.begin(115200); 67 | 68 | #ifdef ESP32 69 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 70 | #elif ESP8266 71 | RECEIVER_PIN = 4; TRANSMITTER_PIN = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 72 | #else 73 | RECEIVER_PIN = 0; TRANSMITTER_PIN = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 74 | #endif 75 | 76 | //CC1101 Settings: (Settings with "//" are optional!) 77 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 78 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 79 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 80 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 81 | ELECHOUSE_cc1101.SetRx(); // set Receive on 82 | 83 | // set callback funktion for raw messages 84 | rf.setPulseTrainCallBack(rfRawCallback); 85 | // inittilize receiver 86 | rf.initReceiver(RECEIVER_PIN); 87 | 88 | Serial.println( 89 | "Press and hold one of the buttons on your remote or wait until"); 90 | Serial.println("another device such as a weather station has sent new codes"); 91 | Serial.println( 92 | "The debugger will automatically reset itself after one second of"); 93 | Serial.println( 94 | "failed leads. It will keep running until you explicitly stop it."); 95 | } 96 | 97 | void loop() { 98 | // process input queue and may fire calllback 99 | rf.loop(); 100 | delay(10); 101 | } 102 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Repeater_cc1101/Repeater_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for repeating decimal code for cc1101 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pinRx; // int for Receive pin. 14 | int pinTx; // int for Transmit pin. 15 | 16 | RCSwitch mySwitch = RCSwitch(); 17 | 18 | int number = 15; // set number of transmission repetitions. 19 | int TIME = 3000; // set delay befor repeat. For direct repetition after receive set 0. 20 | 21 | int long value; // int to save value 22 | int bits; // int to save bit number 23 | int prot; // int to save Protocol number 24 | int puls; // int to save pulse length 25 | 26 | void setup() { 27 | Serial.begin(9600); 28 | 29 | #ifdef ESP32 30 | pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 31 | #elif ESP8266 32 | pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 33 | #else 34 | pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 35 | #endif 36 | 37 | //CC1101 Settings: (Settings with "//" are optional!) 38 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 39 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 40 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 41 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 42 | 43 | ELECHOUSE_cc1101.SetRx(); // set Receive on 44 | mySwitch.enableReceive(pinRx); // Receiver on 45 | 46 | } 47 | void loop() { 48 | 49 | if (value > 0) { 50 | 51 | ELECHOUSE_cc1101.SetTx(); // set Transmit on 52 | mySwitch.disableReceive(); // Receiver off 53 | mySwitch.enableTransmit(pinTx); // Transmit on 54 | 55 | 56 | mySwitch.setRepeatTransmit(number); // transmission repetitions. 57 | mySwitch.setProtocol(prot); // send Received Protocol 58 | mySwitch.setPulseLength(puls); // send Received Delay 59 | mySwitch.send(value, bits); // send Received value/bits 60 | 61 | Serial.print("Transmit "); 62 | Serial.print( value ); 63 | Serial.print(" / "); 64 | Serial.print( bits ); 65 | Serial.print("bit "); 66 | Serial.print("Protocol: "); 67 | Serial.print( prot ); 68 | Serial.print(" Delay: "); 69 | Serial.println( puls ); 70 | 71 | 72 | ELECHOUSE_cc1101.SetRx(); // set Receive on 73 | mySwitch.disableTransmit(); // set Transmit off 74 | mySwitch.enableReceive(pinRx); // Receiver on 75 | 76 | value = 0; // Reset value after transmit for receive. 77 | 78 | } 79 | 80 | else{ 81 | if (mySwitch.available()){ 82 | 83 | Serial.print("Received "); 84 | Serial.print( mySwitch.getReceivedValue() ); 85 | Serial.print(" / "); 86 | Serial.print( mySwitch.getReceivedBitlength() ); 87 | Serial.print("bit "); 88 | Serial.print("Protocol: "); 89 | Serial.print( mySwitch.getReceivedProtocol() ); 90 | Serial.print(" Delay: "); 91 | Serial.println( mySwitch.getReceivedDelay() ); 92 | 93 | value = mySwitch.getReceivedValue(); // save received Value 94 | bits = mySwitch.getReceivedBitlength(); // save received Bitlength 95 | prot = mySwitch.getReceivedProtocol(); // save received Protocol 96 | puls = mySwitch.getReceivedDelay(); // save received pulse length 97 | 98 | mySwitch.resetAvailable(); 99 | delay(TIME); 100 | } 101 | } 102 | 103 | } 104 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/NewRemoteSwitch examples cc1101/NewRemoteRepeater/NewRemoteRepeater.ino: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo for RF remote switch receiver. 3 | * For details, see NewRemoteReceiver.h! 4 | * 5 | * 6 | * When run, this sketch waits for a valid code from a new-style the receiver, 7 | * decodes it, and retransmits it after 1 seconds. 8 | * 9 | * 10 | * https://github.com/1technophile/NewRemoteSwitch 11 | * https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 12 | * ---------------------------------------------------------- 13 | * Written by Roman.(Arduino Forum) THX! 14 | * Mod by Little Satan. Have Fun! 15 | * ---------------------------------------------------------- 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | int pinTx; // int for Receive pin. 23 | int pinRx; // int for Receive pin. 24 | int Interr = 2; // Interrupt Numer 25 | int Anz = 3; // number of retransmissions 26 | int Tw = 0; // Wait Miliseconds before sending 27 | 28 | int debug = 1; // Debugmode ein (1)/aus(0) 29 | 30 | void setup() { 31 | Serial.begin(115200); 32 | 33 | #ifdef ESP32 34 | pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 35 | #elif ESP8266 36 | pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 37 | #else 38 | pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 39 | #endif 40 | 41 | //CC1101 Settings: (Settings with "//" are optional!) 42 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 43 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 44 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 45 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 46 | 47 | 48 | 49 | ELECHOUSE_cc1101.SetRx(); // set Receive on 50 | // See example ShowReceivedCode for info on this 51 | NewRemoteReceiver::init(pinRx, Interr, ReTrans); 52 | if (debug == 1) {Serial.println("Receiver initialized... ");}} 53 | 54 | void loop() { 55 | } 56 | 57 | void ReTrans(unsigned int period, unsigned long address, unsigned long groupBit, unsigned long unit, unsigned long switchType){ // Disable the receiver; otherwise it might pick up the retransmit as well. 58 | 59 | if (debug == 1) { 60 | // Print the received code. 61 | Serial.print("Receiver: "); 62 | Serial.print("Code: "); 63 | Serial.print(address); 64 | Serial.print(" unit: "); 65 | Serial.print(unit); 66 | Serial.print(" switchType: "); 67 | Serial.print(switchType); 68 | Serial.print(" Period: "); 69 | Serial.print(period); 70 | Serial.print(" groupBit: "); 71 | Serial.println(groupBit); 72 | } 73 | 74 | 75 | 76 | if (debug == 1) {Serial.print("Send: Receiver disable... ");} 77 | NewRemoteReceiver::disable(); 78 | 79 | // Need interrupts for delay() 80 | interrupts(); 81 | 82 | if (debug == 1) {Serial.print("Wait... ");} 83 | 84 | // Wait 1 seconds before sending. 85 | delay(Tw); 86 | 87 | 88 | 89 | ELECHOUSE_cc1101.SetTx(); // set Transmit on 90 | // Create a new transmitter with the received address and period, use digital pin as output pin 91 | NewRemoteTransmitter transmitter(address, pinTx, period, Anz); 92 | if (debug == 1) {Serial.print("Send: Addr " + String(address) + " unit " + String(unit)+" "+ String(switchType)+", period: "+String(period)+" " );} 93 | 94 | // On/Off signal received 95 | bool isOn = switchType == NewRemoteCode::on; 96 | 97 | if (groupBit) { 98 | // Send to the group 99 | transmitter.sendGroup(isOn); 100 | } 101 | else { 102 | // Send to a single unit 103 | transmitter.sendUnit(unit, isOn); 104 | } 105 | 106 | if (debug == 1) {Serial.println("Receiver enable!");} 107 | ELECHOUSE_cc1101.SetRx(); // set Receive on 108 | NewRemoteReceiver::enable(); 109 | } 110 | -------------------------------------------------------------------------------- /lib/RC-switch_mod/examples/Webserver/Webserver.ino: -------------------------------------------------------------------------------- 1 | /* 2 | A simple RCSwitch/Ethernet/Webserver demo 3 | 4 | https://github.com/sui77/rc-switch/ 5 | */ 6 | 7 | #include 8 | #include 9 | #include 10 | 11 | // Ethernet configuration 12 | uint8_t mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; // MAC Address 13 | uint8_t ip[] = { 192,168,0, 2 }; // IP Address 14 | EthernetServer server(80); // Server Port 80 15 | 16 | // RCSwitch configuration 17 | RCSwitch mySwitch = RCSwitch(); 18 | int RCTransmissionPin = 7; 19 | 20 | // More to do... 21 | // You should also modify the processCommand() and 22 | // httpResponseHome() functions to fit your needs. 23 | 24 | 25 | 26 | /** 27 | * Setup 28 | */ 29 | void setup() { 30 | Ethernet.begin(mac, ip); 31 | server.begin(); 32 | mySwitch.enableTransmit( RCTransmissionPin ); 33 | } 34 | 35 | /** 36 | * Loop 37 | */ 38 | void loop() { 39 | char* command = httpServer(); 40 | } 41 | 42 | /** 43 | * Command dispatcher 44 | */ 45 | void processCommand(char* command) { 46 | if (strcmp(command, "1-on") == 0) { 47 | mySwitch.switchOn(1,1); 48 | } else if (strcmp(command, "1-off") == 0) { 49 | mySwitch.switchOff(1,1); 50 | } else if (strcmp(command, "2-on") == 0) { 51 | mySwitch.switchOn(1,2); 52 | } else if (strcmp(command, "2-off") == 0) { 53 | mySwitch.switchOff(1,2); 54 | } 55 | } 56 | 57 | /** 58 | * HTTP Response with homepage 59 | */ 60 | void httpResponseHome(EthernetClient c) { 61 | c.println("HTTP/1.1 200 OK"); 62 | c.println("Content-Type: text/html"); 63 | c.println(); 64 | c.println(""); 65 | c.println(""); 66 | c.println( "RCSwitch Webserver Demo"); 67 | c.println( ""); 70 | c.println(""); 71 | c.println(""); 72 | c.println( "

RCSwitch Webserver Demo

"); 73 | c.println( ""); 77 | c.println( ""); 81 | c.println( "
"); 82 | c.println( "https://github.com/sui77/rc-switch/"); 83 | c.println(""); 84 | c.println(""); 85 | } 86 | 87 | /** 88 | * HTTP Redirect to homepage 89 | */ 90 | void httpResponseRedirect(EthernetClient c) { 91 | c.println("HTTP/1.1 301 Found"); 92 | c.println("Location: /"); 93 | c.println(); 94 | } 95 | 96 | /** 97 | * HTTP Response 414 error 98 | * Command must not be longer than 30 characters 99 | **/ 100 | void httpResponse414(EthernetClient c) { 101 | c.println("HTTP/1.1 414 Request URI too long"); 102 | c.println("Content-Type: text/plain"); 103 | c.println(); 104 | c.println("414 Request URI too long"); 105 | } 106 | 107 | /** 108 | * Process HTTP requests, parse first request header line and 109 | * call processCommand with GET query string (everything after 110 | * the ? question mark in the URL). 111 | */ 112 | char* httpServer() { 113 | EthernetClient client = server.available(); 114 | if (client) { 115 | char sReturnCommand[32]; 116 | int nCommandPos=-1; 117 | sReturnCommand[0] = '\0'; 118 | while (client.connected()) { 119 | if (client.available()) { 120 | char c = client.read(); 121 | if ((c == '\n') || (c == ' ' && nCommandPos>-1)) { 122 | sReturnCommand[nCommandPos] = '\0'; 123 | if (strcmp(sReturnCommand, "\0") == 0) { 124 | httpResponseHome(client); 125 | } else { 126 | processCommand(sReturnCommand); 127 | httpResponseRedirect(client); 128 | } 129 | break; 130 | } 131 | if (nCommandPos>-1) { 132 | sReturnCommand[nCommandPos++] = c; 133 | } 134 | if (c == '?' && nCommandPos == -1) { 135 | nCommandPos = 0; 136 | } 137 | } 138 | if (nCommandPos > 30) { 139 | httpResponse414(client); 140 | sReturnCommand[0] = '\0'; 141 | break; 142 | } 143 | } 144 | if (nCommandPos!=-1) { 145 | sReturnCommand[nCommandPos] = '\0'; 146 | } 147 | // give the web browser time to receive the data 148 | delay(1); 149 | client.stop(); 150 | 151 | return sReturnCommand; 152 | } 153 | return '\0'; 154 | } -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/Receive_Send_Decimal_Demo_Simple/Receive_Send_Decimal_Demo_Simple.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Simple example for Receiving and Transmit decimal code for cc1101 3 | 4 | https://github.com/sui77/rc-switch/ 5 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 6 | ---------------------------------------------------------- 7 | Mod by Little Satan. Have Fun! 8 | ---------------------------------------------------------- 9 | */ 10 | #include 11 | #include 12 | 13 | int pinRx; // int for Receive pin. 14 | int pinTx; // int for Transmit pin. 15 | 16 | RCSwitch mySwitch = RCSwitch(); 17 | 18 | int buttonPin; // for button pin. 19 | int buttonState = 0; // button state 20 | int ccSetRx = 0; // reset state for Receive 21 | int long value = 5393; // int to save value 22 | int bits = 24; // int to save bit number 23 | int prot = 1; // int to save Protocol number 24 | int puls = 320; // int to save pulse length 25 | 26 | void setup() { 27 | Serial.begin(9600); 28 | 29 | #ifdef ESP32 30 | pinRx = 4; pinTx = 2; // for esp32! Receiver on GPIO pin 4. Transmit on GPIO pin 2. 31 | buttonPin = 34; // set button on GPIO pin 34. 32 | #elif ESP8266 33 | pinRx = 4; pinTx = 5; // for esp8266! Receiver on pin 4 = D2. Transmit on pin 5 = D1. 34 | buttonPin = 16; // set button on pin 16 = D0. 35 | #else 36 | pinRx = 0; pinTx = 6; // for Arduino! Receiver on interrupt 0 => that is pin #2. Transmit on pin 6. 37 | buttonPin = 4; // set button on pin D4. 38 | #endif 39 | 40 | //CC1101 Settings: (Settings with "//" are optional!) 41 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 42 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 43 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 44 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 45 | 46 | pinMode(buttonPin, INPUT); // set pin4 as input 47 | 48 | } 49 | void loop() { 50 | 51 | buttonState = digitalRead(buttonPin); // read digital pin and save the state to int 52 | 53 | 54 | if (buttonState == HIGH) { // the button is pressed. Set transmit on. 55 | 56 | ccSetRx = 0; // set resetstate to 0 for next reinit to Recive 57 | ELECHOUSE_cc1101.SetTx(); // set Transmit on 58 | mySwitch.disableReceive(); // Receiver off 59 | mySwitch.enableTransmit(pinTx); // Transmit on 60 | 61 | mySwitch.setRepeatTransmit(3); // transmission repetitions. 62 | mySwitch.setProtocol(prot); // send Received Protocol 63 | mySwitch.setPulseLength(puls);// send Received Delay 64 | mySwitch.send(value, bits); // send Received value/bits 65 | 66 | Serial.print("Transmit "); 67 | Serial.print( value ); 68 | Serial.print(" / "); 69 | Serial.print( bits ); 70 | Serial.print("bit "); 71 | Serial.print("Protocol: "); 72 | Serial.print( prot ); 73 | Serial.print(" Delay: "); 74 | Serial.println( puls ); 75 | } 76 | 77 | 78 | if (buttonState == LOW && ccSetRx == 0){ //the button is not pressed. set cc1101 to Receive. 79 | 80 | ELECHOUSE_cc1101.SetRx(); // set Receive on 81 | mySwitch.disableTransmit(); // set Transmit off 82 | mySwitch.enableReceive(pinRx); // Receiver on 83 | ccSetRx = 1; 84 | } 85 | 86 | if (buttonState == LOW && ccSetRx == 1) { //the button is not pressed and set receive is finish. Receive values. 87 | 88 | 89 | 90 | if (mySwitch.available()){ 91 | 92 | Serial.print("Received "); 93 | Serial.print( mySwitch.getReceivedValue() ); 94 | Serial.print(" / "); 95 | Serial.print( mySwitch.getReceivedBitlength() ); 96 | Serial.print("bit "); 97 | Serial.print("Protocol: "); 98 | Serial.print( mySwitch.getReceivedProtocol() ); 99 | Serial.print(" Delay: "); 100 | Serial.println( mySwitch.getReceivedDelay() ); 101 | 102 | value = mySwitch.getReceivedValue(); // save received Value 103 | bits = mySwitch.getReceivedBitlength(); // save received Bitlength 104 | prot = mySwitch.getReceivedProtocol(); // save received Protocol 105 | puls = mySwitch.getReceivedDelay(); // save received pulse length 106 | 107 | mySwitch.resetAvailable(); 108 | 109 | } 110 | } 111 | 112 | } 113 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/Rc-Switch examples cc1101/ProtocolAnalyzeDemo_cc1101/ProtocolAnalyzeDemo_cc1101.ino: -------------------------------------------------------------------------------- 1 | /* 2 | Example for analyzing and proposing unknown new protocols 3 | 4 | Requires modified rc-switch branch "protocollessreceiver" 5 | with ReceivedInverted() function exposed. 6 | 7 | https://github.com/Martin-Laclaustra/rc-switch/tree/protocollessreceiver 8 | https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 9 | 10 | ---------------------------------------------------------- 11 | CC1101 Mod by Little Satan. Have Fun! 12 | ---------------------------------------------------------- 13 | */ 14 | 15 | #include 16 | #include 17 | 18 | int pin; // int for Receive pin. 19 | 20 | RCSwitch mySwitch = RCSwitch(); 21 | 22 | void setup() { 23 | Serial.begin(9600); 24 | 25 | #ifdef ESP32 26 | pin = 4; // for esp32! Receiver on GPIO pin 4. 27 | #elif ESP8266 28 | pin = 4; // for esp8266! Receiver on pin 4 = D2. 29 | #else 30 | pin = 0; // for Arduino! Receiver on interrupt 0 => that is pin #2 31 | #endif 32 | 33 | //CC1101 Settings: (Settings with "//" are optional!) 34 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 35 | //ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 36 | //ELECHOUSE_cc1101.setPA(10); // set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 37 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 38 | 39 | mySwitch.enableReceive(pin); // Receiver on 40 | 41 | ELECHOUSE_cc1101.SetRx(); // set Receive on 42 | 43 | } 44 | 45 | void loop() { 46 | if (mySwitch.available()) { 47 | 48 | int value = mySwitch.getReceivedValue(); 49 | 50 | if (value == 0) { 51 | Serial.print("Unknown encoding"); 52 | } else { 53 | 54 | int databuffer[64]; // get a copy of the received timings before they are overwritten 55 | int numberoftimings = 2 * mySwitch.getReceivedBitlength() + 2; 56 | if(numberoftimings > 64) numberoftimings = 64; 57 | for (int i = 0; i < numberoftimings; i++) { 58 | databuffer[i] = mySwitch.getReceivedRawdata()[i]; 59 | } 60 | 61 | Serial.print("Received "); 62 | Serial.print( mySwitch.getReceivedValue() ); 63 | Serial.print(" / "); 64 | Serial.print( mySwitch.getReceivedBitlength() ); 65 | Serial.print("bit "); 66 | Serial.print("Protocol: "); 67 | Serial.println( mySwitch.getReceivedProtocol() ); 68 | 69 | unsigned int databitsoffset = abs( (int)mySwitch.getReceivedLevelInFirstTiming() - (int)mySwitch.getReceivedInverted()); 70 | //Serial.println( mySwitch.getReceivedLevelInFirstTiming() ); 71 | //Serial.println( mySwitch.getReceivedInverted() ); 72 | //Serial.println( databitsoffset ); 73 | unsigned long dataduration = 0; 74 | for (unsigned int i = 1 + databitsoffset; i < numberoftimings - 1 + databitsoffset; i++) { 75 | dataduration += databuffer[i]; 76 | } 77 | Serial.print("data bits of pulse train duration: "); 78 | Serial.println( dataduration ); 79 | unsigned int averagebitduration = (int)(0.5 + ((double)dataduration)/mySwitch.getReceivedBitlength()); 80 | unsigned int protocolratio = (unsigned int)(0.5 + ((double)(averagebitduration - mySwitch.getReceivedDelay())) / (double)mySwitch.getReceivedDelay()); 81 | Serial.print("proposed protocol: { "); 82 | Serial.print(mySwitch.getReceivedDelay()); 83 | Serial.print(", { "); 84 | Serial.print( (databitsoffset==0) ? 85 | (int) (0.5 + (double)databuffer[2*mySwitch.getReceivedBitlength()+1]/(double)mySwitch.getReceivedDelay()) 86 | : 87 | (int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay()) 88 | ); 89 | Serial.print(", "); 90 | Serial.print( (databitsoffset==0) ? 91 | (int) (0.5 + (double)databuffer[0]/(double)mySwitch.getReceivedDelay()) 92 | : 93 | (int) (0.5 + (double)databuffer[1]/(double)mySwitch.getReceivedDelay()) 94 | ); 95 | Serial.print(" }, { "); 96 | Serial.print("1"); 97 | Serial.print(", "); 98 | Serial.print(protocolratio); 99 | Serial.print(" }, { "); 100 | Serial.print(protocolratio); 101 | Serial.print(", "); 102 | Serial.print("1"); 103 | Serial.print(" }, "); 104 | Serial.print((mySwitch.getReceivedInverted()) ? "true" : "false" ); 105 | Serial.println(" }"); 106 | 107 | // raw signal 108 | Serial.println("===="); 109 | Serial.print("first level "); 110 | Serial.println((mySwitch.getReceivedLevelInFirstTiming() == 0) ? "down" : "up" ); 111 | for (int i = 0; i < 2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset; i++) { 112 | Serial.print(databuffer[i]); 113 | Serial.print(" "); 114 | if((i - databitsoffset) % 16 == 0) Serial.println(""); 115 | } 116 | if ((2*mySwitch.getReceivedBitlength()+2 - 1 + databitsoffset - 1) % 16 != 0) Serial.println(""); 117 | if (databitsoffset != 1) Serial.println(databuffer[2*mySwitch.getReceivedBitlength()+1]); 118 | // plot signal in spreadsheet 119 | Serial.println("===="); 120 | 121 | } 122 | 123 | mySwitch.resetAvailable(); 124 | } 125 | } 126 | -------------------------------------------------------------------------------- /lib/ESPboyMenuGUI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboy_MenuGUI class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v1.0 6 | */ 7 | 8 | #include "ESPboyMenuGUI.h" 9 | 10 | ESPboyMenuGUI::ESPboyMenuGUI(ESPboyInit *myESPboyPointer) { 11 | myESPboy = myESPboyPointer; 12 | #ifdef U8g2_MENU 13 | u8f = new U8g2_for_TFT_eSPI; 14 | u8f->begin(myESPboy->tft); 15 | u8f->setFontMode(1); // use u8g2 none transparent mode 16 | u8f->setBackgroundColor(TFT_BLACK); 17 | u8f->setFontDirection(0); // left to right 18 | u8f->setFont(u8g2_font_4x6_t_cyrillic); 19 | #endif 20 | } 21 | 22 | 23 | 24 | void ESPboyMenuGUI::menuDraw(){ 25 | static uint16_t scalingFactor; 26 | static uint16_t previousRect = 0; 27 | 28 | if(menuList.menuItemsQuantity>1){ 29 | if(menuList.menuItemsQuantity>=MENU_MAX_LINES_ONSCREEN) 30 | scalingFactor = ((MENU_MAX_LINES_ONSCREEN*MENU_SPACE_BETWEEN_LINES-6)*1000)/(menuList.menuItemsQuantity-1); 31 | else 32 | scalingFactor = ((menuList.menuItemsQuantity*MENU_SPACE_BETWEEN_LINES-6)*1000)/(menuList.menuItemsQuantity-1); 33 | } 34 | else scalingFactor=1; 35 | 36 | myESPboy->tft.drawRect(0, previousRect*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, TFT_BLACK); 37 | myESPboy->tft.fillRect(125,0, 3, 128, TFT_BLACK); 38 | 39 | if (menuList.menuCurrent+1 > MENU_MAX_LINES_ONSCREEN + menuList.menuOffset) { 40 | myESPboy->tft.fillScreen(TFT_BLACK); 41 | menuList.menuOffset++;} 42 | if (menuList.menuCurrent < menuList.menuOffset) { 43 | myESPboy->tft.fillScreen(TFT_BLACK); 44 | menuList.menuOffset--;} 45 | 46 | if(menuList.menuItemsQuantity>=MENU_MAX_LINES_ONSCREEN) 47 | myESPboy->tft.drawLine(126,0, 126, MENU_MAX_LINES_ONSCREEN*MENU_SPACE_BETWEEN_LINES-2, TFT_BLUE); 48 | else 49 | myESPboy->tft.drawLine(126,0, 126, menuList.menuItemsQuantity*MENU_SPACE_BETWEEN_LINES-2, TFT_BLUE); 50 | 51 | for (uint8_t i=0;; i++){ 52 | if(i>=menuList.menuItemsQuantity || i>=MENU_MAX_LINES_ONSCREEN) break; 53 | 54 | #ifndef U8g2_MENU 55 | if(menuList.menuLine[i+menuList.menuOffset][0] == '-'){ 56 | myESPboy->tft.setTextColor(menuList.menuUnselectedLineColor); 57 | myESPboy->tft.drawString(&menuList.menuLine[i+menuList.menuOffset][1], 3, i*MENU_SPACE_BETWEEN_LINES+2); 58 | } 59 | else{ 60 | myESPboy->tft.setTextColor(menuList.menuLineColor); 61 | myESPboy->tft.drawString(menuList.menuLine[i+menuList.menuOffset], 3, i*MENU_SPACE_BETWEEN_LINES+2); 62 | } 63 | #else 64 | if(menuList.menuLine[i+menuList.menuOffset][0] == '-'){ 65 | u8f->setForegroundColor(menuList.menuUnselectedLineColor); 66 | u8f->drawStr(3, i*MENU_SPACE_BETWEEN_LINES+1+GUI_FONT_HEIGHT, &menuList.menuLine[i+menuList.menuOffset][1]); 67 | } 68 | else { 69 | u8f->setForegroundColor(menuList.menuLineColor); 70 | u8f->drawStr(3, i*MENU_SPACE_BETWEEN_LINES+1+GUI_FONT_HEIGHT, menuList.menuLine[i+menuList.menuOffset]); 71 | } 72 | #endif 73 | 74 | if((i+menuList.menuOffset) == menuList.menuCurrent){ 75 | myESPboy->tft.drawRect(0, i*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, menuList.menuSelectionColor); 76 | previousRect=i;} 77 | } 78 | 79 | myESPboy->tft.fillRect(125, (scalingFactor*menuList.menuCurrent+2)/1000, 3, 5, TFT_YELLOW); 80 | } 81 | 82 | 83 | 84 | uint16_t ESPboyMenuGUI::menuInit(const char** menuLinesF, uint16_t menuLineColorF, uint16_t menuUnselectedLineColorF, uint16_t menuSelectionColorF){ 85 | uint16_t count=0; 86 | static uint8_t keyPressed; 87 | myESPboy->tft.fillScreen(TFT_BLACK); 88 | menuList.menuLine = menuLinesF; 89 | menuList.menuLineColor = menuLineColorF; 90 | menuList.menuUnselectedLineColor = menuUnselectedLineColorF; 91 | menuList.menuCurrent = 0; 92 | menuList.menuSelectionColor = menuSelectionColorF; 93 | menuList.menuOffset=0; 94 | while(menuLinesF[count++]); 95 | menuList.menuItemsQuantity = count-1; 96 | 97 | menuDraw(); 98 | 99 | while(1){ 100 | while (!myESPboy->getKeys())delay(50); 101 | 102 | keyPressed = myESPboy->getKeys(); 103 | 104 | if (keyPressed&MenuGUI_PAD_UP && menuList.menuCurrent > 0) { 105 | menuList.menuCurrent--; 106 | #ifdef buttonclicks 107 | myESPboy->playTone(10,10); 108 | #endif 109 | menuDraw(); 110 | } 111 | if (keyPressed&MenuGUI_PAD_DOWN && menuList.menuCurrent+1 < menuList.menuItemsQuantity) { 112 | menuList.menuCurrent++; 113 | #ifdef buttonclicks 114 | myESPboy->playTone(10,10); 115 | #endif 116 | menuDraw(); 117 | } 118 | if (keyPressed&MenuGUI_PAD_ACT && menuList.menuLine[menuList.menuCurrent][0] != '-') { 119 | #ifdef buttonclicks 120 | myESPboy->playTone(100,100); 121 | #endif 122 | 123 | myESPboy->tft.drawRect(0, (menuList.menuCurrent+menuList.menuOffset)*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, TFT_BLACK); 124 | delay(50); 125 | myESPboy->tft.drawRect(0, (menuList.menuCurrent+menuList.menuOffset)*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, menuList.menuSelectionColor); 126 | delay(50); 127 | myESPboy->tft.drawRect(0, (menuList.menuCurrent+menuList.menuOffset)*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, TFT_BLACK); 128 | delay(50); 129 | myESPboy->tft.drawRect(0, (menuList.menuCurrent+menuList.menuOffset)*MENU_SPACE_BETWEEN_LINES, 122, MENU_SPACE_BETWEEN_LINES, menuList.menuSelectionColor); 130 | delay(200); 131 | 132 | myESPboy->tft.fillScreen(TFT_BLACK); 133 | return(menuList.menuCurrent+1); 134 | } 135 | if (keyPressed&MenuGUI_PAD_ESC){ 136 | #ifdef buttonclicks 137 | myESPboy->playTone(100,100); 138 | #endif 139 | myESPboy->tft.fillScreen(TFT_BLACK); 140 | return(0); 141 | } 142 | 143 | delay(120); 144 | } 145 | }; 146 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Transmitt_method_Serial_advanced/cc1101_New_Transmitt_method_Serial_advanced.ino: -------------------------------------------------------------------------------- 1 | //New transmission method. 2 | //In addition, the gdo0 and gdo2 pin are not required. 3 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 4 | //by Little_S@tan 5 | 6 | #include 7 | 8 | const int n = 61; 9 | byte buffer[n] = ""; 10 | 11 | void setup() { 12 | 13 | Serial.begin(9600); 14 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 15 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 16 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 17 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 18 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 19 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 20 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 21 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 22 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 23 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 24 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 25 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 26 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 27 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 28 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 29 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 30 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 31 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 32 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 33 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 34 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 35 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 36 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 37 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 38 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 39 | 40 | Serial.println("Tx Mode"); 41 | } 42 | 43 | void loop() { 44 | 45 | //When sending, we give a little time to completely transmit the message (time in millis). 46 | //You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning. 47 | 48 | if (Serial.available()) { 49 | int len = Serial.readBytesUntil('\n', buffer, n); 50 | buffer[len] = '\0'; 51 | Serial.println((char *)buffer); 52 | ELECHOUSE_cc1101.SendData(buffer, len, 100); 53 | Serial.print("Buffer: "); 54 | for (int i = 0; i 6 | 7 | byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100}; 8 | char *transmitt_char = "Hello World"; 9 | 10 | void setup() { 11 | 12 | Serial.begin(9600); 13 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 14 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 15 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 16 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 17 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 18 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 19 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 20 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 21 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 22 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 23 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 24 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 25 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 26 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 27 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 28 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 29 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 30 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 31 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 32 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 33 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 34 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 35 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 36 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 37 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 38 | 39 | Serial.println("Tx Mode"); 40 | } 41 | 42 | void loop() { 43 | 44 | //3 different methods to send data without gdo 45 | //When sending, we give a little time to completely transmit the message (time in millis). 46 | //You can shorten the time. It depends on the data rate and the packet length. Just try it out for fine tuning. 47 | 48 | //Transmitt "Hello World" from byte format. 49 | ELECHOUSE_cc1101.SendData(transmitt_byte, 11, 100); 50 | delay(2000); 51 | 52 | //Transmitt "Hello World" from char format. 53 | ELECHOUSE_cc1101.SendData(transmitt_char, 100); 54 | delay(2000); 55 | 56 | //Transmitt "Hello World" from char format directly. 57 | ELECHOUSE_cc1101.SendData("Hello World", 100); 58 | delay(2000); 59 | } 60 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/Old_Method_with_GDO/cc1101_Transmitt_Serial_advanced/cc1101_Transmitt_Serial_advanced.ino: -------------------------------------------------------------------------------- 1 | // These examples are from the Electronics Cookbook by Simon Monk 2 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 3 | // mod by Little_S@tan 4 | 5 | #include 6 | 7 | int gdo0; 8 | 9 | const int n = 61; 10 | byte buffer[n] = ""; 11 | 12 | void setup() { 13 | 14 | #ifdef ESP32 15 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 16 | #elif ESP8266 17 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 18 | #else 19 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 20 | #endif 21 | 22 | Serial.begin(9600); 23 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 24 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 25 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 26 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 27 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 28 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 29 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 30 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 31 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 32 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 33 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 34 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 35 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 36 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 37 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 38 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 39 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 40 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 41 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 42 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 43 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 44 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 45 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 46 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 47 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 48 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 49 | 50 | Serial.println("Tx Mode"); 51 | } 52 | 53 | void loop() { 54 | 55 | if (Serial.available()) { 56 | int len = Serial.readBytesUntil('\n', buffer, n); 57 | buffer[len] = '\0'; 58 | Serial.println((char *)buffer); 59 | ELECHOUSE_cc1101.SendData(buffer, len); 60 | Serial.print("Buffer: "); 61 | for (int i = 0; i 5 | 6 | int gdo0; 7 | 8 | byte transmitt_byte[11] = {72,101,108,108,111,32,87,111,114,108,100}; 9 | char *transmitt_char = "Hello World"; 10 | 11 | void setup() { 12 | 13 | #ifdef ESP32 14 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 15 | #elif ESP8266 16 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 17 | #else 18 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 19 | #endif 20 | 21 | Serial.begin(9600); 22 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 23 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 24 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 25 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 26 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 27 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 28 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 29 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 30 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 31 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 32 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 33 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 34 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 35 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 36 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 37 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 38 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 39 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 40 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 41 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 42 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 43 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 44 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 45 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 46 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 47 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 48 | 49 | Serial.println("Tx Mode"); 50 | } 51 | 52 | void loop() { 53 | 54 | //3 different methods to send data 55 | 56 | //Transmitt "Hello World" from byte format. 57 | ELECHOUSE_cc1101.SendData(transmitt_byte, 11); 58 | delay(2000); 59 | 60 | //Transmitt "Hello World" from char format. 61 | ELECHOUSE_cc1101.SendData(transmitt_char); 62 | delay(2000); 63 | 64 | //Transmitt "Hello World" from char format directly. 65 | ELECHOUSE_cc1101.SendData("Hello World"); 66 | delay(2000); 67 | 68 | } 69 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/examples/CC1101 default examples/New_Method_without_GDO/cc1101_New_Receive_method_advanced/cc1101_New_Receive_method_advanced.ino: -------------------------------------------------------------------------------- 1 | //New receiving method. This method checks the Rx Fifo for any data it contains. 2 | //It allows you to do several things in a loop. 3 | //In addition, the gdo0 and gdo2 pin are not required. 4 | //https://github.com/LSatan/SmartRC-CC1101-Driver-Lib 5 | //by Little_S@tan 6 | #include 7 | 8 | void setup(){ 9 | 10 | Serial.begin(9600); 11 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 12 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 13 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 14 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 15 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 16 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 17 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 18 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 19 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 20 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 21 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 22 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 23 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 24 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 25 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 26 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 27 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 28 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 29 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 30 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 31 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 32 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 33 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 34 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 35 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 36 | 37 | Serial.println("Rx Mode"); 38 | } 39 | 40 | byte buffer[61] = {0}; 41 | 42 | void loop(){ 43 | 44 | //Checks whether something has been received. 45 | //When something is received we give some time to receive the message in full.(time in millis) 46 | if (ELECHOUSE_cc1101.CheckRxFifo(100)){ 47 | 48 | //CRC Check. If "setCrc(false)" crc returns always OK! 49 | if (ELECHOUSE_cc1101.CheckCRC()){ 50 | 51 | //Rssi Level in dBm 52 | Serial.print("Rssi: "); 53 | Serial.println(ELECHOUSE_cc1101.getRssi()); 54 | 55 | //Link Quality Indicator 56 | Serial.print("LQI: "); 57 | Serial.println(ELECHOUSE_cc1101.getLqi()); 58 | 59 | //Get received Data and calculate length 60 | int len = ELECHOUSE_cc1101.ReceiveData(buffer); 61 | buffer[len] = '\0'; 62 | 63 | //Print received in char format. 64 | Serial.println((char *) buffer); 65 | 66 | //Print received in bytes format. 67 | for (int i = 0; i 5 | 6 | int gdo0; 7 | 8 | void setup(){ 9 | 10 | #ifdef ESP32 11 | gdo0 = 2; // for esp32! GDO0 on GPIO pin 2. 12 | #elif ESP8266 13 | gdo0 = 5; // for esp8266! GDO0 on pin 5 = D1. 14 | #else 15 | gdo0 = 6; // for Arduino! GDO0 on pin 6. 16 | #endif 17 | 18 | Serial.begin(9600); 19 | ELECHOUSE_cc1101.Init(); // must be set to initialize the cc1101! 20 | ELECHOUSE_cc1101.setGDO(gdo0,0); // set lib internal gdo pins (gdo0,gdo2). Gdo2 not use for this example. 21 | ELECHOUSE_cc1101.setCCMode(1); // set config for internal transmission mode. 22 | ELECHOUSE_cc1101.setModulation(0); // set modulation mode. 0 = 2-FSK, 1 = GFSK, 2 = ASK/OOK, 3 = 4-FSK, 4 = MSK. 23 | ELECHOUSE_cc1101.setMHZ(433.92); // Here you can set your basic frequency. The lib calculates the frequency automatically (default = 433.92).The cc1101 can: 300-348 MHZ, 387-464MHZ and 779-928MHZ. Read More info from datasheet. 24 | ELECHOUSE_cc1101.setDeviation(47.60); // Set the Frequency deviation in kHz. Value from 1.58 to 380.85. Default is 47.60 kHz. 25 | ELECHOUSE_cc1101.setChannel(0); // Set the Channelnumber from 0 to 255. Default is cahnnel 0. 26 | ELECHOUSE_cc1101.setChsp(199.95); // The channel spacing is multiplied by the channel number CHAN and added to the base frequency in kHz. Value from 25.39 to 405.45. Default is 199.95 kHz. 27 | ELECHOUSE_cc1101.setRxBW(812.50); // Set the Receive Bandwidth in kHz. Value from 58.03 to 812.50. Default is 812.50 kHz. 28 | ELECHOUSE_cc1101.setDRate(99.97); // Set the Data Rate in kBaud. Value from 0.02 to 1621.83. Default is 99.97 kBaud! 29 | ELECHOUSE_cc1101.setPA(10); // Set TxPower. The following settings are possible depending on the frequency band. (-30 -20 -15 -10 -6 0 5 7 10 11 12) Default is max! 30 | ELECHOUSE_cc1101.setSyncMode(2); // Combined sync-word qualifier mode. 0 = No preamble/sync. 1 = 16 sync word bits detected. 2 = 16/16 sync word bits detected. 3 = 30/32 sync word bits detected. 4 = No preamble/sync, carrier-sense above threshold. 5 = 15/16 + carrier-sense above threshold. 6 = 16/16 + carrier-sense above threshold. 7 = 30/32 + carrier-sense above threshold. 31 | ELECHOUSE_cc1101.setSyncWord(211, 145); // Set sync word. Must be the same for the transmitter and receiver. (Syncword high, Syncword low) 32 | ELECHOUSE_cc1101.setAdrChk(0); // Controls address check configuration of received packages. 0 = No address check. 1 = Address check, no broadcast. 2 = Address check and 0 (0x00) broadcast. 3 = Address check and 0 (0x00) and 255 (0xFF) broadcast. 33 | ELECHOUSE_cc1101.setAddr(0); // Address used for packet filtration. Optional broadcast addresses are 0 (0x00) and 255 (0xFF). 34 | ELECHOUSE_cc1101.setWhiteData(0); // Turn data whitening on / off. 0 = Whitening off. 1 = Whitening on. 35 | ELECHOUSE_cc1101.setPktFormat(0); // Format of RX and TX data. 0 = Normal mode, use FIFOs for RX and TX. 1 = Synchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 2 = Random TX mode; sends random data using PN9 generator. Used for test. Works as normal mode, setting 0 (00), in RX. 3 = Asynchronous serial mode, Data in on GDO0 and data out on either of the GDOx pins. 36 | ELECHOUSE_cc1101.setLengthConfig(1); // 0 = Fixed packet length mode. 1 = Variable packet length mode. 2 = Infinite packet length mode. 3 = Reserved 37 | ELECHOUSE_cc1101.setPacketLength(0); // Indicates the packet length when fixed packet length mode is enabled. If variable packet length mode is used, this value indicates the maximum packet length allowed. 38 | ELECHOUSE_cc1101.setCrc(1); // 1 = CRC calculation in TX and CRC check in RX enabled. 0 = CRC disabled for TX and RX. 39 | ELECHOUSE_cc1101.setCRC_AF(0); // Enable automatic flush of RX FIFO when CRC is not OK. This requires that only one packet is in the RXIFIFO and that packet length is limited to the RX FIFO size. 40 | ELECHOUSE_cc1101.setDcFilterOff(0); // Disable digital DC blocking filter before demodulator. Only for data rates ≤ 250 kBaud The recommended IF frequency changes when the DC blocking is disabled. 1 = Disable (current optimized). 0 = Enable (better sensitivity). 41 | ELECHOUSE_cc1101.setManchester(0); // Enables Manchester encoding/decoding. 0 = Disable. 1 = Enable. 42 | ELECHOUSE_cc1101.setFEC(0); // Enable Forward Error Correction (FEC) with interleaving for packet payload (Only supported for fixed packet length mode. 0 = Disable. 1 = Enable. 43 | ELECHOUSE_cc1101.setPQT(0); // Preamble quality estimator threshold. The preamble quality estimator increases an internal counter by one each time a bit is received that is different from the previous bit, and decreases the counter by 8 each time a bit is received that is the same as the last bit. A threshold of 4∙PQT for this counter is used to gate sync word detection. When PQT=0 a sync word is always accepted. 44 | ELECHOUSE_cc1101.setAppendStatus(0); // When enabled, two status bytes will be appended to the payload of the packet. The status bytes contain RSSI and LQI values, as well as CRC OK. 45 | 46 | Serial.println("Rx Mode"); 47 | } 48 | 49 | byte buffer[61] = {0}; 50 | 51 | void loop(){ 52 | 53 | //Checks whether something has been received. 54 | if (ELECHOUSE_cc1101.CheckReceiveFlag()){ 55 | 56 | //CRC Check. If "setCrc(false)" crc returns always OK! 57 | if (ELECHOUSE_cc1101.CheckCRC()){ 58 | 59 | //Rssi Level in dBm 60 | Serial.print("Rssi: "); 61 | Serial.println(ELECHOUSE_cc1101.getRssi()); 62 | 63 | //Link Quality Indicator 64 | Serial.print("LQI: "); 65 | Serial.println(ELECHOUSE_cc1101.getLqi()); 66 | 67 | //Get received Data and calculate length 68 | int len = ELECHOUSE_cc1101.ReceiveData(buffer); 69 | buffer[len] = '\0'; 70 | 71 | //Print received in char format. 72 | Serial.println((char *) buffer); 73 | 74 | //Print received in bytes format. 75 | for (int i = 0; i.(at)gmail(dot)com 11 | - Max Horn / max(at)quendi(dot)de 12 | - Robert ter Vehn / .(at)gmail(dot)com 13 | 14 | Project home: https://github.com/sui77/rc-switch/ 15 | 16 | This library is free software; you can redistribute it and/or 17 | modify it under the terms of the GNU Lesser General Public 18 | License as published by the Free Software Foundation; either 19 | version 2.1 of the License, or (at your option) any later version. 20 | 21 | This library is distributed in the hope that it will be useful, 22 | but WITHOUT ANY WARRANTY; without even the implied warranty of 23 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 24 | Lesser General Public License for more details. 25 | 26 | You should have received a copy of the GNU Lesser General Public 27 | License along with this library; if not, write to the Free Software 28 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 29 | */ 30 | #ifndef _RCSwitch_h 31 | #define _RCSwitch_h 32 | 33 | #if defined(ARDUINO) && ARDUINO >= 100 34 | #include "Arduino.h" 35 | #elif defined(ENERGIA) // LaunchPad, FraunchPad and StellarPad specific 36 | #include "Energia.h" 37 | #elif defined(RPI) // Raspberry Pi 38 | #define RaspberryPi 39 | 40 | // Include libraries for RPi: 41 | #include /* memcpy */ 42 | #include /* abs */ 43 | #include 44 | #elif defined(SPARK) 45 | #include "application.h" 46 | #else 47 | #include "WProgram.h" 48 | #endif 49 | 50 | #include 51 | 52 | 53 | // At least for the ATTiny X4/X5, receiving has to be disabled due to 54 | // missing libm depencies (udivmodhi4) 55 | #if defined( __AVR_ATtinyX5__ ) or defined ( __AVR_ATtinyX4__ ) 56 | #define RCSwitchDisableReceiving 57 | #endif 58 | 59 | // Number of maximum high/Low changes per packet. 60 | // We can handle up to (unsigned long) => 32 bit * 2 H/L changes per bit + 2 for sync 61 | // Для keeloq нужно увеличить RCSWITCH_MAX_CHANGES до 23+1+66*2+1=157 62 | #define RCSWITCH_MAX_CHANGES 157 // default 67 63 | 64 | // separationLimit: minimum microseconds between received codes, closer codes are ignored. 65 | // according to discussion on issue #14 it might be more suitable to set the separation 66 | // limit to the same time as the 'low' part of the sync signal for the current protocol. 67 | // should be set to the minimum value of pulselength * the sync signal 68 | #define RCSWITCH_SEPARATION_LIMIT 4100 69 | 70 | class RCSwitch { 71 | 72 | public: 73 | RCSwitch(); 74 | 75 | void switchOn(int nGroupNumber, int nSwitchNumber); 76 | void switchOff(int nGroupNumber, int nSwitchNumber); 77 | void switchOn(const char* sGroup, int nSwitchNumber); 78 | void switchOff(const char* sGroup, int nSwitchNumber); 79 | void switchOn(char sFamily, int nGroup, int nDevice); 80 | void switchOff(char sFamily, int nGroup, int nDevice); 81 | void switchOn(const char* sGroup, const char* sDevice); 82 | void switchOff(const char* sGroup, const char* sDevice); 83 | void switchOn(char sGroup, int nDevice); 84 | void switchOff(char sGroup, int nDevice); 85 | 86 | void sendTriState(const char* sCodeWord); 87 | void send(uint64_t code, unsigned int length); 88 | void send(const char* sCodeWord); 89 | 90 | #if not defined( RCSwitchDisableReceiving ) 91 | void enableReceive(int interrupt); 92 | void enableReceive(); 93 | void disableReceive(); 94 | bool available(); 95 | void resetAvailable(); 96 | 97 | unsigned long long getReceivedValue(); 98 | unsigned int getReceivedBitlength(); 99 | unsigned int getReceivedDelay(); 100 | unsigned int getReceivedProtocol(); 101 | unsigned int* getReceivedRawdata(); 102 | uint8_t getNumProtos(); 103 | #endif 104 | 105 | void enableTransmit(int nTransmitterPin); 106 | void disableTransmit(); 107 | void setPulseLength(int nPulseLength); 108 | void setRepeatTransmit(int nRepeatTransmit); 109 | #if not defined( RCSwitchDisableReceiving ) 110 | void setReceiveTolerance(int nPercent); 111 | void setReceiveProtocolMask(unsigned long long mask); 112 | #endif 113 | 114 | /** 115 | * Description of a single pule, which consists of a high signal 116 | * whose duration is "high" times the base pulse length, followed 117 | * by a low signal lasting "low" times the base pulse length. 118 | * Thus, the pulse overall lasts (high+low)*pulseLength 119 | */ 120 | struct HighLow { 121 | uint8_t high; 122 | uint8_t low; 123 | }; 124 | 125 | /** 126 | * A "protocol" describes how zero and one bits are encoded into high/low 127 | * pulses. 128 | */ 129 | struct Protocol { 130 | /** base pulse length in microseconds, e.g. 350 */ 131 | uint16_t pulseLength; 132 | uint8_t PreambleFactor; 133 | HighLow Preamble; 134 | uint8_t HeaderFactor; 135 | HighLow Header; 136 | 137 | HighLow zero; 138 | HighLow one; 139 | 140 | /** 141 | * If true, interchange high and low logic levels in all transmissions. 142 | * 143 | * By default, RCSwitch assumes that any signals it sends or receives 144 | * can be broken down into pulses which start with a high signal level, 145 | * followed by a a low signal level. This is e.g. the case for the 146 | * popular PT 2260 encoder chip, and thus many switches out there. 147 | * 148 | * But some devices do it the other way around, and start with a low 149 | * signal level, followed by a high signal level, e.g. the HT6P20B. To 150 | * accommodate this, one can set invertedSignal to true, which causes 151 | * RCSwitch to change how it interprets any HighLow struct FOO: It will 152 | * then assume transmissions start with a low signal lasting 153 | * FOO.high*pulseLength microseconds, followed by a high signal lasting 154 | * FOO.low*pulseLength microseconds. 155 | */ 156 | bool invertedSignal; 157 | uint16_t Guard; 158 | }; 159 | 160 | void setProtocol(Protocol protocol); 161 | void setProtocol(int nProtocol); 162 | void setProtocol(int nProtocol, int nPulseLength); 163 | 164 | private: 165 | char* getCodeWordA(const char* sGroup, const char* sDevice, bool bStatus); 166 | char* getCodeWordB(int nGroupNumber, int nSwitchNumber, bool bStatus); 167 | char* getCodeWordC(char sFamily, int nGroup, int nDevice, bool bStatus); 168 | char* getCodeWordD(char group, int nDevice, bool bStatus); 169 | void transmit(HighLow pulses); 170 | 171 | #if not defined( RCSwitchDisableReceiving ) 172 | static void handleInterrupt(); 173 | static bool receiveProtocol(const int p, unsigned int changeCount); 174 | int nReceiverInterrupt; 175 | #endif 176 | int nTransmitterPin; 177 | int nRepeatTransmit; 178 | Protocol protocol; 179 | 180 | #if not defined( RCSwitchDisableReceiving ) 181 | static int nReceiveTolerance; 182 | volatile static unsigned long long nReceivedValue; 183 | volatile static unsigned long long nReceiveProtocolMask; 184 | volatile static unsigned int nReceivedBitlength; 185 | volatile static unsigned int nReceivedDelay; 186 | volatile static unsigned int nReceivedProtocol; 187 | const static unsigned int nSeparationLimit; 188 | /* 189 | * timings[0] contains sync timing, followed by a number of bits 190 | */ 191 | static unsigned int timings[RCSWITCH_MAX_CHANGES]; 192 | // буфер длительностей последних четырех пакетов, [0] - последний 193 | static unsigned int buftimings[4]; 194 | #endif 195 | 196 | 197 | }; 198 | 199 | //// 200 | class Keeloq { 201 | public: 202 | Keeloq(); 203 | void SetKey(unsigned long keyHigh, unsigned long keyLow); 204 | unsigned long GetKey(bool HighLow); 205 | unsigned long Encrypt(unsigned long data); 206 | unsigned long Decrypt(unsigned long data); 207 | void NormLearn(unsigned long FixSN); 208 | unsigned long ReflectPack(unsigned long PackSrc); 209 | private: 210 | unsigned long _keyHigh; 211 | unsigned long _keyLow; 212 | }; 213 | 214 | #endif 215 | -------------------------------------------------------------------------------- /lib/SmartRC-CC1101-Driver-Lib-master/ELECHOUSE_CC1101_SRC_DRV.h: -------------------------------------------------------------------------------- 1 | /* 2 | ELECHOUSE_CC1101.cpp - CC1101 module library 3 | Copyright (c) 2010 Michael. 4 | Author: Michael, 5 | Version: November 12, 2010 6 | 7 | This library is designed to use CC1101/CC1100 module on Arduino platform. 8 | CC1101/CC1100 module is an useful wireless module.Using the functions of the 9 | library, you can easily send and receive data by the CC1101/CC1100 module. 10 | Just have fun! 11 | For the details, please refer to the datasheet of CC1100/CC1101. 12 | ---------------------------------------------------------------------------------------------------------------- 13 | cc1101 Driver for RC Switch. Mod by Little Satan. With permission to modify and publish Wilson Shen (ELECHOUSE). 14 | ---------------------------------------------------------------------------------------------------------------- 15 | */ 16 | #ifndef ELECHOUSE_CC1101_SRC_DRV_h 17 | #define ELECHOUSE_CC1101_SRC_DRV_h 18 | 19 | #include 20 | 21 | //***************************************CC1101 define**************************************************// 22 | // CC1101 CONFIG REGSITER 23 | #define CC1101_IOCFG2 0x00 // GDO2 output pin configuration 24 | #define CC1101_IOCFG1 0x01 // GDO1 output pin configuration 25 | #define CC1101_IOCFG0 0x02 // GDO0 output pin configuration 26 | #define CC1101_FIFOTHR 0x03 // RX FIFO and TX FIFO thresholds 27 | #define CC1101_SYNC1 0x04 // Sync word, high INT8U 28 | #define CC1101_SYNC0 0x05 // Sync word, low INT8U 29 | #define CC1101_PKTLEN 0x06 // Packet length 30 | #define CC1101_PKTCTRL1 0x07 // Packet automation control 31 | #define CC1101_PKTCTRL0 0x08 // Packet automation control 32 | #define CC1101_ADDR 0x09 // Device address 33 | #define CC1101_CHANNR 0x0A // Channel number 34 | #define CC1101_FSCTRL1 0x0B // Frequency synthesizer control 35 | #define CC1101_FSCTRL0 0x0C // Frequency synthesizer control 36 | #define CC1101_FREQ2 0x0D // Frequency control word, high INT8U 37 | #define CC1101_FREQ1 0x0E // Frequency control word, middle INT8U 38 | #define CC1101_FREQ0 0x0F // Frequency control word, low INT8U 39 | #define CC1101_MDMCFG4 0x10 // Modem configuration 40 | #define CC1101_MDMCFG3 0x11 // Modem configuration 41 | #define CC1101_MDMCFG2 0x12 // Modem configuration 42 | #define CC1101_MDMCFG1 0x13 // Modem configuration 43 | #define CC1101_MDMCFG0 0x14 // Modem configuration 44 | #define CC1101_DEVIATN 0x15 // Modem deviation setting 45 | #define CC1101_MCSM2 0x16 // Main Radio Control State Machine configuration 46 | #define CC1101_MCSM1 0x17 // Main Radio Control State Machine configuration 47 | #define CC1101_MCSM0 0x18 // Main Radio Control State Machine configuration 48 | #define CC1101_FOCCFG 0x19 // Frequency Offset Compensation configuration 49 | #define CC1101_BSCFG 0x1A // Bit Synchronization configuration 50 | #define CC1101_AGCCTRL2 0x1B // AGC control 51 | #define CC1101_AGCCTRL1 0x1C // AGC control 52 | #define CC1101_AGCCTRL0 0x1D // AGC control 53 | #define CC1101_WOREVT1 0x1E // High INT8U Event 0 timeout 54 | #define CC1101_WOREVT0 0x1F // Low INT8U Event 0 timeout 55 | #define CC1101_WORCTRL 0x20 // Wake On Radio control 56 | #define CC1101_FREND1 0x21 // Front end RX configuration 57 | #define CC1101_FREND0 0x22 // Front end TX configuration 58 | #define CC1101_FSCAL3 0x23 // Frequency synthesizer calibration 59 | #define CC1101_FSCAL2 0x24 // Frequency synthesizer calibration 60 | #define CC1101_FSCAL1 0x25 // Frequency synthesizer calibration 61 | #define CC1101_FSCAL0 0x26 // Frequency synthesizer calibration 62 | #define CC1101_RCCTRL1 0x27 // RC oscillator configuration 63 | #define CC1101_RCCTRL0 0x28 // RC oscillator configuration 64 | #define CC1101_FSTEST 0x29 // Frequency synthesizer calibration control 65 | #define CC1101_PTEST 0x2A // Production test 66 | #define CC1101_AGCTEST 0x2B // AGC test 67 | #define CC1101_TEST2 0x2C // Various test settings 68 | #define CC1101_TEST1 0x2D // Various test settings 69 | #define CC1101_TEST0 0x2E // Various test settings 70 | 71 | //CC1101 Strobe commands 72 | #define CC1101_SRES 0x30 // Reset chip. 73 | #define CC1101_SFSTXON 0x31 // Enable and calibrate frequency synthesizer (if MCSM0.FS_AUTOCAL=1). 74 | // If in RX/TX: Go to a wait state where only the synthesizer is 75 | // running (for quick RX / TX turnaround). 76 | #define CC1101_SXOFF 0x32 // Turn off crystal oscillator. 77 | #define CC1101_SCAL 0x33 // Calibrate frequency synthesizer and turn it off 78 | // (enables quick start). 79 | #define CC1101_SRX 0x34 // Enable RX. Perform calibration first if coming from IDLE and 80 | // MCSM0.FS_AUTOCAL=1. 81 | #define CC1101_STX 0x35 // In IDLE state: Enable TX. Perform calibration first if 82 | // MCSM0.FS_AUTOCAL=1. If in RX state and CCA is enabled: 83 | // Only go to TX if channel is clear. 84 | #define CC1101_SIDLE 0x36 // Exit RX / TX, turn off frequency synthesizer and exit 85 | // Wake-On-Radio mode if applicable. 86 | #define CC1101_SAFC 0x37 // Perform AFC adjustment of the frequency synthesizer 87 | #define CC1101_SWOR 0x38 // Start automatic RX polling sequence (Wake-on-Radio) 88 | #define CC1101_SPWD 0x39 // Enter power down mode when CSn goes high. 89 | #define CC1101_SFRX 0x3A // Flush the RX FIFO buffer. 90 | #define CC1101_SFTX 0x3B // Flush the TX FIFO buffer. 91 | #define CC1101_SWORRST 0x3C // Reset real time clock. 92 | #define CC1101_SNOP 0x3D // No operation. May be used to pad strobe commands to two 93 | // INT8Us for simpler software. 94 | //CC1101 STATUS REGSITER 95 | #define CC1101_PARTNUM 0x30 96 | #define CC1101_VERSION 0x31 97 | #define CC1101_FREQEST 0x32 98 | #define CC1101_LQI 0x33 99 | #define CC1101_RSSI 0x34 100 | #define CC1101_MARCSTATE 0x35 101 | #define CC1101_WORTIME1 0x36 102 | #define CC1101_WORTIME0 0x37 103 | #define CC1101_PKTSTATUS 0x38 104 | #define CC1101_VCO_VC_DAC 0x39 105 | #define CC1101_TXBYTES 0x3A 106 | #define CC1101_RXBYTES 0x3B 107 | 108 | //CC1101 PATABLE,TXFIFO,RXFIFO 109 | #define CC1101_PATABLE 0x3E 110 | #define CC1101_TXFIFO 0x3F 111 | #define CC1101_RXFIFO 0x3F 112 | 113 | //************************************* class **************************************************// 114 | class ELECHOUSE_CC1101 115 | { 116 | private: 117 | void SpiStart(void); 118 | void SpiEnd(void); 119 | void GDO_Set (void); 120 | void Reset (void); 121 | void setSpi(void); 122 | void RegConfigSettings(void); 123 | void Calibrate(void); 124 | void Split_PKTCTRL0(void); 125 | void Split_PKTCTRL1(void); 126 | void Split_MDMCFG1(void); 127 | void Split_MDMCFG2(void); 128 | void Split_MDMCFG4(void); 129 | public: 130 | bool getCC1101(void); 131 | void Init(void); 132 | byte SpiReadStatus(byte addr); 133 | void setSpiPin(byte sck, byte miso, byte mosi, byte ss); 134 | void setGDO(byte gdo0, byte gdo2); 135 | void setCCMode(bool s); 136 | void setModulation(byte m); 137 | void setPA(int p); 138 | void setMHZ(float mhz); 139 | void setChannel(byte chnl); 140 | void setChsp(float f); 141 | void setRxBW(float f); 142 | void setDRate(float d); 143 | void setDeviation(float d); 144 | void SetTx(void); 145 | void SetRx(void); 146 | void SetTx(float mhz); 147 | void SetRx(float mhz); 148 | int getRssi(void); 149 | byte getLqi(void); 150 | void setSres(void); 151 | void SendData(byte *txBuffer, byte size); 152 | void SendData(char *txchar); 153 | void SendData(byte *txBuffer, byte size, int t); 154 | void SendData(char *txchar, int t); 155 | byte CheckReceiveFlag(void); 156 | byte ReceiveData(byte *rxBuffer); 157 | bool CheckCRC(void); 158 | void SpiStrobe(byte strobe); 159 | void SpiWriteReg(byte addr, byte value); 160 | void SpiWriteBurstReg(byte addr, byte *buffer, byte num); 161 | byte SpiReadReg(byte addr); 162 | void SpiReadBurstReg(byte addr, byte *buffer, byte num); 163 | void setClb(byte b, byte s, byte e); 164 | void setSyncWord(byte sh, byte sl); 165 | void setAddr(byte v); 166 | void setWhiteData(bool v); 167 | void setPktFormat(byte v); 168 | void setCrc(bool v); 169 | void setLengthConfig(byte v); 170 | void setPacketLength(byte v); 171 | void setDcFilterOff(bool v); 172 | void setManchester(bool v); 173 | void setSyncMode(byte v); 174 | void setFEC(bool v); 175 | void setPQT(byte v); 176 | void setCRC_AF(bool v); 177 | void setAppendStatus(bool v); 178 | void setAdrChk(byte v); 179 | bool CheckRxFifo(int t); 180 | }; 181 | 182 | extern ELECHOUSE_CC1101 ELECHOUSE_cc1101; 183 | 184 | #endif 185 | -------------------------------------------------------------------------------- /lib/ESPboyTerminalGUI.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | ESPboyTerminalGUI class 3 | for www.ESPboy.com project by RomanS 4 | https://hackaday.io/project/164830-espboy-games-iot-stem-for-education-fun 5 | v2.1 6 | */ 7 | 8 | #include "ESPboyTerminalGUI.h" 9 | 10 | const uint8_t ESPboyTerminalGUI::keybOnscr[2][3][21] PROGMEM = { 11 | {"+1234567890abcdefghi", "jklmnopqrstuvwxyz -=", "?!@$%&*()_[]\":;.,^begin(*tft); 29 | u8f->setFontMode(1); // use u8g2 none transparent mode 30 | u8f->setBackgroundColor(TFT_BLACK); 31 | u8f->setFontDirection(0); // left to right 32 | u8f->setFont(u8g2_font_4x6_t_cyrillic); 33 | #endif 34 | consoleStringsVector.push_back(consoleStringS()); 35 | consoleStringsVector.back().consoleString = ""; 36 | consoleStringsVector.back().consoleStringColor = TFT_BLACK; 37 | toggleDisplayMode(1); 38 | } 39 | 40 | 41 | uint8_t ESPboyTerminalGUI::keysAction() { 42 | uint8_t longActPress = 0; 43 | uint8_t keyState = getKeys(); 44 | 45 | if (keyState) { 46 | #ifdef buttonclicks 47 | tone(SOUNDPIN, 100, 10); 48 | #endif 49 | if (!keybParam.displayMode) { 50 | if (keyState & GUI_PAD_LEFT && keyState & GUI_PAD_UP) { // shift 51 | keybParam.shiftOn = !keybParam.shiftOn; 52 | drawKeyboard(keybParam.selX, keybParam.selY, 0); 53 | waitKeyUnpressed(); 54 | } else { 55 | if ((keyState & GUI_PAD_RIGHT) && keybParam.selX < 20) keybParam.selX++; 56 | if ((keyState & GUI_PAD_LEFT) && keybParam.selX > -1) keybParam.selX--; 57 | if ((keyState & GUI_PAD_DOWN) && keybParam.selY < 3) keybParam.selY++; 58 | if ((keyState & GUI_PAD_UP) && keybParam.selY > -1) keybParam.selY--; 59 | if ((keyState & GUI_PAD_LEFT) && keybParam.selX == -1) keybParam.selX = 19; 60 | if ((keyState & GUI_PAD_RIGHT) && keybParam.selX == 20) keybParam.selX = 0; 61 | if ((keyState & GUI_PAD_UP) && keybParam.selY == -1) keybParam.selY = 2; 62 | if ((keyState & GUI_PAD_DOWN) && keybParam.selY == 3) keybParam.selY = 0; 63 | } 64 | 65 | if ((keyState&GUI_PAD_ACT && keyState&GUI_PAD_ESC) || (keyState&GUI_PAD_RGT && keyState&GUI_PAD_LFT)) { 66 | if (keybParam.renderLine > consoleStringsVector.size() - GUI_MAX_STRINGS_ONSCREEN_FULL) 67 | keybParam.renderLine = consoleStringsVector.size() - GUI_MAX_STRINGS_ONSCREEN_FULL; 68 | toggleDisplayMode(1); 69 | waitKeyUnpressed(); 70 | 71 | } else if (keyState&GUI_PAD_RGT && keybParam.renderLine) { 72 | keybParam.renderLine--; 73 | drawConsole(0); 74 | 75 | } else if (keyState&GUI_PAD_LFT && keybParam.renderLine < consoleStringsVector.size() - GUI_MAX_STRINGS_ONSCREEN_SMALL) { 76 | keybParam.renderLine++; 77 | drawConsole(0); 78 | } 79 | 80 | if ((((keyState & GUI_PAD_ACT) && (keybParam.selX == 19 && keybParam.selY == 2)) || (keyState & GUI_PAD_RGT && keyState & GUI_PAD_LFT))) { // enter 81 | if (keybParam.typing.length() > 0) longActPress = 1; 82 | } else if ((keyState & GUI_PAD_ACT) && (keybParam.selX == 18 && keybParam.selY == 2)) { // back space 83 | if (keybParam.typing.length() > 0) keybParam.typing.remove(keybParam.typing.length() - 1); 84 | } else if ((keyState & GUI_PAD_ACT) && (keybParam.selX == 17 && keybParam.selY == 1)) { // SPACE 85 | if (keybParam.typing.length() < GUI_MAX_TYPING_CHARS) keybParam.typing += " "; 86 | } else if ((keyState & GUI_PAD_ACT) && (keybParam.selX == 17 && keybParam.selY == 2)) { 87 | keybParam.shiftOn = !keybParam.shiftOn; 88 | drawKeyboard(keybParam.selX, keybParam.selY, 0); 89 | waitKeyUnpressed(); 90 | } else if (keyState & GUI_PAD_ACT){ 91 | if (waitKeyUnpressed() > GUI_KEY_PRESSED_DELAY_TO_SEND) 92 | longActPress = 1; 93 | else if (keybParam.typing.length() < GUI_MAX_TYPING_CHARS) 94 | keybParam.typing += (char)pgm_read_byte(&keybOnscr[keybParam.shiftOn][keybParam.selY][keybParam.selX]); 95 | } 96 | 97 | if (keyState & GUI_PAD_ESC) { 98 | if (waitKeyUnpressed() > GUI_KEY_PRESSED_DELAY_TO_SEND){ 99 | keybParam.typing = ""; 100 | longActPress=1; 101 | } 102 | else if (keybParam.typing.length() > 0) 103 | keybParam.typing.remove(keybParam.typing.length() - 1); 104 | } 105 | } 106 | 107 | else { 108 | if ((keyState & GUI_PAD_ACT && keyState & GUI_PAD_ESC) || (keyState & GUI_PAD_RGT && keyState & GUI_PAD_LFT)) { 109 | toggleDisplayMode(0); 110 | waitKeyUnpressed(); 111 | } else 112 | 113 | if (((keyState & GUI_PAD_RGT || keyState & GUI_PAD_RIGHT || keyState & GUI_PAD_DOWN)) && keybParam.renderLine > 0) { 114 | keybParam.renderLine--; 115 | drawConsole(0); 116 | } else 117 | 118 | if (((keyState&GUI_PAD_LFT || keyState & GUI_PAD_LEFT || keyState&GUI_PAD_UP)) && keybParam.renderLine < consoleStringsVector.size() - GUI_MAX_STRINGS_ONSCREEN_FULL) { 119 | keybParam.renderLine++; 120 | drawConsole(0); 121 | } else 122 | 123 | if (keyState & GUI_PAD_ESC) 124 | toggleDisplayMode(0); 125 | } 126 | if (!keybParam.displayMode) drawKeyboard(keybParam.selX, keybParam.selY, 1); 127 | } 128 | 129 | if (!keybParam.displayMode) drawBlinkingCursor(); 130 | return (longActPress); 131 | } 132 | 133 | void ESPboyTerminalGUI::toggleDisplayMode(uint8_t mode) { 134 | keybParam.displayMode = mode; 135 | tft->fillScreen(TFT_BLACK); 136 | tft->drawRect(0, 0, 128, 128, TFT_NAVY); 137 | if (!keybParam.displayMode) { 138 | tft->drawRect(0, 128 - 3 * 8 - 5, 128, 3 * 8 + 5, TFT_NAVY); 139 | tft->drawRect(0, 0, 128, 86, TFT_NAVY); 140 | } 141 | if (!keybParam.displayMode) { 142 | drawKeyboard(keybParam.selX, keybParam.selY, 0); 143 | } 144 | drawConsole(0); 145 | } 146 | 147 | String ESPboyTerminalGUI::getUserInput() { 148 | String userInput; 149 | toggleDisplayMode(0); 150 | //while (1) { 151 | while (!keysAction()) delay(GUI_KEYB_CALL_DELAY); 152 | // if (keybParam.typing != "") break; 153 | //} 154 | toggleDisplayMode(1); 155 | userInput = keybParam.typing; 156 | keybParam.typing = ""; 157 | return (userInput); 158 | } 159 | 160 | void ESPboyTerminalGUI::doScroll(){ 161 | uint8_t keyState=0; 162 | #ifdef buttonclicks 163 | tone(SOUNDPIN, 100, 10); 164 | #endif 165 | toggleDisplayMode(1); 166 | // while (!(keyState & GUI_PAD_ESC)){ 167 | ESP.wdtFeed(); 168 | keyState = getKeys(); 169 | if(keyState){ 170 | if (keyState&GUI_PAD_RGT && keybParam.renderLine) { 171 | keybParam.renderLine--;} 172 | if (keyState&GUI_PAD_LFT && keybParam.renderLine < consoleStringsVector.size() - GUI_MAX_STRINGS_ONSCREEN_SMALL) { 173 | keybParam.renderLine++;} 174 | drawConsole(0); 175 | #ifdef buttonclicks 176 | tone(SOUNDPIN, 100, 10); 177 | #endif 178 | delay(GUI_KEYB_CALL_DELAY); 179 | } 180 | //} 181 | } 182 | 183 | 184 | void ESPboyTerminalGUI::printConsole(String bfrstr, uint16_t color, uint8_t ln, uint8_t noAddLine) { 185 | String toprint; 186 | 187 | keybParam.renderLine = 0; 188 | 189 | if(bfrstr == "") bfrstr = " "; 190 | 191 | if (!ln) 192 | if (bfrstr.length() > ((128-4)/GUI_FONT_WIDTH)) { 193 | bfrstr = bfrstr.substring(0, ((128-4)/GUI_FONT_WIDTH)); 194 | toprint = bfrstr; 195 | toprint.trim(); 196 | } 197 | 198 | uint16_t traskStr=0; 199 | for (uint8_t i = 0; i <= ((bfrstr.length()-1) / ((128-4)/GUI_FONT_WIDTH)); i++) { 200 | ESP.wdtFeed(); 201 | toprint = bfrstr.substring(traskStr); 202 | toprint = toprint.substring(0, (128-4)/GUI_FONT_WIDTH); 203 | traskStr += (128-4)/GUI_FONT_WIDTH; 204 | toprint.trim(); 205 | if (!noAddLine) consoleStringsVector.push_back(consoleStringS()); 206 | consoleStringsVector.back().consoleString = toprint; 207 | consoleStringsVector.back().consoleStringColor = color; 208 | } 209 | 210 | drawConsole(noAddLine); 211 | 212 | while (consoleStringsVector.size() > GUI_MAX_CONSOLE_STRINGS){ 213 | consoleStringsVector.erase(consoleStringsVector.begin()); 214 | consoleStringsVector.shrink_to_fit(); 215 | } 216 | } 217 | 218 | 219 | 220 | void ESPboyTerminalGUI::drawConsole(uint8_t onlyLastLine) { 221 | uint16_t lines; 222 | uint16_t offsetY; 223 | uint16_t quantityLinesToDraw; 224 | int16_t startVectorToDraw; 225 | 226 | if (keybParam.displayMode) lines = GUI_MAX_STRINGS_ONSCREEN_FULL; 227 | else lines = GUI_MAX_STRINGS_ONSCREEN_SMALL; 228 | 229 | 230 | #ifndef U8g2 231 | if (!onlyLastLine) tft->fillRect(1, 4, 126, lines * GUI_FONT_HEIGHT, TFT_BLACK); 232 | else tft->fillRect(1, (lines-1) * GUI_FONT_HEIGHT+4, 126, GUI_FONT_HEIGHT, TFT_BLACK); 233 | #else 234 | if (!onlyLastLine) tft->fillRect(1, 1, 126, lines * GUI_FONT_HEIGHT, TFT_BLACK); 235 | else tft->fillRect(1, (lines-1) * GUI_FONT_HEIGHT, 126, GUI_FONT_HEIGHT+1, TFT_BLACK); 236 | #endif 237 | 238 | 239 | #ifndef U8g2 240 | offsetY = lines * GUI_FONT_HEIGHT - 4; 241 | #else 242 | offsetY = lines * GUI_FONT_HEIGHT; 243 | #endif 244 | 245 | if(consoleStringsVector.size() < lines ) quantityLinesToDraw = consoleStringsVector.size(); 246 | else quantityLinesToDraw = lines; 247 | 248 | startVectorToDraw = consoleStringsVector.size()-1-keybParam.renderLine; 249 | 250 | for (uint8_t i = 0; i< quantityLinesToDraw; i++) { 251 | ESP.wdtFeed(); 252 | #ifndef U8g2 253 | tft->setTextColor(consoleStringsVector[startVectorToDraw].consoleStringColor, TFT_BLACK); 254 | tft->drawString(consoleStringsVector[startVectorToDraw].consoleString, 3, offsetY); 255 | #else 256 | u8f->setForegroundColor(consoleStringsVector[startVectorToDraw].consoleStringColor); 257 | u8f->drawStr(2, offsetY, consoleStringsVector[startVectorToDraw].consoleString.c_str()); 258 | #endif 259 | offsetY -= GUI_FONT_HEIGHT; 260 | startVectorToDraw--; 261 | if(startVectorToDraw<0) startVectorToDraw=0; 262 | } 263 | } 264 | 265 | 266 | uint8_t ESPboyTerminalGUI::getKeys() { return (~mcp->readGPIOAB() & 255); } 267 | 268 | 269 | uint32_t ESPboyTerminalGUI::waitKeyUnpressed() { 270 | uint32_t timerStamp = millis(); 271 | while (getKeys() && (millis() - timerStamp) < GUI_KEY_UNPRESSED_TIMEOUT) ESP.wdtFeed();; 272 | return (millis() - timerStamp); 273 | } 274 | 275 | 276 | void ESPboyTerminalGUI::drawKeyboard(uint8_t slX, uint8_t slY, uint8_t onlySelected) { 277 | static char chr[2]={0,0}; 278 | static uint8_t prevX = 0, prevY = 0; 279 | 280 | if (!onlySelected) { 281 | tft->fillRect(1, 128 - 24, 126, 23, TFT_BLACK); 282 | tft->setTextColor(TFT_YELLOW, TFT_BLACK); 283 | for (uint8_t j = 0; j < 3; j++) 284 | for (uint8_t i = 0; i < 20; i++) { 285 | chr[0] = pgm_read_byte(&keybOnscr[keybParam.shiftOn][j][i]); 286 | tft->drawString(&chr[0], i * 6 + 4, 128 - 2 - 8 * (3 - j)); 287 | } 288 | } 289 | 290 | tft->setTextColor(TFT_YELLOW, TFT_BLACK); 291 | chr[0] = pgm_read_byte(&keybOnscr[keybParam.shiftOn][prevY][prevX]); 292 | tft->drawString(&chr[0], prevX * 6 + 4, 128 - 24 + prevY * 8 - 2); 293 | 294 | tft->setTextColor(TFT_WHITE, TFT_BLACK); 295 | tft->drawString("^setTextColor(TFT_YELLOW, TFT_RED); 298 | chr[0] = pgm_read_byte(&keybOnscr[keybParam.shiftOn][slY][slX]); 299 | tft->drawString(&chr[0], slX * 6 + 4, 128 - 24 + slY * 8 - 2); 300 | 301 | prevX = slX; 302 | prevY = slY; 303 | 304 | drawTyping(0); 305 | } 306 | 307 | 308 | void ESPboyTerminalGUI::drawTyping(uint8_t changeCursor) { 309 | static char cursorType[2] = {220, '_'}; 310 | static uint8_t cursorTypeFlag=0; 311 | 312 | if(changeCursor) cursorTypeFlag=!cursorTypeFlag; 313 | tft->fillRect(1, 128 - 5 * 8, 126, 10, TFT_BLACK); 314 | if (keybParam.typing.length() < 20) { 315 | tft->setTextColor(TFT_WHITE, TFT_BLACK); 316 | tft->drawString(keybParam.typing + cursorType[cursorTypeFlag], 4, 128 - 5 * 8 + 1); 317 | } else { 318 | tft->setTextColor(TFT_WHITE, TFT_BLACK); 319 | tft->drawString("<" + keybParam.typing.substring(keybParam.typing.length() - 18) +cursorType[cursorTypeFlag], 4, 128 - 5 * 8 + 1); 320 | } 321 | } 322 | 323 | 324 | void ESPboyTerminalGUI::drawOwnTypingLine(String typingLine, uint16_t colorLine){ 325 | keybParam.typing = typingLine; 326 | toggleDisplayMode(0); 327 | keybParam.typing = typingLine; 328 | tft->fillRect(1, 128 - 5 * 8, 126, 10, TFT_BLACK); 329 | tft->setTextColor(colorLine, TFT_BLACK); 330 | tft->drawString(keybParam.typing, 4, 128 - 5 * 8 + 1); 331 | } 332 | 333 | 334 | 335 | void ESPboyTerminalGUI::drawBlinkingCursor() { 336 | static uint32_t cursorBlinkMillis = 0; 337 | if (millis() > (cursorBlinkMillis + GUI_CURSOR_BLINKING_PERIOD)) { 338 | cursorBlinkMillis = millis(); 339 | drawTyping(1); 340 | } 341 | } 342 | 343 | 344 | void ESPboyTerminalGUI::SetKeybParamTyping(String str){ 345 | keybParam.typing = str; 346 | } 347 | --------------------------------------------------------------------------------