LightHub 4.6.0
Open-source smart home controller firmware
Loading...
Searching...
No Matches
out_Motor Class Reference

Motorized gate/shutter driver with analog position feedback, channel type CH_MOTOR = 12. More...

#include <out_motor.h>

Inheritance diagram for out_Motor:

Public Member Functions

void link (Item *_item)
 Links the channel item and reads the pin config from itemArg.
int Setup () override
 Sets the up/down pins as outputs, the feedback pin as input, resets the action flags.
int Poll (short cause) override
 Drives the motor toward the target position with speed ramp, enforces the max on-time, and stops at target.
int Stop () override
 Deactivates both motor outputs and resets the channel state.
int getChanType () override
 Returns CH_PWM (3).
int Ctrl (itemCmd cmd, char *subItem=NULL, bool toExecute=true, bool authorized=false) override
 Sets the target position via /set (0-255) and /cmd on/off, requesting a move (see class doc).
Public Member Functions inherited from abstractOut
 abstractOut ()
virtual int isActive ()
virtual bool isAllowed (itemCmd cmd)
virtual itemCmd getDefaultOnVal ()
virtual int Status () override
virtual void setStatus (uint8_t status) override
Item * getItem ()
Public Member Functions inherited from abstractCh
 abstractCh ()
virtual ~abstractCh ()

Public Attributes

int8_t pinUp
int8_t pinDown
int8_t pinFeedback
int16_t maxOnTime
uint16_t feedbackOpen
uint16_t feedbackClosed
bool inverted

Protected Member Functions

void getConfig ()
Protected Member Functions inherited from abstractOut
int pubAction (bool state)
Protected Member Functions inherited from abstractCh
int publishTopic (const char *topic, long value, const char *subtopic=NULL)
int publishTopic (const char *topic, float value, const char *subtopic=NULL)
int publishTopic (const char *topic, const char *value, const char *subtopic=NULL, const char *suffix=NULL)

Additional Inherited Members

Protected Attributes inherited from abstractOut
Item * item
 Item currently linked to this driver.

Detailed Description

Motorized gate/shutter driver with analog position feedback, channel type CH_MOTOR = 12.

Drives the up/down motor pins (with PWM speed control where the pins support PWM) until the analog feedback reaches the target position 0-255. No more than MOTOR_QUOTE (2) motors run simultaneously, and the motor is stopped after maxOnTime ms regardless of position.

JSON config (itemArg): [pinUp, pinDown, pinFeedback, fbOpen, fbClosed, maxOnTime_ms(default 10000)]

  • negative pin numbers invert the output; defaults pinUp=32, pinDown=33;
  • fbOpen / fbClosed: raw analog readings at fully open / fully closed.

Ctrl: /set <0-255> - target position; /cmd on / off (off drives to 0).

The current position (0-255) is derived from the analog feedback pin.

Member Function Documentation

◆ Ctrl()

int out_Motor::Ctrl ( itemCmd cmd,
char * subItem = NULL,
bool toExecute = true,
bool authorized = false )
overridevirtual

Sets the target position via /set (0-255) and /cmd on/off, requesting a move (see class doc).

Implements abstractOut.

◆ getChanType()

int out_Motor::getChanType ( )
overridevirtual

Returns CH_PWM (3).

Reimplemented from abstractOut.

◆ getConfig()

void out_Motor::getConfig ( )
protected

◆ link()

void out_Motor::link ( Item * _item)
inlinevirtual

Links the channel item and reads the pin config from itemArg.

Reimplemented from abstractOut.

◆ Poll()

int out_Motor::Poll ( short cause)
overridevirtual

Drives the motor toward the target position with speed ramp, enforces the max on-time, and stops at target.

Reimplemented from abstractCh.

◆ Setup()

int out_Motor::Setup ( )
overridevirtual

Sets the up/down pins as outputs, the feedback pin as input, resets the action flags.

Reimplemented from abstractOut.

◆ Stop()

int out_Motor::Stop ( )
overridevirtual

Deactivates both motor outputs and resets the channel state.

Reimplemented from abstractCh.

Member Data Documentation

◆ feedbackClosed

uint16_t out_Motor::feedbackClosed

◆ feedbackOpen

uint16_t out_Motor::feedbackOpen

◆ inverted

bool out_Motor::inverted

◆ maxOnTime

int16_t out_Motor::maxOnTime

◆ pinDown

int8_t out_Motor::pinDown

◆ pinFeedback

int8_t out_Motor::pinFeedback

◆ pinUp

int8_t out_Motor::pinUp

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