|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
FILES: the state, the requests to the card's task, the footer's operations and the screen's interface (files_screen.h). files_draw.c draws the screen, files_events.c takes its touch events, and files_int.h is what the three share. More...
#include "files_screen.h"#include <inttypes.h>#include <stdio.h>#include <string.h>#include "card_tree.h"#include "fm_name.h"#include "fm_ops.h"#include "log_name.h"#include "log_select.h"#include "log_viewer_screen.h"#include "ui_screen.h"#include "ui_text.h"#include "ui_textkey.h"#include "files_int.h"Data Structures | |
| struct | place_t |
| What of a pane RESCAN's answer keeps: its top row on screen, copied before the answer replaces the page. The selection is kept by fm_tree_page(), by name. More... | |
Enumerations | |
| enum | need_t { NEED_NONE = 0 , NEED_PAGE , NEED_UP , NEED_ENTER } |
| A pane's request waiting for the card's task. More... | |
Functions | |
| static void | read_bench (void) |
| The bench as the gate and the rules see it now: the io's, ARMED also when the band says so, and the log folders in force. | |
| static bool | io_ok (void) |
| Whether the io can take requests. | |
| static void | keep_arg (char to[FM_NAME_BUF], const char *from) |
Copy from into the message's argument to, "" for NULL. | |
| void | fs_say (bool ok, ui_text_id_t id, const char *a, const char *b) |
The message line says id, with up to two names. | |
| void | fs_say_err (fm_err_t err, const char *name) |
The message line says why err, for name (fs_err_text()). | |
| void | fs_quiet (void) |
| The message line says nothing. | |
| const char * | fs_message (char *buf, size_t n) |
| The message line in the language showing. | |
| void | fs_err_text (fm_err_t err, const char *name, char *out, size_t n) |
The words of a refusal or a failure, for name. | |
| static bool | submit (void) |
| Hand s.req to the card's task, the log folders in force with it. | |
| static void | want (int i, need_t need, fm_go_t go) |
Pane i is to be read: a page, the folder above, or the folder on its selected row. A newer wish replaces the one waiting. | |
| static void | start_panes (void) |
| Both panes in their start folders, nothing read: the card's root and USER LOG FOLDER. | |
| static void | select_name (int i, const char *name) |
Select name on pane i's page when it is there, and scroll the row into sight. | |
| static int | place_of (const fm_tree_t *t, const fm_entry_t *e) |
The row of pane t where entry e stands in the pane's order: e's own row, or the first row that ranks behind it. | |
| static void | place_note (int i, place_t *p) |
Pane i's place, as RESCAN keeps it. | |
| static void | place_keep (int i, const place_t *p) |
RESCAN's answer for pane i keeps the pane's place: the entry that was the top row on screen stays the top row, and the selection stays on its entry (fm_tree_page() keeps it by name). | |
| static void | take_pane (void) |
| The answer of a pane's request: the pane as the card's task read it. A pane read from another card than the other's sends both back to their start folders. | |
| static void | take_job (void) |
| The answer of a job: the message, and both panes read again. | |
| static void | take_answer (void) |
| The answer of the request under way, once it is in. | |
| static void | send_next (void) |
| The next pane's request out, when nothing is under way. | |
| static void | pump (void) |
| Take the answer that is in, then send what waits. | |
| const fm_entry_t * | fs_selected (void) |
| The selected entry of the active pane. | |
| bool | fs_paged (int i) |
| Whether a pane's folder holds more than its page. | |
| void | fs_clamp_scroll (int i) |
Pane i's scroll held to its rows. | |
| void | fs_bar_thumb (int i, int *y, int *h) |
The scroll bar's thumb of pane i. | |
| int | fs_bar_scroll_at (int i, int top) |
The scroll of pane i that puts the thumb's top nearest top. | |
| static bool | logs_tab_of (const char *dir, log_viewer_tab_t *tab) |
The LOGS tab whose folder dir is, when LOGS shows the files of it. | |
| static bool | logs_shows (const char *dir, const fm_entry_t *e) |
Whether LOGS shows entry e of folder dir: a .csv file, or a report, in the folder of one of its tabs. The names are the ones LOGS' list holds (log_select_lists()); a report is the name the list here labels one (fm_kind_of(), log_report_number()). | |
| bool | fs_foot_live (fs_foot_t b, fm_err_t *why) |
Whether footer button b takes a press now, and why not. | |
| static void | start_job (fm_err_t err, const char *name) |
Start a job of s.req, filled by an fm_job_*() call that answered err: its box, or the refusal. | |
| static void | open_in_logs (const fm_entry_t *e) |
| OPEN on a file LOGS shows: LOGS, on that file's tab, with it open. A file LOGS' list does not hold now, one gone from the card since this list was read, stays here with FM_E_NOT_FOUND. | |
| void | fs_foot (fs_foot_t b) |
Act on footer button b: a tap on it, live or dimmed. | |
| void | fs_turn (int i, fm_go_t go, bool up) |
Read another page of pane i, or the folder above it. | |
| void | fs_row_tap (int i, int row) |
A tap on row row of pane i: the pane active and the row selected; a tap on the selected row of the active pane opens it. | |
| void | fs_delete_doomed (void) |
| The DELETE question's DELETE: the job that deletes it. | |
| void | fs_new_name (bool folder) |
| NEW's choice: the keyboard for the new entry's name. | |
| void | fs_name_typed (const char *name) |
The keyboard closed with name: the job that makes or renames. | |
| void | fs_job_cancel (void) |
| CANCEL on the progress box. | |
| void | files_size_text (char *out, size_t n, uint64_t bytes) |
| A size as the panes and INFO write it, no space before the unit: "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes. | |
| void | files_time_text (char *out, size_t n, int64_t mtime) |
| A time as INFO writes it: "2024-05-17 12:34", read as UTC, or "" for -1. INFO hands it the stamp moved into the zone SETUP holds (wall_local_s()), and writes FM_INFO_NO_TIME for a stamp wall_stamp_known() refuses. | |
| void | files_screen_set_io (const files_io_t *io) |
| Point the screen at the card's task. NULL leaves it without one: both panes show no card. | |
| files_view_t | files_screen_view (void) |
| The view on top. | |
| int | files_screen_active (void) |
| The active pane: the one OPEN, RENAME, DELETE, NEW and INFO act in, and whose entry COPY and MOVE take to the other. | |
| const fm_tree_t * | files_screen_pane (int i) |
| A pane as last read. | |
| int | files_screen_scroll (int i) |
| A pane's first row on screen. | |
| const char * | files_screen_message (void) |
| The message line: the last result or refusal, worded in the language showing; "" for none. The write gate's sentence, drawn while the line holds nothing, is not part of it. | |
| bool | files_screen_busy (void) |
| Whether a request is under way on the card's task. | |
| void | files_screen_invalidate (void) |
| Repaint the cached chrome into every framebuffer. | |
| static void | reset (void) |
| The screen as a start leaves it: the card's root on the left, USER LOG FOLDER on the right, neither read. The io stays; a request under way stays the card's task's. | |
| static void | enter (void) |
| On the way in: both panes read, from their first pages the first time and as they were left after that, the slot looked at first. | |
| static void | leave (void) |
| On the way out: the keyboard and the boxes close; a job under way goes on, and its box shows again on the way back in. | |
| static void | tick (float dt_s) |
| Time passed: the answer taken when it is in, the progress and the gate followed for the drawing. | |
| static bool | back (void) |
| The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on top the screen is left. | |
| const ui_screen_t * | files_screen (void) |
| The screen. | |
Variables | |
| fs_state_t | fs_s |
| The screen's state; files_int.h names it s. | |
| static need_t | s_need [2] |
| What each pane waits for (need_t), beside s.need_go. | |
| static const ui_screen_t | s_screen |
| The screen's table for the router. | |
FILES: the state, the requests to the card's task, the footer's operations and the screen's interface (files_screen.h). files_draw.c draws the screen, files_events.c takes its touch events, and files_int.h is what the three share.
Every card call of the screen is a request (fm_req.h) on the card's task. The listings wait in a queue of one per pane; INFO and a job go out when nothing else is under way. An answer is taken in tick(), and a job's answer reads both panes again, since a copy or a move changes the other pane's folder too.
SPDX-License-Identifier: MIT
| enum need_t |
|
static |
The home tag: a box or the keyboard closes, a job's box cancels a copy and stays; with the panes on top the screen is left.
| const ui_screen_t * files_screen | ( | void | ) |
The screen.
| int files_screen_active | ( | void | ) |
The active pane: the one OPEN, RENAME, DELETE, NEW and INFO act in, and whose entry COPY and MOVE take to the other.
| bool files_screen_busy | ( | void | ) |
Whether a request is under way on the card's task.
| const char * files_screen_message | ( | void | ) |
The message line: the last result or refusal, worded in the language showing; "" for none. The write gate's sentence, drawn while the line holds nothing, is not part of it.
| const fm_tree_t * files_screen_pane | ( | int | i | ) |
A pane as last read.
| i | 0 for the left pane, 1 for the right |
i | int files_screen_scroll | ( | int | i | ) |
A pane's first row on screen.
| i | 0 for the left pane, 1 for the right |
i | void files_screen_set_io | ( | const files_io_t * | io | ) |
Point the screen at the card's task. NULL leaves it without one: both panes show no card.
| io | the io, copied |
| files_view_t files_screen_view | ( | void | ) |
The view on top.
| void files_size_text | ( | char * | out, |
| size_t | n, | ||
| uint64_t | bytes ) |
A size as the panes and INFO write it, no space before the unit: "300B", "4kB", "3.0MB" from 1MiB, "8.00GB" from 1GiB. The units are binary: 1kB is 1024 bytes.
| out | takes the text |
| n | bytes at out |
| bytes | the size |
| void files_time_text | ( | char * | out, |
| size_t | n, | ||
| int64_t | mtime ) |
A time as INFO writes it: "2024-05-17 12:34", read as UTC, or "" for -1. INFO hands it the stamp moved into the zone SETUP holds (wall_local_s()), and writes FM_INFO_NO_TIME for a stamp wall_stamp_known() refuses.
| out | takes the text |
| n | bytes at out |
| mtime | seconds since 1970-01-01, or -1 |
| int fs_bar_scroll_at | ( | int | i, |
| int | top ) |
The scroll of pane i that puts the thumb's top nearest top.
| i | the pane |
| top | the thumb's top the finger asks for |
| void fs_bar_thumb | ( | int | i, |
| int * | y, | ||
| int * | h ) |
The scroll bar's thumb of pane i.
| i | the pane |
| y | takes its top |
| h | takes its height |
| void fs_clamp_scroll | ( | int | i | ) |
Pane i's scroll held to its rows.
| i | the pane |
| void fs_err_text | ( | fm_err_t | err, |
| const char * | name, | ||
| char * | out, | ||
| size_t | n ) |
The words of a refusal or a failure, for name.
| err | the answer |
| name | the entry's name, for the formats that name it |
| out | takes the sentence |
| n | bytes at out |
| void fs_foot | ( | fs_foot_t | b | ) |
Act on footer button b: a tap on it, live or dimmed.
| b | the button |
Whether footer button b takes a press now, and why not.
| b | the button |
| why | takes the refusal, FM_OK when it takes one; may be NULL |
| const char * fs_message | ( | char * | buf, |
| size_t | n ) |
The message line in the language showing.
| buf | takes the line |
| n | bytes at buf, FS_MSG_MAX for the longest |
buf, "" for no message; "" also for a NULL buf or a zero n | void fs_name_typed | ( | const char * | name | ) |
The keyboard closed with name: the job that makes or renames.
| name | the name typed |
| void fs_new_name | ( | bool | folder | ) |
NEW's choice: the keyboard for the new entry's name.
| folder | a folder, else an empty text file |
| bool fs_paged | ( | int | i | ) |
Whether a pane's folder holds more than its page.
| i | the pane |
| void fs_row_tap | ( | int | i, |
| int | row ) |
A tap on row row of pane i: the pane active and the row selected; a tap on the selected row of the active pane opens it.
| i | the pane |
| row | the row's index on the page |
| void fs_say | ( | bool | ok, |
| ui_text_id_t | id, | ||
| const char * | a, | ||
| const char * | b ) |
The message line says id, with up to two names.
The line keeps the ID and the names, and fs_message() words it in the language showing, so a change of SET_LANGUAGE rewords it.
| ok | a result, not a refusal |
| id | the text: FM_COPIED, FM_MOVED, LOG_DELETED and FM_MADE format a, FM_RENAMED a and b; any other is shown as it is |
| a | the first name, or NULL |
| b | the second name, or NULL |
| void fs_say_err | ( | fm_err_t | err, |
| const char * | name ) |
The message line says why err, for name (fs_err_text()).
| err | the answer |
| name | the entry's name, or NULL |
| const fm_entry_t * fs_selected | ( | void | ) |
The selected entry of the active pane.
| void fs_turn | ( | int | i, |
| fm_go_t | go, | ||
| bool | up ) |
Read another page of pane i, or the folder above it.
| i | the pane |
| go | which page; FM_GO_FIRST with up for the folder above |
| up | go up one folder |
|
static |
Whether the io can take requests.
|
static |
Copy from into the message's argument to, "" for NULL.
| to | the argument, FM_NAME_BUF bytes |
| from | the name, or NULL |
|
static |
Whether LOGS shows entry e of folder dir: a .csv file, or a report, in the folder of one of its tabs. The names are the ones LOGS' list holds (log_select_lists()); a report is the name the list here labels one (fm_kind_of(), log_report_number()).
| dir | the entry's folder |
| e | the entry |
|
static |
The LOGS tab whose folder dir is, when LOGS shows the files of it.
| dir | a folder |
| tab | takes the tab |
|
static |
OPEN on a file LOGS shows: LOGS, on that file's tab, with it open. A file LOGS' list does not hold now, one gone from the card since this list was read, stays here with FM_E_NOT_FOUND.
| e | the entry |
|
static |
RESCAN's answer for pane i keeps the pane's place: the entry that was the top row on screen stays the top row, and the selection stays on its entry (fm_tree_page() keeps it by name).
A top row gone from the card leaves the entry now at its place on top. A selected entry gone from the card, or moved off the page, leaves nothing selected, as after a DELETE: MOVE and RENAME act on the selection without a question, so no other entry takes it. The scroll is held to the rows after (fs_clamp_scroll()).
| i | the pane |
| p | the place before the answer (place_note()) |
|
static |
Pane i's place, as RESCAN keeps it.
| i | the pane |
| p | takes the place |
|
static |
The row of pane t where entry e stands in the pane's order: e's own row, or the first row that ranks behind it.
| t | the pane |
| e | the entry |
e
|
static |
Select name on pane i's page when it is there, and scroll the row into sight.
| i | the pane |
| name | the name |
|
static |
Start a job of s.req, filled by an fm_job_*() call that answered err: its box, or the refusal.
| err | the start's answer |
| name | the entry's name, for a refusal's words |
|
static |
Hand s.req to the card's task, the log folders in force with it.
|
static |
Time passed: the answer taken when it is in, the progress and the gate followed for the drawing.
| dt_s | seconds since the last tick |
Pane i is to be read: a page, the folder above, or the folder on its selected row. A newer wish replaces the one waiting.
| i | the pane |
| need | what is read |
| go | for NEED_PAGE, which page |
| fs_state_t fs_s |
The screen's state; files_int.h names it s.
The screen's state, defined in files_screen.c.
The screen's state; files_int.h names it s.
|
static |
The screen's table for the router.