Noise Nugget SDK
Loading...
Searching...
No Matches
pgb1.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 Fabien Chouteau @ Wee Noise Makers
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
14#pragma once
15#include "pico/stdlib.h"
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21// Keyboard key definitions
22#define K_TRACK 0x10000000
23#define K_STEP 0x08000000
24#define K_PLAY 0x02000000
25#define K_REC 0x04000000
26#define K_ALT 0x00040000
27#define K_PATT 0x00001000
28#define K_SONG 0x00000040
29#define K_MENU 0x00000020
30#define K_UP 0x00020000
31#define K_DOWN 0x00800000
32#define K_RIGHT 0x00000800
33#define K_LEFT 0x20000000
34#define K_A 0x01000000
35#define K_B 0x00000001
36#define K_1 0x00400000
37#define K_2 0x00010000
38#define K_3 0x00000400
39#define K_4 0x00000010
40#define K_5 0x00000002
41#define K_6 0x00000080
42#define K_7 0x00002000
43#define K_8 0x00080000
44#define K_9 0x00200000
45#define K_10 0x00008000
46#define K_11 0x00000200
47#define K_12 0x00000008
48#define K_13 0x00000004
49#define K_14 0x00000100
50#define K_15 0x00004000
51#define K_16 0x00100000
52
53
57void keyboard_init(void);
58
62void keyboard_scan(void);
63
69bool pressed(uint32_t key);
70
76bool falling(uint32_t key);
77
78
84bool raising(uint32_t key);
85
86#define PGB1_LEDS_COUNT 24
87
91void leds_init(void);
92
96void leds_clear(void);
97
102bool leds_update(void);
103
108typedef struct LedColor {
109 uint8_t r;
110 uint8_t g;
111 uint8_t b;
112} LedColor;
113
114#define White (LedColor){255 / 8, 255 / 8, 255 / 8}
115#define Red (LedColor){255 / 8, 000 / 8, 000 / 8}
116#define Rose (LedColor){255 / 8, 000 / 8, 128 / 8}
117#define Magenta (LedColor){255 / 8, 000 / 8, 255 / 8}
118#define Violet (LedColor){128 / 8, 000 / 8, 255 / 8}
119#define Blue (LedColor){000 / 8, 000 / 8, 255 / 8}
120#define Azure (LedColor){000 / 8, 128 / 8, 255 / 8}
121#define Cyan (LedColor){000 / 8, 255 / 8, 255 / 8}
122#define Spring_Green (LedColor){000 / 8, 255 / 8, 128 / 8}
123#define Green (LedColor){000 / 8, 255 / 8, 000 / 8}
124#define Chartreuse (LedColor){128 / 8, 255 / 8, 000 / 8}
125#define Yellow (LedColor){255 / 8, 255 / 8, 000 / 8}
126#define Orange (LedColor){255 / 8, 128 / 8, 000 / 8}
127
136void leds_set_rgb(int id, uint8_t r, uint8_t g, uint8_t b);
137
144void leds_set_color(int id, LedColor rgb);
145
149void screen_init(void);
150
154void screen_clear(void);
155
160bool screen_update(void);
161
169void screen_set_pixel(int x, int y, bool set);
170
180void screen_draw_line(int x0, int y0, int x1, int y1, bool set);
181
188void screen_printc(int x, int y, char c);
189
196void screen_print(int x, int y, const char *str);
197
204typedef void (*midi_in_cb_t)(uint32_t msg);
205
211void midi_init(midi_in_cb_t cb);
212
213#ifdef __cplusplus
214}
215#endif
void midi_init(midi_in_cb_t cb)
Initializes the MIDI interface with a callback for incoming messages.
Definition pgb1.c:362
void screen_clear(void)
Clears the OLED screen to a blank state.
Definition pgb1.c:252
void screen_set_pixel(int x, int y, bool set)
Sets or clears a pixel on the screen.
Definition pgb1.c:269
bool falling(uint32_t key)
Checks if a key has transitioned from not-pressed to pressed state.
Definition pgb1.c:79
bool raising(uint32_t key)
Checks if a key has transitioned from pressed to not-pressed state.
Definition pgb1.c:84
bool leds_update(void)
Updates the LED states to the device.
Definition pgb1.c:106
void keyboard_init(void)
Initializes the keyboard interface.
Definition pgb1.c:33
void screen_print(int x, int y, const char *str)
Prints a string at a specified position on the screen.
Definition pgb1.c:336
void leds_init(void)
Initializes the LED subsystem.
Definition pgb1.c:92
void leds_set_color(int id, LedColor rgb)
Sets an individual LED internal state to a predefined color. The new state will be visible after a ca...
Definition pgb1.c:131
bool screen_update(void)
Updates the screen with the current graphics buffer.
Definition pgb1.c:256
void leds_clear(void)
Clears all LEDs to off state.
Definition pgb1.c:119
void screen_printc(int x, int y, char c)
Prints a single character at a specified position on the screen.
Definition pgb1.c:321
void screen_draw_line(int x0, int y0, int x1, int y1, bool set)
Draws a line between two points on the screen.
Definition pgb1.c:281
void screen_init(void)
Initializes the OLED screen.
Definition pgb1.c:207
void keyboard_scan(void)
Scans the keyboard state and updates internal key state tracking.
Definition pgb1.c:51
bool pressed(uint32_t key)
Checks if a key is currently pressed.
Definition pgb1.c:75
void leds_set_rgb(int id, uint8_t r, uint8_t g, uint8_t b)
Sets an individual LED internal state to a specific RGB color. The new state will be visible after a ...
Definition pgb1.c:123
void(* midi_in_cb_t)(uint32_t msg)
Type definition for MIDI input callback functions.
Definition pgb1.h:204
Represents an RGB color value.
Definition pgb1.h:108
uint8_t b
Blue component.
Definition pgb1.h:111
uint8_t g
Green component.
Definition pgb1.h:110
uint8_t r
Red component.
Definition pgb1.h:109