cmdInterpreter.h 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // safety againts double-include
  2. #ifndef cmdInterpreter_h
  3. #define cmdInterpreter_h
  4. #include <Arduino.h>
  5. #include "doubleSerial.h"
  6. #include "pca9635.h"
  7. #define CMD_BUFFER_LENGTH 256
  8. #define CMD_CR '\r'
  9. typedef enum {
  10. RETURN_ERROR = 7,
  11. RETURN_CR = CMD_CR,
  12. } return_code_t;
  13. // Stub extension for now
  14. class cmdInterpreter {
  15. public:
  16. cmdInterpreter();
  17. boolean addToBuffer(uint8_t d);
  18. return_code_t interprete(pca9635 pwm_driver[], uint8_t cnt, uint8_t oe_pin);
  19. void prepareForNextCommand();
  20. private:
  21. uint8_t cmdBuffer[CMD_BUFFER_LENGTH];
  22. uint8_t *cmdBuffer_ptr = cmdBuffer;
  23. uint8_t debug = false;
  24. typedef enum {
  25. MODE_SINGLE_VALUE = 1,
  26. MODE_MULTIPLE_VALUE = 2,
  27. } interpreteMode_t;
  28. return_code_t readParameters(uint8_t *cmd_buf_pntr, uint8_t cmd_len, uint8_t parameters[], uint8_t num_parameters);
  29. return_code_t readParametersWithLength(uint8_t *cmd_buf_pntr, uint8_t cmd_len, uint8_t parameters[], uint8_t *num_parameters, cmdInterpreter::interpreteMode_t m);
  30. };
  31. extern doubleSerial doubleS;
  32. void PrintHex8(char *dstptr, uint8_t *srcdata, uint8_t length);
  33. void PrintHex8(char *dstptr, boolean *srcdata, uint8_t length);
  34. uint8_t ascii2byte(const uint8_t *val);
  35. #endif
  36. // *********** END OF CODE **********