• back

    Nb: other point, but I think my above drawing is completely wrong ( .. )
    'this being said",

    From what I could read, 38kHz is a far reach for the esp8266, if its said max is actually 100Hz ( & I'm not talking about code taking too much time to exec & disrupting the WiFi part .. )
    From the post linked above, it seems using 'gpio_write(pin, 1)' & 'os_delay_us(13)' for HIGH & then for LOW could do the trick on the esp8266 platform - maybe as a tiny module or tweak to the build ?

    I'm also wondering which of the following could best suit the need ( & work as intended, if working at all, on most of the platforms .. ):

    // way A
    var arr38kHz = [0.013,0.013,0.013,0.013, ..]; // huuge array ?
    function sendSig(sigArr){
      digitalPulse(irLed_anodePin, 1, arr38kHz); // start 38kHz
      digitalPulse(irLed_cathodePin, 1, sigArr); // send signal
      digitalPulse(irLed_cathodePin, 1, 0); // wait until signal finished before further code execution
      digitalRead(irLed_anodePin); // stop 38kHz
      // or digitalWrite(irLed_anodePin, 0); // if I'm not wrong ;)
      // or digitalPulse(irLed_anodePin, 0, 0); // as well as above  ;)
    }
    
    // way B
    var interval
    function sendSig(sigArr){
      interval = setInterval(function(){
        digitalPulse(irLed_anodePin, 1, 0.013);
        digitalPulse(irLed_anodePin, 0, 0.013);
      }, 0.026); // start 38kHz
      digitalPulse(irLed_cathodePin, 1, sigArr); // send signal
      digitalPulse(irLed_cathodePin, 1, 0); // wait until signal finished before further code execution
      clearInterval(interval); // stop 38kHz
      digitalRead(irLed_anodePin); // make sure it's off
    }
    
    // way C
    var signal = [.., ..];
    for(var i=0; i< signal.length; i++){
      if( i.isEven() ){ // we need a HIGH
        digitalWrite(irLed_cathodePin, 1);
        for(var j=0; j < signal[i]/2; j++){
          digitalPulse(irLed_anodePin, 1, 0.013);
          digitalPulse(irLed_anodePin, 0, 0.013);
        }
      } else { // we need a LOW
        digitalPulse(irLed_cathodePin, 0, signal[i]); // stay Low for a while
        /* or, but not mandatory since we're LOW anyway ?
        digitalWrite(irLed_cathodePin, 0);
        for(var j=0; j < signal[i]/2; j++){
          digitalPulse(irLed_anodePin, 1, 0.013);
          digitalPulse(irLed_anodePin, 0, 0.013);
        }
        */
      }
    }
    
    // way D - using only one leg of the IR LED & the other to Gnd ?
    var signal = [.., ..];
    for(var i=0; i< signal.length; i++){
      if( i.isEven() ){ // we need a HIGH
        for(var j=0; j < signal[i]/2; j++){
          digitalPulse(irLed_cathodePin, 1, 0.013);
          digitalPulse(irLed_cathodePin, 0, 0.013);
        }
      } else { // we need a LOW
        digitalPulse(irLed_cathodePin, 0, signal[i]); // stay Low for a while
      }
    }
    
    

    I'll test as soon as I can, but sadly I'm surely not as confident in tweaking the esp build or writing a quick module for it for now :/ ..

About

Avatar for stephaneAG @stephaneAG started