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// Keyboard key definitions
18#define K_TRACK 0x10000000
19#define K_STEP 0x08000000
20#define K_PLAY 0x02000000
21#define K_REC 0x04000000
22#define K_ALT 0x00040000
23#define K_PATT 0x00001000
24#define K_SONG 0x00000040
25#define K_MENU 0x00000020
26#define K_UP 0x00020000
27#define K_DOWN 0x00800000
28#define K_RIGHT 0x00000800
29#define K_LEFT 0x20000000
30#define K_A 0x01000000
31#define K_B 0x00000001
32#define K_1 0x00400000
33#define K_2 0x00010000
34#define K_3 0x00000400
35#define K_4 0x00000010
36#define K_5 0x00000002
37#define K_6 0x00000080
38#define K_7 0x00002000
39#define K_8 0x00080000
40#define K_9 0x00200000
41#define K_10 0x00008000
42#define K_11 0x00000200
43#define K_12 0x00000008
44#define K_13 0x00000004
45#define K_14 0x00000100
46#define K_15 0x00004000
47#define K_16 0x00100000
48
49
53void keyboard_init(void);
54
58void keyboard_scan(void);
59
65bool pressed(uint32_t key);
66
72bool falling(uint32_t key);
73
74
80bool raising(uint32_t key);
81
82#define PGB1_LEDS_COUNT 24
83
87void leds_init(void);
88
92void leds_clear(void);
93
98bool leds_update(void);
99
104typedef struct LedColor {
105 uint8_t r;
106 uint8_t g;
107 uint8_t b;
108} LedColor;
109
110#define White (LedColor){255 / 8, 255 / 8, 255 / 8}
111#define Red (LedColor){255 / 8, 000 / 8, 000 / 8}
112#define Rose (LedColor){255 / 8, 000 / 8, 128 / 8}
113#define Magenta (LedColor){255 / 8, 000 / 8, 255 / 8}
114#define Violet (LedColor){128 / 8, 000 / 8, 255 / 8}
115#define Blue (LedColor){000 / 8, 000 / 8, 255 / 8}
116#define Azure (LedColor){000 / 8, 128 / 8, 255 / 8}
117#define Cyan (LedColor){000 / 8, 255 / 8, 255 / 8}
118#define Spring_Green (LedColor){000 / 8, 255 / 8, 128 / 8}
119#define Green (LedColor){000 / 8, 255 / 8, 000 / 8}
120#define Chartreuse (LedColor){128 / 8, 255 / 8, 000 / 8}
121#define Yellow (LedColor){255 / 8, 255 / 8, 000 / 8}
122#define Orange (LedColor){255 / 8, 128 / 8, 000 / 8}
123
132void leds_set_rgb(int id, uint8_t r, uint8_t g, uint8_t b);
133
140void leds_set_color(int id, LedColor rgb);
141
145void screen_init(void);
146
150void screen_clear(void);
151
156bool screen_update(void);
157
165void screen_set_pixel(int x, int y, bool set);
166
176void screen_draw_line(int x0, int y0, int x1, int y1, bool set);
177
184void screen_printc(int x, int y, char c);
185
192void screen_print(int x, int y, const char *str);
193
200typedef void (*midi_in_cb_t)(uint32_t msg);
201
207void midi_init(midi_in_cb_t cb);
208
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:200
Represents an RGB color value.
Definition pgb1.h:104
uint8_t b
Blue component.
Definition pgb1.h:107
uint8_t g
Green component.
Definition pgb1.h:106
uint8_t r
Red component.
Definition pgb1.h:105