lovyan03 / LovyanGFX

SPI LCD graphics library for ESP32 (ESP-IDF/ArduinoESP32) / ESP8266 (ArduinoESP8266) / SAMD51(Seeed ArduinoSAMD51)
Other
1.02k stars 187 forks source link

setWindow not affecting fillRect?! #526

Closed Starbane closed 2 months ago

Starbane commented 2 months ago

Carefully written Issues are more likely to be given priority. 丁寧に記述された報告は優先して対応される可能性が高くなります。

Environment ( 実行環境 )

Problem Description ( 問題の内容 )

I can not get setWindow to work. I am using M5Unified that uses LovyanGFX and I can not get fillRect to work correctly. It is as if I never set the setWindow, or it is supposed to work in a different way?! What I can see it used the right low-end method from M5.Display.fillRect to lgfx::v1::LGFXBase::fillRect to lgfx::v1::LGFXBase::writeFillRect to lgfx::v1::LGFXBase::writeFillRectPreclipped to lgfx::v1::IPanel::writeFillRectPreclipped that seem to use offset, the same offset that setWindow sets but it does not work :(

Expected Behavior ( 期待される動作 )

The fillRect should not be drawn at origo of the LCD but rather at the origo of the window set by setWindow

Actual Behavior ( 実際の動作 )

Steps to reproduce ( 再現のための前提条件 )

Use the M5Stack library M5Unified, that contain or wraps LovyanGFX Run the code on a M5Stack Core 2 Notice the golden rectangle is not at position 50,50 but rather 0,0

// If possible, attach a picture of your setup/wiring here.

Code to reproduce this issue ( 再現させるためのコード )

Please submit complete source code that can reproduce your problem. あなたの問題を再現できる完全なソースコードを提示してください。

#include <Arduino.h>

#include <M5UnitLCD.h>

#include <M5Unified.h>

void setup(void) {
  //Here the cfg is pulled and modified to suite the M5Stack Core 2
  M5.begin(cfg);
  M5.Display.setBrightness(128);

  M5.Display.startWrite();

  M5.Display.drawRect(49,49,102,102,TFT_WHITE); //Rect to show outside boundary of window set below
  M5.Display.setWindow(50,50,150,150);

  M5.Display.fillRect(0,0,50,50,TFT_GOLD); // This should be drawn at position 50,50 but is drawn at 0,0

  M5.Display.endWrite();
}

void loop() {
  M5.delay(1000);
}

// If your code is longer than 30 lines, GIST is preferred.

tobozo commented 2 months ago

if you want to restrict drawing to an area, try setClipRect(x,y,w,h) and clearClipRect()