DIY fertilizer mixer and plant watering machine https://www.xythobuz.de/giessomat.html
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

DebugLog.cpp 978B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include <Arduino.h>
  2. #ifdef PLATFORM_ESP
  3. #include "WifiStuff.h"
  4. #endif // PLATFORM_ESP
  5. #include "DebugLog.h"
  6. DebugLog debug;
  7. #ifdef PLATFORM_ESP
  8. String DebugLog::getBuffer(void) {
  9. String r;
  10. for (unsigned int i = 0; i < buffer.size(); i++) {
  11. r += buffer[i];
  12. }
  13. return r;
  14. }
  15. void DebugLog::addToBuffer(String s) {
  16. for (unsigned int i = 0; i < s.length(); i++) {
  17. buffer.push(s[i]);
  18. }
  19. }
  20. #endif // PLATFORM_ESP
  21. void DebugLog::sendToTargets(String s) {
  22. Serial.print(s);
  23. #ifdef PLATFORM_ESP
  24. s = "log:" + s;
  25. wifi_send_websocket(s);
  26. #endif // PLATFORM_ESP
  27. }
  28. void DebugLog::print(String s) {
  29. #ifdef PLATFORM_ESP
  30. addToBuffer(s);
  31. #endif // PLATFORM_ESP
  32. sendToTargets(s);
  33. }
  34. void DebugLog::print(int n) {
  35. print(String(n));
  36. }
  37. void DebugLog::println(void) {
  38. print(String('\n'));
  39. }
  40. void DebugLog::println(String s) {
  41. s += '\n';
  42. print(s);
  43. }
  44. void DebugLog::println(int n) {
  45. println(String(n));
  46. }