GFXcanvasSerialDemo.cpp 731 B

1234567891011121314151617181920212223242526272829303132
  1. #include "GFXcanvasSerialDemo.h"
  2. #include <Arduino.h>
  3. GFXcanvasSerialDemo::GFXcanvasSerialDemo(uint16_t w, uint16_t h)
  4. : GFXcanvas8(w, h) {}
  5. void GFXcanvasSerialDemo::print(bool rotated) {
  6. char pixel_buffer[8];
  7. uint16_t width, height;
  8. if (rotated) {
  9. width = this->width();
  10. height = this->height();
  11. } else {
  12. width = this->WIDTH;
  13. height = this->HEIGHT;
  14. }
  15. for (uint16_t y = 0; y < height; y++) {
  16. for (uint16_t x = 0; x < width; x++) {
  17. uint8_t pixel;
  18. if (rotated) {
  19. pixel = this->getPixel(x, y);
  20. } else {
  21. pixel = this->getRawPixel(x, y);
  22. }
  23. sprintf(pixel_buffer, " %02x", pixel);
  24. Serial.print(pixel_buffer);
  25. }
  26. Serial.print("\n");
  27. }
  28. }