From 46665739106ef90ae8c792158c35ba0e5acebe8a Mon Sep 17 00:00:00 2001 From: Gordon Henderson Date: Sat, 25 Aug 2012 12:31:14 +0100 Subject: [PATCH] Added C++ wrappers for some of the newer .h files --- examples/softPwm.c | 25 +++++++++++++++++++++++++ wiringPi/lcd.h | 8 ++++++++ wiringPi/piNes.h | 8 ++++++++ wiringPi/softPwm.h | 8 ++++++++ 4 files changed, 49 insertions(+) diff --git a/examples/softPwm.c b/examples/softPwm.c index e558c4b..09b4ae0 100644 --- a/examples/softPwm.c +++ b/examples/softPwm.c @@ -16,6 +16,7 @@ int values [NUM_LEDS] = { 0, 17, 32, 50, 67, 85, 100, 85, 67, 50, 32, 17 } ; int main () { int i, j ; + char buf [80] ; if (wiringPiSetup () == -1) { @@ -29,6 +30,30 @@ int main () printf ("%3d, %3d, %3d\n", i, ledMap [i], values [i]) ; } + fgets (buf, 80, stdin) ; + +// Bring all up one by one: + + for (i = 0 ; i < NUM_LEDS ; ++i) + for (j = 0 ; j <= 100 ; ++j) + { + softPwmWrite (ledMap [i], j) ; + delay (10) ; + } + + fgets (buf, 80, stdin) ; + +// Down fast + + for (i = 100 ; i > 0 ; --i) + { + for (j = 0 ; j < NUM_LEDS ; ++j) + softPwmWrite (ledMap [j], i) ; + delay (10) ; + } + + fgets (buf, 80, stdin) ; + for (;;) { for (i = 0 ; i < NUM_LEDS ; ++i) diff --git a/wiringPi/lcd.h b/wiringPi/lcd.h index 094f5f5..d4c724c 100644 --- a/wiringPi/lcd.h +++ b/wiringPi/lcd.h @@ -33,5 +33,13 @@ extern void lcdPutchar (int fd, uint8_t data) ; extern void lcdPuts (int fd, char *string) ; extern void lcdPrintf (int fd, char *message, ...) ; +#ifdef __cplusplus +extern "C" { +#endif + extern int lcdInit (int rows, int cols, int bits, int rs, int strb, int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) ; + +#ifdef __cplusplus +} +#endif diff --git a/wiringPi/piNes.h b/wiringPi/piNes.h index b76c415..897f181 100644 --- a/wiringPi/piNes.h +++ b/wiringPi/piNes.h @@ -33,5 +33,13 @@ #define NES_B 0x40 #define NES_A 0x80 +#ifdef __cplusplus +extern "C" { +#endif + extern int setupNesJoystick (int dPin, int cPin, int lPin) ; extern unsigned int readNesJoystick (int joystick) ; + +#ifdef __cplusplus +} +#endif diff --git a/wiringPi/softPwm.h b/wiringPi/softPwm.h index 4a17cb0..28ad299 100644 --- a/wiringPi/softPwm.h +++ b/wiringPi/softPwm.h @@ -22,5 +22,13 @@ *********************************************************************** */ +#ifdef __cplusplus +extern "C" { +#endif + extern int softPwmCreate (int pin, int value, int range) ; extern void softPwmWrite (int pin, int value) ; + +#ifdef __cplusplus +} +#endif -- 2.30.2