Atm_out.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #pragma once
  2. #if not defined(ARDUINO_ARCH_ESP32)
  3. #include <Automaton.h>
  4. #include <EthernetUdp.h>
  5. #include <OSCMessage.h>
  6. #include <OSCBundle.h>
  7. class Atm_out : public Machine {
  8. public:
  9. enum { IDLE, ON, START, BLINK_OFF, LOOP, DONE, OFF, WT_ON, WT_START };
  10. enum { EVT_ON_TIMER, EVT_OFF_TIMER, EVT_WT_TIMER, EVT_COUNTER, EVT_ON, EVT_OFF, EVT_BLINK, EVT_TOGGLE, EVT_TOGGLE_BLINK, ELSE, EVT_BRUP, EVT_BRDN }; // BRUP/BRDN pseudo
  11. enum { EVT_START = EVT_BLINK };
  12. Atm_out( void ) : Machine(){};
  13. Atm_out& begin( int attached_pin, bool activeLow,
  14. EthernetUDP& udpRef, OSCBundle& bndl, const char* address );
  15. Atm_out& blink( void );
  16. Atm_out& blink( uint32_t duration );
  17. Atm_out& blink( uint32_t duration, uint32_t pause_duration, uint16_t repeat_count = ATM_COUNTER_OFF );
  18. Atm_out& pwm( uint16_t width, float freq = -1 );
  19. Atm_out& frequency( float freq );
  20. Atm_out& pause( uint32_t duration );
  21. Atm_out& fade( int fade );
  22. Atm_out& lead( uint32_t ms );
  23. Atm_out& repeat( uint16_t repeat );
  24. int brightness( int level = -1 );
  25. Atm_out& on( void );
  26. Atm_out& off( void );
  27. Atm_out& toggle( void );
  28. Atm_out& toggleBlink( void );
  29. Atm_out& start( void );
  30. Atm_out& trace( Stream& stream );
  31. Atm_out& onFinish( Machine& machine, int event = 0 );
  32. Atm_out& onFinish( atm_cb_push_t callback, int idx = 0 );
  33. Atm_out& range( int toLow, int toHigh, bool wrap = false );
  34. Atm_out& levels( unsigned char* map, int mapsize, bool wrap = false );
  35. int brighten( int v = 1 );
  36. Atm_out& trigger( int event );
  37. const char* _adress = "/OSC";
  38. EthernetUDP* _udpRef ;
  39. Atm_out& onOSC(OSCMessage& msg );
  40. OSCBundle* _bndl;
  41. private:
  42. enum { ENT_INIT, ENT_ON, ENT_OFF, EXT_CHAIN };
  43. uint8_t level;
  44. short pin;
  45. bool activeLow;
  46. uint8_t toHigh, toLow;
  47. bool wrap;
  48. uint16_t repeat_count;
  49. uint16_t width;
  50. float freq;
  51. atm_timer_millis on_timer, off_timer, lead_timer;
  52. atm_counter counter;
  53. atm_connector onfinish;
  54. unsigned char* levelMap;
  55. int levelMapSize;
  56. int mapLevel( int level );
  57. int event( int id );
  58. void action( int id );
  59. };
  60. #endif