41 #define SIZEOF_ARRAY(x) (sizeof(x) / sizeof((x)[0]))
43 #define HUD_VSCALE_FLAG_CLEAR 1
44 #define HUD_VSCALE_FLAG_NO_NEGATIVE 2
46 #if defined(PIOS_VIDEO_SPLITBUFFER)
47 #define PIXELS_PER_BIT 8
48 #define CALC_BIT_IN_WORD(x) ((x) & 7)
49 #define CALC_BIT_MASK(x) (1 << (7 - ((x) & 7)))
52 #define COMPUTE_HLINE_EDGE_L_MASK(b) ((1 << (8 - (b))) - 1)
53 #define COMPUTE_HLINE_EDGE_R_MASK(b) (~((1 << (7 - (b))) - 1))
55 #if PIOS_VIDEO_BITS_PER_PIXEL != 2
56 #error "Only 2 bits / pixel is currently supported"
58 #define PIXELS_PER_BIT (8 / PIOS_VIDEO_BITS_PER_PIXEL)
59 #define CALC_BIT_IN_WORD(x) (2 * ((x) & 3))
60 #define CALC_BITSHIFT_WORD(x) (2 * ((x) & 3))
61 #define CALC_BIT_MASK(x) (3 << (6 - CALC_BITSHIFT_WORD(x)))
62 #define PACK_BITS(mask, level) (level << 7 | mask << 6 | level << 5 | mask << 4 | level << 3 | mask << 2 | level << 1 | mask)
63 #define CALC_BIT0_IN_WORD(x) (2 * ((x) & 3))
64 #define CALC_BIT1_IN_WORD(x) (2 * ((x) & 3) + 1)
67 #define COMPUTE_HLINE_EDGE_L_MASK(b) ((1 << (7 - (b))) - 1)
68 #define COMPUTE_HLINE_EDGE_R_MASK(b) (~((1 << (6 - (b))) - 1))
72 #define CALC_BUFF_ADDR(x, y) (((x) / PIXELS_PER_BIT) + ((y) * BUFFER_WIDTH))
76 #define WRITE_WORD_MODE(buff, addr, mask, mode) \
78 case 0: buff[addr] &= ~mask; break; \
79 case 1: buff[addr] |= mask; break; \
80 case 2: buff[addr] ^= mask; break; }
82 #define WRITE_WORD_NAND(buff, addr, mask) { buff[addr] &= ~mask; DEBUG_DELAY; }
83 #define WRITE_WORD_OR(buff, addr, mask) { buff[addr] |= mask; DEBUG_DELAY; }
84 #define WRITE_WORD_XOR(buff, addr, mask) { buff[addr] ^= mask; DEBUG_DELAY; }
85 #define WRITE_WORD(buff, addr, mask, value) { buff[addr] = (buff[addr] & ~mask) | (value & mask);}
89 #define COMPUTE_HLINE_ISLAND_MASK(b0, b1) (COMPUTE_HLINE_EDGE_L_MASK(b0) ^ COMPUTE_HLINE_EDGE_L_MASK(b1));
93 #define SETUP_STROKE_FILL(stroke, fill, mode) \
94 stroke = 0; fill = 0; \
95 if (mode == 0) { stroke = 0; fill = 1; } \
96 if (mode == 1) { stroke = 1; fill = 0; } \
100 #define ENDCAP_ROUND 1
101 #define ENDCAP_FLAT 2
103 #define DRAW_ENDCAP_HLINE(e, x, y, s, f, l) \
104 if ((e) == ENDCAP_ROUND) \
105 { write_pixel_lm(x, y, f, l); } \
106 else if ((e) == ENDCAP_FLAT) \
107 { write_pixel_lm(x, y - 1, s, l); write_pixel_lm(x, y, s, l); write_pixel_lm(x, y + 1, s, l); }
109 #define DRAW_ENDCAP_VLINE(e, x, y, s, f, l) \
110 if ((e) == ENDCAP_ROUND) \
111 { write_pixel_lm(x, y, f, l); } \
112 else if ((e) == ENDCAP_FLAT) \
113 { write_pixel_lm(x - 1, y, s, l); write_pixel_lm(x, y, s, l); write_pixel_lm(x + 1, y, s, l); }
116 #define CIRCLE_PLOT_8(buff, cx, cy, x, y, mode) \
117 CIRCLE_PLOT_4(buff, cx, cy, x, y, mode); \
118 if ((x) != (y)) { CIRCLE_PLOT_4(buff, cx, cy, y, x, mode); }
120 #define CIRCLE_PLOT_4(buff, cx, cy, x, y, mode) \
121 write_pixel(buff, (cx) + (x), (cy) + (y), mode); \
122 write_pixel(buff, (cx) - (x), (cy) + (y), mode); \
123 write_pixel(buff, (cx) + (x), (cy) - (y), mode); \
124 write_pixel(buff, (cx) - (x), (cy) - (y), mode);
127 #define FONT_BOLD 1 // bold text (no outline)
128 #define FONT_INVERT 2 // invert: border white, inside black
130 #define TEXT_VA_TOP 0
131 #define TEXT_VA_MIDDLE 1
132 #define TEXT_VA_BOTTOM 2
133 #define TEXT_HA_LEFT 0
134 #define TEXT_HA_CENTER 1
135 #define TEXT_HA_RIGHT 2
138 #define MAX3(a, b, c) MAX(a, MAX(b, c))
139 #define MIN3(a, b, c) MIN(a, MIN(b, c))
140 #define LIMIT(x, l, h) MAX(l, MIN(x, h))
143 #define CHECK_COORDS(x, y) if (x < GRAPHICS_LEFT || x > GRAPHICS_RIGHT || y < GRAPHICS_TOP || y > GRAPHICS_BOTTOM) { return; }
144 #define CHECK_COORD_X(x) if (x < GRAPHICS_LEFT || x > GRAPHICS_RIGHT) { return; }
145 #define CHECK_COORD_Y(y) if (y < GRAPHICS_TOP || y > GRAPHICS_BOTTOM) { return; }
148 #define CLIP_COORDS(x, y) { CLIP_COORD_X(x); CLIP_COORD_Y(y); }
149 #define CLIP_COORD_X(x) { x = x < GRAPHICS_LEFT ? GRAPHICS_LEFT : x > GRAPHICS_RIGHT ? GRAPHICS_RIGHT : x; }
150 #define CLIP_COORD_Y(y) { y = y < GRAPHICS_TOP ? GRAPHICS_TOP : y > GRAPHICS_BOTTOM ? GRAPHICS_BOTTOM : y; }
153 #define SWAP(a, b) { a ^= b; b ^= a; a ^= b; }
169 void plotFourQuadrants(int32_t centerX, int32_t centerY, int32_t deltaX, int32_t deltaY);
170 void ellipse(
int centerX,
int centerY,
int horizontalRadius,
int verticalRadius);
171 void drawArrow(uint16_t x, uint16_t y, uint16_t angle, uint16_t size_quarter);
172 void drawBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
182 void write_line_lm(
int x0,
int y0,
int x1,
int y1,
int mmode,
int lmode);
185 int mode,
int mmode);
188 int mode,
int mmode,
int dots);
192 void draw_polygon(int16_t x, int16_t y,
float angle,
const point_t * points, uint8_t n_points,
int mode,
int mmode);
void write_string(char *str, int x, int y, int xs, int ys, int va, int ha, int flags, int font)
void write_circle_outlined(int cx, int cy, int r, int dashp, int bmode, int mode, int mmode)
void draw_polygon(int16_t x, int16_t y, float angle, const point_t *points, uint8_t n_points, int mode, int mmode)
void write_vline_lm(int x, int y0, int y1, int lmode, int mmode)
void write_vline_outlined(int x, int y0, int y1, int endcap0, int endcap1, int mode, int mmode)
void draw_image(uint16_t x, uint16_t y, const struct Image *image)
OSD gen module, handles OSD draw. Parts from CL-OSD and SUPEROSD projects.
void write_rectangle_outlined(int x, int y, int width, int height, int mode, int mmode)
void write_line_outlined_dashed(int x0, int y0, int x1, int y1, __attribute__((unused)) int endcap0, __attribute__((unused)) int endcap1, int mode, int mmode, int dots)
void write_line_outlined(int x0, int y0, int x1, int y1, __attribute__((unused)) int endcap0, __attribute__((unused)) int endcap1, int mode, int mmode)
void calc_text_dimensions(char *str, const struct FontEntry *font, int xs, int ys, struct FontDimensions *dim)
void write_line_lm(int x0, int y0, int x1, int y1, int mmode, int lmode)
void plotFourQuadrants(int32_t centerX, int32_t centerY, int32_t deltaX, int32_t deltaY)
void write_hline_outlined(int x0, int x1, int y, int endcap0, int endcap1, int mode, int mmode)
void drawBox(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2)
const struct FontEntry * get_font_info(int font)
Includes PiOS and core architecture components.
void ellipse(int centerX, int centerY, int horizontalRadius, int verticalRadius)
void drawArrow(uint16_t x, uint16_t y, uint16_t angle, uint16_t size_quarter)
void write_hline_lm(int x0, int x1, int y, int lmode, int mmode)
void write_filled_rectangle_lm(int x, int y, int width, int height, int lmode, int mmode)
void lla_to_ned(int32_t lat, int32_t lon, float alt, float *NED)
void write_pixel_lm(int x, int y, int mmode, int lmode)