|
rcbench
Servo and ESC test bench: panel, IOmcu and shared C
|
The SUPPLY screen. See supply_screen.h. This file holds the state, the commands and the screen's interface; supply_events.c takes the touch events and frames, supply_draw.c draws, and supply_screen_int.h is what the three share. More...
#include "supply_screen.h"#include <math.h>#include <stdint.h>#include <string.h>#include "settings.h"#include "ui_keypad.h"#include "ui_plot.h"#include "ui_slider.h"#include "ui_tabs.h"#include "ui_text.h"#include "ui_theme.h"#include "ui_widgets.h"#include "ui_workbench.h"#include "supply_screen_int.h"Functions | |
| static void | forget_drawn (void) |
| void | supply_invalidate (void) |
| Everything SUPPLY draws is drawn again on its next frame. | |
| void | sup_bind_colours (void) |
| Sets the plot's series colours from the active theme. | |
| static int16_t | set_ctrl_y (int row) |
The top of set point row's controls. | |
| static gfx_rect_t | set_track (int row) |
Set point row's track, between its two step keys. | |
| static gfx_rect_t | nudge_rect (int row, bool up) |
Set point row's fine step key, down at the track's left end or up at its right. | |
| gfx_rect_t | sup_set_value_rect (int row) |
| A set point's value, at the right end of its controls: tapped, the keypad. | |
| gfx_rect_t | sup_card_rect (int i) |
Returns the rectangle of reading card i on the rail. | |
| gfx_rect_t | sup_strip_area (void) |
| The strip's row with its trough's 3px around it. | |
| static void | strip_widen (void) |
| The strip's tabs laid out again at SUPPLY's sizes, SU_TAB_W x SU_STRIP_H from (SU_STRIP_X, SU_STRIP_Y): the tasks, their order and their labels as ui_wb_strip_init() set them. | |
| bool | sup_on_live (void) |
| Returns whether the LIVE task shows. | |
| gfx_rect_t | sup_overlay_area (void) |
| Returns the area the keypad, the question and SETTINGS' page take. | |
| gfx_rect_t | sup_row_rect (int i) |
SETTINGS' row i: its label and its value, in its column. | |
| gfx_rect_t | sup_row_value_rect (int i) |
The value of SETTINGS' row i, at the row's right end: tapped, the keypad or a switch's flip. | |
| static void | apply_caps (void) |
| static supply_limits_t | limits_from_settings (void) |
| void | sup_refresh_limits (void) |
| Re-reads the operator's limits from the settings and narrows the caps. | |
| static void | reset (void) |
| The screen at its start: the state cleared, every control laid out, the model's set points. | |
| void | sup_owner_settle (void) |
| Clears the owner and any owed OFF once the output is off with no ON asked. | |
| void | sup_post_on (supply_by_t by) |
| Asks for the output ON, unless an OFF is pending or a programming port holds the supply. | |
| void | sup_post_off (void) |
| Asks for the output OFF. | |
| bool | supply_screen_poll_cmd (supply_cmd_t *out) |
| void | supply_screen_push (const supply_state_t *st) |
| const supply_state_t * | supply_screen_reading (void) |
| void | sup_let_go (void) |
| Ends the press on a slider or key and lets the set points follow the supply. | |
| void | supply_screen_set_output (bool on) |
| void | supply_screen_set_caps (const supply_caps_t *caps) |
| void | supply_screen_set_baud (uint32_t baud) |
| void | supply_screen_set_pins (int tx, int rx) |
| The PD mini's UART pins, IOmcu GPIO numbers, named in the header ("PD MINI TX GPIO 12 RX GPIO 13"). | |
| void | supply_screen_set_model (bool model) |
| bool | supply_screen_model (void) |
| Whether the numbers come from the panel's model. | |
| float | supply_screen_set_v (void) |
| float | supply_screen_set_i (void) |
| The current limit's set point as the screen holds it, snapped to the caps. | |
| void | supply_screen_settings_loaded (void) |
| bool | sup_confirm_needed (int from) |
| Returns whether a change waits for a confirmation: only while the output is on and as the operator's settings ask. | |
| void | sup_propose (int from) |
| Gives a set point change to the supply, or opens the question when one is needed. | |
| bool | sup_confirm_stands (void) |
| Returns whether the question about a live output still stands: the output on or an ON on its way, and no stop since it was asked. | |
| void | sup_confirm_close (bool apply) |
| Closes the question, applying the pending change or dropping it. | |
| supply_limits_t | supply_screen_limits (void) |
| supply_caps_t | supply_screen_caps (void) |
| const ui_keypad_t * | supply_screen_keypad (void) |
| The keypad of the set points and of SETTINGS' rows, open or closed, for a test to read what it opened with and where its keys are. | |
| bool | supply_screen_typed_asks (void) |
| static void | port_held_apply (bool held) |
| The supply's lock as the two programmers' words make it: held while either holds a port. | |
| void | supply_screen_set_port_held (bool held) |
| void | supply_screen_set_hitec_held (bool held) |
| The Hitec programmer's word on the same hold: the supply is held while either programmer says so. supply_screen_set_port_held() is the KST programmer's. | |
| bool | supply_screen_port_held (void) |
| Whether a programming port holds the supply (supply_screen_set_port_held()). | |
| void | supply_screen_adopt (float v, float i) |
| void | supply_screen_put (float v, float i) |
| bool | supply_screen_output_on (void) |
| Whether the output is on as this screen believes it: what the supply reported, with an OFF this screen asked for and has not yet seen answered counted as off. | |
| bool | supply_screen_output_live (void) |
| uint32_t | supply_screen_off_count (void) |
| void | supply_screen_ask_on (supply_by_t by) |
| supply_by_t | supply_screen_owner (void) |
| bool | supply_screen_off_owed (void) |
| void | supply_screen_claim (supply_by_t by) |
| void | supply_screen_entered (supply_by_t by) |
| void | supply_screen_left (supply_by_t by) |
| void | supply_screen_ask_off (void) |
| bool | supply_screen_off_pending (void) |
| bool | supply_screen_output_held (void) |
| void | supply_screen_limits_changed (void) |
| void | supply_screen_set_on_coming (bool coming) |
| void | supply_screen_cancel_on (void) |
| static void | leave (void) |
| static void | enter (void) |
| int | supply_screen_task (void) |
| static void | cancel (void) |
| static bool | back (void) |
| const ui_screen_t * | supply_screen (void) |
| The SUPPLY screen as the router drives it. | |
Variables | |
| const ui_plot_series_t | sup_series [S_COUNT] |
| The plot's five series: voltage, current, power, and the voltage and current set points. | |
| static const ui_text_id_t | k_tab_labels [] |
| sup_state_t | sup_s |
| The supply screen's state, in supply_screen.c. | |
| static const ui_screen_t | k_screen |
The SUPPLY screen. See supply_screen.h. This file holds the state, the commands and the screen's interface; supply_events.c takes the touch events and frames, supply_draw.c draws, and supply_screen_int.h is what the three share.
MOTOR & ESC's frame and its rules for what repaints when: chrome once per framebuffer, the numbers when a sample arrives, the plot when it moves, and each control on its own counter.
SPDX-License-Identifier: MIT
|
static |
Set point row's fine step key, down at the track's left end or up at its right.
| row | 0 the voltage, 1 the current limit |
| up | the step up |
|
static |
The supply's lock as the two programmers' words make it: held while either holds a port.
| held | whether a programming port holds the supply |
|
static |
The top of set point row's controls.
| row | 0 the voltage, 1 the current limit |
|
static |
Set point row's track, between its two step keys.
| row | 0 the voltage, 1 the current limit |
| gfx_rect_t sup_card_rect | ( | int | i | ) |
Returns the rectangle of reading card i on the rail.
| i | card index, 0 to 3 |
| void sup_confirm_close | ( | bool | apply | ) |
Closes the question, applying the pending change or dropping it.
| apply | true for APPLY, false for CANCEL |
| bool sup_confirm_needed | ( | int | from | ) |
Returns whether a change waits for a confirmation: only while the output is on and as the operator's settings ask.
| from | where the change came from, FROM_SLIDER or FROM_KEYPAD |
| bool sup_confirm_stands | ( | void | ) |
Returns whether the question about a live output still stands: the output on or an ON on its way, and no stop since it was asked.
| bool sup_on_live | ( | void | ) |
Returns whether the LIVE task shows.
| gfx_rect_t sup_overlay_area | ( | void | ) |
Returns the area the keypad, the question and SETTINGS' page take.
| void sup_post_on | ( | supply_by_t | by | ) |
Asks for the output ON, unless an OFF is pending or a programming port holds the supply.
| by | the screen the ON belongs to |
| void sup_propose | ( | int | from | ) |
Gives a set point change to the supply, or opens the question when one is needed.
| from | where the change came from, FROM_SLIDER or FROM_KEYPAD |
| gfx_rect_t sup_row_rect | ( | int | i | ) |
SETTINGS' row i: its label and its value, in its column.
| i | the row, an index of k_rows |
| gfx_rect_t sup_row_value_rect | ( | int | i | ) |
The value of SETTINGS' row i, at the row's right end: tapped, the keypad or a switch's flip.
| i | the row, an index of k_rows |
| gfx_rect_t sup_set_value_rect | ( | int | row | ) |
A set point's value, at the right end of its controls: tapped, the keypad.
| row | 0 the voltage, 1 the current limit |
| gfx_rect_t sup_strip_area | ( | void | ) |
The strip's row with its trough's 3px around it.
| const ui_screen_t * supply_screen | ( | void | ) |
The SUPPLY screen as the router drives it.
| void supply_screen_adopt | ( | float | v, |
| float | i ) |
The set points a programming port gave the supply, onto the screen: supply_screen_put() for the one caller that reports and does not ask.
| void supply_screen_ask_off | ( | void | ) |
OUTPUT OFF tapped elsewhere: an OFF is posted, and any ON dropped.
| void supply_screen_ask_on | ( | supply_by_t | by | ) |
OUTPUT ON's hold completed elsewhere, as it does here: an ON is posted unless an OFF already is, and the output is by's from then on.
| void supply_screen_cancel_on | ( | void | ) |
A hold under way is abandoned and a pending ON dropped: STOP.
| supply_caps_t supply_screen_caps | ( | void | ) |
The set points' range: the supply's caps narrowed by the operator's.
| void supply_screen_claim | ( | supply_by_t | by | ) |
An output reported on that nobody here asked for becomes by's: the servo programmer's CONNECT, which switches a PD mini on through the IOmcu and not through this screen. An owned output keeps its owner.
| void supply_screen_entered | ( | supply_by_t | by | ) |
Screen by is shown again: an OFF owed for leaving it is dropped.
| const ui_keypad_t * supply_screen_keypad | ( | void | ) |
The keypad of the set points and of SETTINGS' rows, open or closed, for a test to read what it opened with and where its keys are.
| void supply_screen_left | ( | supply_by_t | by | ) |
Screen by is left. An output it owns – on, or an ON on its way – is switched off. While a servo programming port holds the supply (supply_screen_set_port_held()) an OFF would end the port's session and cut a write on the wire: the OFF is owed instead, and sent when the port lets go, unless supply_screen_entered() came first. An output another screen owns, or none, stays as it is.
| supply_limits_t supply_screen_limits | ( | void | ) |
The operator's limits as the screen last read them from the settings.
| void supply_screen_limits_changed | ( | void | ) |
The caps were changed in the settings from elsewhere, so read them again.
| bool supply_screen_model | ( | void | ) |
Whether the numbers come from the panel's model.
| uint32_t supply_screen_off_count | ( | void | ) |
How many times the output has been reported going off. A question about a live output records it and stands only while it is unchanged: an OFF and a new ON between two frames end the run it was about.
| bool supply_screen_off_owed | ( | void | ) |
Whether an OFF is owed for a screen left while a port held the supply.
| bool supply_screen_off_pending | ( | void | ) |
Whether an OFF is posted and not yet taken by supply_screen_poll_cmd().
| bool supply_screen_output_held | ( | void | ) |
Whether OUTPUT ON is being held on this screen: a press on the switch that began with the output off.
| bool supply_screen_output_live | ( | void | ) |
The output on, or an ON asked for and still on its way: what a set point change is asked about.
| bool supply_screen_output_on | ( | void | ) |
Whether the output is on as this screen believes it: what the supply reported, with an OFF this screen asked for and has not yet seen answered counted as off.
| supply_by_t supply_screen_owner | ( | void | ) |
The screen whose ON the output is, or SUPPLY_BY_NONE: off, no ON on its way, or an OFF asked since.
| bool supply_screen_poll_cmd | ( | supply_cmd_t * | out | ) |
True when anything was asked; clears it.
| bool supply_screen_port_held | ( | void | ) |
Whether a programming port holds the supply (supply_screen_set_port_held()).
| void supply_screen_push | ( | const supply_state_t * | s | ) |
One sample, for the readouts and, while the output is on, the plot.
| void supply_screen_put | ( | float | v, |
| float | i ) |
Both set points, typed elsewhere and confirmed where they needed it; snapped to the caps.
| const supply_state_t * supply_screen_reading | ( | void | ) |
The newest sample supply_screen_push() took, as it took it: zeroed, so not online, before the first.
| void supply_screen_set_baud | ( | uint32_t | baud | ) |
The PD mini's UART (universal asynchronous receiver-transmitter) rate in baud, shown after ONLINE in the header ("ONLINE 38400"); 0 shows none. Not shown for the model, nor while the module does not answer.
| void supply_screen_set_caps | ( | const supply_caps_t * | caps | ) |
What the set points may be; the sliders and steps follow it.
| void supply_screen_set_hitec_held | ( | bool | held | ) |
The Hitec programmer's word on the same hold: the supply is held while either programmer says so. supply_screen_set_port_held() is the KST programmer's.
| held | whether the Hitec programmer, or the SUPPLY page's own LINK_SP_PORT, says a programming port holds the supply |
| float supply_screen_set_i | ( | void | ) |
The current limit's set point as the screen holds it, snapped to the caps.
| void supply_screen_set_model | ( | bool | model | ) |
Whether the numbers come from the panel's model rather than a supply.
| void supply_screen_set_on_coming | ( | bool | coming | ) |
Whether an ON this screen asked for can still be on its way: false once the application has taken every ON it sent and the output is not on, so an ON it dropped – stale, or lost to a full queue – stops counting as live. An ON this screen holds and has not handed over still counts.
| void supply_screen_set_output | ( | bool | on | ) |
Whether the supply's output is on, as the supply reports it. That bounds a run: switching on clears the plot and starts it, switching off holds it.
| void supply_screen_set_pins | ( | int | tx, |
| int | rx ) |
The PD mini's UART pins, IOmcu GPIO numbers, named in the header ("PD MINI TX GPIO 12 RX GPIO 13").
With either pin not set, or both on one GPIO, the header says "PD MINI NO PINS": the page holds no pins then. Not shown for the model.
| tx | the TX pin; negative is not set |
| rx | the RX pin; negative is not set |
| void supply_screen_set_port_held | ( | bool | held | ) |
The output as the supply last reported it. Whether a servo programming port is out of PWM. The IOmcu then takes an OFF from the panel and no other command (supply_page.h), and this screen offers the same: OUTPUT OFF and RESET PEAKS work, OUTPUT ON, the sliders, the steps and the set points' keypads take no press and are drawn dimmed, supply_screen_put() and supply_screen_ask_on() do nothing, and the MODE card says who holds the supply. What was under way when the port left PWM – a hold on OUTPUT ON, a drag, a keypad of a set point, a question – ends unanswered.
| float supply_screen_set_v | ( | void | ) |
The set points as the screen holds them, snapped to the caps.
| void supply_screen_settings_loaded | ( | void | ) |
The settings have been loaded: take the limits from them and start the set points at the start values. Called once after settings_init(); the screen reads nothing from the settings before it.
| int supply_screen_task | ( | void | ) |
The task shown, a ui_wb_task_t: LIVE or SETTINGS. A tile opens LIVE; a tap on the other tab switches, and takes an open keypad with it.
| bool supply_screen_typed_asks | ( | void | ) |
Whether a set point typed now waits for a question before it reaches the supply: the output live or an ON on its way, and SETTINGS, CONFIRM WHILE ON, KEYPAD on.
|
static |
|
static |
| const ui_plot_series_t sup_series[S_COUNT] |
The plot's five series: voltage, current, power, and the voltage and current set points.