GFXcanvasSerialDemo.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. #include "GFXcanvasSerialDemo.h"
  2. #include <Arduino.h>
  3. GFXcanvas1SerialDemo::GFXcanvas1SerialDemo(uint16_t w, uint16_t h)
  4. : GFXcanvas1(w, h) {}
  5. void GFXcanvas1SerialDemo::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. bool pixel;
  18. if (rotated) {
  19. pixel = this->getPixel(x, y);
  20. } else {
  21. pixel = this->getRawPixel(x, y);
  22. }
  23. sprintf(pixel_buffer, " %d", pixel);
  24. Serial.print(pixel_buffer);
  25. }
  26. Serial.print("\n");
  27. }
  28. }
  29. GFXcanvas8SerialDemo::GFXcanvas8SerialDemo(uint16_t w, uint16_t h)
  30. : GFXcanvas8(w, h) {}
  31. void GFXcanvas8SerialDemo::print(bool rotated) {
  32. char pixel_buffer[8];
  33. uint16_t width, height;
  34. if (rotated) {
  35. width = this->width();
  36. height = this->height();
  37. } else {
  38. width = this->WIDTH;
  39. height = this->HEIGHT;
  40. }
  41. for (uint16_t y = 0; y < height; y++) {
  42. for (uint16_t x = 0; x < width; x++) {
  43. uint8_t pixel;
  44. if (rotated) {
  45. pixel = this->getPixel(x, y);
  46. } else {
  47. pixel = this->getRawPixel(x, y);
  48. }
  49. sprintf(pixel_buffer, " %02x", pixel);
  50. Serial.print(pixel_buffer);
  51. }
  52. Serial.print("\n");
  53. }
  54. }
  55. GFXcanvas16SerialDemo::GFXcanvas16SerialDemo(uint16_t w, uint16_t h)
  56. : GFXcanvas16(w, h) {}
  57. void GFXcanvas16SerialDemo::print(bool rotated) {
  58. char pixel_buffer[8];
  59. uint16_t width, height;
  60. if (rotated) {
  61. width = this->width();
  62. height = this->height();
  63. } else {
  64. width = this->WIDTH;
  65. height = this->HEIGHT;
  66. }
  67. for (uint16_t y = 0; y < height; y++) {
  68. for (uint16_t x = 0; x < width; x++) {
  69. uint16_t pixel;
  70. if (rotated) {
  71. pixel = this->getPixel(x, y);
  72. } else {
  73. pixel = this->getRawPixel(x, y);
  74. }
  75. sprintf(pixel_buffer, " %04x", pixel);
  76. Serial.print(pixel_buffer);
  77. }
  78. Serial.print("\n");
  79. }
  80. }