Brick Groove Machine 0.9.3
Firmware embarqué pour contrôleur/synthé Brick
 
Chargement...
Recherche...
Aucune correspondance
ui_primitives.h
Aller à la documentation de ce fichier.
1
16#ifndef BRICK_SOMEPATH_SOMEFILE_H
17#define BRICK_SOMEPATH_SOMEFILE_H
18
19#include <drv_display.h>
20#include <stdint.h>
21#include <stdbool.h>
22
23/* ============================================================
24 * Fonctions de base : pixels et lignes
25 * ============================================================ */
26
34static inline void ui_px(int x, int y, bool on) {
35 if (x < 0 || x >= OLED_WIDTH || y < 0 || y >= OLED_HEIGHT) return;
36 uint8_t *buf = drv_display_get_buffer();
37 const int index = x + (y >> 3) * OLED_WIDTH;
38 const uint8_t mask = (uint8_t)(1u << (y & 7));
39 if (on) buf[index] |= mask;
40 else buf[index] &= (uint8_t)~mask;
41}
42
51static inline void ui_hline(int x, int y, int w, bool on) {
52 for (int i = 0; i < w; ++i)
53 ui_px(x + i, y, on);
54}
55
64static inline void ui_vline(int x, int y, int h, bool on) {
65 for (int i = 0; i < h; ++i)
66 ui_px(x, y + i, on);
67}
68
69/* ============================================================
70 * Formes rectangulaires
71 * ============================================================ */
72
82static inline void ui_rect(int x, int y, int w, int h, bool on) {
83 if (w <= 0 || h <= 0) return;
84 ui_hline(x, y, w, on);
85 ui_hline(x, y + h - 1, w, on);
86 ui_vline(x, y, h, on);
87 ui_vline(x + w - 1, y, h, on);
88}
89
99static inline void ui_fill_rect(int x, int y, int w, int h, bool on) {
100 for (int yy = 0; yy < h; ++yy)
101 ui_hline(x, y + yy, w, on);
102}
103
104/* ============================================================
105 * Blitting (copie de bitmaps 1bpp)
106 * ============================================================ */
107
120static inline void ui_blit_mono(int x, int y, int w, int h,
121 const uint8_t *bits, int stride_bytes) {
122 for (int yy = 0; yy < h; ++yy) {
123 const uint8_t *row = bits + yy * stride_bytes;
124 int xx = 0;
125 for (int b = 0; b < stride_bytes && xx < w; ++b) {
126 uint8_t v = row[b];
127 for (int bit = 7; bit >= 0 && xx < w; --bit, ++xx) {
128 bool on = ((v >> bit) & 1u) != 0;
129 ui_px(x + xx, y + yy, on);
130 }
131 }
132 }
133}
134#endif /* BRICK_UI_PRIMITIVES_H */
uint8_t * drv_display_get_buffer(void)
Retourne un pointeur sur le framebuffer interne.
Definition drv_display.c:86
Interface du driver OLED SPI SSD1309 (128×64) pour Brick.
#define OLED_HEIGHT
Hauteur en pixels de l’écran OLED.
Definition drv_display.h:35
#define OLED_WIDTH
Largeur en pixels de l’écran OLED.
Definition drv_display.h:32