rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
supply_draw.c File Reference

The SUPPLY screen's drawing: the strip row, the rail with the readings and the CONTROL card, LIVE's plot or table and set points, SETTINGS' page and the question. supply_screen.c holds the state, the commands and the screen's interface (supply_screen.h); supply_screen_int.h is what it shares with this file and supply_events.c. More...

#include <math.h>
#include <stdio.h>
#include <stdint.h>
#include <string.h>
#include "bench_state.h"
#include "settings.h"
#include "supply_screen.h"
#include "ui_hero.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"

Macros

#define CARD_NUM_DX   170
 A reading card's left part: its name and the set point in brackets end by x + 170 ("SPANN. (21.00)", 14 cells).

Enumerations

enum  { TAG_LIVE = 0 , TAG_HELD , TAG_IDLE , TAG_COUNT }

Functions

static gfx_color_t out_fill (void)
 Returns the OUTPUT button's fill: the OK green when off, the danger red when on.
static void draw_out_button (gfx_canvas_t *c)
 OUTPUT ON / OFF at the CONTROL card's foot.
static const char * mode_text (void)
 Returns the mode's name: CV, CC, the tripped or off word, or "--" when the supply does not answer.
static const char * mode_line (void)
 Returns the mode's explanation line: a held port, a trip, CC or CV; "" when there is none.
void supply_screen_header_text (char *out, size_t size)
 The left text of the header strip: the supply and its pins, the answer and the rate ("PD MINI TX GPIO 12 RX GPIO 13 ONLINE 38400"), 47 characters at most.
static void draw_header (gfx_canvas_t *c)
 The row right of the strip: where the numbers come from, in the label face, and at its right end the range the set points may take, in the fine face. The longest, PD MINI TX GPIO 12 RX GPIO 13 ANTWORTET NICHT, is 47 cells of the label face (470px) and 10.0-21.0V 0.50-5.00A 22 of the fine face (176px): 646px of the 680px the row holds.
static void draw_strip (gfx_canvas_t *c)
 Draws the task strip, LIVE | SETTINGS, on the background.
static void num_text (gfx_canvas_t *c, int right, int y, int w, const char *t, gfx_color_t col)
 A reading's numerals in the 32 x 44 face, the 20 x 36 one where they are wider than w, right-aligned to right.
static void draw_card (gfx_canvas_t *c, gfx_rect_t r, const char *label, const char *set, const char *unit, gfx_color_t color, int decimals, float value, const char *extreme, float peak, bool pressed)
 One card of the rail, CARD_H px high, as MOTOR & ESC draws them: the name, with the set point in brackets after it when there is one, over the extreme, and the live value in the 32 x 44 numerals, right-aligned with its unit.
static float shown_set_v (void)
 The set points as the supply reports holding them, or as this screen holds them while it does not answer.
static float shown_set_i (void)
 Returns the current limit as the supply reports it, or as this screen holds it while the supply does not answer.
static void draw_cards (gfx_canvas_t *c)
 The rail's four cards: VOLT, CURR and PWR with their set points and extremes, and MODE.
static void draw_table (gfx_canvas_t *c)
 TABLE: each reading's set point and its value now, under the header line, in the legend's and the plot's place.
static void draw_totals (gfx_canvas_t *c)
 What the run has taken from the supply, on the CONTROL card's title line, right of its tag: STEUERUNG's 9 cells and the tab's 26px.
static void draw_setters (gfx_canvas_t *c)
 The two set points: the label, the track, and the value in its box at the right end of the controls, in the reading's colour. Held by a programming port the value takes no press, and is drawn faint, as SERVO's SET row draws it.
static void draw_steps (gfx_canvas_t *c)
 The fine steps at both ends of each track, dim while a programming port holds the supply.
static uint8_t save_state (void)
 Whether the settings reached the medium: 0 saved, 1 waiting for a quiet moment, 2 refused, 3 changed on SETUP and not asked to be saved – which nothing writes until SAVE there, or a change here, asks for it.
static void row_value_text (int i, char *buf, size_t n)
 Writes the value of SETTINGS' row i with its unit.
static void draw_settings (gfx_canvas_t *c)
 SETTINGS' page in the left column under the strip: the caps and the start values on the left with RESET PD MINI under them, the trips, their help and the confirmations on the right, and the save line at the foot.
static void draw_confirm (gfx_canvas_t *c)
 The question a change to a live output asks: what changes, from what to what, and APPLY or CANCEL; where to turn it off at its foot. OUTPUT OFF and STOP stay where they are.
static uint8_t output_tag (void)
 The heading says what the output is doing, on either pane: a held run is the plot's to show, so TABLE says IDLE where PLOT says HELD.
void sup_render (gfx_canvas_t *c, int buffer_index)
 A frame: the chrome once per framebuffer, then each part on its own counter.

Variables

static const ui_text_id_t k_tag [TAG_COUNT]
 Text of each output tag: LIVE, HELD, IDLE.

Detailed Description

The SUPPLY screen's drawing: the strip row, the rail with the readings and the CONTROL card, LIVE's plot or table and set points, SETTINGS' page and the question. supply_screen.c holds the state, the commands and the screen's interface (supply_screen.h); supply_screen_int.h is what it shares with this file and supply_events.c.

SPDX-License-Identifier: MIT

Function Documentation

◆ draw_card()

void draw_card ( gfx_canvas_t * c,
gfx_rect_t r,
const char * label,
const char * set,
const char * unit,
gfx_color_t color,
int decimals,
float value,
const char * extreme,
float peak,
bool pressed )
static

One card of the rail, CARD_H px high, as MOTOR & ESC draws them: the name, with the set point in brackets after it when there is one, over the extreme, and the live value in the 32 x 44 numerals, right-aligned with its unit.

Parameters
cthe canvas
rthe card
labelthe reading's name
setthe set point in brackets, or NULL
unitthe unit
colorthe reading's colour
decimalsthe value's decimals
valuethe live value, NAN for none
extremethe extreme's name, or NULL for none
peakthe extreme, NAN for none
pressedwhether a press holds the card

◆ draw_cards()

void draw_cards ( gfx_canvas_t * c)
static

The rail's four cards: VOLT, CURR and PWR with their set points and extremes, and MODE.

Parameters
cthe canvas

◆ draw_confirm()

void draw_confirm ( gfx_canvas_t * c)
static

The question a change to a live output asks: what changes, from what to what, and APPLY or CANCEL; where to turn it off at its foot. OUTPUT OFF and STOP stay where they are.

Parameters
cthe canvas

◆ draw_header()

void draw_header ( gfx_canvas_t * c)
static

The row right of the strip: where the numbers come from, in the label face, and at its right end the range the set points may take, in the fine face. The longest, PD MINI TX GPIO 12 RX GPIO 13 ANTWORTET NICHT, is 47 cells of the label face (470px) and 10.0-21.0V 0.50-5.00A 22 of the fine face (176px): 646px of the 680px the row holds.

Parameters
cthe canvas

◆ draw_out_button()

void draw_out_button ( gfx_canvas_t * c)
static

OUTPUT ON / OFF at the CONTROL card's foot.

Parameters
cthe canvas

◆ draw_setters()

void draw_setters ( gfx_canvas_t * c)
static

The two set points: the label, the track, and the value in its box at the right end of the controls, in the reading's colour. Held by a programming port the value takes no press, and is drawn faint, as SERVO's SET row draws it.

Parameters
cthe canvas

◆ draw_settings()

void draw_settings ( gfx_canvas_t * c)
static

SETTINGS' page in the left column under the strip: the caps and the start values on the left with RESET PD MINI under them, the trips, their help and the confirmations on the right, and the save line at the foot.

Parameters
cthe canvas

◆ draw_steps()

void draw_steps ( gfx_canvas_t * c)
static

The fine steps at both ends of each track, dim while a programming port holds the supply.

Parameters
cthe canvas

◆ draw_table()

void draw_table ( gfx_canvas_t * c)
static

TABLE: each reading's set point and its value now, under the header line, in the legend's and the plot's place.

Parameters
cthe canvas

◆ draw_totals()

void draw_totals ( gfx_canvas_t * c)
static

What the run has taken from the supply, on the CONTROL card's title line, right of its tag: STEUERUNG's 9 cells and the tab's 26px.

Parameters
cthe canvas

◆ num_text()

void num_text ( gfx_canvas_t * c,
int right,
int y,
int w,
const char * t,
gfx_color_t col )
static

A reading's numerals in the 32 x 44 face, the 20 x 36 one where they are wider than w, right-aligned to right.

Parameters
cthe canvas
righttheir right edge, px
ytheir top, px
wthe width they may take, px
tthe numerals
coltheir colour

◆ sup_render()

void sup_render ( gfx_canvas_t * c,
int buffer_index )

A frame: the chrome once per framebuffer, then each part on its own counter.

Parameters
cthe canvas
buffer_indexthe framebuffer drawn into, 0 or 1

◆ supply_screen_header_text()

void supply_screen_header_text ( char * out,
size_t size )

The left text of the header strip: the supply and its pins, the answer and the rate ("PD MINI TX GPIO 12 RX GPIO 13 ONLINE 38400"), 47 characters at most.

Parameters
outtakes the text
sizebytes at out

Variable Documentation

◆ k_tag

const ui_text_id_t k_tag[TAG_COUNT]
static
Initial value:
= {
TX_SUP_TAG_LIVE, TX_SUP_TAG_HELD, TX_SUP_TAG_IDLE,
}

Text of each output tag: LIVE, HELD, IDLE.