atm_serial_debug.hpp 1015 B

1234567891011121314151617181920212223242526272829303132
  1. /*
  2. * Automaton.h - Reactive State Machine Framework for Arduino.
  3. * Published under the MIT License (MIT), Copyright (c) 2015-2016, J.P. van der Landen
  4. */
  5. #pragma once
  6. #include "Arduino.h"
  7. class atm_serial_debug { // It seems necessary to put this code in .h to keep it from being compiled in unnecessarily
  8. public:
  9. static void trace( Stream* stream, Machine& machine, const char label[], const char current[], const char next[], const char trigger[], uint32_t runtime,
  10. uint32_t cycles ) {
  11. stream->print( millis() );
  12. stream->print( " Switch " );
  13. stream->print( label );
  14. stream->print( "@" );
  15. stream->print( (long)&machine, HEX );
  16. stream->print( " from " );
  17. stream->print( current );
  18. stream->print( " to " );
  19. stream->print( next );
  20. stream->print( " on " );
  21. stream->print( trigger );
  22. stream->print( " (" );
  23. stream->print( cycles );
  24. stream->print( " cycles in " );
  25. stream->print( runtime );
  26. stream->println( " ms)" );
  27. }
  28. };