Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

ofxGPIO

> 编程语言
Open source

Library C++ for raspberrypi and orangepi, GPIO interfaces compatible with openframeworks.

193 stars0 likes0 views
WebsiteGitHub

About

Library C++ for raspberrypi and orangepi, GPIO interfaces compatible with openframeworks.

ofxGPIO

A small library in C++ for the use of GPIO raspberrypi (A/B/2/3/Zero) orangepi (one/zero/plus) this library is compatible with the toolkit for creative coding Openframeworks. Interface GPIO: SPI (Serial Peripheral Interface), I2C (Inter Integrated Circuit), IO Pin read/write. With utilities such as: graphical gui (Gtk+ / Zenity) and TCP Unix socket implementation.

Documentation

c
/* define for activated more functionality */

-D COMPILE_WITHOUT_OPENFRAMEWORKS /* if = 1 work pure c++ without openframeworks toolkit */
-D GTK_UI 			  /* if = 1 activated c++ simple bridge for UI gtk+ */
-D ENABLE_BCM2835		  /* if = 1 activated c header BCM2835 */
-D ENABLE_ZENITY                  /* if = 1 activated zenity for UI debug */

Sample simple syntax ofxGPIO I/O

c
#include 
#include "ofxGPIO.h"

int main() 
{
        GPIO gpio;
        string state;
        int i = 0;

        gpio.setup(GPIO17,OUT,LOW);

        while(iaddressSet(0x04);

while(1) 
{
	bus->writeByte(0x04,1);
	usleep(500000);
	bus->writeByte(0x04,0);
	usleep(500000);
}

Zenity UI Utility

Sample

Sample syntax ofxGPIO SPI

c
SPI2 spi;
char data[2];

data[0] = 1;
data[1] = 2;

spi.setup("/dev/spidev0.0",1000000);
spi.readWrite(1, (unsigned char *)data, 2);

Example ofxGPIO

Example scanner with nRF24L01:

Raspberry pi (2/3/Zero/A/A+/B+)

nRF24L01

fritzing example:

Example simple Button Read state:

Raspberry pi (2/3/Zero/A/A+/B+)

Button

fritzing example:

Example simple Led Blink:

Raspberry pi (2/3/Zero/A/A+/B+)

Led

fritzing example:

Example simple Relay on / off Light:

Raspberry pi (2/3/Zero/A/A+/B+)

Relay 5v

Lamp

fritzing example:

Example GPS UART: http://aprs.gids.nl/nmea/

Raspberry pi (2/3/Zero/A/A+/B+)

GPS breakout v3

fritzing example:

Example i2c multiple byte read MPU6050:

Raspberry pi (2/3/Zero/A/A+/B+)

MPU6050

fritzing example:

Example Led Matrix8x8:

Raspberry pi (2/3/Zero/A/A+/B+)

Led Matrix

fritzing example:

Example Servo motor(Attention raspberry not to have pin PWM, for this we use a CLK pin, advice integrated pwm):

Raspberry pi (2/3/Zero/A/A+/B+)

Servo Motor

fritzing example:

Example GPIO read/write stepper rotation:

Raspberry PI

Stepper Motor bipolar

sn754410ne H-Bridge

Button

wiring

fritzing example:

sn754410ne H-Bridge:

video: http://www.youtube.com/watch?v=lwRd5D9EuU0 Example GPIO I2C communication:

Raspberry PI

Arduino

LED

Resistor 75 ohm

wiring

fritzing example:

video: http://www.youtube.com/watch?v=SRz750EdjfY Example GPIO SPI add Analog pin MCP3008 potentiometer:

Raspberry

MCP3008

Potentiometer

wiring

fritzing example:

MCP3008 8-Channel 10-Bit ADC

video: http://www.youtube.com/watch?v=PkDkCJyZ2go for i2c and SPI configuration visit this page:

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-spi

https://learn.adafruit.com/adafruits-raspberry-pi-lesson-4-gpio-setup/configuring-i2c

Datasheet integrated list:

Drive motor:

http://www.ti.com/lit/ds/symlink/l293.pdf

http://www.ti.com/lit/ds/symlink/sn754410.pdf

http://www.ti.com/lit/ds/symlink/uln2003a.pdf

http://www.st.com/content/ccc/resource/technical/document/datasheet/f3/6e/c8/64/4d/b3/4e/38/CD00001244.pdf/files/CD00001244.pdf/jcr:content/translations/en.CD00001244.pdf

Motor stepper Bipolar / Unipolar:

http://motion.schneider-electric.com/downloads/datasheets/14_mtr.pdf

http://www.mitsumi.co.jp/latest/Catalog/pdf/motor_m35sp_9_e.pdf

A/D Converters:

https://cdn-shop.adafruit.com/datasheets/MCP3008.pdf

http://ww1.microchip.com/downloads/en/DeviceDoc/21295C.pdf

ATmega48A/PA/88A/PA/168A/PA/328/P:

http://www.atmel.com/images/Atmel-8271-8-bit-AVR-Microcontroller-ATmega48A-48PA-88A-88PA-168A-168PA-328-328P_datasheet_Complete.pdf

MPU-6000 / MPU-6050:

https://www.cdiweb.com/datasheets/invensense/MPU-6050_DataSheet_V3%204.pdf

Adafruit Ultimate GPS:

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-ultimate-gps.pdf

Adafruit LED Backpacks:

https://cdn-learn.adafruit.com/downloads/pdf/adafruit-led-backpack.pdf

EEPROM

http://www.bucek.name/pdf/24c16.pdf http://www.st.com/content/ccc/resource/technical/document/datasheet/5c/df/52/a5/15/f2/48/bd/CD00259166.pdf/files/CD00259166.pdf/jcr:content/translations/en.CD00259166.pdf

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++banana-pic-plus-plusgpiogtk

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言