add cgi for setting background image
This commit is contained in:
+1
-1
Submodule front-end updated: d4931c1f31...bd933657f4
@@ -49,6 +49,10 @@ apars_handle_osc(char *buffer)
|
|||||||
buffer[0] = 'G';
|
buffer[0] = 'G';
|
||||||
notify_growl(buffer);
|
notify_growl(buffer);
|
||||||
}
|
}
|
||||||
|
else if (n == 70) {
|
||||||
|
// ESPTerm: backdrop
|
||||||
|
screen_set_backdrop(buffer);
|
||||||
|
}
|
||||||
else if (n >= 81 && n <= 85) {
|
else if (n >= 81 && n <= 85) {
|
||||||
// ESPTerm: action button label
|
// ESPTerm: action button label
|
||||||
screen_set_button_text(n - 80, buffer);
|
screen_set_button_text(n - 80, buffer);
|
||||||
|
|||||||
+11
-2
@@ -256,10 +256,16 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
|
|
||||||
if (GET_ARG("term_title")) {
|
if (GET_ARG("term_title")) {
|
||||||
cgi_dbg("Terminal title default text: \"%s\"", buff);
|
cgi_dbg("Terminal title default text: \"%s\"", buff);
|
||||||
strncpy_safe(termconf->title, buff, 64); // ATTN those must match the values in
|
strncpy_safe(termconf->title, buff, TERM_TITLE_LEN); // ATTN those must match the values in
|
||||||
topics |= TOPIC_CHANGE_TITLE;
|
topics |= TOPIC_CHANGE_TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (GET_ARG("backdrop")) {
|
||||||
|
cgi_dbg("Terminal backdrop url: \"%s\"", buff);
|
||||||
|
strncpy_safe(termconf->backdrop, buff, TERM_BACKDROP_LEN); // ATTN those must match the values in
|
||||||
|
topics |= TOPIC_CHANGE_BACKDROP;
|
||||||
|
}
|
||||||
|
|
||||||
for (int btn_i = 1; btn_i <= TERM_BTN_COUNT; btn_i++) {
|
for (int btn_i = 1; btn_i <= TERM_BTN_COUNT; btn_i++) {
|
||||||
sprintf(buff, "btn%d", btn_i);
|
sprintf(buff, "btn%d", btn_i);
|
||||||
if (GET_ARG(buff)) {
|
if (GET_ARG(buff)) {
|
||||||
@@ -416,7 +422,7 @@ cgiTermCfgSetParams(HttpdConnData *connData)
|
|||||||
httpd_cgi_state ICACHE_FLASH_ATTR
|
httpd_cgi_state ICACHE_FLASH_ATTR
|
||||||
tplTermCfg(HttpdConnData *connData, char *token, void **arg)
|
tplTermCfg(HttpdConnData *connData, char *token, void **arg)
|
||||||
{
|
{
|
||||||
#define BUFLEN TERM_TITLE_LEN
|
#define BUFLEN 100 // large enough for backdrop
|
||||||
char buff[BUFLEN];
|
char buff[BUFLEN];
|
||||||
char buff2[10];
|
char buff2[10];
|
||||||
|
|
||||||
@@ -492,6 +498,9 @@ tplTermCfg(HttpdConnData *connData, char *token, void **arg)
|
|||||||
else if (streq(token, "term_title")) {
|
else if (streq(token, "term_title")) {
|
||||||
strncpy_safe(buff, termconf->title, BUFLEN);
|
strncpy_safe(buff, termconf->title, BUFLEN);
|
||||||
}
|
}
|
||||||
|
else if (streq(token, "backdrop")) {
|
||||||
|
strncpy_safe(buff, termconf->backdrop, BUFLEN);
|
||||||
|
}
|
||||||
else if (streq(token, "uart_baud")) {
|
else if (streq(token, "uart_baud")) {
|
||||||
sprintf(buff, "%d", sysconf->uart_baudrate);
|
sprintf(buff, "%d", sysconf->uart_baudrate);
|
||||||
}
|
}
|
||||||
|
|||||||
+43
-7
@@ -213,6 +213,7 @@ terminal_restore_defaults(void)
|
|||||||
termconf->debugbar = SCR_DEF_DEBUGBAR;
|
termconf->debugbar = SCR_DEF_DEBUGBAR;
|
||||||
termconf->allow_decopt_12 = SCR_DEF_DECOPT12;
|
termconf->allow_decopt_12 = SCR_DEF_DECOPT12;
|
||||||
termconf->ascii_debug = SCR_DEF_ASCIIDEBUG;
|
termconf->ascii_debug = SCR_DEF_ASCIIDEBUG;
|
||||||
|
termconf->backdrop[0] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -247,6 +248,11 @@ terminal_apply_settings_noclear(void)
|
|||||||
termconf->ascii_debug = SCR_DEF_ASCIIDEBUG;
|
termconf->ascii_debug = SCR_DEF_ASCIIDEBUG;
|
||||||
changed = 1;
|
changed = 1;
|
||||||
}
|
}
|
||||||
|
if (termconf->config_version < 4) {
|
||||||
|
persist_dbg("termconf: Updating to version %d", 1);
|
||||||
|
termconf->backdrop[0] = 0;
|
||||||
|
changed = 1;
|
||||||
|
}
|
||||||
|
|
||||||
termconf->config_version = TERMCONF_VERSION;
|
termconf->config_version = TERMCONF_VERSION;
|
||||||
|
|
||||||
@@ -385,6 +391,7 @@ screen_reset_do(bool size, bool labels)
|
|||||||
|
|
||||||
if (labels) {
|
if (labels) {
|
||||||
strcpy(termconf_live.title, termconf->title);
|
strcpy(termconf_live.title, termconf->title);
|
||||||
|
strcpy(termconf_live.backdrop, termconf->backdrop);
|
||||||
|
|
||||||
for (int i = 1; i <= TERM_BTN_COUNT; i++) {
|
for (int i = 1; i <= TERM_BTN_COUNT; i++) {
|
||||||
strcpy(termconf_live.btn[i], termconf->btn[i]);
|
strcpy(termconf_live.btn[i], termconf->btn[i]);
|
||||||
@@ -394,7 +401,7 @@ screen_reset_do(bool size, bool labels)
|
|||||||
termconf_live.show_buttons = termconf->show_buttons;
|
termconf_live.show_buttons = termconf->show_buttons;
|
||||||
termconf_live.show_config_links = termconf->show_config_links;
|
termconf_live.show_config_links = termconf->show_config_links;
|
||||||
|
|
||||||
topics |= TOPIC_CHANGE_TITLE | TOPIC_CHANGE_BUTTONS;
|
topics |= TOPIC_CHANGE_TITLE | TOPIC_CHANGE_BUTTONS | TOPIC_CHANGE_BACKDROP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// initial values in the save buffer in case of receiving restore without storing first
|
// initial values in the save buffer in case of receiving restore without storing first
|
||||||
@@ -1009,6 +1016,18 @@ screen_set_button_text(int num, const char *text)
|
|||||||
NOTIFY_DONE(TOPIC_CHANGE_BUTTONS);
|
NOTIFY_DONE(TOPIC_CHANGE_BUTTONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper function to set terminalbackdrop
|
||||||
|
* @param url - url
|
||||||
|
*/
|
||||||
|
void ICACHE_FLASH_ATTR
|
||||||
|
screen_set_backdrop(const char *url)
|
||||||
|
{
|
||||||
|
NOTIFY_LOCK();
|
||||||
|
strncpy(termconf_live.backdrop, url, TERM_BACKDROP_LEN);
|
||||||
|
NOTIFY_DONE(TOPIC_CHANGE_BACKDROP);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift screen upwards
|
* Shift screen upwards
|
||||||
*/
|
*/
|
||||||
@@ -1907,6 +1926,7 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
|
|||||||
#define TOPICMARK_BELL '!'
|
#define TOPICMARK_BELL '!'
|
||||||
#define TOPICMARK_CURSOR 'C'
|
#define TOPICMARK_CURSOR 'C'
|
||||||
#define TOPICMARK_SCREEN 'S'
|
#define TOPICMARK_SCREEN 'S'
|
||||||
|
#define TOPICMARK_BACKDROP 'W'
|
||||||
|
|
||||||
if (ss == NULL) {
|
if (ss == NULL) {
|
||||||
// START!
|
// START!
|
||||||
@@ -2025,9 +2045,11 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
|
|||||||
bufput_c(TOPICMARK_TITLE);
|
bufput_c(TOPICMARK_TITLE);
|
||||||
|
|
||||||
int len = (int) strlen(termconf_live.title);
|
int len = (int) strlen(termconf_live.title);
|
||||||
memcpy(bb, termconf_live.title, len);
|
if (len > 0) {
|
||||||
bb += len;
|
memcpy(bb, termconf_live.title, len);
|
||||||
remain -= len;
|
bb += len;
|
||||||
|
remain -= len;
|
||||||
|
}
|
||||||
bufput_c('\x01');
|
bufput_c('\x01');
|
||||||
END_TOPIC
|
END_TOPIC
|
||||||
|
|
||||||
@@ -2038,13 +2060,27 @@ screenSerializeToBuffer(char *buffer, size_t buf_len, ScreenNotifyTopics topics,
|
|||||||
|
|
||||||
for (int i = 0; i < TERM_BTN_COUNT; i++) {
|
for (int i = 0; i < TERM_BTN_COUNT; i++) {
|
||||||
int len = (int) strlen(termconf_live.btn[i]);
|
int len = (int) strlen(termconf_live.btn[i]);
|
||||||
memcpy(bb, termconf_live.btn[i], len);
|
if (len > 0) {
|
||||||
bb += len;
|
memcpy(bb, termconf_live.btn[i], len);
|
||||||
remain -= len;
|
bb += len;
|
||||||
|
remain -= len;
|
||||||
|
}
|
||||||
bufput_c('\x01');
|
bufput_c('\x01');
|
||||||
}
|
}
|
||||||
END_TOPIC
|
END_TOPIC
|
||||||
|
|
||||||
|
BEGIN_TOPIC(TOPIC_CHANGE_BACKDROP, TERM_BACKDROP_LEN+1+1)
|
||||||
|
bufput_c(TOPICMARK_BACKDROP);
|
||||||
|
|
||||||
|
int len = (int) strlen(termconf_live.backdrop);
|
||||||
|
if (len > 0) {
|
||||||
|
memcpy(bb, termconf_live.backdrop, len);
|
||||||
|
bb += len;
|
||||||
|
remain -= len;
|
||||||
|
}
|
||||||
|
bufput_c('\x01');
|
||||||
|
END_TOPIC
|
||||||
|
|
||||||
BEGIN_TOPIC(TOPIC_INTERNAL, 45)
|
BEGIN_TOPIC(TOPIC_INTERNAL, 45)
|
||||||
bufput_c(TOPICMARK_DEBUG);
|
bufput_c(TOPICMARK_DEBUG);
|
||||||
// General flags
|
// General flags
|
||||||
|
|||||||
+8
-2
@@ -38,6 +38,7 @@
|
|||||||
#define TERM_BTN_MSG_LEN 10
|
#define TERM_BTN_MSG_LEN 10
|
||||||
#define TERM_TITLE_LEN 64
|
#define TERM_TITLE_LEN 64
|
||||||
#define TERM_BTN_COUNT 5
|
#define TERM_BTN_COUNT 5
|
||||||
|
#define TERM_BACKDROP_LEN 100
|
||||||
|
|
||||||
#define SCR_DEF_DISPLAY_TOUT_MS 12
|
#define SCR_DEF_DISPLAY_TOUT_MS 12
|
||||||
#define SCR_DEF_DISPLAY_COOLDOWN_MS 35
|
#define SCR_DEF_DISPLAY_COOLDOWN_MS 35
|
||||||
@@ -74,8 +75,8 @@ enum CursorShape {
|
|||||||
|
|
||||||
// Size designed for the terminal config structure
|
// Size designed for the terminal config structure
|
||||||
// Must be constant to avoid corrupting user config after upgrade
|
// Must be constant to avoid corrupting user config after upgrade
|
||||||
#define TERMCONF_SIZE 300
|
#define TERMCONF_SIZE 400
|
||||||
#define TERMCONF_VERSION 3
|
#define TERMCONF_VERSION 4
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
u32 width;
|
u32 width;
|
||||||
@@ -100,6 +101,7 @@ typedef struct {
|
|||||||
bool debugbar;
|
bool debugbar;
|
||||||
bool allow_decopt_12;
|
bool allow_decopt_12;
|
||||||
bool ascii_debug;
|
bool ascii_debug;
|
||||||
|
char backdrop[TERM_BACKDROP_LEN];
|
||||||
} TerminalConfigBundle;
|
} TerminalConfigBundle;
|
||||||
|
|
||||||
// Live config
|
// Live config
|
||||||
@@ -148,6 +150,8 @@ void screen_resize(int rows, int cols);
|
|||||||
void screen_set_title(const char *title);
|
void screen_set_title(const char *title);
|
||||||
/** Set a button text */
|
/** Set a button text */
|
||||||
void screen_set_button_text(int num, const char *text);
|
void screen_set_button_text(int num, const char *text);
|
||||||
|
/** Change backdrop */
|
||||||
|
void screen_set_backdrop(const char *url);
|
||||||
|
|
||||||
// --- Encoding ---
|
// --- Encoding ---
|
||||||
|
|
||||||
@@ -169,6 +173,7 @@ enum ScreenSerializeTopic {
|
|||||||
TOPIC_CHANGE_CURSOR = (1<<5),
|
TOPIC_CHANGE_CURSOR = (1<<5),
|
||||||
TOPIC_INTERNAL = (1<<6), // debugging internal state
|
TOPIC_INTERNAL = (1<<6), // debugging internal state
|
||||||
TOPIC_BELL = (1<<7), // beep
|
TOPIC_BELL = (1<<7), // beep
|
||||||
|
TOPIC_CHANGE_BACKDROP = (1<<8),
|
||||||
TOPIC_FLAG_NOCLEAN = (1<<15), // do not clean dirty extents
|
TOPIC_FLAG_NOCLEAN = (1<<15), // do not clean dirty extents
|
||||||
|
|
||||||
// combos
|
// combos
|
||||||
@@ -177,6 +182,7 @@ enum ScreenSerializeTopic {
|
|||||||
TOPIC_CHANGE_CONTENT_ALL |
|
TOPIC_CHANGE_CONTENT_ALL |
|
||||||
TOPIC_CHANGE_CURSOR |
|
TOPIC_CHANGE_CURSOR |
|
||||||
TOPIC_CHANGE_TITLE |
|
TOPIC_CHANGE_TITLE |
|
||||||
|
TOPIC_CHANGE_BACKDROP |
|
||||||
TOPIC_CHANGE_BUTTONS,
|
TOPIC_CHANGE_BUTTONS,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -150,6 +150,8 @@ static void ICACHE_FLASH_ATTR user_start(void *unused)
|
|||||||
// Critically important for client application if any kind of screen persistence / content re-use is needed
|
// Critically important for client application if any kind of screen persistence / content re-use is needed
|
||||||
UART_WriteChar(UART0, CAN, UART_TIMEOUT_US); // 0x18 - 24 - CAN
|
UART_WriteChar(UART0, CAN, UART_TIMEOUT_US); // 0x18 - 24 - CAN
|
||||||
|
|
||||||
|
dbg("tsize=%d", sizeof(TerminalConfigBundle));
|
||||||
|
|
||||||
#if DEBUG_HEAP
|
#if DEBUG_HEAP
|
||||||
// Heap use timer & blink
|
// Heap use timer & blink
|
||||||
TIMER_START(&prHeapTimer, prHeapTimerCb, HEAP_TIMER_MS, 1);
|
TIMER_START(&prHeapTimer, prHeapTimerCb, HEAP_TIMER_MS, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user