1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146
| #include <Arduino_GFX_Library.h> int32_t w, h;
#if defined(DISPLAY_DEV_KIT) Arduino_GFX *gfx = create_default_Arduino_GFX(); #else
Arduino_DataBus *bus = create_default_Arduino_DataBus();
Arduino_GFX *gfx = new Arduino_ST7789(bus, DF_GFX_RST, 0 , true );
#endif
static inline uint32_t micros_start() __attribute__((always_inline)); static inline uint32_t micros_start() { uint8_t oms = millis(); while ((uint8_t)millis() == oms) ; return micros(); }
void setup(){ Serial.begin(9600); gfx->begin(); w = gfx->width(); h = gfx->height();
#ifdef DF_GFX_BL pinMode(DF_GFX_BL, OUTPUT); digitalWrite(DF_GFX_BL, HIGH); #endif }
void loop(){ uint32_t start = micros_start();
gfx->fillScreen(BLACK); testLines(); uint32_t usecLines = micros() - start;
gfx->setCursor(0, 20); gfx->setTextSize(3); gfx->setTextColor(RED); gfx->println(F("Cost Time:"));
gfx->setCursor(0, 50); gfx->setTextSize(4); gfx->setTextColor(RED); gfx->println(usecLines);
delay(60 * 1000L); }
int32_t testLines() { uint32_t start; int32_t x1, y1, x2, y2;
start = micros_start();
x1 = y1 = 0; y2 = h - 1; for (x2 = 0; x2 < w; x2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x2 = w - 1; for (y2 = 0; y2 < h; y2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x1 = w - 1; y1 = 0; y2 = h - 1; for (x2 = 0; x2 < w; x2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x2 = 0; for (y2 = 0; y2 < h; y2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x1 = 0; y1 = h - 1; y2 = 0; for (x2 = 0; x2 < w; x2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x2 = w - 1; for (y2 = 0; y2 < h; y2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x1 = w - 1; y1 = h - 1; y2 = 0; for (x2 = 0; x2 < w; x2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
x2 = 0; for (y2 = 0; y2 < h; y2 += 6) { gfx->drawLine(x1, y1, x2, y2, BLUE); } #ifdef ESP8266 yield(); #endif
return micros() - start; }
|