74 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			74 lines
		
	
	
		
			2.7 KiB
		
	
	
	
		
			C++
		
	
	
	
/*********************************************************************************
 | 
						|
 *  MIT License
 | 
						|
 *  
 | 
						|
 *  Copyright (c) 2020-2022 Gregg E. Berman
 | 
						|
 *  
 | 
						|
 *  https://github.com/HomeSpan/HomeSpan
 | 
						|
 *  
 | 
						|
 *  Permission is hereby granted, free of charge, to any person obtaining a copy
 | 
						|
 *  of this software and associated documentation files (the "Software"), to deal
 | 
						|
 *  in the Software without restriction, including without limitation the rights
 | 
						|
 *  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 | 
						|
 *  copies of the Software, and to permit persons to whom the Software is
 | 
						|
 *  furnished to do so, subject to the following conditions:
 | 
						|
 *  
 | 
						|
 *  The above copyright notice and this permission notice shall be included in all
 | 
						|
 *  copies or substantial portions of the Software.
 | 
						|
 *  
 | 
						|
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 | 
						|
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 | 
						|
 *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 | 
						|
 *  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 | 
						|
 *  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 | 
						|
 *  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 | 
						|
 *  SOFTWARE.
 | 
						|
 *  
 | 
						|
 ********************************************************************************/
 | 
						|
 | 
						|
#include "HomeSpan.h"             // include the HomeSpan library
 | 
						|
#include "extras/RFControl.h"     // include RF Control Library
 | 
						|
 | 
						|
void setup() {     
 | 
						|
 
 | 
						|
  Serial.begin(115200);           // start the Serial interface
 | 
						|
  Serial.flush();
 | 
						|
  delay(1000);                    // wait for interface to flush
 | 
						|
 | 
						|
  Serial.print("\n\nHomeSpan RF Transmitter Example\n\n");
 | 
						|
 | 
						|
  RFControl rf(13);               // create an instance of RFControl with signal output to pin 13 of the ESP32
 | 
						|
 | 
						|
  rf.clear();                     // clear the pulse train memory buffer
 | 
						|
 | 
						|
  rf.add(5000,5000);              // create a pulse train with three 5000-tick high/low pulses
 | 
						|
  rf.add(5000,5000);
 | 
						|
  rf.add(5000,10000);             // double duration of final low period
 | 
						|
 | 
						|
  Serial.print("Starting 4 cycles of three 500 ms on pulses...");
 | 
						|
  
 | 
						|
  rf.start(4,100);                // start transmission of 4 cycles of the pulse train with 1 tick=100 microseconds
 | 
						|
 | 
						|
  Serial.print("Done!\n");
 | 
						|
 | 
						|
  delay(2000);
 | 
						|
 | 
						|
  rf.clear();
 | 
						|
 | 
						|
  for(int i=1000;i<10000;i+=1000)
 | 
						|
    rf.add(i,10000-i);
 | 
						|
  rf.add(10000,10000);
 | 
						|
  
 | 
						|
  Serial.print("Starting 3 cycles of 100-1000 ms pulses...");
 | 
						|
  
 | 
						|
  rf.start(3,100);                // start transmission of 3 cycles of the pulse train with 1 tick=100 microseconds
 | 
						|
 | 
						|
  Serial.print("Done!\n");
 | 
						|
  
 | 
						|
  Serial.print("\nEnd Example");
 | 
						|
  
 | 
						|
} // end of setup()
 | 
						|
 | 
						|
void loop(){
 | 
						|
 | 
						|
} // end of loop()
 |