Rpi-hw (short for "Raspberry Pi Hardware") is a free C++ library designed to manage the Raspberry Pi's GPIO connector and its other buses. It allows you to connect several devices to the board (including displays, keypads, stepper motors, and sensors) as you would with Arduino's libraries.
- Low-level access to the GPIO Connector and SPI, I2C, UART buses
- High-level input/output interfaces
- Support for I/O expander ICs
- Support for many devices, including displays, keypads, stepper motors, and sensors (see "List of supported devices" section)
- Unicode support (built-in)
- Support for standard fonts (using FreeType) (optional)
- Support for multiple image formats (using Magick++ API) (optional)
- Drawing functions
- 8-bit I/O expander with I2C/SPI (MCP23008, MCP23S08)
- 16-bit I/O expander with I2C/SPI (MCP23017, MCP23S17)
- Character LCDs (Hitachi HD44780)
- Graphical LCDs (Philips PCD8544)
- Single and multiple 7-segments diplays
- Matrix keypads
- Ultrasonic distance sensor (HC-SR04)
- Stepper motors
- Support for UART interface
Accessing to the GPIO connector:
// Get the GPIO controller
gpio &io = gpio::get();
// Set the mode of GPIO #11
io.setup( 25, OUTPUT );
// Write on GPIO #11
io.write( 25, HIGH );
Reading from 16-keys keypad:
// Define the keymap
std::vector< uint8_t > keymap = {
'1', '2', '3', 'A',
'4', '5', '6', 'B',
'7', '8', '9', 'C',
'*', '0', '#', 'D'
};
// Matrix keypad controller
keypad::matrix dev( { 14, 15, 18, 23 }, { 24, 25, 8, 7 }, keymap );
// Main loop
for ( ;; ) {
// Check the button state
if ( dev.keyPressed('2') || dev.keyPressed('3') )
std::cout << "You have pressed keys '2' or '3'!\n";
// Wait some time
time::msleep( 100 );
}
Writing texts on a Hitachi HD44780-based LCD:
// Display controller
display::hd44780 dev( 14, 18, 4, 17, 21, 22 );
// Initialize the 16x2 display
dev.init( 16, 2 );
// Move the cursor position
dev.move( 2, 0 );
// Write a string at cursor position
dev.write( "Hello World!" );
Detailed documentation of Rpi-hw's features and usage can be found on the official wiki.
Also you can find some articles about the library on http://hackyourmind.org/.
The library is released under terms of the GNU LGPL v3.
Rpi-hw is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation version 3 of the License.
Rpi-hw is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
See COPYING file for more details.
Have a bug? Please create an issue on GitHub at https://github.com/Wicker25/Rpi-hw/issues.