|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
Log viewer: browse the card, review the import, plot the file. More...
#include <stddef.h>#include <stdint.h>#include "card_state.h"#include "log_csv.h"#include "log_text.h"#include "ui_screen.h"Go to the source code of this file.
Data Structures | |
| struct | log_viewer_file_t |
| struct | log_viewer_row_t |
| The texts of one row of the file list, as the list draws them. More... | |
| struct | log_viewer_page_t |
| struct | log_viewer_io_t |
Macros | |
| #define | LOG_VIEWER_MAX_FILES 48 |
| #define | LOG_VIEWER_NAME_MAX 64 |
| #define | LOG_VIEWER_OPEN_MAX 0x7FFFFFFFull |
| #define | LOG_VIEWER_NAME_CELLS 60 |
| The cells a row's name takes: a longer name, of up to LOG_VIEWER_NAME_MAX - 1 (63) bytes, shows its first 58 and "..". | |
| #define | LOG_RANGE_CELLS 17u |
The range of a numeric column as the import view writes it into out (n bytes): "lo..hiunit". One decimal while both ends are below 1000 in magnitude, none from 1000 on, so "2392..14639rpm" fits the 140px box of the view. A text over LOG_RANGE_CELLS glyphs (code points, gfx_text_cells(), so "µs" is 2) drops the decimal: "-999.9..-999.9mOhm" reads "-1000..-1000mOhm". A text still wider, such as two 7-digit negative ends, is cut at the box's edge. No unit with an empty unit. | |
Enumerations | |
| enum | log_page_dir_t { LOG_PAGE_FROM = 0 , LOG_PAGE_AFTER , LOG_PAGE_BEFORE } |
| enum | log_viewer_tab_t { LOG_TAB_USER = 0 , LOG_TAB_BENCH , LOG_TAB_ROOT , LOG_TAB_COUNT } |
| enum | log_viewer_view_t { LOG_VIEW_BROWSE = 0 , LOG_VIEW_IMPORT , LOG_VIEW_PLOT , LOG_VIEW_TEXT } |
| enum | log_viewer_show_t { LOG_SHOW_OPEN = 0 , LOG_SHOW_NOT_LISTED , LOG_SHOW_OTHER_CARD } |
| What log_viewer_show() found. More... | |
Functions | |
| void | log_viewer_row_text (const log_viewer_file_t *f, log_viewer_row_t *out) |
The texts of the list's row for f: its name, cut as FILES cuts a name; its time as FILES INFO writes it (files_time_text() of wall_local_s()), and nothing for none or a 1980 stamp; its size. | |
| const char * | log_viewer_tab_dir (log_viewer_tab_t tab) |
| void | log_viewer_set_io (const log_viewer_io_t *io) |
| log_viewer_view_t | log_viewer_view (void) |
| log_viewer_tab_t | log_viewer_tab (void) |
| void | log_viewer_set_tab (log_viewer_tab_t tab) |
| log_viewer_show_t | log_viewer_show (log_viewer_tab_t tab, const char *name, unsigned mount) |
Show tab with file name open, as a tap on the tab, a tap on the file's row and OPEN do: FILES' OPEN on a file of one of the three folders. The page read is the one that starts at the name, and it must come from the mount FILES listed the file from. | |
| const char * | log_viewer_open_name (void) |
| const log_analysis_t * | log_viewer_analysis (void) |
| const log_data_t * | log_viewer_data (void) |
| const log_text_t * | log_viewer_text (void) |
| The report the TEXT view shows. | |
| int | log_viewer_text_first (void) |
| The TEXT view's first row on screen. | |
| void | log_viewer_window (int *first, int *count) |
| void | log_viewer_browse_title (char *out, size_t n) |
| gfx_color_t | log_viewer_series_color (int k) |
| int | log_viewer_cursor (void) |
| void | log_viewer_size_text (char *out, size_t n, uint64_t bytes) |
A file's size as the list and the DELETE question write it into out (n bytes): "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes, 1GB 1024^3. | |
| const char * | log_viewer_message (void) |
| The footer message: the last result or refusal, worded in the language showing; "" for none. | |
| void | log_viewer_range_text (char *out, size_t n, double lo, double hi, const char *unit) |
| void | log_viewer_refresh (void) |
| const ui_screen_t * | log_viewer_screen (void) |
| void | log_viewer_invalidate (void) |
Log viewer: browse the card, review the import, plot the file.
The screen owns no filesystem. It is handed an I/O (input/output) vtable (list, open, close), so the firmware points it at the SD card while the host tests and the screenshot renderer point it at a string in memory.
Four views, in the order they are used:
BROWSE the files of one folder of the card, and DELETE for the selected one behind a confirmation that names it. Three tabs choose the folder, left to right: ROOT (the card's root, where firmware 0.21.0 and older wrote every run), USER (USER/LOGS, the tests a user starts) and BENCH (BENCH/LOGS, the automatic logs). The list holds the CSV files and the reports (log_select_lists()) IMPORT what the CSV (comma-separated values) reader detected, and the controls to override it PLOT the traces, on one time base with a scale each TEXT a report, ATESTnnn.TXT or LIMITnnn.TXT, as text (log_text.h): OPEN on a report shows it in place of IMPORT
The import view shows the detected delimiter and decimal convention before anything is plotted: a decimal-comma file read as decimal-point turns 22,34V into 2234V.
Pure C, no ESP-IDF (Espressif Internet-of-Things Development Framework).
SPDX-License-Identifier: MIT
| #define LOG_RANGE_CELLS 17u |
The range of a numeric column as the import view writes it into out (n bytes): "lo..hiunit". One decimal while both ends are below 1000 in magnitude, none from 1000 on, so "2392..14639rpm" fits the 140px box of the view. A text over LOG_RANGE_CELLS glyphs (code points, gfx_text_cells(), so "µs" is 2) drops the decimal: "-999.9..-999.9mOhm" reads "-1000..-1000mOhm". A text still wider, such as two 7-digit negative ends, is cut at the box's edge. No unit with an empty unit.
the 140px range box in 8px glyphs
| enum log_page_dir_t |
Which page of the volume list() writes.
A page is up to LOG_VIEWER_MAX_FILES entries that stand next to each other in log_name_rank() order, newest run first. It is named by the name at its edge, key, and not by its number: the directory is read in one walk per page and nothing about the pages before it is held, so the walk keeps the entries on the right side of key and counts the rest. A key whose file has gone still names a place in that order.
| enum log_viewer_show_t |
What log_viewer_show() found.
| enum log_viewer_tab_t |
| enum log_viewer_view_t |
| const log_analysis_t * log_viewer_analysis | ( | void | ) |
What was detected, or NULL when nothing has been analysed.
| void log_viewer_browse_title | ( | char * | out, |
| size_t | n ) |
The browse list's tab into out of n bytes: the page's place in the card, "FILES 49 TO 96 OF 121", on a card of more than one page, and "FILES" otherwise. The list draws this text.
| int log_viewer_cursor | ( | void | ) |
The sample the cursor is on, or -1 with nothing plotted.
| const log_data_t * log_viewer_data | ( | void | ) |
The loaded traces, or NULL when nothing is plotted.
| const char * log_viewer_message | ( | void | ) |
The footer message: the last result or refusal, worded in the language showing; "" for none.
| const char * log_viewer_open_name | ( | void | ) |
The file currently open, or "" – the overview header shows this.
| void log_viewer_refresh | ( | void | ) |
Re-read the directory from its first page, e.g. after a card was inserted. Closes an open DELETE question: the name it asked about may be on another card now. Selects the newest numbered run, so the run just recorded is the one OPEN opens.
| void log_viewer_row_text | ( | const log_viewer_file_t * | f, |
| log_viewer_row_t * | out ) |
The texts of the list's row for f: its name, cut as FILES cuts a name; its time as FILES INFO writes it (files_time_text() of wall_local_s()), and nothing for none or a 1980 stamp; its size.
| f | the entry |
| out | takes the texts; all three "" for a NULL f |
| gfx_color_t log_viewer_series_color | ( | int | k | ) |
The colour series k is drawn in.
| void log_viewer_set_tab | ( | log_viewer_tab_t | tab | ) |
Show tab and read its folder from the first page, as a tap on the tab does. A tab outside the three is ignored.
| log_viewer_show_t log_viewer_show | ( | log_viewer_tab_t | tab, |
| const char * | name, | ||
| unsigned | mount ) |
Show tab with file name open, as a tap on the tab, a tap on the file's row and OPEN do: FILES' OPEN on a file of one of the three folders. The page read is the one that starts at the name, and it must come from the mount FILES listed the file from.
| tab | the folder's tab |
| name | the file's name in that folder |
| mount | the mount number (log_viewer_io_t mounts()) FILES read the name from |
| void log_viewer_size_text | ( | char * | out, |
| size_t | n, | ||
| uint64_t | bytes ) |
A file's size as the list and the DELETE question write it into out (n bytes): "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes, 1GB 1024^3.
| out | the text |
| n | its size, bytes |
| bytes | the file's size |
| log_viewer_tab_t log_viewer_tab | ( | void | ) |
The tab BROWSE shows.
| const char * log_viewer_tab_dir | ( | log_viewer_tab_t | tab | ) |
The folder of tab, a path from the card's root ("" the root itself); "" for a tab outside the three. USER and BENCH list the folders SETUP > SD CARD names in force, as the logger writes them (card_folder_use(): the default folder for one card_folder_check() refuses). Valid until the next call for the same tab.
| const log_text_t * log_viewer_text | ( | void | ) |
The report the TEXT view shows.
| int log_viewer_text_first | ( | void | ) |
The TEXT view's first row on screen.
| log_viewer_view_t log_viewer_view | ( | void | ) |
Which of the three views is showing.
| void log_viewer_window | ( | int * | first, |
| int * | count ) |
The samples the plot shows: the first in first and how many in count. The whole file until two fingers zoom in; both 0 with nothing plotted.