Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
rpisensehat.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_RPISENSEHAT_H
27#define _ULTIBO_RPISENSEHAT_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/i2c.h"
35#include "ultibo/keyboard.h"
36#include "ultibo/framebuffer.h"
37
39#define RPISENSE_SIGNATURE 0xEAEBECED
40
42#define RPISENSE_FRAMEBUFFER_DESCRIPTION "Raspberry Pi Sense HAT Framebuffer"
43
44#define RPISENSE_PHYSICAL_WIDTH 8
45#define RPISENSE_PHYSICAL_HEIGHT 8
46
48#define RPISENSE_JOYSTICK_DESCRIPTION "Raspberry Pi Sense HAT Joystick"
49
50static const uint16_t RPISENSE_JOYSTICK_KEYMAP[5] = {
56
58#define RPISENSE_FB 0x00
59#define RPISENSE_WAI 0xF0
60#define RPISENSE_VER 0xF1
61#define RPISENSE_KEYS 0xF2
62#define RPISENSE_EE_WP 0xF3
63
65#define RPISENSE_GAMMA_VALUES_DEFAULT 0
66#define RPISENSE_GAMMA_VALUES_LOW 1
67#define RPISENSE_GAMMA_VALUES_USER 2
68
70typedef struct _RPISENSE RPISENSE;
79
82{
83 // Framebuffer Properties
85 // RPiSense Properties
87 uint32_t width;
88 uint32_t height;
89 uint32_t rotation;
90 uint32_t dirtyy1;
91 uint32_t dirtyy2;
96 uint32_t framerate;
97 uint8_t gamma[32];
98 uint8_t gammauser[32];
99 uint16_t pixeldata[64];
100 uint8_t blockdata[193];
101};
102
103
106{
107 // Keyboard Properties
109 // RPiSense Properties
112 uint32_t pin;
113 uint32_t trigger;
114 int32_t previouskeys;
115 // Statistics Properties
116 uint32_t callbackcount;
117};
118
120
130HANDLE STDCALL rpisense_start(char *i2cdevice, char *gpiodevice, uint32_t rotation, uint32_t width, uint32_t height);
131
138
139#ifdef __cplusplus
140}
141#endif
142
143#endif // _ULTIBO_RPISENSEHAT_H
struct _FRAMEBUFFER_DEVICE FRAMEBUFFER_DEVICE
Definition framebuffer.h:112
#define SCAN_CODE_RIGHT_ARROW
Keyboard Right Arrow.
Definition globalconst.h:654
#define SCAN_CODE_UP_ARROW
Keyboard Up Arrow.
Definition globalconst.h:657
#define SCAN_CODE_DOWN_ARROW
Keyboard Down Arrow.
Definition globalconst.h:656
#define SCAN_CODE_ENTER
Keyboard Enter).
Definition globalconst.h:615
#define SCAN_CODE_LEFT_ARROW
Keyboard Left Arrow.
Definition globalconst.h:655
int32_t LONGBOOL
Compatibility with FPC LongBool type (4 bytes).
Definition globaltypes.h:56
size_t HANDLE
Definition globaltypes.h:51
#define STDCALL
Definition globaltypes.h:45
_Bool BOOL
Built in Boolean type (1 byte) (Redeclared here for flexibility).
Definition globaltypes.h:55
HANDLE TIMER_HANDLE
Definition globaltypes.h:119
HANDLE MUTEX_HANDLE
Definition globaltypes.h:105
struct _GPIO_DEVICE GPIO_DEVICE
Forward declared for GPIOPin.
Definition gpio.h:85
struct _I2C_DEVICE I2C_DEVICE
Definition i2c.h:81
struct _KEYBOARD_DEVICE KEYBOARD_DEVICE
Definition keyboard.h:203
struct _RPISENSE_JOYSTICK RPISENSE_JOYSTICK
Definition rpisensehat.h:104
HANDLE STDCALL rpisense_start(char *i2cdevice, char *gpiodevice, uint32_t rotation, uint32_t width, uint32_t height)
Create, register and allocate a new RPiSenseHat Framebuffer device which can be accessed using the fr...
BOOL STDCALL rpisense_stop(HANDLE handle)
Release, deregister and destroy an RPiSenseHat Framebuffer device created by this driver.
struct _RPISENSE_FRAMEBUFFER RPISENSE_FRAMEBUFFER
Definition rpisensehat.h:80
struct _RPISENSE RPISENSE
Definition rpisensehat.h:70
Definition rpisensehat.h:82
uint8_t gamma[32]
Current gamma values.
Definition rpisensehat.h:97
MUTEX_HANDLE lock
Lock for dirty region redraw.
Definition rpisensehat.h:94
uint8_t gammauser[32]
User gamma values.
Definition rpisensehat.h:98
I2C_DEVICE * i2c
The I2C device the device is connected to.
Definition rpisensehat.h:86
uint32_t width
Framebuffer Width in Pixels (Virtual).
Definition rpisensehat.h:87
uint32_t height
Framebuffer Height in Pixels (Virtual).
Definition rpisensehat.h:88
uint32_t framerate
Frame rate for display refresh (in Frames Per Second).
Definition rpisensehat.h:96
uint8_t blockdata[193]
Block data for display update.
Definition rpisensehat.h:100
LONGBOOL ready
If True timer should be enabled during Mark operation.
Definition rpisensehat.h:92
uint16_t pixeldata[64]
Pixel data for framebuffer update.
Definition rpisensehat.h:99
FRAMEBUFFER_DEVICE framebuffer
Definition rpisensehat.h:84
LONGBOOL blank
If True then display is currently blanked.
Definition rpisensehat.h:93
uint32_t rotation
Framebuffer Rotation (eg FRAMEBUFFER_ROTATION_180).
Definition rpisensehat.h:89
uint32_t dirtyy2
Last line of dirty region (or 0 if none dirty).
Definition rpisensehat.h:91
TIMER_HANDLE timer
Handle for dirty region redraw timer.
Definition rpisensehat.h:95
uint32_t dirtyy1
First line of dirty region (or Height - 1 if none dirty).
Definition rpisensehat.h:90
Definition rpisensehat.h:106
GPIO_DEVICE * gpio
The GPIO device the device is connected to.
Definition rpisensehat.h:111
uint32_t pin
The GPIO pin used to signal joystick events (GPIO_PIN_23).
Definition rpisensehat.h:112
I2C_DEVICE * i2c
The I2C device the device is connected to.
Definition rpisensehat.h:110
uint32_t callbackcount
Number of callback requests received by the device.
Definition rpisensehat.h:116
KEYBOARD_DEVICE keyboard
Definition rpisensehat.h:108
int32_t previouskeys
The keys pressed on the last GPIO event callback.
Definition rpisensehat.h:114
uint32_t trigger
The GPIO trigger to detect joystick events (GPIO_TRIGGER_RISING).
Definition rpisensehat.h:113
Definition rpisensehat.h:72
GPIO_DEVICE * gpio
GPIO device.
Definition rpisensehat.h:75
I2C_DEVICE * i2c
I2C device.
Definition rpisensehat.h:74
FRAMEBUFFER_DEVICE * framebuffer
Framebuffer device.
Definition rpisensehat.h:76
KEYBOARD_DEVICE * joystick
Joystick (Keyboard) device.
Definition rpisensehat.h:77
uint32_t signature
Signature for entry validation.
Definition rpisensehat.h:73