Console: ui off "text" shows a line under the ui off message (Ultra)

The text identifies a tinySA, e.g. the tracking generator and the spectrum
analyzer when a PC uses two tinySA. ui off "text" draws the screen again,
also when the UI is off already, so a new text replaces the old one; a
plain ui off keeps the text and ui off "" removes it. Characters outside
the font show as '?', characters beyond the screen width are left out (39
characters fit the console line, 39 wide ones not the screen).
main
erikkaashoek 2 weeks ago
parent a42d1fe49e
commit 7ea574948e

@ -1073,11 +1073,16 @@ VNA_SHELL_FUNCTION(cmd_ui)
shell_printf("ui %s" VNA_SHELL_NEWLINE_STR, ui_off ? "off" : "on");
return;
}
int m = generic_option_cmd("ui", "off|on", argc, argv[0]);
if (m >= 0) {
set_ui(m);
ui_on_notice = false; // the PC asked for it
int m = get_str_index(argv[0], "off|on");
if (m < 0 || argc > 2 || (argc == 2 && m)) {
usage_printf("ui [off [\"text\"]|on]" VNA_SHELL_NEWLINE_STR);
return;
}
if (argc == 2)
set_ui_text(argv[1]); // a line under the message, e.g. "Tracking generator"
else
set_ui(m);
ui_on_notice = false; // the PC asked for it
}
#endif

@ -1679,6 +1679,7 @@ bool isFullScreenMode(void);
extern bool ui_off; // the screen shows the ui off message, the drawing functions return at once
extern volatile bool ui_on_notice;
void set_ui(bool on);
void set_ui_text(char *text);
#define UI_OFF ui_off
#else
#define UI_OFF false

34
ui.c

@ -208,6 +208,15 @@ static void redraw_ui(void)
bool ui_off = false;
volatile bool ui_on_notice = false; // the UI is back: "ui on" starts the next console reply
// A centered line of the ui off screen: 0 the message, 1 the text of ui off "text"
static void ui_off_line(const char *s, int line)
{
int w = 0;
for (const char *p = s; *p; p++)
w += wFONT_GET_WIDTH(*p);
ili9341_drawstring_10x14(s, (LCD_WIDTH - w)/2, (LCD_HEIGHT - wFONT_GET_HEIGHT)/2 + line*2*wFONT_STR_HEIGHT);
}
// ui off: the screen shows a message and the console never waits for the screen. A touch or
// the jog (ui_process), ui on, a command that needs the user (CMD_UI_ON), USB DISK mode or a
// lost connection give the UI back.
@ -221,10 +230,6 @@ void set_ui(bool on)
redraw_ui();
return;
}
static const char msg[] = "Remote only mode. Touch screen to enable UI";
int w = 0;
for (const char *p = msg; *p; p++)
w += wFONT_GET_WIDTH(*p);
#ifdef __SD_FILE_BROWSER__
if (ui_mode == UI_BROWSER) // set_ui(true) can not redraw the browser
ui_mode_normal();
@ -232,9 +237,28 @@ void set_ui(bool on)
ili9341_set_foreground(LCD_FG_COLOR);
ili9341_set_background(LCD_BG_COLOR);
ili9341_clear_screen();
ili9341_drawstring_10x14(msg, (LCD_WIDTH - w)/2, (LCD_HEIGHT - wFONT_GET_HEIGHT)/2);
ui_off_line("Remote only mode. Touch screen to enable UI", 0);
ui_off = true;
}
// ui off "text": the ui off screen with a line under the message, also when the UI is off
// already, e.g. to tell the TG from the SA in a tracking generator setup of two tinySA
void set_ui_text(char *text)
{
int w = 0;
for (char *p = text; *p; p++) {
if ((uint8_t)*p > '~') // not in the font
*p = '?';
w += wFONT_GET_WIDTH(*p);
if (w > LCD_WIDTH) { // only the characters that fit on the screen
*p = 0;
break;
}
}
ui_off = false; // draw the screen again
set_ui(false);
ui_off_line(text, 1);
}
#endif
bool isFullScreenMode(void) {

Loading…
Cancel
Save

Powered by TurnKey Linux.