mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-04-19 12:57:19 +00:00
Add HASP_TARGET_ARDUINO and HASP_TARGET_PC macros
This commit is contained in:
parent
b738c22c67
commit
96bfbf397b
@ -33,6 +33,11 @@
|
||||
|
||||
#define HASP_USE_APP 1
|
||||
|
||||
/* Validate that build target was specified */
|
||||
#if HASP_TARGET_ARDUINO + HASP_TARGET_PC != 1
|
||||
#error "Build target invalid! Set *one* of: HASP_TARGET_ARDUINO, HASP_TARGET_PC"
|
||||
#endif
|
||||
|
||||
#ifndef HASP_USE_DEBUG
|
||||
#define HASP_USE_DEBUG 1
|
||||
#endif
|
||||
@ -190,6 +195,41 @@
|
||||
|
||||
#define HASP_OBJECT_NOTATION "p%ub%u"
|
||||
|
||||
#ifndef HASP_ATTRIBUTE_FAST_MEM
|
||||
#define HASP_ATTRIBUTE_FAST_MEM
|
||||
#endif
|
||||
|
||||
#ifndef IRAM_ATTR
|
||||
#define IRAM_ATTR
|
||||
#endif
|
||||
|
||||
#ifndef FPSTR
|
||||
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper*>(pstr_pointer))
|
||||
#endif
|
||||
|
||||
#ifndef PGM_P
|
||||
#define PGM_P const char*
|
||||
#endif
|
||||
|
||||
/* Workarounds for PC build */
|
||||
#if HASP_TARGET_PC
|
||||
#ifndef __FlashStringHelper
|
||||
#define __FlashStringHelper char
|
||||
#endif
|
||||
|
||||
#ifndef F
|
||||
#define F(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef PSTR
|
||||
#define PSTR(x) x
|
||||
#endif
|
||||
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Includes */
|
||||
#ifdef WINDOWS
|
||||
#include "winsock2.h"
|
||||
@ -281,7 +321,7 @@ static WiFiSpiClass WiFi;
|
||||
#if HASP_USE_MQTT > 0
|
||||
#include "mqtt/hasp_mqtt.h"
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#define HASP_USE_PAHO
|
||||
#else
|
||||
#define HASP_USE_ESP_MQTT
|
||||
@ -326,51 +366,20 @@ static WiFiSpiClass WiFi;
|
||||
#include "sys/svc/hasp_slave.h"
|
||||
#endif
|
||||
|
||||
#ifndef HASP_ATTRIBUTE_FAST_MEM
|
||||
#define HASP_ATTRIBUTE_FAST_MEM
|
||||
#endif
|
||||
|
||||
#ifndef IRAM_ATTR
|
||||
#define IRAM_ATTR
|
||||
#endif
|
||||
|
||||
#ifndef FPSTR
|
||||
#define FPSTR(pstr_pointer) (reinterpret_cast<const __FlashStringHelper*>(pstr_pointer))
|
||||
#endif
|
||||
|
||||
#ifndef PGM_P
|
||||
#define PGM_P const char*
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#ifndef __FlashStringHelper
|
||||
#define __FlashStringHelper char
|
||||
#endif
|
||||
|
||||
#ifndef F
|
||||
#define F(x) (x)
|
||||
#endif
|
||||
|
||||
#ifndef PSTR
|
||||
#define PSTR(x) x
|
||||
#endif
|
||||
|
||||
#ifndef PROGMEM
|
||||
#define PROGMEM
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS)
|
||||
#include <Windows.h>
|
||||
#define delay Sleep
|
||||
#endif
|
||||
|
||||
#if defined(POSIX)
|
||||
#define delay SDL_Delay
|
||||
#endif
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
|
||||
#if HASP_TARGET_PC
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#if USE_MONITOR
|
||||
#include <SDL2/SDL.h>
|
||||
#endif
|
||||
|
@ -12,15 +12,15 @@
|
||||
#include "user_config_override.h"
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#define HASP_RANDOM(x) rand() % x
|
||||
#elif defined(ARDUINO)
|
||||
#elif HASP_TARGET_ARDUINO
|
||||
#define HASP_RANDOM(x) random(x)
|
||||
#else
|
||||
#define HASP_RANDOM(x) random() % x
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#define LOG_OUTPUT(x, ...) printf(__VA_ARGS__)
|
||||
#else
|
||||
|
||||
|
@ -227,7 +227,7 @@ typedef void* lv_fs_drv_user_data_t;
|
||||
//# define LV_FS_IF_SPIFFS '\0' // no internal esp Flash
|
||||
#endif
|
||||
#endif /*LV_USE_FS_IF*/
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
#define LV_FS_PC_PATH "/littlefs"
|
||||
#endif
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
* INCLUDES
|
||||
*********************/
|
||||
|
||||
#if !(defined(WINDOWS) || defined(POSIX) || defined(STM32F7xx))
|
||||
#if !(HASP_TARGET_PC || defined(STM32F7xx))
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdio.h>
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "Arduino.h"
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#include <cstdint>
|
||||
#endif
|
||||
#if defined(POSIX)
|
||||
|
@ -77,10 +77,10 @@ class BaseTft {
|
||||
#elif defined(STM32F7)
|
||||
#warning Building for STM32F7xx Tfts
|
||||
#include "tft_driver_tftespi.h"
|
||||
#elif USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
|
||||
#elif USE_MONITOR && HASP_TARGET_PC
|
||||
// #warning Building for SDL2
|
||||
#include "tft_driver_sdl2.h"
|
||||
#elif USE_WIN32DRV && (defined(WINDOWS) || defined(POSIX))
|
||||
#elif USE_WIN32DRV && HASP_TARGET_PC
|
||||
// #warning Building for Win32Drv
|
||||
#include "tft_driver_win32drv.h"
|
||||
#else
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
|
||||
#if USE_MONITOR && HASP_TARGET_PC
|
||||
|
||||
#include "hasplib.h"
|
||||
#include "lvgl.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "tft_driver.h"
|
||||
|
||||
#if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
|
||||
#if USE_MONITOR && HASP_TARGET_PC
|
||||
// #warning Building H driver TFT SDL2
|
||||
|
||||
#include "lvgl.h"
|
||||
@ -40,6 +40,6 @@ class TftSdl : BaseTft {
|
||||
using dev::TftSdl;
|
||||
extern dev::TftSdl haspTft;
|
||||
|
||||
#endif // defined(WINDOWS) || defined(POSIX)
|
||||
#endif // HASP_TARGET_PC
|
||||
|
||||
#endif // HASP_SDL2_DRIVER_H
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#if USE_WIN32DRV && (defined(WINDOWS) || defined(POSIX))
|
||||
#if USE_WIN32DRV && HASP_TARGET_PC
|
||||
|
||||
#include "hasplib.h"
|
||||
#include "lvgl.h"
|
||||
|
@ -6,7 +6,7 @@
|
||||
|
||||
#include "tft_driver.h"
|
||||
|
||||
#if USE_WIN32DRV && (defined(WINDOWS) || defined(POSIX))
|
||||
#if USE_WIN32DRV && HASP_TARGET_PC
|
||||
// #warning Building H driver WIN32DRV
|
||||
|
||||
#include "lvgl.h"
|
||||
@ -39,6 +39,6 @@ class TftWin32Drv : BaseTft {
|
||||
using dev::TftWin32Drv;
|
||||
extern dev::TftWin32Drv haspTft;
|
||||
|
||||
#endif // defined(WINDOWS) || defined(POSIX)
|
||||
#endif // HASP_TARGET_PC
|
||||
|
||||
#endif // HASP_SDL2_DRIVER_H
|
||||
#endif // HASP_WIN32DRV_DRIVER_H
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "ArduinoLog.h"
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "../hasp_debug.h"
|
||||
#include "hasp_gui.h" // for screenshot
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
@ -1113,7 +1113,7 @@ void dispatch_reboot(bool saveConfig)
|
||||
LOG_VERBOSE(TAG_MSGR, F("-------------------------------------"));
|
||||
LOG_TRACE(TAG_MSGR, F(D_DISPATCH_REBOOT));
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
fflush(stdout);
|
||||
#else
|
||||
Serial.flush();
|
||||
@ -1217,7 +1217,7 @@ void dispatch_send_discovery(const char*, const char*, uint8_t source)
|
||||
#if HASP_USE_HTTP > 0
|
||||
network_get_ipaddress(buffer, sizeof(buffer));
|
||||
doc[F("uri")] = String(F("http://")) + String(buffer);
|
||||
#elif defined(WINDOWS) || defined(POSIX)
|
||||
#elif HASP_TARGET_PC
|
||||
doc[F("uri")] = "http://google.pt";
|
||||
#endif
|
||||
|
||||
|
@ -68,7 +68,7 @@ void font_setup()
|
||||
} else {
|
||||
LOG_ERROR(TAG_FONT, F("FreeType " D_SERVICE_START_FAILED));
|
||||
}
|
||||
#elif defined(WINDOWS) || defined(POSIX)
|
||||
#elif HASP_TARGET_PC
|
||||
#else
|
||||
#endif
|
||||
|
||||
|
@ -179,7 +179,7 @@ int hasp_parse_json_attributes(lv_obj_t* obj, const JsonObject& doc)
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX) || defined(ESP32)
|
||||
#if HASP_TARGET_PC || defined(ESP32)
|
||||
std::string v;
|
||||
v.reserve(64);
|
||||
|
||||
|
@ -99,7 +99,7 @@ static inline void debug_flush()
|
||||
HASP_SERIAL.flush();
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
fflush(stdout);
|
||||
#endif
|
||||
}
|
||||
@ -116,7 +116,7 @@ void debugEverySecond()
|
||||
void debugStart(void)
|
||||
{
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
debug_newline();
|
||||
debugPrintHaspHeader(NULL);
|
||||
debug_newline();
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
#include "lang/lang.h"
|
||||
|
||||
#if(!defined(WINDOWS)) && (!defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
/* ===== Default Event Processors ===== */
|
||||
void debugSetup(JsonObject settings);
|
||||
|
||||
|
@ -309,7 +309,7 @@ void guiSetup()
|
||||
static lv_indev_drv_t indev_drv;
|
||||
lv_indev_drv_init(&indev_drv);
|
||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||
#if USE_MONITOR && (defined(WINDOWS) || defined(POSIX))
|
||||
#if USE_MONITOR && HASP_TARGET_PC
|
||||
indev_drv.read_cb = mouse_read;
|
||||
#else
|
||||
indev_drv.read_cb = gui_touch_read;
|
||||
@ -345,7 +345,7 @@ void guiSetup()
|
||||
gui_hide_pointer(false);
|
||||
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
|
||||
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
// drv_touch_init(gui_settings.rotation); // Touch driver
|
||||
haspTouch.init(tft_width, tft_height);
|
||||
haspTouch.set_calibration(gui_settings.cal_data);
|
||||
@ -386,7 +386,7 @@ IRAM_ATTR void guiLoop(void)
|
||||
// tick.update();
|
||||
#endif
|
||||
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
// haspTouch.loop();
|
||||
#endif
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* MIT License - Copyright (c) 2019-2024 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
|
||||
/*
|
||||
#ifdef CORE_DEBUG_LEVEL
|
||||
|
@ -1,7 +1,7 @@
|
||||
/* MIT License - Copyright (c) 2019-2022 Francis Van Roie
|
||||
For full license information read the LICENSE file in the project folder */
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
|
||||
#if defined(WINDOWS)
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
#define RETAINED true
|
||||
|
||||
#if defined(WINDOWS) || defined(POSIX)
|
||||
#if HASP_TARGET_PC
|
||||
extern std::string mqttNodeTopic;
|
||||
extern std::string mqttGroupTopic;
|
||||
#else
|
||||
@ -35,7 +35,7 @@ const char FP_MQTT_HA_NAME[] PROGMEM = "name";
|
||||
const char FP_MQTT_HA_MODEL[] PROGMEM = "mdl";
|
||||
const char FP_MQTT_HA_MANUFACTURER[] PROGMEM = "mf";
|
||||
|
||||
#if !(defined(WINDOWS) || defined(POSIX))
|
||||
#if HASP_TARGET_ARDUINO
|
||||
|
||||
#include "hal/hasp_hal.h"
|
||||
|
||||
|
@ -6,7 +6,8 @@ extra_scripts =
|
||||
tools/linux_build_extra.py
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D HASP_MODEL="MacOS X App"
|
||||
-D HASP_MODEL="MacOS X App"
|
||||
-D HASP_TARGET_PC=1
|
||||
|
||||
; ----- Monitor
|
||||
-D TFT_WIDTH=240
|
||||
|
@ -35,6 +35,7 @@ files =
|
||||
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D HASP_TARGET_ARDUINO=1
|
||||
-D HTTP_UPLOAD_BUFLEN=1024 ; lower http upload buffer
|
||||
-D MQTT_MAX_PACKET_SIZE=2048 ; longer PubSubClient messages
|
||||
-D HASP_CONSOLE_BUFFER=256 ; maximum length of a console/telnet command
|
||||
|
@ -12,6 +12,7 @@ board_build.f_cpu = 160000000L ; set frequency to 160MHz
|
||||
monitor_filters = esp8266_exception_decoder
|
||||
|
||||
build_flags=
|
||||
-D HASP_TARGET_ARDUINO=1
|
||||
-D HTTP_UPLOAD_BUFLEN=512 ; lower http upload buffer
|
||||
-D MQTT_MAX_PACKET_SIZE=1024 ; longer PubSubClient messages
|
||||
-D HASP_CONSOLE_BUFFER=160 ; maximum length of a console/telnet command
|
||||
|
@ -6,6 +6,7 @@ extra_scripts =
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D HASP_MODEL="Linux App"
|
||||
-D HASP_TARGET_PC=1
|
||||
|
||||
; ----- Monitor
|
||||
-D TFT_WIDTH=240
|
||||
|
@ -3,6 +3,7 @@
|
||||
framework = arduino
|
||||
platform = ststm32
|
||||
build_flags=
|
||||
-D HASP_TARGET_ARDUINO=1
|
||||
-I include/stm32f4
|
||||
-D MQTT_MAX_PACKET_SIZE=2048 ; longer PubSubClient messages
|
||||
-D HASP_CONSOLE_BUFFER=220 ; maximum length of a console/telnet command
|
||||
@ -21,4 +22,4 @@ build_flags=
|
||||
|
||||
lib_deps =
|
||||
stm32duino/STM32duino LwIP @ ^2.1.2
|
||||
;https://github.com/stm32duino/LwIP.git
|
||||
;https://github.com/stm32duino/LwIP.git
|
||||
|
@ -3,6 +3,7 @@
|
||||
framework = arduino
|
||||
platform = ststm32
|
||||
build_flags=
|
||||
-D HASP_TARGET_ARDUINO=1
|
||||
; -I include/stm32f4
|
||||
-D MQTT_MAX_PACKET_SIZE=2048 ; longer PubSubClient messages
|
||||
-D HASP_CONSOLE_BUFFER=220 ; maximum length of a console/telnet command
|
||||
|
@ -6,6 +6,7 @@ extra_scripts =
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D HASP_MODEL="Windows App"
|
||||
-D HASP_TARGET_PC=1
|
||||
|
||||
; ----- Monitor
|
||||
-D TFT_WIDTH=240
|
||||
|
@ -6,6 +6,7 @@ extra_scripts =
|
||||
build_flags =
|
||||
${env.build_flags}
|
||||
-D HASP_MODEL="Windows App"
|
||||
-D HASP_TARGET_PC=1
|
||||
|
||||
; ----- Monitor
|
||||
-D TFT_WIDTH=240
|
||||
|
Loading…
x
Reference in New Issue
Block a user