Add bootscreen and pages.jsonl

This commit is contained in:
fvanroie 2021-03-11 21:06:19 +01:00
parent 3a95dd0caf
commit 81b6614520
6 changed files with 43 additions and 17 deletions

View File

@ -33,7 +33,7 @@ void hal_setup(void)
/* Add 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
* Use the 'mouse' driver which reads the PC's mouse*/

View File

@ -49,7 +49,7 @@ void TftSdl::init(int w, int h)
/* Add 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());
/* Add the mouse as input device

View File

@ -5,6 +5,12 @@
#include "ArduinoLog.h"
#endif
#if defined(WINDOWS) || defined(POSIX)
#include <iostream>
#include <fstream>
#include <sstream>
#endif
#include "ArduinoJson.h"
#if HASP_USE_EEPROM > 0
@ -601,6 +607,15 @@ void haspLoadPage(const char* pagesfile)
LOG_INFO(TAG_HASP, F("Loaded jsonl from EEPROM"));
#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
}

View File

@ -768,7 +768,7 @@ void dispatch_parse_json(const char*, const char* payload)
#ifdef ARDUINO
void dispatch_parse_jsonl(Stream& stream)
#else
void dispatch_parse_jsonl(std::istringstream& stream)
void dispatch_parse_jsonl(std::istream& stream)
#endif
{
uint8_t savedPage = haspGetPage();

View File

@ -41,7 +41,7 @@ void dispatch_text_line(const char* cmnd);
#ifdef ARDUINO
void dispatch_parse_jsonl(Stream& stream);
#else
void dispatch_parse_jsonl(std::istringstream& stream);
void dispatch_parse_jsonl(std::istream& stream);
#endif
void dispatch_clear_page(const char* page);

View File

@ -4,11 +4,19 @@
#if defined(WINDOWS) || defined(POSIX)
#if defined(WINDOWS)
#include <windows.h>
#include <direct.h>
// MSDN recommends against using getcwd & chdir names
#define cwd _getcwd
#define cd _chdir
#endif
#if defined(POSIX)
#include <netdb.h>
#include <unistd.h>
#define cwd getcwd
#define cd chdir
#endif
#include <cstdlib>
@ -170,7 +178,6 @@ void loop()
// delay(6);
}
void usage(char* progName)
{
std::cout << progName << " [options]" << std::endl
@ -201,16 +208,9 @@ int main(int argc, char* argv[])
{
bool showhelp = false;
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)
InitializeConsoleOutput();
SetConsoleCP(65001); // 65001 = UTF-8
static const char s[] = "tränenüberströmt™\n";
DWORD slen = lstrlen(s);
@ -218,13 +218,25 @@ int main(int argc, char* argv[])
HANDLE std_out = GetStdHandle(STD_OUTPUT_HANDLE);
if(std_out == INVALID_HANDLE_VALUE) {
// return 66;
return 66;
}
if(!WriteConsole(std_out, "Hello World!", 12, NULL, NULL)) {
// return 67;
if(!WriteConsole(std_out, "Hello World!\n", 13, NULL, NULL)) {
return 67;
}
#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++) {
if(argv[count][0] == '-') {
@ -272,5 +284,4 @@ int main(int argc, char* argv[])
return 0;
}
#endif