Magpie Stuff
  • Abstraction Layers

    Project Ideas
    2 4 26

    replicatR
    20
    1

    Note: This is not a project idea but I wasnt sure where else to put it and just wanted to get it down,


    It seems to me that our conversations keep coming back to wanting / needing some kind of abstraction layer.

    All of these libraries are kinda bad IMO. Even Adafruit ones are always make me say "WTF" at least once every time I use one,

    Since we are wanting to support all different kinds of HW but we also want to keep our "business logic" as portable and modular as possible I think abstraction layers make sense.

    So in practice, that means we would come up with our own HW agnostic display API. One that can theoretically do anything we need but doesnt directly talk to any HW,

    Whenever we write display code we will write it to the spec of our own API instead of the specific HW.

    Then we will make HW abstractions for each device we want to use. Which translates our custom API calls to the device specific code as needed,

    It is obviously slightly more upfront work for each new display driver we want to support but I think its the only realistic way to actually reuse code across even slightly different driver,

  • replicatR replicat referenced this topic on
  • AnalogWeaponA
    26
    1

    Pots and buttons could be a good place to start. They're really simple (almost too simple. lol), but it would be a place to start coming up with some standards maybe.

  • replicatR
    20
    1

    I think pots are a really good example since they have different curves and ranges but in theory could be abstracted to always output a linear value between 0 and 1.

    By always doing exactly that, we can write code that takes that and creates its own curves and other behaviours and never need to worry about the specifics of the pot it gets the data from. The same code could work the same way on two completely different pots.

    Proof of concept would really just be taking two totally different pots, run them against the exact same "high level" code and see that the code results in the same exact outputs.

  • replicatR
    20
    1

    @AnalogWeapon
    Another kind of easy example might be to take a few different capacitive touch sensors and do the same thing.

    IMO doing this for buttons doesnt seem super valuable to me since as far as I know almost all buttons have the exact same outputs. There really is nothing to abstract there is there?