mirror of
https://github.com/HASwitchPlate/openHASP.git
synced 2025-07-19 09:16:41 +00:00
Add bootscreen and pages.jsonl
This commit is contained in:
parent
3a95dd0caf
commit
81b6614520
@ -33,7 +33,7 @@ void hal_setup(void)
|
|||||||
|
|
||||||
/* 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();
|
monitor_init(MONITOR_HOR_RES, MONITOR_VER_RES);
|
||||||
|
|
||||||
/* Add the mouse as input device
|
/* Add the mouse as input device
|
||||||
* Use the 'mouse' driver which reads the PC's mouse*/
|
* Use the 'mouse' driver which reads the PC's mouse*/
|
||||||
|
@ -49,7 +49,7 @@ void TftSdl::init(int w, int 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();
|
monitor_init(MONITOR_HOR_RES, MONITOR_VER_RES);
|
||||||
monitor_title(haspDevice.get_hostname());
|
monitor_title(haspDevice.get_hostname());
|
||||||
|
|
||||||
/* Add the mouse as input device
|
/* Add the mouse as input device
|
||||||
|
@ -5,6 +5,12 @@
|
|||||||
#include "ArduinoLog.h"
|
#include "ArduinoLog.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
|
#include <iostream>
|
||||||
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "ArduinoJson.h"
|
#include "ArduinoJson.h"
|
||||||
|
|
||||||
#if HASP_USE_EEPROM > 0
|
#if HASP_USE_EEPROM > 0
|
||||||
@ -601,6 +607,15 @@ void haspLoadPage(const char* pagesfile)
|
|||||||
LOG_INFO(TAG_HASP, F("Loaded jsonl from EEPROM"));
|
LOG_INFO(TAG_HASP, F("Loaded jsonl from EEPROM"));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
std::ifstream ifs("pages.json", std::ifstream::in);
|
||||||
|
if(ifs) {
|
||||||
|
LOG_TRACE(TAG_HASP, F("Loading file %s"), pagesfile);
|
||||||
|
dispatch_parse_jsonl(ifs);
|
||||||
|
LOG_INFO(TAG_HASP, F("File %s loaded"), pagesfile);
|
||||||
|
} else {
|
||||||
|
LOG_ERROR(TAG_HASP, F("Non existing file %s"), pagesfile);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -768,7 +768,7 @@ void dispatch_parse_json(const char*, const char* payload)
|
|||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
void dispatch_parse_jsonl(Stream& stream)
|
void dispatch_parse_jsonl(Stream& stream)
|
||||||
#else
|
#else
|
||||||
void dispatch_parse_jsonl(std::istringstream& stream)
|
void dispatch_parse_jsonl(std::istream& stream)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
uint8_t savedPage = haspGetPage();
|
uint8_t savedPage = haspGetPage();
|
||||||
|
@ -41,7 +41,7 @@ void dispatch_text_line(const char* cmnd);
|
|||||||
#ifdef ARDUINO
|
#ifdef ARDUINO
|
||||||
void dispatch_parse_jsonl(Stream& stream);
|
void dispatch_parse_jsonl(Stream& stream);
|
||||||
#else
|
#else
|
||||||
void dispatch_parse_jsonl(std::istringstream& stream);
|
void dispatch_parse_jsonl(std::istream& stream);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void dispatch_clear_page(const char* page);
|
void dispatch_clear_page(const char* page);
|
||||||
|
@ -4,11 +4,19 @@
|
|||||||
#if defined(WINDOWS) || defined(POSIX)
|
#if defined(WINDOWS) || defined(POSIX)
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#include <direct.h>
|
||||||
|
// MSDN recommends against using getcwd & chdir names
|
||||||
|
#define cwd _getcwd
|
||||||
|
#define cd _chdir
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(POSIX)
|
#if defined(POSIX)
|
||||||
#include <netdb.h>
|
#include <netdb.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#define cwd getcwd
|
||||||
|
#define cd chdir
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
@ -170,7 +178,6 @@ void loop()
|
|||||||
// delay(6);
|
// delay(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void usage(char* progName)
|
void usage(char* progName)
|
||||||
{
|
{
|
||||||
std::cout << progName << " [options]" << std::endl
|
std::cout << progName << " [options]" << std::endl
|
||||||
@ -201,16 +208,9 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
bool showhelp = false;
|
bool showhelp = false;
|
||||||
int count;
|
int count;
|
||||||
#ifdef WINDOWS
|
|
||||||
InitializeConsoleOutput();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Display each command-line argument.
|
|
||||||
std::cout << "\nCommand-line arguments:\n";
|
|
||||||
for(count = 0; count < argc; count++)
|
|
||||||
std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush;
|
|
||||||
|
|
||||||
#if defined(WINDOWS)
|
#if defined(WINDOWS)
|
||||||
|
InitializeConsoleOutput();
|
||||||
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);
|
||||||
@ -218,13 +218,25 @@ int main(int argc, char* argv[])
|
|||||||
|
|
||||||
HANDLE std_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
HANDLE std_out = GetStdHandle(STD_OUTPUT_HANDLE);
|
||||||
if(std_out == INVALID_HANDLE_VALUE) {
|
if(std_out == INVALID_HANDLE_VALUE) {
|
||||||
// return 66;
|
return 66;
|
||||||
}
|
}
|
||||||
if(!WriteConsole(std_out, "Hello World!", 12, NULL, NULL)) {
|
if(!WriteConsole(std_out, "Hello World!\n", 13, NULL, NULL)) {
|
||||||
// return 67;
|
return 67;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
SDL_Init(0); // Needs to be initialized for GetPerfPath
|
||||||
|
char buf[4096]; // never know how much is needed
|
||||||
|
std::cout << "CWD: " << cwd(buf, sizeof buf) << std::endl;
|
||||||
|
cd(SDL_GetPrefPath("hasp", "hasp"));
|
||||||
|
std::cout << "CWD changed to: " << cwd(buf, sizeof buf) << std::endl;
|
||||||
|
SDL_Quit(); // We'll properly init later
|
||||||
|
|
||||||
|
// Change to preferences dir
|
||||||
|
std::cout << "\nCommand-line arguments:\n";
|
||||||
|
for(count = 0; count < argc; count++)
|
||||||
|
std::cout << " argv[" << count << "] " << argv[count] << "\n" << std::endl << std::flush;
|
||||||
|
|
||||||
for(count = 0; count < argc; count++) {
|
for(count = 0; count < argc; count++) {
|
||||||
if(argv[count][0] == '-') {
|
if(argv[count][0] == '-') {
|
||||||
|
|
||||||
@ -272,5 +284,4 @@ int main(int argc, char* argv[])
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user