Skip to content

[Feature Request] GPIO support in MeshCore #3522

Description

@helgeolav

I need to access GPIO pins on my meshcore nodes. I guess that this is something that others also want, and I can write an implementation of this if the proposal is acceptable. The idea is that we expose new CLI commands that lets you set/retieve the values of a GPIO-pin. This is something that I want to implement on all roles.

I want to make some new defines:

GPIO_IN
GPIO_OUT
GPIO_DAC
GPIO_ADC

These defines is a comma-separated list of GPIO-pins that is accessible using the CLI. If a define is not present, then there will be no corresponding GPIO for that type.

Then I want to extend mesh::MainBoard in src/MeshCore.h with some new member functions. These should be overridden at the board type (ESP32 etc).

class MainBoard {
    public:
    virtual bool setGPIO(int pin, bool newState) = 0; // returns true if the pin was set
    virtual bool setDAC(int pin, float value) = 0; // returns true if the pin was set
    virtual bool getGPIO(int pin); // return the value, or false if the pin does not exist
    virutal float getADC(int pin); // returns the value, or 0
}

I know that getGpio() and setGpio() is defined in MainBoard already, and probably it would be a good idea to use them. I just don't know the consequence yet of using these.

I have not a GPIO-init function here. I think that can be handled by the MainBoard subclass own setup/begin() function.

Then change the common CLI, add some new commands.

set gpio 1 1
get gpio 1
set gpio 2 3.43

If the GPIO is analog, use float values, for digital use 0 or 1.

Any thoughts?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions