rcbench
Servo and ESC test bench: panel, IOmcu and shared C
Loading...
Searching...
No Matches
ui_cats.h
Go to the documentation of this file.
1
24
25#pragma once
26
27#include <stdbool.h>
28#include <stdint.h>
29
30#include "gfx.h"
31#include "gfx_sprite.h"
32#include "ui_cats_art.h"
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
39#define UI_CAT_IN(spot) (1u << (unsigned)(spot))
40
43#define UI_CAT_GAP 4
44
46#define UI_CAT_RANDOM (-1)
48#define UI_CAT_NONE (-2)
49
51typedef struct {
52 const char *name;
54 uint32_t spots;
56
59
65
67typedef struct {
69 int16_t x;
70 int16_t y;
73
76typedef struct {
77 int8_t pose;
78 int8_t spot;
80
82#define UI_CAT_PICK_NONE ((ui_cat_pick_t){ UI_CAT_NONE, UI_CAT_NONE })
83
89typedef bool (*ui_cat_clear_fn)(gfx_rect_t r);
90
97gfx_rect_t ui_cat_rect(int pose, const ui_cat_spot_t *spot);
98
114ui_cat_pick_t ui_cats_pick(const ui_cat_spot_t *spots, int n,
115 ui_cat_clear_fn clear, uint32_t roll);
116
126 const ui_cat_spot_t *spots, int n);
127
132typedef uint32_t (*ui_cats_random_fn)(void);
133
140
145void ui_cats_seed(uint32_t seed);
146
151uint32_t ui_cats_roll(void);
152
158void ui_cats_force(int pose);
159
164int ui_cats_forced(void);
165
166#ifdef __cplusplus
167}
168#endif
gfx: an RGB565 (16-bit red, green, blue) rasteriser with no dependencies.
A sprite: an image with alpha, run-length encoded, blended onto a canvas.
Definition gfx.h:129
Definition gfx.h:81
An encoded image with alpha.
Definition gfx_sprite.h:58
A pick: a pose and the index of its spot in the screen's list, or both UI_CAT_NONE.
Definition ui_cats.h:76
int8_t spot
Definition ui_cats.h:78
int8_t pose
Definition ui_cats.h:77
One pose: its drawing and the spots it may take.
Definition ui_cats.h:51
uint32_t spots
Definition ui_cats.h:54
gfx_sprite_t art
Definition ui_cats.h:53
const char * name
Definition ui_cats.h:52
A free place on one screen, where a cat stands on a line.
Definition ui_cats.h:67
int16_t y
Definition ui_cats.h:70
ui_cat_spot_id_t id
Definition ui_cats.h:68
int16_t x
Definition ui_cats.h:69
ui_cat_side_t side
Definition ui_cats.h:71
bool(*) ui_cat_clear_fn(gfx_rect_t r)
Whether a screen has nothing within UI_CAT_GAP of a box.
Definition ui_cats.h:89
uint32_t(*) ui_cats_random_fn(void)
The source of random numbers.
Definition ui_cats.h:132
gfx_rect_t ui_cat_rect(int pose, const ui_cat_spot_t *spot)
The box pose pose covers in spot.
Definition ui_cats.c:50
gfx_rect_t ui_cats_draw(gfx_canvas_t *c, ui_cat_pick_t pick, const ui_cat_spot_t *spots, int n)
Draw a pick.
Definition ui_cats.c:140
ui_cat_side_t
Which corner of the cat a spot's point holds.
Definition ui_cats.h:61
@ UI_CAT_FROM_RIGHT
Definition ui_cats.h:63
@ UI_CAT_FROM_LEFT
Definition ui_cats.h:62
void ui_cats_set_random(ui_cats_random_fn fn)
Name the source ui_cats_roll() reads.
Definition ui_cats.c:24
const ui_cat_pose_t ui_cat_poses[UI_CAT_POSES]
Every pose; ui_cats_art.c, generated by tools/gen_cats.py.
Definition ui_cats_art.c:7408
ui_cat_pick_t ui_cats_pick(const ui_cat_spot_t *spots, int n, ui_cat_clear_fn clear, uint32_t roll)
Pick a pose among the ones with a clear spot, and that spot.
Definition ui_cats.c:114
int ui_cats_forced(void)
The pose ui_cats_force() set.
Definition ui_cats.c:48
uint32_t ui_cats_roll(void)
The next random number from the source.
Definition ui_cats.c:28
void ui_cats_force(int pose)
Put one pose, or none, in place of the random pick.
Definition ui_cats.c:42
void ui_cats_seed(uint32_t seed)
Seed the built-in xorshift.
Definition ui_cats.c:26
The number of cat poses and the spots they take: the part of ui_cats.h tools/gen_cats....
ui_cat_spot_id_t
The free places on the screens a cat may take.
Definition ui_cats_art.h:16
#define UI_CAT_POSES
The poses in ui_cat_poses[], 8.
Definition ui_cats_art.h:13