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

The drawing of the SERVO screen's pages of rows and the panels they open: SETTINGS' pages and a run's settings with their notes and the save line, the list, the profile warning, the HV warning and SUPPLY's question about a live output. More...

#include <stdio.h>
#include <string.h>
#include "servo_limrun.h"
#include "settings.h"
#include "supply_screen.h"
#include "ui_keypad.h"
#include "ui_tabs.h"
#include "ui_textkey.h"
#include "ui_text.h"
#include "ui_theme.h"
#include "ui_widgets.h"
#include "servo_screen_int.h"

Macros

#define NOTE_CELLS   ((OV_W - 20) / SV_CELL)
 A line of a page's note: the page less 10px each side, 60 cells.
#define WARN_CELLS   ((OV_W - 32) / 12)
 A line of a warning: the left column less 20px left and 12px right, in cells of SV_FONT_BODY, 49.
#define WARN_TITLE_DY   20
 A warning's title, what it is about, and its first line.
#define WARN_WHAT_DY   76
#define WARN_LINE_DY   120
#define WARN_PITCH   28

Functions

void draw_save_line (gfx_canvas_t *c)
 Whether the settings reached the card, along the bottom of a page.
static bool row_unused (const ov_row_t *r)
 Whether a row is drawn faint: a test setting the length rule leaves unused, a setting under its lock, a limit run's row it cannot take now.
static void row_value (const ov_row_t *r, char *buf, size_t n)
 A row's value as text.
static void draw_note (gfx_canvas_t *c, int x, int y, const char *const *lines, int count)
 A page's note, NOTE_PITCH px a line, in the faint colour.
bool servo_in_force_note (char *l1, char *l2, size_t size, uint16_t hz, uint8_t target, uint8_t gpio, bool pwm, int setting)
 The OUTPUT page's note while a rate is SERVO_RATE_IN_FORCE: two lines into l1 and l2 of size bytes each, for the rate hz, the drive target / gpio / pwm (as servo_screen_set_drive()) and the PWM TARGET setting setting (SET_SERVO_TARGET: 0 OUTPUTS, 1 PROG PORT, the target the panel asks for). The first line names the target the IOmcu holds, not the setting: "In force: OUTPUTS run at 50Hz.", "In force: PROG PORT GPIO 13 runs at 560Hz.", the port without a known pin, or the target not known (the page not known). With no link it names no rate: "No link: the rate in force is not known.". The second line says "The TARGET chosen is not active." while the setting and the drive differ, "PORT PWM is OFF" while the port renders no pulse, else that a PPM output keeps its own frame. Returns whether the note takes the warning colour: the setting and the drive differ, no link, the target not known, a port without a known pin, or a port with its pulse off. Neither line is written with a NULL buffer or a size of 0, and false is returned.
static void draw_rate_note (gfx_canvas_t *c, int x, int y)
 Whether the frame rate reached the pins, in two lines or more.
void draw_rows_page (gfx_canvas_t *c)
 A page of rows in the page area: SETTINGS' page under its tabs, or a run's settings under the run's name. Its notes, and the save line.
static void draw_choice (gfx_canvas_t *c)
 The list: its title, its choices, the one in force in the accent, and CANCEL.
static gfx_color_t warn_fill (void)
 HOLD TO APPLY's fill: sunk, fading to the danger red across its hold.
void draw_warn_apply (gfx_canvas_t *c)
 The profile warning's HOLD TO APPLY.
static void warn_frame (gfx_canvas_t *c, gfx_rect_t a, gfx_color_t red)
 The red frame of a warning, 3px, around the left column.
static void draw_warning (gfx_canvas_t *c)
 The warning a type or a frame rate that can destroy a servo needs before it is applied: in the danger colour, saying what it is and what it does to a servo not made for it.
void draw_ask_apply (gfx_canvas_t *c)
 The HV warning's HOLD TO APPLY.
static void draw_hv (gfx_canvas_t *c)
 The HV warning: a voltage raised past a standard servo's rating, in the danger colour of the profile warning, saying what it does to a servo not rated for it.
static void draw_ask (gfx_canvas_t *c)
 SUPPLY's question before a set point changes a live output, with its words: the change reaches the load at once. The HV warning where the voltage passes a standard servo's rating.
void draw_overlay (gfx_canvas_t *c)
 The panel open over the left column, if any: the keypad, the keyboard, the question or the HV warning, the profile warning, or the list.

Detailed Description

The drawing of the SERVO screen's pages of rows and the panels they open: SETTINGS' pages and a run's settings with their notes and the save line, the list, the profile warning, the HV warning and SUPPLY's question about a live output.

What a press on them does, and the rows they draw, are servo_settings_panel.c; the state and the layout they share are servo_screen_int.h.

SPDX-License-Identifier: MIT

Macro Definition Documentation

◆ WARN_LINE_DY

#define WARN_LINE_DY   120

Its first line of prose, px.

◆ WARN_PITCH

#define WARN_PITCH   28

Its lines' pitch in SV_FONT_BODY, px.

◆ WARN_WHAT_DY

#define WARN_WHAT_DY   76

What it is about, under the title, px.

Function Documentation

◆ draw_ask()

void draw_ask ( gfx_canvas_t * c)
static

SUPPLY's question before a set point changes a live output, with its words: the change reaches the load at once. The HV warning where the voltage passes a standard servo's rating.

Parameters
cthe canvas

◆ draw_ask_apply()

void draw_ask_apply ( gfx_canvas_t * c)

The HV warning's HOLD TO APPLY.

Parameters
cthe canvas

◆ draw_choice()

void draw_choice ( gfx_canvas_t * c)
static

The list: its title, its choices, the one in force in the accent, and CANCEL.

Parameters
cthe canvas

◆ draw_hv()

void draw_hv ( gfx_canvas_t * c)
static

The HV warning: a voltage raised past a standard servo's rating, in the danger colour of the profile warning, saying what it does to a servo not rated for it.

Parameters
cthe canvas

◆ draw_note()

void draw_note ( gfx_canvas_t * c,
int x,
int y,
const char *const * lines,
int count )
static

A page's note, NOTE_PITCH px a line, in the faint colour.

Parameters
cthe canvas
xits left edge, px
yits first line's top, px
linesthe lines
counthow many

◆ draw_overlay()

void draw_overlay ( gfx_canvas_t * c)

The panel open over the left column, if any: the keypad, the keyboard, the question or the HV warning, the profile warning, or the list.

Parameters
cthe canvas

◆ draw_rate_note()

void draw_rate_note ( gfx_canvas_t * c,
int x,
int y )
static

Whether the frame rate reached the pins, in two lines or more.

Parameters
cthe canvas
xthe note's left edge, px
yits first line's top, px

◆ draw_rows_page()

void draw_rows_page ( gfx_canvas_t * c)

A page of rows in the page area: SETTINGS' page under its tabs, or a run's settings under the run's name. Its notes, and the save line.

Parameters
cthe canvas

◆ draw_save_line()

void draw_save_line ( gfx_canvas_t * c)

Whether the settings reached the card, along the bottom of a page.

Parameters
cthe canvas

◆ draw_warn_apply()

void draw_warn_apply ( gfx_canvas_t * c)

The profile warning's HOLD TO APPLY.

Parameters
cthe canvas

◆ draw_warning()

void draw_warning ( gfx_canvas_t * c)
static

The warning a type or a frame rate that can destroy a servo needs before it is applied: in the danger colour, saying what it is and what it does to a servo not made for it.

Parameters
cthe canvas

◆ row_unused()

bool row_unused ( const ov_row_t * r)
static

Whether a row is drawn faint: a test setting the length rule leaves unused, a setting under its lock, a limit run's row it cannot take now.

Parameters
rthe row
Returns
true to draw it faint

◆ row_value()

void row_value ( const ov_row_t * r,
char * buf,
size_t n )
static

A row's value as text.

Parameters
rthe row
bufthe text
nits size

◆ servo_in_force_note()

bool servo_in_force_note ( char * l1,
char * l2,
size_t size,
uint16_t hz,
uint8_t target,
uint8_t gpio,
bool pwm,
int setting )

The OUTPUT page's note while a rate is SERVO_RATE_IN_FORCE: two lines into l1 and l2 of size bytes each, for the rate hz, the drive target / gpio / pwm (as servo_screen_set_drive()) and the PWM TARGET setting setting (SET_SERVO_TARGET: 0 OUTPUTS, 1 PROG PORT, the target the panel asks for). The first line names the target the IOmcu holds, not the setting: "In force: OUTPUTS run at 50Hz.", "In force: PROG PORT GPIO 13 runs at 560Hz.", the port without a known pin, or the target not known (the page not known). With no link it names no rate: "No link: the rate in force is not known.". The second line says "The TARGET chosen is not active." while the setting and the drive differ, "PORT PWM is OFF" while the port renders no pulse, else that a PPM output keeps its own frame. Returns whether the note takes the warning colour: the setting and the drive differ, no link, the target not known, a port without a known pin, or a port with its pulse off. Neither line is written with a NULL buffer or a size of 0, and false is returned.

Parameters
l1out: the first line
l2out: the second line
sizethe size of each, bytes
hzthe rate in force
targetthe drive's target, as servo_screen_set_drive()
gpiothe drive's pin, as servo_screen_set_drive()
pwmwhether the port renders a pulse, as servo_screen_set_drive()
settingSET_SERVO_TARGET: 0 OUTPUTS, 1 PROG PORT
Returns
whether the note takes the warning colour

◆ warn_fill()

gfx_color_t warn_fill ( void )
static

HOLD TO APPLY's fill: sunk, fading to the danger red across its hold.

Returns
the fill

◆ warn_frame()

void warn_frame ( gfx_canvas_t * c,
gfx_rect_t a,
gfx_color_t red )
static

The red frame of a warning, 3px, around the left column.

Parameters
cthe canvas
athe left column
redthe frame's colour