mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-19 09:16:41 +00:00
Add width() and height() to haspTFT driver #278
This commit is contained in:
parent
5e0198efc1
commit
084f7bd6ee
@ -94,7 +94,7 @@ void LovyanGfx::init(int w, int h)
|
|||||||
{ // Set SPI bus control
|
{ // Set SPI bus control
|
||||||
auto bus = (lgfx::v1::Bus_SPI*)tft._bus_instance;
|
auto bus = (lgfx::v1::Bus_SPI*)tft._bus_instance;
|
||||||
auto cfg = bus->config(); // Get the structure for bus configuration.
|
auto cfg = bus->config(); // Get the structure for bus configuration.
|
||||||
cfg.spi_host = HSPI_HOST; // Select the SPI to use (VSPI_HOST or HSPI_HOST)
|
cfg.spi_host = FSPI_HOST; // Select the SPI to use (VSPI_HOST or HSPI_HOST)
|
||||||
cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3)
|
cfg.spi_mode = 0; // Set SPI communication mode (0 ~ 3)
|
||||||
cfg.freq_write = SPI_FREQUENCY; // SPI clock during transmission (Max 80MHz, 80MHz Can be rounded to the value
|
cfg.freq_write = SPI_FREQUENCY; // SPI clock during transmission (Max 80MHz, 80MHz Can be rounded to the value
|
||||||
// divided by an integer )
|
// divided by an integer )
|
||||||
@ -185,7 +185,7 @@ void LovyanGfx::init(int w, int h)
|
|||||||
cfg.offset_rotation = 0; // Adjustment when the display and touch orientation do not match:
|
cfg.offset_rotation = 0; // Adjustment when the display and touch orientation do not match:
|
||||||
// Set with a value from 0 to 7
|
// Set with a value from 0 to 7
|
||||||
cfg.bus_shared = true; // Set to true if you are using the same bus as the screen
|
cfg.bus_shared = true; // Set to true if you are using the same bus as the screen
|
||||||
cfg.spi_host = HSPI_HOST; // Select the SPI to use (HSPI_HOST or VSPI_HOST)
|
cfg.spi_host = FSPI_HOST; // Select the SPI to use (HSPI_HOST or VSPI_HOST)
|
||||||
cfg.pin_sclk = TFT_SCLK; // SCLK Pin Number
|
cfg.pin_sclk = TFT_SCLK; // SCLK Pin Number
|
||||||
cfg.pin_mosi = TFT_MOSI; // MOSI Pin Number
|
cfg.pin_mosi = TFT_MOSI; // MOSI Pin Number
|
||||||
cfg.pin_miso = TFT_MISO; // MISO Pin Number
|
cfg.pin_miso = TFT_MISO; // MISO Pin Number
|
||||||
|
@ -61,6 +61,13 @@ class LovyanGfx : BaseTft {
|
|||||||
|
|
||||||
const char* get_tft_model();
|
const char* get_tft_model();
|
||||||
|
|
||||||
|
int32_t width(){
|
||||||
|
return tft.width();
|
||||||
|
}
|
||||||
|
int32_t height(){
|
||||||
|
return tft.height();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32_t get_tft_driver();
|
uint32_t get_tft_driver();
|
||||||
uint32_t get_touch_driver();
|
uint32_t get_touch_driver();
|
||||||
|
@ -41,7 +41,16 @@ static int tick_thread(void* data)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TftSdl::init(int w, int h)
|
int32_t TftSdl::width()
|
||||||
|
{
|
||||||
|
return _width;
|
||||||
|
}
|
||||||
|
int32_t TftSdl::height()
|
||||||
|
{
|
||||||
|
return _height;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TftSdl::init(int32_t w, int h)
|
||||||
{
|
{
|
||||||
|
|
||||||
// Workaround for sdl2 `-m32` crash
|
// Workaround for sdl2 `-m32` crash
|
||||||
@ -50,6 +59,9 @@ void TftSdl::init(int w, int h)
|
|||||||
setenv("DBUS_FATAL_WARNINGS", "0", 1);
|
setenv("DBUS_FATAL_WARNINGS", "0", 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
_width = w;
|
||||||
|
_height = h;
|
||||||
|
|
||||||
/* Add a display
|
/* Add a display
|
||||||
* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
|
* Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/
|
||||||
monitor_init(w, h); // (MONITOR_HOR_RES, MONITOR_VER_RES);
|
monitor_init(w, h); // (MONITOR_HOR_RES, MONITOR_VER_RES);
|
||||||
|
@ -27,6 +27,12 @@ class TftSdl : BaseTft {
|
|||||||
bool is_driver_pin(uint8_t pin);
|
bool is_driver_pin(uint8_t pin);
|
||||||
|
|
||||||
const char* get_tft_model();
|
const char* get_tft_model();
|
||||||
|
|
||||||
|
int32_t width();
|
||||||
|
int32_t height();
|
||||||
|
|
||||||
|
private:
|
||||||
|
int32_t _width, _height;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dev
|
} // namespace dev
|
||||||
|
@ -40,6 +40,13 @@ class TftEspi : BaseTft {
|
|||||||
|
|
||||||
const char* get_tft_model();
|
const char* get_tft_model();
|
||||||
|
|
||||||
|
int32_t width(){
|
||||||
|
return tft.width();
|
||||||
|
}
|
||||||
|
int32_t height(){
|
||||||
|
return tft.height();
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void tftOffsetInfo(uint8_t pin, uint8_t x_offset, uint8_t y_offset)
|
void tftOffsetInfo(uint8_t pin, uint8_t x_offset, uint8_t y_offset)
|
||||||
{
|
{
|
||||||
|
@ -1115,8 +1115,8 @@ void dispatch_send_discovery(const char*, const char*, uint8_t source)
|
|||||||
|
|
||||||
// Display resolution
|
// Display resolution
|
||||||
JsonArray disp = doc.createNestedArray(F("disp"));
|
JsonArray disp = doc.createNestedArray(F("disp"));
|
||||||
disp.add(haspTft.tft.width());
|
disp.add(haspTft.width());
|
||||||
disp.add(haspTft.tft.height());
|
disp.add(haspTft.height());
|
||||||
|
|
||||||
size_t len = serializeJson(doc, data);
|
size_t len = serializeJson(doc, data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user