diff --git a/src/dev/posix/hasp_posix.cpp b/src/dev/posix/hasp_posix.cpp index b3782006..52604f2a 100644 --- a/src/dev/posix/hasp_posix.cpp +++ b/src/dev/posix/hasp_posix.cpp @@ -73,7 +73,9 @@ bool PosixDevice::get_backlight_power() void PosixDevice::update_backlight() { +#ifndef TARGET_OS_MAC monitor_backlight(_backlight_power ? map(_backlight_level, 0, 100, 0, 255) : 0); +#endif } size_t PosixDevice::get_free_max_block() diff --git a/src/drv/tft_driver_sdl2.h b/src/drv/tft_driver_sdl2.h index b3633f86..e917ee74 100644 --- a/src/drv/tft_driver_sdl2.h +++ b/src/drv/tft_driver_sdl2.h @@ -49,7 +49,9 @@ class TftSdl2 : BaseTft { /* Add a display * Use the 'monitor' driver which creates window on PC's monitor to simulate a display*/ monitor_init(); +#ifndef TARGET_OS_MAC monitor_title(haspDevice.get_hostname()); +#endif /* Add the mouse as input device * Use the 'mouse' driver which reads the PC's mouse*/ @@ -94,4 +96,4 @@ class TftSdl2 : BaseTft { using dev::TftSdl2; extern dev::TftSdl2 haspTft; -#endif \ No newline at end of file +#endif diff --git a/tools/osx_build_extra.py b/tools/osx_build_extra.py new file mode 100644 index 00000000..e02f2e42 --- /dev/null +++ b/tools/osx_build_extra.py @@ -0,0 +1,15 @@ +Import("env") + +env.Append( + BUILD_FLAGS=[ + "-I/usr/local/include", + "-L/usr/local/lib", + "-DTARGET_OS_MAC=1"], +) + +env.Replace(CC="gcc-10", CXX="g++-10") + +env.Replace(BUILD_SCRIPT="tools/osx_build_script.py") + +#print('=====================================') +print(env.Dump()) diff --git a/tools/osx_build_script.py b/tools/osx_build_script.py new file mode 100644 index 00000000..b1fbe229 --- /dev/null +++ b/tools/osx_build_script.py @@ -0,0 +1,38 @@ +""" + Builder for native platform +""" + +from SCons.Script import AlwaysBuild, Default, DefaultEnvironment + +env = DefaultEnvironment() + +# Preserve C and C++ build flags +backup_cflags = env.get("CFLAGS", []) +backup_cxxflags = env.get("CXXFLAGS", []) + +# Scan for GCC compiler +env.Tool("gcc") +env.Tool("g++") + +# Restore C/C++ build flags as they were overridden by env.Tool +env.Append(CFLAGS=backup_cflags, CXXFLAGS=backup_cxxflags) + +# +# Target: Build executable program +# + +target_bin = env.BuildProgram() + +# +# Target: Print binary size +# + +target_size = env.Alias("size", target_bin, env.VerboseAction( + "$SIZEPRINTCMD", "Calculating size $SOURCE")) +AlwaysBuild(target_size) + +# +# Default targets +# + +Default([target_bin]) diff --git a/user_setups/darwin_sdl/darwin_sdl_64bits.ini b/user_setups/darwin_sdl/darwin_sdl_64bits.ini new file mode 100644 index 00000000..5953df26 --- /dev/null +++ b/user_setups/darwin_sdl/darwin_sdl_64bits.ini @@ -0,0 +1,95 @@ +[env:darwin_sdl_64bits] +lib_archive = false +platform = native@^1.1.3 +extra_scripts = + pre:tools/osx_build_extra.py + tools/linux_build_extra.py +build_flags = + ${env.build_flags} + ; ----- Monitor + -D TFT_WIDTH=240 + -D TFT_HEIGHT=320 + ; SDL drivers options + ;-D LV_LVGL_H_INCLUDE_SIMPLE + ;-D LV_DRV_NO_CONF + -D LV_MEM_SIZE=262144U ; 256kB lvgl memory + -D USE_MONITOR + -D MONITOR_ZOOM=1 ; can be fractional like 1.5 or 2 + -D USE_MOUSE + -D USE_MOUSEWHEEL + -D USE_KEYBOARD + ; ----- ArduinoJson + -D ARDUINOJSON_DECODE_UNICODE=1 + -D HASP_NUM_PAGES=12 + -D HASP_USE_SPIFFS=0 + -D HASP_USE_LITTLEFS=0 + -D HASP_USE_EEPROM=0 + -D HASP_USE_GPIO=0 + -D HASP_USE_CONFIG=0 ; Standalone application, as library + -D HASP_USE_DEBUG=1 + -D HASP_USE_MQTT=1 + -D MQTT_MAX_PACKET_SIZE=2048 + ;-D LV_LOG_LEVEL=LV_LOG_LEVEL_INFO + ;-D LV_LOG_PRINTF=1 + ; Add recursive dirs for hal headers search + -D POSIX + -D PAHO_MQTT_STATIC + -DPAHO_WITH_SSL=TRUE + -DPAHO_BUILD_DOCUMENTATION=FALSE + -DPAHO_BUILD_SAMPLES=FALSE + -DCMAKE_BUILD_TYPE=Release + -DCMAKE_VERBOSE_MAKEFILE=TRUE + ;-D NO_PERSISTENCE + -I.pio/libdeps/darwin_sdl_64bits/paho/src + -I.pio/libdeps/darwin_sdl_64bits/ArduinoJson/src + -I lib/ArduinoJson/src + -I lib/lv_fs_if + !python -c "import os; print(' '.join(['-I {}'.format(i[0].replace('\x5C','/')) for i in os.walk('hal/sdl2')]))" + ; ----- Statically linked libraries -------------------- + -lSDL2 + -lm + -lpthread + +lib_deps = + ${env.lib_deps} + lv_drivers@~7.9.1 + ;lv_drivers=https://github.com/littlevgl/lv_drivers/archive/7d71907c1d6b02797d066f50984b866e080ebeed.zip + https://github.com/eclipse/paho.mqtt.c.git + bblanchon/ArduinoJson@^6.17.2 ; Json(l) parser + +lib_ignore = + paho + AXP192 + ArduinoLog + lv_fs_if + +src_filter = + +<*> + -<*.h> + +<../hal/sdl2> + +<../.pio/libdeps/darwin_sdl_64bits/paho/src/*.c> + +<../.pio/libdeps/darwin_sdl_64bits/paho/src/MQTTClient.c> + -<../.pio/libdeps/darwin_sdl_64bits/paho/src/MQTTAsync.c> + -<../.pio/libdeps/darwin_sdl_64bits/paho/src/MQTTAsyncUtils.c> + -<../.pio/libdeps/darwin_sdl_64bits/paho/src/MQTTVersion.c> + -<../.pio/libdeps/darwin_sdl_64bits/paho/src/SSLSocket.c> + + + - + - + - + - + - + - + - + - + - + + + - + - + - + + + + + + + - + + + +<../.pio/libdeps/darwin_sdl_64bits/ArduinoJson/src/ArduinoJson.h>