Lumitronix_Iflex_Pro_Workshop
Library to interact with the iFlexPro
LUMITRONIX_iFlexWorkshop_Pulse.h
Go to the documentation of this file.
1 #ifndef HEADER_LUMITRONIX_IFLEX_WORKSHOP_PULSE
2 #define HEADER_LUMITRONIX_IFLEX_WORKSHOP_PULSE
3 
4 
5 #include <Arduino.h>
6 
7 
12 public:
14  }
15 
16  void Begin() {
17  // nop
18  }
19 
20  /* @return 127.5 · sin( 2π/period · (x + offset) ) + 127.5
21  */
22  uint8_t operator()(float const periodMs, float const offsetMs = 0.f) {
23  constexpr static float UINT8_HALF{static_cast<float>(UINT8_MAX) / 2.f};
24 
25  return static_cast<uint8_t>(UINT8_HALF * sinf(TWO_PI / periodMs * (millis() + offsetMs)) + UINT8_HALF);
26  }
27 };
28 
29 
30 #endif
31 
Definition: LUMITRONIX_iFlexWorkshop_Pulse.h:11
void Begin()
Definition: LUMITRONIX_iFlexWorkshop_Pulse.h:16
uint8_t operator()(float const periodMs, float const offsetMs=0.f)
Definition: LUMITRONIX_iFlexWorkshop_Pulse.h:22
LUMITRONIX_iFlexWorkshop_Pulse()
Definition: LUMITRONIX_iFlexWorkshop_Pulse.h:13