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

The drawing of the programmer's overlay. More...

#include "kst_panel.h"
#include <limits.h>
#include <stdio.h>
#include <string.h>
#include "kst_port.h"
#include "kst_reg.h"
#include "link_pages.h"
#include "ui_card_text.h"
#include "ui_tabs.h"
#include "ui_text.h"
#include "ui_textkey.h"
#include "ui_theme.h"
#include "ui_widgets.h"
#include "kst_panel_int.h"

Data Structures

struct  note_t
 One note: its text and its colour. More...
struct  notes_plan_t
 Where the notes go: their rows from the first note's place to the message, the page each takes, and where the shown page puts each line. More...

Macros

#define NOTES_MAX   5
 Most notes a page holds.
#define NOTE_Y   (ROW0 + 4 * PITCH + ROW_H + 8)
 The notes' first place: 8px under the SERVO tab's fifth row.

Functions

static void kp_button (gfx_canvas_t *c, gfx_rect_t r, const char *label, gfx_color_t fill, bool pressed, bool enabled)
 A button of the overlay, its label in KP_FONT.
static gfx_color_t level_color (unsigned level)
 Returns the text colour of a warning level: danger, warning or plain.
static int note (note_t *n, int i, int slot, const char *s, gfx_color_t color)
 Writes note i of n and returns the next index.
static int standing (const char *out[2], bool *warn)
 What stands until it is dealt with: up to two lines on the SERVO tab. Returns the lines used; warn is set for amber, cleared for red.
const char * kst_panel_standing_line (int i)
static int message_shown (char text[KST_PANEL_MSG_LINES][KST_PANEL_LINE])
 The lines of the last message the overlay shows. One that only repeats what stands on the SERVO tab is left out.
static void state_line (char *out, size_t n)
 Writes the programmer's state, with the port, into out.
static const char * state_second (bool *type)
 The line under the state: what the state needs, or the servo's type.
const char * kst_panel_status_line (int i)
static int notes_standing (note_t *n, int i)
 What stands until it is dealt with, over the last message.
static int page_notes (note_t *n)
 The notes of the page shown, in their order down the page. Their text is static: the caller draws it after this returns.
int kst_panel_pack_notes (const int *rows, const bool *standing, int count, int room, int *page)
 The page each of count notes takes in room rows.
static void plan_notes (notes_plan_t *p)
 Plans the notes of the page shown: their rows, pages and places, and the message's.
static int rows_foot (void)
 The highest a note rises to: 4px under the lowest row of the tab shown, the area's top for a tab with none.
static void layout_notes (notes_plan_t *p)
 The page's notes from the top, each at its place or under the one above, and the last message from the area's last row up: three rows for one that takes fewer. Notes that need more rows than there are above the message take pages: the standing notes are on the first, whole, the other notes page after them, the area's last notes row counts the pages, and a tap on the notes shows the next. Where the standing notes and the message leave no row for the count, the other notes wait for the message to go. Where the standing notes leave no row for the count beside the message, they yield to it: they page with the others, first, and one taller than a page waits for the message to go. Every line of the message is drawn: the longest takes 5 rows of the 7 under the SERVO tab's last row on SERVO's left card, which end 4px above the alert band (kpn_notes_foot()). No note rises above 4px under the tab's last row.
static void draw_notes (gfx_canvas_t *c)
 Draws the notes and the message of the page shown.
static gfx_rect_t notes_rect (const notes_plan_t *p)
 Returns the area the notes take, for the page-turning press.
bool kpn_notes_paged_at (int x, int y)
 Whether (x, y) is on notes that take more than one page.
gfx_rect_t kst_panel_notes_rect (void)
int kst_panel_note_pages (void)
int kst_panel_note_page (void)
const char * kst_panel_shown_note (int i)
int kst_panel_shown_message_lines (void)
gfx_rect_t kst_panel_notes_drawn (void)
static void act_value (const row_t *r, char *out, size_t n)
 Writes the value of an action row, from the programmer's state, into out.
const char * kst_panel_button (int page, int row, int col)
static void draw_row (gfx_canvas_t *c, int i)
 Draws row i of the page shown: its label and its control, highlighted while pressed.
static void draw_page (gfx_canvas_t *c)
 Draws the page shown: the tabs, CLOSE, its rows and its notes.
static void draw_choice (gfx_canvas_t *c)
 Draws the list of choices: its title, an entry per value and CANCEL.
static void draw_warning (gfx_canvas_t *c)
 Draws the warning page: the title, its lines and the hold button.
void kst_panel_render (gfx_canvas_t *c)
 Draws the overlay: the keypad or the keyboard alone while one is open, else the warning, the list of choices or the page.

Variables

static const uint8_t k_warn_pitch [] = { 28, 26, 24, 22, LINE_H }
 A warning page's pitches between its lines, the widest that fits first: a line of one row at 28px leaves 8px under a row of KP_FONT.
static char s_msg [KST_PANEL_MSG_LINES][KST_PANEL_LINE]
 Static: the message's lines, written on the UI task's deepest path.
static notes_plan_t s_plan
 Static: the notes are planned on the UI task's deepest path. One plan serves the draw and every query; none of them calls another.

Detailed Description

The drawing of the programmer's overlay.

The drawing of the programmer's overlay for KST and Chaservo servos: the notes under a page – the standing message, the state line, a page of notes and the message – and the pages, their rows, the list of choices and the warning pages. The state and the seam are kst_panel_int.h.

SPDX-License-Identifier: MIT

Function Documentation

◆ kp_button()

void kp_button ( gfx_canvas_t * c,
gfx_rect_t r,
const char * label,
gfx_color_t fill,
bool pressed,
bool enabled )
static

A button of the overlay, its label in KP_FONT.

Parameters
cthe canvas
rthe button
labelits label
fillits colour
pressedlightens the fill
enabledfalse dims it

◆ kpn_notes_paged_at()

bool kpn_notes_paged_at ( int x,
int y )

Whether (x, y) is on notes that take more than one page.

Parameters
xthe column, px
ythe row, px
Returns
true when the point is on paged notes

◆ kst_panel_button()

const char * kst_panel_button ( int page,
int row,
int col )

The text on the button of the row at page, row, col.

◆ kst_panel_note_page()

int kst_panel_note_page ( void )

The notes' page shown, from 0.

◆ kst_panel_note_pages()

int kst_panel_note_pages ( void )

The pages the open tab's notes take: 1 when they fit above the message; a tap on the notes shows the next.

◆ kst_panel_notes_drawn()

gfx_rect_t kst_panel_notes_drawn ( void )

The rows the notes and the message of the page shown are drawn in, across the area; empty for none.

◆ kst_panel_notes_rect()

gfx_rect_t kst_panel_notes_rect ( void )

The notes' area, a tap on which shows the next page; empty while the notes take one page.

◆ kst_panel_pack_notes()

int kst_panel_pack_notes ( const int * rows,
const bool * standing,
int count,
int room,
int * page )

The page each of count notes takes in room rows.

Every note is on page 0 when they fit, else on pages that keep their last row for the page count, a note never split. A note marked in standing is on page 0, and the others fill the rows left after the standing ones. With no row left beside the standing notes for the count, they yield: every note pages in pages of room - 1 rows, the standing ones first, and a note taller than that gets page -1, shown on no page until the room grows.

Parameters
rowseach note's rows
standingwhether each note stands
countthe notes
roomthe rows they have
pageout: each note's page, -1 for none
Returns
the number of pages

◆ kst_panel_render()

void kst_panel_render ( gfx_canvas_t * c)

Draws the overlay: the keypad or the keyboard alone while one is open, else the warning, the list of choices or the page.

Parameters
cthe canvas

◆ kst_panel_shown_message_lines()

int kst_panel_shown_message_lines ( void )

The lines of the last message drawn under the notes.

◆ kst_panel_shown_note()

const char * kst_panel_shown_note ( int i)

The i-th note on the page shown, from the top; NULL past the last.

◆ kst_panel_standing_line()

const char * kst_panel_standing_line ( int i)

Line i, 0 or 1, of what stands on the SERVO tab until it is dealt with; NULL where there is none.

◆ kst_panel_status_line()

const char * kst_panel_status_line ( int i)

The SERVO tab's line i under its rows: 0 the port's state, 1 what explains it; NULL where the tab draws none.

◆ rows_foot()

int rows_foot ( void )
static

The highest a note rises to: 4px under the lowest row of the tab shown, the area's top for a tab with none.

Returns
the y, body pixels