You are reading a single comment by @user156811 and its replies. Click here to read the full conversation.
  • Comment/Question

    _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.

    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

About

Avatar for user156811 @user156811 started