Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using WiringPI c-lib in QB64
#1
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
Reply
#2
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.
Reply
#3
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-t...GE=EN&&r=1

Rudy M
Reply




Users browsing this thread: 2 Guest(s)