a32u4_interface.cpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. #include "a32u4_interface.h"
  2. HardwareSerial MySerial_two(2);
  3. void A32u4Interface::begin() {
  4. MySerial_two.begin(BAUD32U4, SERIAL_8N1, 25, 4);
  5. delay(2000);
  6. Serial.println("Setup A32U4 Serial Interface");
  7. MySerial_two.println("DELAY 1");
  8. delay(1000);
  9. uint8_t a32u4_rep = 0;
  10. if (MySerial_two.available()) {
  11. a32u4_rep = (uint8_t)MySerial_two.read();
  12. }
  13. //display_string.trim();
  14. //Serial.println("\nDisplay string: " + (String)display_string);
  15. if (a32u4_rep != 0) {
  16. this->supported = true;
  17. display_obj.tft.setTextColor(TFT_GREEN, TFT_BLACK);
  18. display_obj.tft.println("ATmega32U4 Found!");
  19. display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
  20. }
  21. else {
  22. display_obj.tft.setTextColor(TFT_RED, TFT_BLACK);
  23. display_obj.tft.println("ATmega32U4 Not Found");
  24. display_obj.tft.setTextColor(TFT_CYAN, TFT_BLACK);
  25. Serial.print("A32U4 Said: ");
  26. Serial.println(a32u4_rep);
  27. }
  28. this->initTime = millis();
  29. }
  30. void A32u4Interface::runScript(String script) {
  31. MySerial_two.println(script);
  32. }
  33. void A32u4Interface::test() {
  34. MySerial_two.println("STRING Hello, World!");
  35. }
  36. void A32u4Interface::main(uint32_t current_time) {
  37. if (current_time - this->initTime >= 1000) {
  38. this->initTime = millis();
  39. //MySerial_two.write("PING");
  40. //delay(1);
  41. if (MySerial_two.available()) {
  42. Serial.println("Got A32U4 Serial data");
  43. Serial.println(MySerial_two.read());
  44. }
  45. }
  46. //delay(1);*/
  47. }