1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

Add HAL function configureInput(vpin,...) and configureServo(vpin,...).

This commit is contained in:
Neil McKechnie 2021-08-27 10:58:00 +01:00
parent 0a9fcf6ebc
commit 0c218e1e13

View File

@ -112,6 +112,18 @@ public:
// configure is used invoke an IODevice instance's _configure method // configure is used invoke an IODevice instance's _configure method
static bool configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, int params[]); static bool configure(VPIN vpin, ConfigTypeEnum configType, int paramCount, int params[]);
// User-friendly function for configuring an input pin.
inline static bool configureInput(VPIN vpin, bool pullupEnable) {
int params[] = {pullupEnable};
return IODevice::configure(vpin, CONFIGURE_INPUT, 1, params);
}
// User-friendly function for configuring a servo pin.
inline static bool configureServo(VPIN vpin, uint16_t activePosition, uint16_t inactivePosition, uint8_t profile, uint8_t initialState=0) {
int params[] = {(int)activePosition, (int)inactivePosition, profile, initialState};
return IODevice::configure(vpin, CONFIGURE_SERVO, 4, params);
}
// write invokes the IODevice instance's _write method. // write invokes the IODevice instance's _write method.
static void write(VPIN vpin, int value); static void write(VPIN vpin, int value);
@ -161,16 +173,11 @@ protected:
(void)vpin; (void)value; (void)vpin; (void)value;
}; };
// Method to write an analogue value (optionally implemented within device class) // Method to write an 'analogue' value (optionally implemented within device class)
virtual void _writeAnalogue(VPIN vpin, int value, int profile) { virtual void _writeAnalogue(VPIN vpin, int value, int profile) {
(void)vpin; (void)value; (void) profile; (void)vpin; (void)value; (void) profile;
}; };
// Method called from within a filter device to trigger its output (which may
// have the same VPIN id as the input to the filter). It works through the
// later devices in the chain only.
void writeDownstream(VPIN vpin, int value);
// Function called to check whether callback notification is supported by this pin. // Function called to check whether callback notification is supported by this pin.
// Defaults to no, if not overridden by the device. // Defaults to no, if not overridden by the device.
// The same value should be returned by all pins on the device, so only one need // The same value should be returned by all pins on the device, so only one need