"""Real ST7789 SPI flush at native widths >255 and non-eight-row heights.""" from pathlib import Path import os import subprocess import tempfile import unittest ROOT = Path(__file__).resolve().parents[1] class NativeTransferTest(unittest.TestCase): def test_flush_covers_only_native_panel_rows(self): driver = (ROOT / "src/helpers/ui/ST7789Spi.h").read_text() flush = driver[driver.index(" void display(void)"):driver.index(" virtual void resetOrientation()")] source = r''' #include #include #include #include #include using std::min; using std::max; #define LOW 0 #define HIGH 1 #define rtos_malloc std::malloc #define rtos_free std::free void yield() {} struct Bus { int transfers=0, expected_bytes=0; template void beginTransaction(T) {} void endTransaction() {} void transfer(void*,void*,int bytes) { assert(bytes==expected_bytes); ++transfers; } }; class Panel { public: int displayWidth,displayHeight,_buffheight; uint16_t _RGB=0xffff; int _spiSettings=0; Bus bus; Bus* _spi=&bus; std::vector front,back; uint8_t* buffer; uint8_t* buffer_back; std::vector rows; Panel(int w,int h):displayWidth(w),displayHeight(h),_buffheight((h+7)/8), front(w*_buffheight,0xff),back(w*_buffheight,0), buffer(front.data()),buffer_back(back.data()),rows(h,0) {} void set_CS(int) {} void setAddrWindow(int x,int y,int w,int h) { assert(x==0 && w==displayWidth && h==1 && y>=0 && y