status_message_level => alert_level
This commit is contained in:
parent
24655a6bf3
commit
10b85be405
|
@ -26,7 +26,7 @@
|
||||||
#include "../feature/leds/leds.h"
|
#include "../feature/leds/leds.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// These displays all share the MarlinUI class
|
// All displays share the MarlinUI class
|
||||||
#if HAS_DISPLAY
|
#if HAS_DISPLAY
|
||||||
#include "ultralcd.h"
|
#include "ultralcd.h"
|
||||||
#include "fontutils.h"
|
#include "fontutils.h"
|
||||||
|
@ -56,7 +56,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef MAX_MESSAGE_LENGTH
|
#ifdef MAX_MESSAGE_LENGTH
|
||||||
uint8_t MarlinUI::status_message_level; // = 0
|
uint8_t MarlinUI::alert_level; // = 0
|
||||||
char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
|
char MarlinUI::status_message[MAX_MESSAGE_LENGTH + 1];
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1316,7 +1316,7 @@ void MarlinUI::update() {
|
||||||
bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
|
bool MarlinUI::has_status() { return (status_message[0] != '\0'); }
|
||||||
|
|
||||||
void MarlinUI::set_status(const char * const message, const bool persist) {
|
void MarlinUI::set_status(const char * const message, const bool persist) {
|
||||||
if (status_message_level > 0) return;
|
if (alert_level) return;
|
||||||
|
|
||||||
// Here we have a problem. The message is encoded in UTF8, so
|
// Here we have a problem. The message is encoded in UTF8, so
|
||||||
// arbitrarily cutting it will be a problem. We MUST be sure
|
// arbitrarily cutting it will be a problem. We MUST be sure
|
||||||
|
@ -1343,8 +1343,8 @@ void MarlinUI::update() {
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
|
|
||||||
void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
|
void MarlinUI::status_printf_P(const uint8_t level, PGM_P const fmt, ...) {
|
||||||
if (level < status_message_level) return;
|
if (level < alert_level) return;
|
||||||
status_message_level = level;
|
alert_level = level;
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
|
vsnprintf_P(status_message, MAX_MESSAGE_LENGTH, fmt, args);
|
||||||
|
@ -1353,19 +1353,18 @@ void MarlinUI::update() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
|
void MarlinUI::set_status_P(PGM_P const message, int8_t level) {
|
||||||
if (level < 0) level = status_message_level = 0;
|
if (level < 0) level = alert_level = 0;
|
||||||
if (level < status_message_level) return;
|
if (level < alert_level) return;
|
||||||
status_message_level = level;
|
alert_level = level;
|
||||||
|
|
||||||
// Here we have a problem. The message is encoded in UTF8, so
|
// Since the message is encoded in UTF8 it must
|
||||||
// arbitrarily cutting it will be a problem. We MUST be sure
|
// only be cut on a character boundary.
|
||||||
// that there is no cutting in the middle of a multibyte character!
|
|
||||||
|
|
||||||
// Get a pointer to the null terminator
|
// Get a pointer to the null terminator
|
||||||
PGM_P pend = message + strlen_P(message);
|
PGM_P pend = message + strlen_P(message);
|
||||||
|
|
||||||
// If length of supplied UTF8 string is greater than
|
// If length of supplied UTF8 string is greater than
|
||||||
// our buffer size, start cutting whole UTF8 chars
|
// the buffer size, start cutting whole UTF8 chars
|
||||||
while ((pend - message) > MAX_MESSAGE_LENGTH) {
|
while ((pend - message) > MAX_MESSAGE_LENGTH) {
|
||||||
--pend;
|
--pend;
|
||||||
while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;
|
while (!START_OF_UTF8_CHAR(pgm_read_byte(pend))) --pend;
|
||||||
|
|
|
@ -277,8 +277,8 @@ public:
|
||||||
static char status_message[];
|
static char status_message[];
|
||||||
static bool has_status();
|
static bool has_status();
|
||||||
|
|
||||||
static uint8_t status_message_level; // Higher levels block lower levels
|
static uint8_t alert_level; // Higher levels block lower levels
|
||||||
static inline void reset_alert_level() { status_message_level = 0; }
|
static inline void reset_alert_level() { alert_level = 0; }
|
||||||
|
|
||||||
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
#if ENABLED(STATUS_MESSAGE_SCROLLING)
|
||||||
static uint8_t status_scroll_offset;
|
static uint8_t status_scroll_offset;
|
||||||
|
|
Loading…
Reference in a new issue