verified functionality on ESP32-S2
This commit is contained in:
parent
fd3955f0c2
commit
4419a91bef
|
|
@ -6,6 +6,9 @@
|
||||||
Pixel::Pixel(int pin){
|
Pixel::Pixel(int pin){
|
||||||
|
|
||||||
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
rf=new RFControl(pin,false,false); // set clock to 1/80 usec, no default driver
|
||||||
|
if(!rf)
|
||||||
|
return;
|
||||||
|
|
||||||
setTiming(0.32, 0.88, 0.64, 0.56, 80.0); // set default timing parameters (suitable for most SK68 and WS28 RGB pixels)
|
setTiming(0.32, 0.88, 0.64, 0.56, 80.0); // set default timing parameters (suitable for most SK68 and WS28 RGB pixels)
|
||||||
|
|
||||||
rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler
|
rmt_isr_register(loadData,NULL,0,NULL); // set custom interrupt handler
|
||||||
|
|
|
||||||
|
|
@ -73,19 +73,24 @@ struct Effect2 {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//Pixel px(21,8);
|
#if defined(CONFIG_IDF_TARGET_ESP32C3)
|
||||||
//Effect1 effect1(&px,5);
|
#define PIN 1
|
||||||
//Effect2 effect2(&px,100);
|
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
|
||||||
|
#define PIN 1
|
||||||
#ifdef CONFIG_IDF_TARGET_ESP32C3
|
|
||||||
#define PIN 7
|
|
||||||
#define RMT_MEM_SIZE 48
|
|
||||||
#else
|
#else
|
||||||
#define PIN 13
|
#define PIN 21
|
||||||
#define RMT_MEM_SIZE 64
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
volatile uint32_t data[10];
|
Pixel px2(2);
|
||||||
|
Pixel px3(3);
|
||||||
|
Pixel px4(4);
|
||||||
|
Pixel px(PIN);
|
||||||
|
Pixel px5(5);
|
||||||
|
Pixel px6(6);
|
||||||
|
Pixel px7(7);
|
||||||
|
|
||||||
|
Effect1 effect1(&px,5);
|
||||||
|
Effect2 effect2(&px,100);
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
|
|
||||||
|
|
@ -95,79 +100,8 @@ void setup() {
|
||||||
|
|
||||||
Serial.println("\n\nHomeSpan Pixel Example\n");
|
Serial.println("\n\nHomeSpan Pixel Example\n");
|
||||||
|
|
||||||
Pixel px0(22);
|
|
||||||
Pixel px1(3);
|
|
||||||
Pixel px(21);
|
|
||||||
|
|
||||||
uint32_t colors[20];
|
|
||||||
|
|
||||||
colors[0]=px.getColorRGB(40,0,0);
|
|
||||||
colors[1]=px.getColorRGB(40,0,0);
|
|
||||||
colors[2]=px.getColorRGB(40,0,0);
|
|
||||||
colors[3]=px.getColorRGB(40,40,0);
|
|
||||||
colors[4]=px.getColorRGB(40,40,0);
|
|
||||||
colors[5]=px.getColorRGB(40,40,0);
|
|
||||||
colors[6]=px.getColorRGB(0,40,0);
|
|
||||||
colors[7]=px.getColorRGB(40,0,40);
|
|
||||||
|
|
||||||
px.setColors(colors,8);
|
|
||||||
px.setHSV(240,100,40,2);
|
|
||||||
Serial.println("\n\nDone\n\n");
|
|
||||||
while(1);
|
|
||||||
|
|
||||||
RFControl rf(PIN,true,false);
|
|
||||||
rmt_set_clk_div(rf.getChannel(),100); // set clock divider
|
|
||||||
|
|
||||||
rmt_isr_register(eot,(void *)data,0,NULL);
|
|
||||||
rmt_set_tx_intr_en(rf.getChannel(),true);
|
|
||||||
rmt_set_tx_thr_intr_en(rf.getChannel(),true,32);
|
|
||||||
|
|
||||||
RMTMEM.chan[0].data32[0].val=5000<<16 | 5000 | 1<<15;
|
|
||||||
RMTMEM.chan[0].data32[1].val=5000<<16 | 5000 | 1<<15;
|
|
||||||
|
|
||||||
for(int i=2;i<RMT_MEM_SIZE;i++)
|
|
||||||
RMTMEM.chan[0].data32[i].val=200<<16 | 200 | 1<<15;
|
|
||||||
|
|
||||||
data[0]=5;
|
|
||||||
|
|
||||||
rmt_tx_start(rf.getChannel(),true);
|
|
||||||
|
|
||||||
while(1);
|
|
||||||
|
|
||||||
// Serial.printf("PX on Pin=%d check: %s\n",px.getPin(),px?"OKAY":"BAD");
|
|
||||||
//
|
|
||||||
// px.setRGB(0,0,0,8);
|
|
||||||
// for(int i=1;i<5;i++){
|
|
||||||
// px.setHSV(0,100,20,i);
|
|
||||||
// delay(500);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// for(int i=5;i<8;i++){
|
|
||||||
// px.setHSV(60,100,30,i);
|
|
||||||
// delay(500);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// px.setHSV(120,100,100,8);
|
|
||||||
// delay(500);
|
|
||||||
|
|
||||||
} // end of setup()
|
} // end of setup()
|
||||||
|
|
||||||
void loop(){
|
void loop(){
|
||||||
|
effect2.update();
|
||||||
// effect2.update();
|
|
||||||
}
|
|
||||||
|
|
||||||
void eot(void *arg){
|
|
||||||
Serial.printf("%08X\n",RMT.int_st.val);
|
|
||||||
RMT.int_clr.ch0_tx_end=1; // must clear interrupt immediately, else havoc will break out
|
|
||||||
RMT.int_clr.ch0_tx_thr_event=1; // must clear interrupt immediately, else havoc will break out
|
|
||||||
Serial.printf("%08X\n",RMT.int_st.val);
|
|
||||||
volatile uint32_t *x=(uint32_t *)arg;
|
|
||||||
Serial.printf("%d\n",x[0]);
|
|
||||||
if(--x[0]==0)
|
|
||||||
RMTMEM.chan[0].data32[0].val=0;
|
|
||||||
|
|
||||||
// x[1]--;
|
|
||||||
// if(x[1])
|
|
||||||
// REG_WRITE(RMT_CH0CONF1_REG,0x0000000D); // use REF_TICK clock; reset xmit and receive memory address to start of channel; START TRANSMITTING!
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue