gpioExpanderService on mangOH Yellow?

Hello,

I want to use the GPIO expander on my mangOh Yellow to drive the generic green led of the board.

In the past I used the gpioExpanderService app (here) to manage the GPIO expander of my mangOH Red.
However this service seems to only be available for mangOH Red and mangOH Green.

Is there a service available for mangOH Yellow to do the same ?

Thank you for your time

BR

Hi,

On mangOH Yellow, there’s an app called leds, which drives all the software-controlled LEDs on the board. You can control that through the dataHub either using the Data Hub’s C APIs or using the dhub command-line tool.

The “generic” green LED appears in the Data Hub at resource path /app/leds/mono/enable.
You can run the following command to see all the dataHub connected to the leds app:

root@swi-mdm9x28-wp:~# dhub list /app/leds

To turn on the LED using the dhub command-line tool, run:

root@swi-mdm9x28-wp:~# dhub push /app/leds/mono/enable true

To turn it off, run:

root@swi-mdm9x28-wp:~# dhub push /app/leds/mono/enable false

To control the LEDs using the Data Hub’s “Admin API” in C, you first need to give your component access to that API by adding the following to your Component.cdef:

requires:
{
    api:
    {
        dhubAdmin = admin.api
    }
}

This creates a client-side interface on your component that can be connected up to the server-side interface called “admin” on the dataHub app. You create that connection by adding the following to your app’s .adef file:

bindings:
{
    myExe.myComponent.dhubAdmin -> dataHub.admin
}

Now you can use the Data Hub’s Admin API to control the /app/leds/mono/enable resource in your component’s C code like this:

dhubAdmin_PushBoolean("/app/leds/mono/enable", 0, newState);
  • The second parameter (0) is the timestamp you are assigning to the “sample” that you are pushing to that resource. 0 is a special value which means “now”.
  • The last parameter (newState) is the boolean value of your “sample”.

So, this will push a new data sample to that resource, which will be delivered to the leds app, which will respond by setting the LED state to the value in that sample (false = off, true = on).

Cheers,

–Jen

1 Like