_impl stuff quite odd
so I don't get why there is _impl everywhere
I can see that. I don't think this is a standard way of doing things. This is kind of my hack to get the code moved out of the main bangle file without adding any runtime abstraction. Most abstractions like how linux kernel would add a lot of overhead but this should produce basically the same or close to the same binary.
How it works
So the impl name scheme is like this
Bangle_hardware_impl.h/c - "Impl" short for implementation
So if you think of this as like OOP. This file is your base class. Then i label most of the functions weak to make them "virtual" functions.
Bangle_ hardware_device_impl.c
Then you can make as many device files as you want. Any function in these files will override the functions in the base_impl.c file. In these files you can override all or just some of the functions. Many pieces of hardware don't need a completely setup. So when it builds what ever functions it doesn't override will you the base_impl.c implementation. Which in many cases is just nothing. Also these files are added at compile time and are chosen based on the hardware defines in your device.py file.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Comment/Question
I can see that. I don't think this is a standard way of doing things. This is kind of my hack to get the code moved out of the main bangle file without adding any runtime abstraction. Most abstractions like how linux kernel would add a lot of overhead but this should produce basically the same or close to the same binary.
How it works
So the impl name scheme is like this
So if you think of this as like OOP. This file is your base class. Then i label most of the functions weak to make them "virtual" functions.
Then you can make as many device files as you want. Any function in these files will override the functions in the base_impl.c file. In these files you can override all or just some of the functions. Many pieces of hardware don't need a completely setup. So when it builds what ever functions it doesn't override will you the base_impl.c implementation. Which in many cases is just nothing. Also these files are added at compile time and are chosen based on the hardware defines in your device.py file.
example
This is the file for the KX023 accelerometer driver.
answer
So basically there's a lot of .c files because i use a different c file for each configuration needed for each piece of hardware or feature.
@fanoush