Testing pronto codes
This commit is contained in:
parent
5976fd3d0d
commit
760abae5ce
|
|
@ -2,37 +2,64 @@
|
|||
|
||||
#include "RFControl.h" // include RF Control Library
|
||||
|
||||
#define PRONTO_N 0.241246
|
||||
|
||||
uint16_t pronto[]={0000,0x006D,0x0000,0x0022,0x00AC,0x00AC,0x0015,0x0040,0x0015,0x0040,0x0015,0x0040,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0040,0x0015,0x0040,0x0015,0x0040,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0015,0x0040,0x0015,0x0015,0x0015,0x0015,0x0015,0x0040,0x0015,0x0040,0x0015,0x0015,0x0015,0x0015,0x0015,0x0040,0x0015,0x0015,0x0015,0x0040,0x0015,0x0040,0x0015,0x0015,0x0015,0x0015,0x0015,0x0040,0x0015,0x0040,0x0015,0x0015,0x0015,0x0689};
|
||||
//uint16_t pronto[]={0000,0x006D,0x0000,0x0022,0x00AC,0x00AC,0x0017,0x003E,0x0017,0x003E,0x0017,0x003E,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x003E,0x0017,0x003E,0x0017,0x003E,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x0013,0x0017,0x003E,0x0017,0x003E,0x0017,0x0013,0x0017,0x0013,0x0017,0x003E,0x0017,0x003E,0x0018,0x003E,0x0017,0x003E,0x0017,0x0013,0x0017,0x0013,0x0017,0x003E,0x0017,0x003E,0x0017,0x0013,0x0017,0x0746};
|
||||
//uint16_t pronto[]={0000,0x0067,0x0000,0x000d,0x0060,0x0018,0x0018,0x0018,0x0030,0x0018,0x0030,0x0018,0x0030,0x0018,0x0018,0x0018,0x0030,0x0018,0x0018,0x0018,0x0030,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x0018,0x03f6};
|
||||
|
||||
uint32_t data[100];
|
||||
|
||||
void setup() {
|
||||
|
||||
Serial.begin(115200); // start the Serial interface
|
||||
Serial.flush();
|
||||
delay(1000); // wait for interface to flush
|
||||
|
||||
Serial.println("\n\nHomeSpan RF Transmitter Example");
|
||||
Serial.println("\n\nHomeSpan RF Transmitter Example\n\n");
|
||||
|
||||
RFControl rf(10); // create an instance of RFControl with signal output to pin 17
|
||||
RFControl rf(10); // create an instance of RFControl with signal output to pin 10
|
||||
|
||||
uint32_t cf = 1e6/(pronto[1]*PRONTO_N);
|
||||
double unit=pronto[1]*PRONTO_N;
|
||||
|
||||
Serial.printf("Carrier Frequency = %d\n",cf);
|
||||
Serial.printf("Unit = %g\n",unit);
|
||||
|
||||
rf.enableCarrier(
|
||||
|
||||
Serial.printf("CONF0: %d\n",REG_GET_FIELD(RMT_CH0CONF0_REG,RMT_DIV_CNT_CH0));
|
||||
Serial.printf("CONF1: %d\n",REG_GET_FIELD(RMT_CH0CONF1_REG,RMT_REF_ALWAYS_ON_CH0));
|
||||
Serial.printf("CHIGH: %d\n",REG_GET_FIELD(RMT_CH0CARRIER_DUTY_REG,RMT_CARRIER_HIGH_CH0));
|
||||
Serial.printf("CLOW: %d\n",REG_GET_FIELD(RMT_CH0CARRIER_DUTY_REG,RMT_CARRIER_LOW_CH0));
|
||||
|
||||
rf.clear();
|
||||
|
||||
// rf.add(1000000,1000000);
|
||||
// rf.add(1000000,1000000);
|
||||
rf.add(100000,1);
|
||||
uint32_t len=0;
|
||||
|
||||
for(int i=100;i>=0;i-=5){
|
||||
rf.enableCarrier(38000,i/100.0);
|
||||
rf.start(1,4);
|
||||
for(int i=0,n=4;i<pronto[3]*2;i++){
|
||||
uint32_t pulse=pronto[n]*unit;
|
||||
while((int)pulse>0){
|
||||
uint16_t data = pulse>32767?32767:pulse;
|
||||
boolean phase=(i%2==0);
|
||||
Serial.printf("Pulse %d: %d %d %d\n",i,pronto[n],data,phase);
|
||||
pulse-=32767;
|
||||
rf.phase(data,phase);
|
||||
len+=data;
|
||||
}
|
||||
n++;
|
||||
}
|
||||
// rf.disableCarrier();
|
||||
// rf.start(1,200);
|
||||
|
||||
while(1);
|
||||
int repeat=20;
|
||||
|
||||
Serial.printf("Total Time: %d usec\n",len*repeat);
|
||||
|
||||
uint32_t t0=micros();
|
||||
rf.start(4,80);
|
||||
rf.start(repeat,1);
|
||||
uint32_t t1=micros();
|
||||
Serial.printf("Actual Time: %d usec\n",t1-t0);
|
||||
|
||||
Serial.println("End Example");
|
||||
Serial.println((t1-t0)/1000);
|
||||
|
||||
} // end of setup()
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue