User avatar
GerardWassink
Posts: 103
Joined: Sun Aug 02, 2015 5:57 pm
Location: Ulrum (Gr), Netherlands
Contact: Website

C Libraries for Adafruit servo HAT?

Mon Sep 07, 2015 6:24 pm

Hi guys,

Asked this question in another board as well, but thought it would be more appropriate here...

I have ordered this Adafruit servo HAT. It will arrive tomorrow. It works with a combination of !2C and PWM.

From what I can see, all examples are for Python. But I want to incorporate this in a C project that I'm working on.

What libraries are available in C that have been proven to work?

Pointers appreciated,

Gerard
---------ooooO----- \\\\\|/// -----Oooo--------
Hacker on ELF-II, ZX80/1, Commodore 64, 8080, x86,
IBM 370 family mainframes
Machine code! Assembly! C good second.
Running Pi's with Hercules and S/370 OS's

-------------oooO-----------Oooo-------------

Yam
Posts: 68
Joined: Wed May 16, 2012 12:14 pm

Re: C Libraries for Adafruit servo HAT?

Mon Sep 07, 2015 9:12 pm

I don't know if this is what your looking for but I found this on my travels
https://github.com/raspberrypi/hats

User avatar
GerardWassink
Posts: 103
Joined: Sun Aug 02, 2015 5:57 pm
Location: Ulrum (Gr), Netherlands
Contact: Website

Re: C Libraries for Adafruit servo HAT?

Tue Sep 08, 2015 7:23 am

Hi Yam,

Thanks for replying, the post you're referring to, AFAICT, is about the hardware design of HAT's. And I'm not so much into hardware.

Just looking for a library to make use of this specific HAT.

But thanks for sharing!

Gerard
---------ooooO----- \\\\\|/// -----Oooo--------
Hacker on ELF-II, ZX80/1, Commodore 64, 8080, x86,
IBM 370 family mainframes
Machine code! Assembly! C good second.
Running Pi's with Hercules and S/370 OS's

-------------oooO-----------Oooo-------------

User avatar
joan
Posts: 14590
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: C Libraries for Adafruit servo HAT?

Tue Sep 08, 2015 7:30 am

The Python is about 90 lines of code wrapping I2C calls. It shouldn't take that long to port to C and test if nobody has already bothered.

User avatar
GerardWassink
Posts: 103
Joined: Sun Aug 02, 2015 5:57 pm
Location: Ulrum (Gr), Netherlands
Contact: Website

Re: C Libraries for Adafruit servo HAT?

Tue Sep 08, 2015 7:36 am

Hi Joan,

Thanks!

Would you happen to have a url for me pls?

Gerard
---------ooooO----- \\\\\|/// -----Oooo--------
Hacker on ELF-II, ZX80/1, Commodore 64, 8080, x86,
IBM 370 family mainframes
Machine code! Assembly! C good second.
Running Pi's with Hercules and S/370 OS's

-------------oooO-----------Oooo-------------


User avatar
GerardWassink
Posts: 103
Joined: Sun Aug 02, 2015 5:57 pm
Location: Ulrum (Gr), Netherlands
Contact: Website

Re: C Libraries for Adafruit servo HAT?

Tue Sep 08, 2015 9:10 am

Perfect, thanks!

I'll have a look at it and see wether I can port it to C.

Gerard
---------ooooO----- \\\\\|/// -----Oooo--------
Hacker on ELF-II, ZX80/1, Commodore 64, 8080, x86,
IBM 370 family mainframes
Machine code! Assembly! C good second.
Running Pi's with Hercules and S/370 OS's

-------------oooO-----------Oooo-------------

User avatar
Fastcash
Posts: 2
Joined: Fri Oct 30, 2015 8:58 am
Location: Nîmes, France

Re: C Libraries for Adafruit servo HAT?

Fri Oct 30, 2015 9:06 am

Hi Gerard,

Did you manage to port the python library to C?
Can you give us some feedbacks about your work?

Best regards,

User avatar
GerardWassink
Posts: 103
Joined: Sun Aug 02, 2015 5:57 pm
Location: Ulrum (Gr), Netherlands
Contact: Website

Re: C Libraries for Adafruit servo HAT?

Fri Oct 30, 2015 10:38 am

Fastcash wrote:Hi Gerard,

Did you manage to port the python library to C?
Can you give us some feedbacks about your work?

Best regards,
I decided not to port. I switched to python (having to learn this language first). The result can be found here. The code incorporates the ability to work with the Adafruit servo Pi Hat, as well as with the 16 relay board of my own design, for which I wrote my own driver (also in python).

There's footage of the first test of the relay driver board to be found at my YouTube channel.

Mind you, these efforts are not meant to be used to make "fast cash" ;)

HTH,
Gerard
---------ooooO----- \\\\\|/// -----Oooo--------
Hacker on ELF-II, ZX80/1, Commodore 64, 8080, x86,
IBM 370 family mainframes
Machine code! Assembly! C good second.
Running Pi's with Hercules and S/370 OS's

-------------oooO-----------Oooo-------------

davenull
Posts: 1159
Joined: Thu Oct 22, 2015 7:22 am
Location: a small planet close to Betelgeuze

Re: C Libraries for Adafruit servo HAT?

Fri Oct 30, 2015 11:00 am

IMO that's really a pity that all those HATs don't provide a convenient C lib but just support Python.
As I only use g++ and never will use Python, the company will probably never win me to become a customer for all those HATs...

Not a reasonable company policy IMO, though...
#define S sqrt(t+2*i*i)<2
#define F(a,b) for(a=0;a<b;++a)
float x,y,r,i,s,j,t,n;int main(){F(y,64){F(x,99){r=i=t=0;s=x/33-2;j=y/32-1;F(n,50&S){t=r*r-i*i;i=2*r*i+j;r=t+s;}if(S){PointOut(x,y);}}}for(;;);}

Return to “C/C++”