Atm_out.h 2.0 KB

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