Skip to content

Commit e0f360d

Browse files
authored
Merge pull request #999 from alvarolobato/headless
Add headless build target with null display driver
2 parents d3ac0c8 + e70c798 commit e0f360d

6 files changed

Lines changed: 324 additions & 0 deletions

File tree

src/drv/tft/tft_driver.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ class BaseTft {
8787
#elif USE_FBDEV && HASP_TARGET_PC
8888
// #warning Building for POSIX fbdev
8989
#include "tft_driver_posix_fbdev.h"
90+
#elif HASP_USE_NULL_DRIVER && HASP_TARGET_PC
91+
// #warning Building for Null (headless)
92+
#include "tft_driver_null.h"
9093
#else
9194
// #warning Building for Generic Tfts
9295
using dev::BaseTft;

src/drv/tft/tft_driver_null.cpp

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
2+
For full license information read the LICENSE file in the project folder */
3+
4+
#if HASP_USE_NULL_DRIVER && HASP_TARGET_PC
5+
6+
#include "hasplib.h"
7+
#include "lvgl.h"
8+
9+
#include "drv/tft/tft_driver.h"
10+
#include "tft_driver_null.h"
11+
12+
#include "dev/device.h"
13+
#include "hasp_debug.h"
14+
15+
#include <unistd.h>
16+
#include <pthread.h>
17+
18+
namespace dev {
19+
20+
static void* tick_thread(void* data)
21+
{
22+
(void)data;
23+
24+
while(1) {
25+
usleep(5000);
26+
lv_tick_inc(5);
27+
}
28+
29+
return 0;
30+
}
31+
32+
int32_t TftNullDrv::width()
33+
{
34+
return _width;
35+
}
36+
int32_t TftNullDrv::height()
37+
{
38+
return _height;
39+
}
40+
41+
void TftNullDrv::init(int32_t w, int h)
42+
{
43+
_width = w;
44+
_height = h;
45+
46+
pthread_t tick_pthread;
47+
pthread_create(&tick_pthread, 0, tick_thread, NULL);
48+
49+
LOG_VERBOSE(TAG_TFT, F("Null driver initialized (%dx%d)"), w, h);
50+
}
51+
52+
void TftNullDrv::show_info()
53+
{
54+
LOG_VERBOSE(TAG_TFT, F("Driver : Null (headless)"));
55+
}
56+
57+
void TftNullDrv::splashscreen()
58+
{}
59+
60+
void TftNullDrv::set_rotation(uint8_t rotation)
61+
{}
62+
63+
void TftNullDrv::set_invert(bool invert)
64+
{}
65+
66+
void TftNullDrv::flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p)
67+
{
68+
lv_disp_flush_ready(disp);
69+
}
70+
71+
bool TftNullDrv::is_driver_pin(uint8_t pin)
72+
{
73+
return false;
74+
}
75+
76+
const char* TftNullDrv::get_tft_model()
77+
{
78+
return "Null (headless)";
79+
}
80+
81+
} // namespace dev
82+
83+
dev::TftNullDrv haspTft;
84+
85+
#endif // HASP_USE_NULL_DRIVER && HASP_TARGET_PC

src/drv/tft/tft_driver_null.h

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
2+
For full license information read the LICENSE file in the project folder */
3+
4+
#ifndef HASP_NULL_DRIVER_H
5+
#define HASP_NULL_DRIVER_H
6+
7+
#include "tft_driver.h"
8+
9+
#if HASP_USE_NULL_DRIVER && HASP_TARGET_PC
10+
11+
#include "lvgl.h"
12+
13+
namespace dev {
14+
15+
class TftNullDrv : BaseTft {
16+
public:
17+
void init(int w, int h);
18+
void show_info();
19+
void splashscreen();
20+
21+
void set_rotation(uint8_t rotation);
22+
void set_invert(bool invert);
23+
24+
void flush_pixels(lv_disp_drv_t* disp, const lv_area_t* area, lv_color_t* color_p);
25+
bool is_driver_pin(uint8_t pin);
26+
27+
const char* get_tft_model();
28+
29+
int32_t width();
30+
int32_t height();
31+
32+
private:
33+
int32_t _width, _height;
34+
};
35+
36+
} // namespace dev
37+
38+
using dev::TftNullDrv;
39+
extern dev::TftNullDrv haspTft;
40+
41+
#endif // HASP_USE_NULL_DRIVER && HASP_TARGET_PC
42+
43+
#endif // HASP_NULL_DRIVER_H

src/hasp_gui.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ File pFileOut;
2727
bool gui_pop_screenshot_request(void);
2828
#endif
2929

30+
#if defined(POSIX)
31+
#include <limits.h>
32+
#endif
33+
3034
#if ESP32
3135
static SemaphoreHandle_t xGuiSemaphore = NULL;
3236
static TaskHandle_t g_lvgl_task_handle;
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
[env:darwin_headless]
2+
lib_archive = false
3+
platform = native@^1.2.1
4+
extra_scripts =
5+
pre:tools/osx_build_extra.py
6+
tools/linux_build_extra.py
7+
build_flags =
8+
${env.build_flags}
9+
-D HASP_MODEL="MacOS Headless"
10+
-D HASP_TARGET_PC=1
11+
12+
; ----- Display
13+
-D TFT_WIDTH=320
14+
-D TFT_HEIGHT=480
15+
-D HASP_USE_NULL_DRIVER=1
16+
; ----- ArduinoJson
17+
-D ARDUINOJSON_DECODE_UNICODE=1
18+
-D HASP_NUM_PAGES=12
19+
-D HASP_USE_SPIFFS=0
20+
-D HASP_USE_LITTLEFS=0
21+
-D HASP_USE_EEPROM=0
22+
-D HASP_USE_GPIO=0
23+
-D HASP_USE_CONFIG=1
24+
-D HASP_USE_DEBUG=1
25+
-D HASP_USE_PNGDECODE=1
26+
-D HASP_USE_BMPDECODE=1
27+
-D HASP_USE_GIFDECODE=0
28+
-D HASP_USE_JPGDECODE=0
29+
-D HASP_USE_QRCODE=0
30+
-D HASP_USE_MQTT=1
31+
-D MQTT_MAX_PACKET_SIZE=2048
32+
-D HASP_ATTRIBUTE_FAST_MEM=
33+
-D IRAM_ATTR= ; No IRAM_ATTR available
34+
-D PROGMEM= ; No PROGMEM available
35+
; Add recursive dirs for hal headers search
36+
-D POSIX
37+
-D PAHO_MQTT_STATIC
38+
-DPAHO_WITH_SSL=TRUE
39+
-DPAHO_BUILD_DOCUMENTATION=FALSE
40+
-DPAHO_BUILD_SAMPLES=FALSE
41+
-DCMAKE_BUILD_TYPE=Release
42+
-DCMAKE_VERBOSE_MAKEFILE=TRUE
43+
-I.pio/libdeps/darwin_headless/paho/src
44+
-I.pio/libdeps/darwin_headless/ArduinoJson/src
45+
-I lib/ArduinoJson/src
46+
-I lib/lv_fs_if
47+
48+
; ----- Statically linked libraries --------------------
49+
-lm
50+
-lpthread
51+
-DTARGET_OS_MAC=1
52+
53+
lib_deps =
54+
${env.lib_deps}
55+
${arduinojson.lib_deps}
56+
https://github.com/eclipse/paho.mqtt.c.git
57+
https://github.com/fvanroie/lv_drivers
58+
git+https://github.com/lvgl/lv_lib_png.git#release/v7
59+
60+
lib_ignore =
61+
paho
62+
AXP192
63+
ArduinoLog
64+
lv_lib_qrcode
65+
ETHSPI
66+
freetype
67+
68+
build_src_filter =
69+
+<*>
70+
-<*.h>
71+
+<../.pio/libdeps/darwin_headless/paho/src/*.c>
72+
-<../.pio/libdeps/darwin_headless/paho/src/MQTTClient.c>
73+
+<../.pio/libdeps/darwin_headless/paho/src/MQTTAsync.c>
74+
+<../.pio/libdeps/darwin_headless/paho/src/MQTTAsyncUtils.c>
75+
-<../.pio/libdeps/darwin_headless/paho/src/MQTTVersion.c>
76+
-<../.pio/libdeps/darwin_headless/paho/src/SSLSocket.c>
77+
-<MQTTClient.c>
78+
+<MQTTAsync.c>
79+
+<MQTTAsyncUtils.c>
80+
-<MQTTVersion.c>
81+
-<SSLSocket.c>
82+
-<sys/>
83+
+<sys/gpio/>
84+
+<sys/svc/>
85+
-<hal/>
86+
+<drv/>
87+
-<drv/touch>
88+
+<drv/tft>
89+
+<dev/>
90+
-<hal/>
91+
-<svc/>
92+
-<hasp_filesystem.cpp>
93+
+<font/>
94+
+<hasp/>
95+
+<lang/>
96+
-<log/>
97+
+<mqtt/>
98+
+<../.pio/libdeps/darwin_headless/ArduinoJson/src/ArduinoJson.h>
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[env:linux_headless]
2+
platform = native@^1.2.1
3+
extra_scripts =
4+
tools/linux_build_extra.py
5+
build_flags =
6+
${env.build_flags}
7+
-D HASP_MODEL="Linux Headless"
8+
-D HASP_TARGET_PC=1
9+
10+
; ----- Display
11+
-D TFT_WIDTH=320
12+
-D TFT_HEIGHT=480
13+
-D HASP_USE_NULL_DRIVER=1
14+
; ----- ArduinoJson
15+
-D ARDUINOJSON_DECODE_UNICODE=1
16+
-D HASP_NUM_PAGES=12
17+
-D HASP_USE_SPIFFS=0
18+
-D HASP_USE_LITTLEFS=0
19+
-D HASP_USE_EEPROM=0
20+
-D HASP_USE_GPIO=0
21+
-D HASP_USE_CONFIG=1
22+
-D HASP_USE_DEBUG=1
23+
-D HASP_USE_PNGDECODE=1
24+
-D HASP_USE_BMPDECODE=1
25+
-D HASP_USE_GIFDECODE=0
26+
-D HASP_USE_JPGDECODE=0
27+
-D HASP_USE_QRCODE=0
28+
-D HASP_USE_MQTT=1
29+
-D MQTT_MAX_PACKET_SIZE=2048
30+
-D HASP_ATTRIBUTE_FAST_MEM=
31+
-D IRAM_ATTR= ; No IRAM_ATTR available
32+
-D PROGMEM= ; No PROGMEM available
33+
; Add recursive dirs for hal headers search
34+
-D POSIX
35+
-D PAHO_MQTT_STATIC
36+
-DPAHO_WITH_SSL=TRUE
37+
-DPAHO_BUILD_DOCUMENTATION=FALSE
38+
-DPAHO_BUILD_SAMPLES=FALSE
39+
-DCMAKE_BUILD_TYPE=Release
40+
-DCMAKE_VERBOSE_MAKEFILE=TRUE
41+
-I.pio/libdeps/linux_headless/paho/src
42+
-I.pio/libdeps/linux_headless/ArduinoJson/src
43+
44+
; ----- Statically linked libraries --------------------
45+
-lm
46+
-lpthread
47+
48+
lib_deps =
49+
${env.lib_deps}
50+
${arduinojson.lib_deps}
51+
https://github.com/eclipse/paho.mqtt.c.git
52+
https://github.com/fvanroie/lv_drivers
53+
54+
lib_ignore =
55+
paho
56+
AXP192
57+
ArduinoLog
58+
lv_lib_qrcode
59+
ETHSPI
60+
61+
build_src_filter =
62+
+<*>
63+
-<*.h>
64+
+<../.pio/libdeps/linux_headless/paho/src/*.c>
65+
-<../.pio/libdeps/linux_headless/paho/src/MQTTClient.c>
66+
+<../.pio/libdeps/linux_headless/paho/src/MQTTAsync.c>
67+
+<../.pio/libdeps/linux_headless/paho/src/MQTTAsyncUtils.c>
68+
-<../.pio/libdeps/linux_headless/paho/src/MQTTVersion.c>
69+
-<../.pio/libdeps/linux_headless/paho/src/SSLSocket.c>
70+
-<MQTTClient.c>
71+
+<MQTTAsync.c>
72+
+<MQTTAsyncUtils.c>
73+
-<MQTTVersion.c>
74+
-<SSLSocket.c>
75+
-<sys/>
76+
+<sys/gpio/>
77+
+<sys/svc/>
78+
-<hal/>
79+
+<drv/>
80+
-<drv/touch>
81+
+<drv/tft>
82+
+<dev/>
83+
-<hal/>
84+
-<svc/>
85+
-<hasp_filesystem.cpp>
86+
+<font/>
87+
+<hasp/>
88+
+<lang/>
89+
-<log/>
90+
+<mqtt/>
91+
+<../.pio/libdeps/linux_headless/ArduinoJson/src/ArduinoJson.h>

0 commit comments

Comments
 (0)