Upload
akhilesh-chaudhry
View
218
Download
0
Embed Size (px)
Citation preview
7/26/2019 Tutorial API - Gnublin
1/4
13/05/2016 Tutorial API - GNUBLIN
http://en.gnublin.org/index.php/Tutorial_API 1/4
Homepage Wiki Forum Buy
Tutorial API
From GNUBLIN
Link to the documentation: API
Contents
1 Primary aims of the API:2 Internal GPIO as output3 Internal GPIO as input
4 Internal analog input5 I2C6 SPI7 Module-Relay8 Module-Display (2x16)9 Module-Temperature10 Module-Step11 Ordner Struktur
Primary aims of the API:
Easyfor hardware beginnersNo complicated C/C++ spellingspartially Based on Arduino functions
Internal GPIO as output
#define BOARD GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main(){
gnublin_gpio gpio;
gpio.pinMode(3,OUTPUT);
while(1){gpio.digitalWrite(3,HIGH);
sleep(2);gpio.digitalWrite(3,LOW);sleep(2);
}}
http://en.gnublin.org/index.php/APIhttp://gnublin.embedded-projects.net/buy/http://forum.gnublin.org/http://wiki.gnublin.org/http://www.gnublin.org/7/26/2019 Tutorial API - Gnublin
2/4
13/05/2016 Tutorial API - GNUBLIN
http://en.gnublin.org/index.php/Tutorial_API 2/4
Internal GPIO as input
#define BOARD GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main()
{gnublin_gpio gpio;
gpio.pinMode(3,INPUT);
while(1){if(gpio.digitalRead(3)){
printf("GPIO is set \n");}sleep(2);
}}
Internal analog input
#define BOARD GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main(){
gnublin_adc ad;
while(1){printf("AD value %i \n",ad.getValue(1));
}}
I2C
#define BOARD GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main(){
gnublin_i2c i2c;
i2c.setAddress(0x42);
char buffer[8];char RxBuf[8];
buffer[0]=0x22;
i2c.send(buffer,5);i2c.send(0x12, buffer, 2); //sende 2 byte aus buffer an RegisterAdresse 0x12
i2c.receive(RxBuf, 3); // lese 3 bytes und speichere sie in RxBufi2c.receive(0x23, RxBuf, 3); // lese von RegisterAdresse 0x23 3 bytes und speichere sie in RxBuf
}
7/26/2019 Tutorial API - Gnublin
3/4
7/26/2019 Tutorial API - Gnublin
4/4
13/05/2016 Tutorial API - GNUBLIN
http://en.gnublin.org/index.php/Tutorial_API 4/4
dogm.print("Zeile 1, Offset 2", 1, 2);
sleep(2);
dogm.controlDisplay(0,1,0);}
Module-Temperature
#define BOARD GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main(){
gnublin_module_lm75 lm75;
lm75.setAddress(0x4f);
printf("Temperature %i \n", lm75.getTemp());
printf("Raw Value %i \n",lm75.getValue());printf("Temperature Float Value %f \n",lm75.getTempFloat());
}
Module-Step
#define BOARD_GNUBLIN//#define BOARD RASPBERRY_PI
#include "gnublin.h"
int main(){
gnublin_module_step motor;
motor.setAddress(0x76);motor.getFullStatus1();motor.runInit();motor.resetPosition();motor.setPosition(1000);return0;
}
Ordner Struktur
examplesExample Programsmodules Classes for modulesgnublin-tools GNUBLIN terminal toolsdriversI2C, UART, SPI, ... Functions are used as the basis for Modules & Co.
Retrieved from "http://en.gnublin.org/index.php?title=Tutorial_API&oldid=581"Category: API
This page was last modified on 13 May 2013, at 10:26. - This page has been accessed 4,882times. - Disclaimers - About GNUBLIN
http://en.gnublin.org/index.php/GNUBLIN:Abouthttp://en.gnublin.org/index.php/GNUBLIN:General_disclaimerhttp://en.gnublin.org/index.php/Category:APIhttp://en.gnublin.org/index.php/Special:Categorieshttp://en.gnublin.org/index.php?title=Tutorial_API&oldid=581