Go Down

Topic: Algorithm for generating complicated pattens of pulses on several channels (Read 333 times) previous topic - next topic

jimLee

Here's is another approach.

Code: [Select]
#include "squareWave.h"
#include "blinker.h"


// **************************************************************
// doubleWave class
// **************************************************************


class doubleWave : public blinker {

   public:
               doubleWave(int pinNum, float hfPulseMs, float hfPeriodMs,float lfPulseMs,float lfPeriodMs);
   virtual     ~doubleWave(void);

               void  trigger(bool onOff);
   virtual     void  pulseOn(void);
   virtual     void  pulseOff(void);
   
               blinker     hfWave;
};

               
doubleWave::doubleWave(int pinNum, float hfPulseMs,float hfPeriodMs,float lfPulseMs, float lfPeriodMs)
   : blinker(pinNum,lfPulseMs,lfPeriodMs) {
   
   hfWave.setPeriod(hfPeriodMs);
   hfWave.setPulse(hfPulseMs);
}

   
doubleWave::~doubleWave(void) {  }


void doubleWave::pulseOn(void) { hfWave.setOnOff(true); }
void doubleWave::pulseOff(void) { hfWave.setOnOff(false); }         


   
// **************************************************************
// And we make it go..
// **************************************************************



doubleWave blinky(13,20,100,1000,2000); // Devine your double waves. (YOu can crreate as many as you like..)


void setup() {
   
   blinky.setOnOff(true);  // Turn it on..
}

void loop() {
 
  idle();                  // Let the idlers have some time.
}



You'll need this library..
LC_baseTools

But this lets you spawn as many of these "complicated pulse patters" as you want.

-jim lee
PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)
GITHUB -> https://github.com/leftCoast

leo_pribram

My special thanks to gcjr for the idea of the approach and to 6v6gt for the code. I hope I'll be able to understand all its detals...

Regards,
Leo

leo_pribram

jimLee thank you for the coding example and reffering a new library.

Best,
Leo

jimLee

PNW Ardiuno & Maker club
1012 9Th Street, Anacortes, WA 98221 (Around the back of building)
GITHUB -> https://github.com/leftCoast

Go Up