Unit RPISENSEHAT
Return to Unit Reference
Description
Raspberry Pi SenstHat Driver unit
The SenseHAT 8x8 LED matrix is presented in Ultibo as an 8x8 pixel framebuffer. This allows full access to the display at both the individual pixel level and also using the higher level console functions to display text and graphics on the matrix.
The framebuffer device supports rotation around the full 360 degrees by supplying the required rotation value in the framebuffer properties when calling FramebufferAllocate() or by calling the SenseHAT specific function RPiSenseFramebufferSetRotation().
As per the official Python libraries, the default rotation (FRAMEBUFFER_ROTATION_0) gives correct viewing when the HDMI port is facing downwards.
The SenseHAT joystick appears as a keyboard device and the pressed buttons are received as key presses that represent the Left, Right, Up, Down and Enter keys.
Constants
RPISENSE_*
RPISENSE_SIGNATURE = $EAEBECED;
|
RPISENSE_FRAMEBUFFER_*
RPISENSE_FRAMEBUFFER_DESCRIPTION = 'Raspberry Pi Sense HAT Framebuffer';
|
Description of RPiSense framebuffer device |
RPISENSE_PHYSICAL_WIDTH = 8;
|
|
RPISENSE_PHYSICAL_HEIGHT = 8;
|
RPISENSE_JOYSTICK_*
RPISENSE_JOYSTICK_DESCRIPTION = 'Raspberry Pi Sense HAT Joystick';
|
Description of RPiSense joystick device |
RPISENSE_JOYSTICK_KEYMAP:array[0..4] of Word = (
| |
SCAN_CODE_DOWN_ARROW,
|
|
SCAN_CODE_RIGHT_ARROW,
|
|
SCAN_CODE_UP_ARROW,
|
|
SCAN_CODE_ENTER,
|
|
SCAN_CODE_LEFT_ARROW
|
RPISENSE_FB*
RPISENSE_FB = $00;
|
|
RPISENSE_WAI = $F0;
|
|
RPISENSE_VER = $F1;
|
|
RPISENSE_KEYS = $F2;
|
|
RPISENSE_EE_WP = $F3;
|
RPISENSE_GAMMA_*
RPISENSE_GAMMA_VALUES_DEFAULT = 0;
|
|
RPISENSE_GAMMA_VALUES_LOW = 1;
|
|
RPISENSE_GAMMA_VALUES_USER = 2;
|
Type definitions
RPi sense
PRPiSense = ^TRPiSense;
TRPiSense = record
Signature:LongWord;
|
Signature for entry validation |
I2C:PI2CDevice;
|
I2C device |
GPIO:PGPIODevice;
|
GPIO device |
Framebuffer:PFramebufferDevice;
|
Framebuffer device |
Joystick:PKeyboardDevice;
|
Joystick (Keyboard) device |
RPi sense gamma
PRPiSenseGamma = ^TRPiSenseGamma;
TRPiSenseGamma = array[0..31] of Byte;
RPi sense framebuffer
PRPiSenseFramebuffer = ^TRPiSenseFramebuffer;
TRPiSenseFramebuffer = record
Framebuffer Properties | |
Framebuffer:TFramebufferDevice;
|
|
RPiSense Properties | |
I2C:PI2CDevice;
|
The I2C device the device is connected to |
Width:LongWord;
|
Framebuffer Width in Pixels (Virtual) |
Height:LongWord;
|
Framebuffer Height in Pixels (Virtual) |
Rotation:LongWord;
|
Framebuffer Rotation (eg FRAMEBUFFER_ROTATION_180) |
DirtyY1:LongWord;
|
First line of dirty region (or Height - 1 if none dirty) |
DirtyY2:LongWord;
|
Last line of dirty region (or 0 if none dirty) |
Ready:LongBool;
|
If True timer should be enabled during Mark operation |
Blank:LongBool;
|
If True then display is currently blanked |
Lock:TMutexHandle;
|
Lock for dirty region redraw |
Timer:TTimerHandle;
|
Handle for dirty region redraw timer |
FrameRate:LongWord;
|
Frame rate for display refresh (in Frames Per Second) |
Gamma:TRPiSenseGamma;
|
Current gamma values |
GammaUser:TRPiSenseGamma;
|
User gamma values |
PixelData:array[0..63] of Word;
|
Pixel data for framebuffer update |
BlockData:array[0..192] of Byte;
|
Block data for display update |
RPi sense joystick
PRPiSenseJoystick = ^TRPiSenseJoystick;
TRPiSenseJoystick = record
Keyboard Properties | |
Keyboard:TKeyboardDevice;
|
|
RPiSense Properties | |
I2C:PI2CDevice;
|
The I2C device the device is connected to |
GPIO:PGPIODevice;
|
The GPIO device the device is connected to |
Pin:LongWord;
|
The GPIO pin used to signal joystick events (GPIO_PIN_23) |
Trigger:LongWord;
|
The GPIO trigger to detect joystick events (GPIO_TRIGGER_RISING) |
PreviousKeys:LongInt;
|
The keys pressed on the last GPIO event callback |
Statistics Properties | |
CallbackCount:LongWord;
|
Number of callback requests received by the device |
Public variables
RPiSenseHat specific variables
RPISENSE_I2C_DEVICE:String = 'I2C0';
|
RPISENSE_GPIO_DEVICE:String = 'GPIO0';
|
RPISENSE_FRAMEBUFFER_ROTATION:LongWord = FRAMEBUFFER_ROTATION_0;
|
RPISENSE_FRAMEBUFFER_WIDTH:LongWord = RPISENSE_PHYSICAL_WIDTH;
|
RPISENSE_FRAMEBUFFER_HEIGHT:LongWord = RPISENSE_PHYSICAL_HEIGHT;
|
RPISENSE_I2C_ADDRESS:Word = $46;
|
RPISENSE_LSM9DS1_MAGN_ADDRESS:Word = $1C;
|
RPISENSE_LSM9DS1_ACCEL_ADDRESS:Word = $6A;
|
RPISENSE_LPS25H_PRESS_ADDRESS:Word = $5C;
|
RPISENSE_HTS221_HUMID_ADDRESS:Word = $5F;
|
Function declarations
To be documented
Return to Unit Reference