mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-20 17:56:34 +00:00
commit
ee49a2c6b3
@ -107,6 +107,7 @@
|
|||||||
#ifdef WINDOWS
|
#ifdef WINDOWS
|
||||||
#include "winsock2.h"
|
#include "winsock2.h"
|
||||||
#include "Windows.h"
|
#include "Windows.h"
|
||||||
|
#elif defined(POSIX)
|
||||||
#else
|
#else
|
||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
#endif
|
||||||
@ -183,7 +184,7 @@ static WiFiSpiClass WiFi;
|
|||||||
#if HASP_USE_MQTT > 0
|
#if HASP_USE_MQTT > 0
|
||||||
#include "mqtt/hasp_mqtt.h"
|
#include "mqtt/hasp_mqtt.h"
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#define USE_PAHO
|
#define USE_PAHO
|
||||||
#else
|
#else
|
||||||
#define USE_PUBSUBCLIENT
|
#define USE_PUBSUBCLIENT
|
||||||
@ -230,7 +231,7 @@ static WiFiSpiClass WiFi;
|
|||||||
#define PGM_P const char*
|
#define PGM_P const char*
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#ifndef __FlashStringHelper
|
#ifndef __FlashStringHelper
|
||||||
#define __FlashStringHelper char
|
#define __FlashStringHelper char
|
||||||
#endif
|
#endif
|
||||||
@ -248,11 +249,17 @@ static WiFiSpiClass WiFi;
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS)
|
||||||
|
#include <Windows.h>
|
||||||
|
#define delay Sleep
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX)
|
||||||
|
#define delay SDL_Delay
|
||||||
|
#endif
|
||||||
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <strings.h>
|
#include <strings.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <Windows.h>
|
|
||||||
#include <SDL2/SDL.h>
|
#include <SDL2/SDL.h>
|
||||||
|
|
||||||
#define snprintf_P snprintf
|
#define snprintf_P snprintf
|
||||||
@ -261,7 +268,6 @@ static WiFiSpiClass WiFi;
|
|||||||
#define strcmp_P strcmp
|
#define strcmp_P strcmp
|
||||||
#define strstr_P strstr
|
#define strstr_P strstr
|
||||||
#define halRestartMcu()
|
#define halRestartMcu()
|
||||||
#define delay Sleep
|
|
||||||
#define millis SDL_GetTicks
|
#define millis SDL_GetTicks
|
||||||
|
|
||||||
#define DEC 10
|
#define DEC 10
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#ifndef HASP_MACRO_H
|
#ifndef HASP_MACRO_H
|
||||||
#define HASP_MACRO_H
|
#define HASP_MACRO_H
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#define LOG_OUTPUT(x, ...) printf(__VA_ARGS__)
|
#define LOG_OUTPUT(x, ...) printf(__VA_ARGS__)
|
||||||
#else
|
#else
|
||||||
#define LOG_OUTPUT(...) Log.output(...)
|
#define LOG_OUTPUT(...) Log.output(...)
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* INCLUDES
|
* INCLUDES
|
||||||
*********************/
|
*********************/
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#if !(defined(WINDOWS)||defined(POSIX))
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
#include "Arduino.h"
|
#include "Arduino.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX)
|
||||||
|
#include <stddef.h>
|
||||||
|
#endif
|
||||||
|
#ifdef WINDOWS
|
||||||
#include "Windows.h"
|
#include "Windows.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -97,6 +102,10 @@ class BaseDevice {
|
|||||||
#elif defined(WINDOWS)
|
#elif defined(WINDOWS)
|
||||||
#warning Building for Win32 Devices
|
#warning Building for Win32 Devices
|
||||||
#include "win32/hasp_win32.h"
|
#include "win32/hasp_win32.h"
|
||||||
|
#elif defined(POSIX)
|
||||||
|
#warning Building for Posix Devices
|
||||||
|
#include "posix/hasp_posix.h"
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#warning Building for Generic Devices
|
#warning Building for Generic Devices
|
||||||
using dev::BaseDevice;
|
using dev::BaseDevice;
|
||||||
|
108
src/dev/posix/hasp_posix.cpp
Normal file
108
src/dev/posix/hasp_posix.cpp
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#if defined(POSIX)
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
#include "hasp_posix.h"
|
||||||
|
|
||||||
|
#include "hasp_conf.h"
|
||||||
|
#include "hasp/hasp_utilities.h"
|
||||||
|
#include "hasp_debug.h"
|
||||||
|
|
||||||
|
#include "display/monitor.h"
|
||||||
|
|
||||||
|
namespace dev {
|
||||||
|
|
||||||
|
void PosixDevice::reboot()
|
||||||
|
{}
|
||||||
|
void PosixDevice::show_info()
|
||||||
|
{
|
||||||
|
LOG_VERBOSE(0, F("Processor : %s"), "unknown");
|
||||||
|
LOG_VERBOSE(0, F("CPU freq. : %i MHz"), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* PosixDevice::get_hostname()
|
||||||
|
{
|
||||||
|
return _hostname.c_str();
|
||||||
|
}
|
||||||
|
void PosixDevice::set_hostname(const char* hostname)
|
||||||
|
{
|
||||||
|
_hostname = hostname;
|
||||||
|
}
|
||||||
|
const char* PosixDevice::get_core_version()
|
||||||
|
{
|
||||||
|
return "posix";
|
||||||
|
}
|
||||||
|
const char* PosixDevice::get_display_driver()
|
||||||
|
{
|
||||||
|
return "SDL2";
|
||||||
|
}
|
||||||
|
|
||||||
|
void PosixDevice::set_backlight_pin(uint8_t pin)
|
||||||
|
{
|
||||||
|
// PosixDevice::backlight_pin = pin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PosixDevice::set_backlight_level(uint8_t level)
|
||||||
|
{
|
||||||
|
uint8_t new_level = level >= 0 ? level : 0;
|
||||||
|
new_level = new_level <= 100 ? new_level : 100;
|
||||||
|
|
||||||
|
if(_backlight_level != new_level)
|
||||||
|
{
|
||||||
|
_backlight_level = new_level;
|
||||||
|
update_backlight();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t PosixDevice::get_backlight_level()
|
||||||
|
{
|
||||||
|
return _backlight_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PosixDevice::set_backlight_power(bool power)
|
||||||
|
{
|
||||||
|
_backlight_power = power;
|
||||||
|
update_backlight();
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PosixDevice::get_backlight_power()
|
||||||
|
{
|
||||||
|
return _backlight_power != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void PosixDevice::update_backlight()
|
||||||
|
{
|
||||||
|
monitor_backlight(_backlight_power ? map(_backlight_level, 0, 100, 0, 255) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t PosixDevice::get_free_max_block()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t PosixDevice::get_free_heap(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t PosixDevice::get_heap_fragmentation()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint16_t PosixDevice::get_cpu_frequency()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PosixDevice::is_system_pin(uint8_t pin)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace dev
|
||||||
|
|
||||||
|
dev::PosixDevice haspDevice;
|
||||||
|
|
||||||
|
#endif // POSIX
|
76
src/dev/posix/hasp_posix.h
Normal file
76
src/dev/posix/hasp_posix.h
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
/* MIT License - Copyright (c) 2020 Francis Van Roie
|
||||||
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
|
#ifndef HASP_DEVICE_POSIX_H
|
||||||
|
#define HASP_DEVICE_POSIX_H
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <cstddef>
|
||||||
|
extern "C"
|
||||||
|
{
|
||||||
|
#include <inttypes.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "hasp_conf.h"
|
||||||
|
#include "../device.h"
|
||||||
|
|
||||||
|
#if defined(POSIX)
|
||||||
|
static inline void itoa(int i, char *out, int unused_)
|
||||||
|
{
|
||||||
|
(void) unused_;
|
||||||
|
sprintf(out, "%d", i);
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace dev {
|
||||||
|
|
||||||
|
class PosixDevice : public BaseDevice {
|
||||||
|
|
||||||
|
public:
|
||||||
|
PosixDevice()
|
||||||
|
{
|
||||||
|
_hostname = "localhost";
|
||||||
|
_backlight_power = 1;
|
||||||
|
_backlight_level = 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
void reboot() override;
|
||||||
|
void show_info() override;
|
||||||
|
|
||||||
|
const char* get_hostname();
|
||||||
|
void set_hostname(const char*);
|
||||||
|
const char* get_core_version();
|
||||||
|
const char* get_display_driver();
|
||||||
|
|
||||||
|
void set_backlight_pin(uint8_t pin);
|
||||||
|
void set_backlight_level(uint8_t val);
|
||||||
|
uint8_t get_backlight_level();
|
||||||
|
void set_backlight_power(bool power);
|
||||||
|
bool get_backlight_power();
|
||||||
|
|
||||||
|
size_t get_free_max_block();
|
||||||
|
size_t get_free_heap();
|
||||||
|
uint8_t get_heap_fragmentation();
|
||||||
|
uint16_t get_cpu_frequency();
|
||||||
|
|
||||||
|
bool is_system_pin(uint8_t pin) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::string _hostname;
|
||||||
|
|
||||||
|
uint8_t _backlight_pin;
|
||||||
|
uint8_t _backlight_level;
|
||||||
|
uint8_t _backlight_power;
|
||||||
|
|
||||||
|
void update_backlight();
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace dev
|
||||||
|
|
||||||
|
using dev::PosixDevice;
|
||||||
|
extern dev::PosixDevice haspDevice;
|
||||||
|
|
||||||
|
#endif // POSIX
|
||||||
|
|
||||||
|
#endif // HASP_DEVICE_POSIX_H
|
@ -40,7 +40,7 @@ class BaseTft {
|
|||||||
#elif defined(STM32F4)
|
#elif defined(STM32F4)
|
||||||
#warning Building for STM32F4xx Devices
|
#warning Building for STM32F4xx Devices
|
||||||
#include "tft_driver_tftespi.h"
|
#include "tft_driver_tftespi.h"
|
||||||
#elif defined(WINDOWS)
|
#elif defined(WINDOWS) || defined(POSIX)
|
||||||
#warning Building for Win32 Devices
|
#warning Building for Win32 Devices
|
||||||
#include "tft_driver_sdl2.h"
|
#include "tft_driver_sdl2.h"
|
||||||
#else
|
#else
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
#include "../hasp_debug.h"
|
#include "../hasp_debug.h"
|
||||||
#include "hasp_gui.h" // for screenshot
|
#include "hasp_gui.h" // for screenshot
|
||||||
|
|
||||||
#if WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
@ -988,7 +988,7 @@ void dispatch_reboot(bool saveConfig)
|
|||||||
LOG_VERBOSE(TAG_MSGR, F("-------------------------------------"));
|
LOG_VERBOSE(TAG_MSGR, F("-------------------------------------"));
|
||||||
LOG_TRACE(TAG_MSGR, F(D_DISPATCH_REBOOT));
|
LOG_TRACE(TAG_MSGR, F(D_DISPATCH_REBOOT));
|
||||||
|
|
||||||
#if WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
#else
|
#else
|
||||||
Serial.flush();
|
Serial.flush();
|
||||||
|
@ -605,7 +605,7 @@ void hasp_process_attribute(uint8_t pageid, uint8_t objid, const char* attr, con
|
|||||||
int hasp_parse_json_attributes(lv_obj_t* obj, const JsonObject& doc)
|
int hasp_parse_json_attributes(lv_obj_t* obj, const JsonObject& doc)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
// String v((char *)0);
|
// String v((char *)0);
|
||||||
// v.reserve(64);
|
// v.reserve(64);
|
||||||
std::string v;
|
std::string v;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
|
|
||||||
#include "lang/lang.h"
|
#include "lang/lang.h"
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#if (!defined(WINDOWS)) && (!defined(POSIX))
|
||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
|
|
||||||
/* ===== Default Event Processors ===== */
|
/* ===== Default Event Processors ===== */
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
#include "hasplib.h"
|
#include "hasplib.h"
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
#include "display/monitor.h"
|
#include "display/monitor.h"
|
||||||
#include "indev/mouse.h"
|
#include "indev/mouse.h"
|
||||||
#endif
|
#endif
|
||||||
@ -152,7 +152,7 @@ void guiSetup(void)
|
|||||||
const size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2
|
const size_t guiVDBsize = 2 * 512u; // 4 KBytes * 2
|
||||||
guiVdbBuffer1 = (lv_color_t*)malloc(sizeof(lv_color_t) * guiVDBsize);
|
guiVdbBuffer1 = (lv_color_t*)malloc(sizeof(lv_color_t) * guiVDBsize);
|
||||||
|
|
||||||
#elif defined(WINDOWS)
|
#elif defined(WINDOWS) || defined(POSIX)
|
||||||
const size_t guiVDBsize = LV_HOR_RES_MAX * 10;
|
const size_t guiVDBsize = LV_HOR_RES_MAX * 10;
|
||||||
static lv_color_t guiVdbBuffer1[guiVDBsize]; /*Declare a buffer for 10 lines*/
|
static lv_color_t guiVdbBuffer1[guiVDBsize]; /*Declare a buffer for 10 lines*/
|
||||||
|
|
||||||
@ -228,7 +228,7 @@ void guiSetup(void)
|
|||||||
lv_indev_drv_t indev_drv;
|
lv_indev_drv_t indev_drv;
|
||||||
lv_indev_drv_init(&indev_drv);
|
lv_indev_drv_init(&indev_drv);
|
||||||
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
indev_drv.type = LV_INDEV_TYPE_POINTER;
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
indev_drv.read_cb = mouse_read;
|
indev_drv.read_cb = mouse_read;
|
||||||
#else
|
#else
|
||||||
indev_drv.read_cb = drv_touch_read;
|
indev_drv.read_cb = drv_touch_read;
|
||||||
@ -260,7 +260,7 @@ void guiSetup(void)
|
|||||||
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
|
lv_indev_set_cursor(mouse_indev, cursor); /*Connect the image object to the driver*/
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !(defined(WINDOWS) || defined(POSIX))
|
||||||
drv_touch_init(gui_settings.rotation); // Touch driver
|
drv_touch_init(gui_settings.rotation); // Touch driver
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -289,7 +289,7 @@ void guiLoop(void)
|
|||||||
// tick.update();
|
// tick.update();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(WINDOWS)
|
#if !(defined(WINDOWS) || defined(POSIX))
|
||||||
drv_touch_loop(); // update touch
|
drv_touch_loop(); // update touch
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
||||||
For full license information read the LICENSE file in the project folder */
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#if !(defined(WINDOWS) || defined(POSIX))
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "lvgl.h"
|
#include "lvgl.h"
|
||||||
|
@ -1,9 +1,14 @@
|
|||||||
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
/* MIT License - Copyright (c) 2019-2021 Francis Van Roie
|
||||||
For full license information read the LICENSE file in the project folder */
|
For full license information read the LICENSE file in the project folder */
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#endif
|
||||||
|
#if defined(POSIX)
|
||||||
|
#include <netdb.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
@ -27,6 +32,7 @@ bool isRunning = 1;
|
|||||||
uint8_t mainLoopCounter = 0;
|
uint8_t mainLoopCounter = 0;
|
||||||
unsigned long mainLastLoopTime = 0;
|
unsigned long mainLastLoopTime = 0;
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
// https://gist.github.com/kingseva/a918ec66079a9475f19642ec31276a21
|
// https://gist.github.com/kingseva/a918ec66079a9475f19642ec31276a21
|
||||||
void BindStdHandlesToConsole()
|
void BindStdHandlesToConsole()
|
||||||
{
|
{
|
||||||
@ -86,6 +92,7 @@ void InitializeConsoleOutput()
|
|||||||
// Redirect all standard output streams to the console
|
// Redirect all standard output streams to the console
|
||||||
BindStdHandlesToConsole();
|
BindStdHandlesToConsole();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void debugLvglLogEvent(lv_log_level_t level, const char* file, uint32_t line, const char* funcname, const char* descr)
|
void debugLvglLogEvent(lv_log_level_t level, const char* file, uint32_t line, const char* funcname, const char* descr)
|
||||||
{
|
{
|
||||||
@ -121,11 +128,14 @@ void setup()
|
|||||||
|
|
||||||
mainLastLoopTime = millis() - 1000; // reset loop counter
|
mainLastLoopTime = millis() - 1000; // reset loop counter
|
||||||
delay(250);
|
delay(250);
|
||||||
|
printf("%s %d\n", __FILE__, __LINE__);
|
||||||
}
|
}
|
||||||
|
|
||||||
void loop()
|
void loop()
|
||||||
{
|
{
|
||||||
|
printf("1 \n");
|
||||||
haspLoop();
|
haspLoop();
|
||||||
|
printf("2 \n");
|
||||||
mqttLoop();
|
mqttLoop();
|
||||||
|
|
||||||
// debugLoop(); // Console
|
// debugLoop(); // Console
|
||||||
@ -156,11 +166,11 @@ void loop()
|
|||||||
}
|
}
|
||||||
mainLastLoopTime += 1000;
|
mainLastLoopTime += 1000;
|
||||||
}
|
}
|
||||||
|
printf("loop\n");
|
||||||
// delay(6);
|
// delay(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WINDOWS
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
|
|
||||||
void usage(char* progName)
|
void usage(char* progName)
|
||||||
{
|
{
|
||||||
@ -181,18 +191,20 @@ void usage(char* progName)
|
|||||||
// << " -v | --verbose Verbosity level" << std::endl
|
// << " -v | --verbose Verbosity level" << std::endl
|
||||||
<< std::endl;
|
<< std::endl;
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
|
#if defined(WINDOWS)
|
||||||
static const char s[] = "\n";
|
static const char s[] = "\n";
|
||||||
DWORD slen = lstrlen(s);
|
DWORD slen = lstrlen(s);
|
||||||
WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), s, slen, &slen, NULL);
|
WriteConsoleA(GetStdHandle(STD_OUTPUT_HANDLE), s, slen, &slen, NULL);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[])
|
int main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
bool showhelp = false;
|
bool showhelp = false;
|
||||||
int count;
|
int count;
|
||||||
|
#ifdef WINDOWS
|
||||||
InitializeConsoleOutput();
|
InitializeConsoleOutput();
|
||||||
|
#endif
|
||||||
|
|
||||||
haspDevice.show_info();
|
haspDevice.show_info();
|
||||||
|
|
||||||
@ -221,6 +233,7 @@ int main(int argc, char* argv[])
|
|||||||
for(count = 0; count < argc; count++)
|
for(count = 0; count < argc; count++)
|
||||||
std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush;
|
std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush;
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
SetConsoleCP(65001); // 65001 = UTF-8
|
SetConsoleCP(65001); // 65001 = UTF-8
|
||||||
static const char s[] = "tränenüberströmt™\n";
|
static const char s[] = "tränenüberströmt™\n";
|
||||||
DWORD slen = lstrlen(s);
|
DWORD slen = lstrlen(s);
|
||||||
@ -233,7 +246,7 @@ int main(int argc, char* argv[])
|
|||||||
if(!WriteConsole(std_out, "Hello World!", 12, NULL, NULL)) {
|
if(!WriteConsole(std_out, "Hello World!", 12, NULL, NULL)) {
|
||||||
// return 67;
|
// return 67;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
for(count = 0; count < argc; count++) {
|
for(count = 0; count < argc; count++) {
|
||||||
if(argv[count][0] == '-') {
|
if(argv[count][0] == '-') {
|
||||||
|
|
||||||
@ -257,24 +270,29 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
if(showhelp) {
|
if(showhelp) {
|
||||||
usage("hasp-lvgl");
|
usage("hasp-lvgl");
|
||||||
|
|
||||||
|
#if defined(WINDOWS)
|
||||||
WriteConsole(std_out, "bye", 3, NULL, NULL);
|
WriteConsole(std_out, "bye", 3, NULL, NULL);
|
||||||
|
|
||||||
FreeConsole();
|
FreeConsole();
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// printf("%s %d\n", __FILE__, __LINE__);
|
// printf("%s %d\n", __FILE__, __LINE__);
|
||||||
// fflush(stdout);
|
// fflush(stdout);
|
||||||
|
printf("pre setup\n");
|
||||||
setup();
|
setup();
|
||||||
|
printf("to loop\n");
|
||||||
|
|
||||||
while(isRunning) {
|
while(isRunning) {
|
||||||
loop();
|
loop();
|
||||||
// std::cout << "HSetup OK\n";
|
// std::cout << "HSetup OK\n";
|
||||||
}
|
}
|
||||||
|
printf("endrunning\n");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -9,7 +9,8 @@
|
|||||||
|
|
||||||
#include "hasp_conf.h"
|
#include "hasp_conf.h"
|
||||||
|
|
||||||
// #ifdef WINDOWS
|
|
||||||
|
// #if defined(WINDOWS) || defined(POSIX)
|
||||||
// #define __FlashStringHelper char
|
// #define __FlashStringHelper char
|
||||||
// #endif
|
// #endif
|
||||||
|
|
||||||
@ -22,6 +23,7 @@ enum hasp_mqtt_error_t {
|
|||||||
MQTT_ERR_UNKNOWN = -128
|
MQTT_ERR_UNKNOWN = -128
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
void mqttSetup();
|
void mqttSetup();
|
||||||
void mqttLoop();
|
void mqttLoop();
|
||||||
void mqttEvery5Seconds(bool wifiIsConnected);
|
void mqttEvery5Seconds(bool wifiIsConnected);
|
||||||
|
@ -29,7 +29,7 @@ const char FP_MQTT_HA_NAME[] PROGMEM = "name";
|
|||||||
const char FP_MQTT_HA_MODEL[] PROGMEM = "mdl";
|
const char FP_MQTT_HA_MODEL[] PROGMEM = "mdl";
|
||||||
const char FP_MQTT_HA_MANUFACTURER[] PROGMEM = "mf";
|
const char FP_MQTT_HA_MANUFACTURER[] PROGMEM = "mf";
|
||||||
|
|
||||||
#ifndef WINDOWS
|
#if !(defined(WINDOWS) || defined(POSIX))
|
||||||
|
|
||||||
#include "hal/hasp_hal.h"
|
#include "hal/hasp_hal.h"
|
||||||
|
|
||||||
|
@ -6,28 +6,4 @@ for e in [ env, projenv ]:
|
|||||||
if "-m32" in e['CCFLAGS']:
|
if "-m32" in e['CCFLAGS']:
|
||||||
e.Append(LINKFLAGS = ["-m32"])
|
e.Append(LINKFLAGS = ["-m32"])
|
||||||
|
|
||||||
env.Append(
|
|
||||||
LINKFLAGS=[
|
|
||||||
"-static",
|
|
||||||
"-static-libgcc",
|
|
||||||
"-static-libstdc++"
|
|
||||||
]
|
|
||||||
)
|
|
||||||
|
|
||||||
# Override unused "upload" to execute compiled binary
|
|
||||||
from SCons.Script import AlwaysBuild
|
|
||||||
AlwaysBuild(env.Alias("build", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}"))
|
|
||||||
|
|
||||||
# Add custom target to explorer
|
|
||||||
env.AddTarget(
|
|
||||||
name = "execute",
|
|
||||||
dependencies = "$BUILD_DIR\${PROGNAME}.exe",
|
|
||||||
actions = "$BUILD_DIR\${PROGNAME}.exe",
|
|
||||||
# actions = 'cmd.exe /C "start cmd.exe /C $BUILD_DIR\${PROGNAME}.exe"',
|
|
||||||
title = "Execute",
|
|
||||||
description = "Build and execute",
|
|
||||||
group="General"
|
|
||||||
)
|
|
||||||
|
|
||||||
#print('=====================================')
|
|
||||||
#print(env.Dump())
|
|
||||||
|
25
tools/windows_build_extra.py
Normal file
25
tools/windows_build_extra.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
env.Append(
|
||||||
|
LINKFLAGS=[
|
||||||
|
"-static",
|
||||||
|
"-static-libgcc",
|
||||||
|
"-static-libstdc++"
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Override unused "upload" to execute compiled binary
|
||||||
|
from SCons.Script import AlwaysBuild
|
||||||
|
AlwaysBuild(env.Alias("build", "$BUILD_DIR/${PROGNAME}", "$BUILD_DIR/${PROGNAME}"))
|
||||||
|
|
||||||
|
# Add custom target to explorer
|
||||||
|
env.AddTarget(
|
||||||
|
name = "execute",
|
||||||
|
dependencies = "$BUILD_DIR\${PROGNAME}.exe",
|
||||||
|
actions = "$BUILD_DIR\${PROGNAME}.exe",
|
||||||
|
# actions = 'cmd.exe /C "start cmd.exe /C $BUILD_DIR\${PROGNAME}.exe"',
|
||||||
|
title = "Execute",
|
||||||
|
description = "Build and execute",
|
||||||
|
group="General"
|
||||||
|
)
|
||||||
|
|
||||||
|
#print('=====================================')
|
||||||
|
#print(env.Dump())
|
92
user_setups/linux_sdl/emulator_64bits.ini
Normal file
92
user_setups/linux_sdl/emulator_64bits.ini
Normal file
@ -0,0 +1,92 @@
|
|||||||
|
[env:emulator_64bits]
|
||||||
|
platform = native@^1.1.3
|
||||||
|
extra_scripts = tools/sdl2_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/emulator_64bits/paho/src
|
||||||
|
-I.pio/libdeps/emulator_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.0
|
||||||
|
;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/emulator_64bits/paho/src/*.c>
|
||||||
|
+<../.pio/libdeps/emulator_64bits/paho/src/MQTTClient.c>
|
||||||
|
-<../.pio/libdeps/emulator_64bits/paho/src/MQTTAsync.c>
|
||||||
|
-<../.pio/libdeps/emulator_64bits/paho/src/MQTTAsyncUtils.c>
|
||||||
|
-<../.pio/libdeps/emulator_64bits/paho/src/MQTTVersion.c>
|
||||||
|
-<../.pio/libdeps/emulator_64bits/paho/src/SSLSocket.c>
|
||||||
|
+<MQTTClient.c>
|
||||||
|
-<MQTTAsync.c>
|
||||||
|
-<MQTTAsyncUtils.c>
|
||||||
|
-<MQTTVersion.c>
|
||||||
|
-<SSLSocket.c>
|
||||||
|
-<sys/>
|
||||||
|
-<hal/>
|
||||||
|
-<drv/>
|
||||||
|
-<drv/touch>
|
||||||
|
-<drv/tft>
|
||||||
|
+<dev/>
|
||||||
|
-<hal/>
|
||||||
|
-<svc/>
|
||||||
|
-<hasp_filesystem.cpp>
|
||||||
|
+<font/>
|
||||||
|
+<hasp/>
|
||||||
|
+<lang/>
|
||||||
|
-<log/>
|
||||||
|
+<mqtt/>
|
||||||
|
+<../.pio/libdeps/emulator_64bits/ArduinoJson/src/ArduinoJson.h>
|
@ -1,6 +1,8 @@
|
|||||||
[env:emulator_64bits]
|
[env:emulator_64bits]
|
||||||
platform = native@^1.1.3
|
platform = native@^1.1.3
|
||||||
extra_scripts = tools/sdl2_build_extra.py
|
extra_scripts =
|
||||||
|
tools/sdl2_build_extra.py
|
||||||
|
tools/windows_build_extra.py
|
||||||
build_flags =
|
build_flags =
|
||||||
${env.build_flags}
|
${env.build_flags}
|
||||||
; ----- Monitor
|
; ----- Monitor
|
||||||
|
Loading…
x
Reference in New Issue
Block a user