QB64 Phoenix Edition
Using WiringPI c-lib in QB64 - Printable Version

+- QB64 Phoenix Edition (https://qb64phoenix.com/forum)
+-- Forum: QB64 Rising (https://qb64phoenix.com/forum/forumdisplay.php?fid=1)
+--- Forum: Code and Stuff (https://qb64phoenix.com/forum/forumdisplay.php?fid=3)
+---- Forum: Help Me! (https://qb64phoenix.com/forum/forumdisplay.php?fid=10)
+---- Thread: Using WiringPI c-lib in QB64 (/showthread.php?tid=2846)



Using WiringPI c-lib in QB64 - Rudy M - 07-02-2024

Hello,

I have used WiringPi in freebasic to access GPIO pins on the RaspberryPI 3 Model B+

To give an idea of WiringPI https://pinout.xyz/pinout/wiringpi

WiringPI is a c-lib


I tried to use this lib in QB64 but I get it not working.

Reason I want use this lib because it can read the value (tension) on a gpio pin.

(I use also the RASPI-GPIO utility via the QB64 shell statement, this works fin in QB64,
  but this utility can not read the value of a gpio-pin)

I did some little test with the "Library" statement of QB64 but always run in errors.

Has anybody got working WiringPI or 100% c-lib in QB64?
if yes: Would You publisch the initial code to use such library of a c-lib?

Rudy M


RE: Using WiringPI c-lib in QB64 - DSMan195276 - 07-07-2024

Since you didn't get any responses I took a stab at it. This works to use the library via `Declare Library`:

Code: (Select All)
Declare Library "wiringPi"
        Function wiringPiSetup&()
        Sub pinMode(ByVal pin As Long, ByVal mode As Long)

        Function digitalRead&(ByVal pin As Long)
        Sub digitalWrite(ByVal pin As Long, ByVal value As Long)
End Declare

With basic usage looking something like this:

Code: (Select All)
e& = wiringPiSetup&

pinMode 0, 1 ' Pin 0 for Output

digitalWrite 0, 1

pinMode 0, 0 ' Pin 0 for Input

d& = digitalRead&(0)

Obviously I haven't included the definitions of every function provided by wiringPi, but adding more functions isn't too hard. You'll want to read the header file here and convert the function definitions you need into ones for QB64 and place them in the `Declare Library` section. You'll probably also want to turn the `#define FOO 0` lines into `CONST FOO = 0` to make the library nicer to use.


RE: Using WiringPI c-lib in QB64 - Rudy M - 07-08-2024

Thank You very much DSMan for Your professional info.

I 'm going to try it out this week.

Therefore I'm going to solder a simple NTC - resistor or NTC-resistor-capacitor circuit on a little test-board.
If a got it working I 'll publish the result.

For later:
Reading the value of a pin gives also the possibility to use also a Platina based temperature sensor.
Advantages: Relative linear response, quick response... etc...  (better and quicker than NTC)

Example of such sensor:
https://www.reichelt.nl/nl/en/platinum-temperature-sensor-cl-b-1000-ohms-m-422-b-pt1000-p151238.html?CCOUNTRY=662&LANGUAGE=nl&GROUPID=9145&START=0&OFFSET=16&SID=93caf4adc05249054b565c84aa49550470b2d53283d074c193b79&LANGUAGE=EN&&r=1

Rudy M