Lydia - Printhead
All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
POT Class Reference

#include <POT.h>

Inheritance diagram for POT:
[legend]

Public Member Functions

short debug ()
 
short info (short val0, short val1)
 
short loop ()
 
short onRegisterMethods (Bridge *bridge)
 
 POT (Component *owner, short _pin, short _id, short _addr)
 
short setup ()
 

Public Attributes

int last_value
 
short pin
 
int value
 

Detailed Description

Definition at line 21 of file POT.h.

Constructor & Destructor Documentation

◆ POT()

POT::POT ( Component *  owner,
short  _pin,
short  _id,
short  _addr 
)
inline

Definition at line 25 of file POT.h.

29  : ModbusValue<int>(_addr, MB_FC::MB_FC_READ_REGISTERS),
30  Component("POT", _id, Component::COMPONENT_DEFAULT, owner),
31  pin(_pin),
32  last_value(0)
33  //registerMode(MB_REGISTER_MODE::E_MB_REGISTER_MODE_NONE)
34  {
35  SBI(nFlags, OBJECT_NET_CAPS::E_NCAPS_MODBUS);
36  setRegisterMode(MB_REGISTER_MODE::E_MB_REGISTER_MODE_READ);
37  }

Member Function Documentation

◆ debug()

short POT::debug ( )
inline

Definition at line 48 of file POT.h.

49  {
50 // Log.verbose(F("POT:debug pin=%d value=%d" CR), pin, value);
51 #ifdef PLATFORM_PORTENTA_H7_M7
52  Log.verbose(F("POT:debug pin=%d value=%d | %d" CR), pin, value, analog_in.read(pin));
53 #else
54  info(0, 0);
55 #endif
56  return E_OK;
57  }

◆ info()

short POT::info ( short  val0,
short  val1 
)
inline

Definition at line 58 of file POT.h.

59  {
60  Log.verboseln("POT::info - Pin=%d | Key=%d | Addr=%d | Val=%d | NetVal=%d ", pin, id, addr, value, netVal());
61  return E_OK;
62  }

◆ loop()

short POT::loop ( )
inline

Definition at line 63 of file POT.h.

64  {
65  if (now - last < ANALOG_POT_READ_INTERVAL)
66  {
67  return E_OK;
68  }
69  last = now;
70 #ifdef PLATFORM_PORTENTA_H7_M7
71  float raw_voltage_ch0 = analog_in.read(pin);
72  float voltage_ch0 = (raw_voltage_ch0 * reference) / 65535 / res_divider;
73  value = voltage_ch0;
74 #else
75  value = analogRead(pin);
76 #endif
77  onSet(value);
78  return value;
79  }

◆ onRegisterMethods()

short POT::onRegisterMethods ( Bridge *  bridge)
inline

Definition at line 81 of file POT.h.

82  {
83  bridge->registerMemberFunction(id, this, C_STR("setFlag"), (ComponentFnPtr)&POT::setFlag);
84  //bridge->registerMemberFunction(id, this, C_STR("clearFlag"), (ComponentFnPtr)&POT::clearFlag);
85  bridge->registerMemberFunction(id, this, C_STR("info"), (ComponentFnPtr)&POT::info);
86  return E_OK;
87  }

◆ setup()

short POT::setup ( )
inline

Definition at line 38 of file POT.h.

39  {
40 #ifdef PLATFORM_PORTENTA_H7_M7
41  analogReadResolution(16);
42  analog_in.set0_10V();
43 #endif
44  last_value = loop();
45  return E_OK;
46  }

Member Data Documentation

◆ last_value

int POT::last_value

Definition at line 90 of file POT.h.

◆ pin

short POT::pin

Definition at line 88 of file POT.h.

◆ value

int POT::value

Definition at line 89 of file POT.h.


The documentation for this class was generated from the following file:
POT::pin
short pin
Definition: POT.h:88
POT::info
short info(short val0, short val1)
Definition: POT.h:58
POT::value
int value
Definition: POT.h:89
ANALOG_POT_READ_INTERVAL
#define ANALOG_POT_READ_INTERVAL
Definition: config_adv.h:110
E_OK
#define E_OK
Definition: enums.h:11
POT::loop
short loop()
Definition: POT.h:63
POT::last_value
int last_value
Definition: POT.h:90