diff --git a/model/standard-module-definitions/src/main/resources/zscript-datamodel/00xx-base-modules/004x-pins.yaml b/model/standard-module-definitions/src/main/resources/zscript-datamodel/00xx-base-modules/004x-pins.yaml index 80c75eab3..864970b16 100644 --- a/model/standard-module-definitions/src/main/resources/zscript-datamodel/00xx-base-modules/004x-pins.yaml +++ b/model/standard-module-definitions/src/main/resources/zscript-datamodel/00xx-base-modules/004x-pins.yaml @@ -34,7 +34,7 @@ commands: description: whether the device supports AtoDs on the pins - name: DtoA description: whether the device supports DtoAs on the pins - - name: PWM + - name: pwm description: whether the device supports PWM on the pins - name: digitalNotification description: whether the device supports notifications for digital pin control diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/PinManager.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/PinManager.hpp index 66c29f2ab..012202b4e 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/PinManager.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/PinManager.hpp @@ -209,7 +209,6 @@ template class PinManager { #ifdef ZSCRIPT_PIN_SUPPORT_NOTIFICATIONS - static void pinInterrupt_00() { pinInterrupt(0); } @@ -1156,7 +1155,6 @@ class PinManager { public: AnalogPinNotificationSetup(uint8_t pin) : notifState(false), notif(false), enabled(false), pinNum(pin), maxVal(0xfff), minVal(0x000), last(0x800) { - } }; @@ -1209,10 +1207,7 @@ class PinManager { #endif public: - #ifdef ZSCRIPT_PIN_SUPPORT_NOTIFICATIONS - - static void setOnNotificationDigital(void (*onNotificationDigital)(void)) { PinManager::onNotificationDigital = onNotificationDigital; } diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinReadCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinReadCommand.hpp index 76543dd10..3a1b8bc8b 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinReadCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinReadCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0035 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0045 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -20,7 +20,6 @@ namespace pins_module { template class AtoDPinReadCommand: public AnalogRead_CommandDefs { public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; if (!ctx.getField(ReqPin__P, &pin)) { diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinSetupCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinSetupCommand.hpp index 96522bf6b..8b857d538 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinSetupCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/AtoDPinSetupCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0034 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0044 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,19 +19,10 @@ namespace pins_module { template class AtoDPinSetupCommand: public AToDSetup_CommandDefs { - static constexpr char ParamPin__P = 'P'; - static constexpr char ParamEnableNotifications__N = 'N'; - static constexpr char ParamLowerLimit__L = 'L'; - static constexpr char ParamUpperLimit__U = 'U'; - - static constexpr char RespBitCount__B = 'B'; - static constexpr char RespSupportsNotifications__N = 'N'; - public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } @@ -42,7 +33,7 @@ class AtoDPinSetupCommand: public AToDSetup_CommandDefs { #ifdef ZSCRIPT_PIN_SUPPORT_ANALOG_NOTIFICATIONS uint8_t index = PinManager::getAnalogIndex(pin); uint16_t enableNotifications; - if (ctx.getField(ParamEnableNotifications__N, &enableNotifications)) { + if (ctx.getField(ReqEnableNotifications__N, &enableNotifications)) { if (enableNotifications != 0) { PinManager::enableAnalogNotification(index); } else { @@ -50,17 +41,17 @@ class AtoDPinSetupCommand: public AToDSetup_CommandDefs { } } uint16_t notificationLower; - if (ctx.getField(ParamLowerLimit__L, ¬ificationLower)) { + if (ctx.getField(ReqLowerLimitNotify__L, ¬ificationLower)) { PinManager::setAnalogNotificationLower(index, notificationLower); } uint16_t notificationUpper; - if (ctx.getField(ParamUpperLimit__U, ¬ificationUpper)) { + if (ctx.getField(ReqUpperLimitNotify__U, ¬ificationUpper)) { PinManager::setAnalogNotificationUpper(index, notificationUpper); } #endif CommandOutStream out = ctx.getOutStream(); #ifdef ZSCRIPT_PIN_SUPPORT_ANALOG_NOTIFICATIONS - out.writeField(RespSupportsNotifications__N, 0); + out.writeField(RespSupportedNotifications__N, 0); #endif if (PIN_SUPPORTS_ANALOG_READ(pin)) { out.writeField(RespBitCount__B, 10); diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinReadCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinReadCommand.hpp index 36adbd0c8..f720ae831 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinReadCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinReadCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0033 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0043 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,15 +19,10 @@ namespace pins_module { template class DigitalPinReadCommand: public DigitalRead_CommandDefs { - static constexpr char ParamPin__P = 'P'; - - static constexpr char RespValue__V = 'V'; - public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } @@ -36,7 +31,7 @@ class DigitalPinReadCommand: public DigitalRead_CommandDefs { return; } CommandOutStream out = ctx.getOutStream(); - out.writeField(RespValue__V, digitalRead(pin) == HIGH ? 1 : 0); + out.writeField(RespValue__V, digitalRead(pin) == HIGH ? high_value : low_value); } }; diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinSetupCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinSetupCommand.hpp index efb338c88..d2ed5ed4c 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinSetupCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinSetupCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0031 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0041 EXISTENCE_MARKER_UTIL namespace Zscript { diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinWriteCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinWriteCommand.hpp index a0638569e..4363ca501 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinWriteCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DigitalPinWriteCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0032 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0042 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,14 +19,10 @@ namespace pins_module { template class DigitalPinWriteCommand: public DigitalWrite_CommandDefs { - static constexpr char ParamPin__P = 'P'; - static constexpr char ParamValue__V = 'V'; - public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } @@ -35,14 +31,14 @@ class DigitalPinWriteCommand: public DigitalWrite_CommandDefs { return; } uint16_t value; - if (!ctx.getField(ParamValue__V, &value)) { + if (!ctx.getField(ReqValue__V, &value)) { ctx.status(ResponseStatus::MISSING_KEY); return; } if (!PinManager::isModeActivated(pin)) { - digitalWrite(pin, value ? HIGH : LOW); + digitalWrite(pin, value != low_Value ? HIGH : LOW); } else { - if ((value != 0) == PinManager::isCollectorNDrain(pin)) { + if ((value != low_Value) == PinManager::isCollectorNDrain(pin)) { pinMode(pin, OUTPUT); } else { if (PinManager::isPullup(pin)) { diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinSetupCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinSetupCommand.hpp index 6e80d16f1..571e92b9f 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinSetupCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinSetupCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0036 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0046 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,15 +19,10 @@ namespace pins_module { template class DtoAPinSetupCommand: public DToASetup_CommandDefs { - static constexpr char ParamPin__P = 'P'; - - static constexpr char RespBitCount__B = 'B'; - public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinWriteCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinWriteCommand.hpp index 73925fe11..ff7512799 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinWriteCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/DtoAPinWriteCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0037 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0047 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,13 +19,10 @@ namespace pins_module { template class DtoAPinWriteCommand: public AnalogWrite_CommandDefs { - static constexpr char ParamPin__P = 'P'; - static constexpr char ParamValue__V = 'V'; - public: static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } @@ -34,7 +31,7 @@ class DtoAPinWriteCommand: public AnalogWrite_CommandDefs { return; } uint16_t value; - if (!ctx.getField(ParamValue__V, &value)) { + if (!ctx.getField(ReqValue__V, &value)) { ctx.status(ResponseStatus::MISSING_KEY); return; } diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PinCapabilitiesCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PinCapabilitiesCommand.hpp index 834f63ea5..9f408556a 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PinCapabilitiesCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PinCapabilitiesCommand.hpp @@ -28,7 +28,7 @@ class PinCapabilitiesCommand : public Capabilities_CommandDefs { #ifdef DEVICE_SUPPORTS_ANALOG_WRITE | RespAvailableControllers_Values::dtoA_field #endif - | RespAvailableControllers_Values::pWM_field); + | RespAvailableControllers_Values::pwm_field); } }; diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinSetupCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinSetupCommand.hpp index d778d95b9..b6fbed4e9 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinSetupCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinSetupCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0038 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0048 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,14 +19,10 @@ namespace pins_module { template class PwmPinSetupCommand: public PwmSetup_CommandDefs { - static constexpr char ParamPin__P = 'P'; - - static constexpr char RespBitCount__B = 'B'; public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } diff --git a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinWriteCommand.hpp b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinWriteCommand.hpp index 8c91e26ce..543ecda4a 100644 --- a/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinWriteCommand.hpp +++ b/receivers/native/arduino/src/main/c++/arduino/pins-module/commands/PwmPinWriteCommand.hpp @@ -11,7 +11,7 @@ #include #include "../PinManager.hpp" -#define COMMAND_EXISTS_0039 EXISTENCE_MARKER_UTIL +#define COMMAND_EXISTS_0049 EXISTENCE_MARKER_UTIL namespace Zscript { @@ -19,14 +19,10 @@ namespace pins_module { template class PwmPinWriteCommand: public PwmWrite_CommandDefs { - static constexpr char ParamPin__P = 'P'; - static constexpr char ParamValue__V = 'V'; - public: - static void execute(ZscriptCommandContext ctx) { uint16_t pin; - if (!ctx.getField(ParamPin__P, &pin)) { + if (!ctx.getField(ReqPin__P, &pin)) { ctx.status(ResponseStatus::MISSING_KEY); return; } @@ -35,7 +31,7 @@ class PwmPinWriteCommand: public PwmWrite_CommandDefs { return; } uint16_t value; - if (!ctx.getField(ParamValue__V, &value)) { + if (!ctx.getField(ReqValue__V, &value)) { ctx.status(ResponseStatus::MISSING_KEY); return; }