muwerk mupplet Core Library
muwerk applets; mupplets: functional units that support specific hardware or reusable applications
Loading...
Searching...
No Matches
Public Member Functions | List of all members
ustd::DigitalOut Class Reference

mupplet-core DigitalOut class More...

#include <mup_digital_out.h>

Public Member Functions

 DigitalOut (String name, uint8_t port, bool activeLogic=false, const char *topic="relay")
 
void begin (Scheduler *_pSched)
 
void set (bool state)
 

Detailed Description

mupplet-core DigitalOut class

The DigitalOut class allows to integrate external relays or similar hardware that can be switched on or off.

Messages

Messages sent by the switch mupplet:

topic message body comment
<mupplet-name>/<topic>/state on, off switch state, on or off.

Message received by the switch mupplet:

topic message body comment
<mupplet-name>/<topic>/set on, off Switches the GPIO output accordingly.

Sample digital out Integration

#define __ESP__ 1 // Platform defines required, see ustd library doc, mainpage.
#include "scheduler.h"
#include "mup_digital_out.h"
ustd::Scheduler sched;
ust::DigitalOut relay("myRelay",13);
void setup() {
relay.begin(&sched);
}

More information: Digital out application notes

Constructor & Destructor Documentation

◆ DigitalOut()

ustd::DigitalOut::DigitalOut ( String  name,
uint8_t  port,
bool  activeLogic = false,
const char *  topic = "relay" 
)
inline

Instantiate a DigitalOut object

Parameters
nameUnique name of this mupplet, appears in pub/sub messages
portGPIO port number
activeLogictrue: calling set with true generate HIGH level (active high), false: calling set with true generates LOW level (active low)
topicTopic name of the device, default value is "relay"

Member Function Documentation

◆ begin()

void ustd::DigitalOut::begin ( Scheduler *  _pSched)
inline

Initialize GPIO and start operation

Parameters
_pSchedPointer to Scheduler object, used for internal task and pub/sub.

◆ set()

void ustd::DigitalOut::set ( bool  state)
inline

set assciated GPIO according to activeLogic defined in begin

Parameters
statelogical state (is inverse to actual GPIO level, if activeLogic=false)

The documentation for this class was generated from the following file: