From 0a7d0f8041759562aacf1b4ef5dd1239045e52d3 Mon Sep 17 00:00:00 2001 From: slaff Date: Tue, 15 Jun 2021 14:34:55 +0200 Subject: [PATCH] Added pulseIn to the list of functions that can be called via Hosted RPC. (#2338) --- Sming/Components/Hosted-Lib/src/Digital.cpp | 6 ++++++ Sming/Components/Hosted/samples/serial/app/application.cpp | 4 +++- Sming/Components/Hosted/samples/tcp/app/application.cpp | 4 +++- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Sming/Components/Hosted-Lib/src/Digital.cpp b/Sming/Components/Hosted-Lib/src/Digital.cpp index d99e748ded..1462f33811 100644 --- a/Sming/Components/Hosted-Lib/src/Digital.cpp +++ b/Sming/Components/Hosted-Lib/src/Digital.cpp @@ -31,3 +31,9 @@ uint8_t digitalRead(uint16_t pin) hostedClient->send(__func__, pin); return hostedClient->wait(); } + +unsigned long pulseIn(uint16_t pin, uint8_t state, unsigned long timeout) +{ + hostedClient->send(__func__, pin, state, timeout); + return hostedClient->wait(); +} diff --git a/Sming/Components/Hosted/samples/serial/app/application.cpp b/Sming/Components/Hosted/samples/serial/app/application.cpp index ba70d7576f..fab436ee0e 100644 --- a/Sming/Components/Hosted/samples/serial/app/application.cpp +++ b/Sming/Components/Hosted/samples/serial/app/application.cpp @@ -22,12 +22,14 @@ void init() * - pinMode * - digitalRead * - digitalWrite + * - pulseIn * You can add more commands here. For every command you should specify command and text description in the format below. * For more information read the SimpleRPC interface API: https://simplerpc.readthedocs.io/en/latest/api/interface.html */ pinMode, F("pinMode: Sets mode of digital pin. @pin: Pin number, @mode: Mode type."), digitalRead, F("digitalRead: Read digital pin. @pin: Pin number. @return: Pin value."), - digitalWrite, F("digitalWrite: Write to a digital pin. @pin: Pin number. @value: Pin value.") + digitalWrite, F("digitalWrite: Write to a digital pin. @pin: Pin number. @value: Pin value."), + pulseIn, F("pulseIn: Measure duration of pulse on pin. @pin: Pin number. @state: State of pulse to measure. @timeout: Maximum duration of pulse. @return: Pulse duration in microseconds)") ); // clang-format on diff --git a/Sming/Components/Hosted/samples/tcp/app/application.cpp b/Sming/Components/Hosted/samples/tcp/app/application.cpp index 2e3a467e83..3702dc2580 100644 --- a/Sming/Components/Hosted/samples/tcp/app/application.cpp +++ b/Sming/Components/Hosted/samples/tcp/app/application.cpp @@ -44,12 +44,14 @@ void connectOk(IpAddress ip, IpAddress mask, IpAddress gateway) * - pinMode * - digitalRead * - digitalWrite + * - pulseIn * You can add more commands here. For every command you should specify command and text description in the format below. * For more information read the SimpleRPC interface API: https://simplerpc.readthedocs.io/en/latest/api/interface.html */ pinMode, F("pinMode: Sets mode of digital pin. @pin: Pin number, @mode: Mode type."), digitalRead, F("digitalRead: Read digital pin. @pin: Pin number. @return: Pin value."), - digitalWrite, F("digitalWrite: Write to a digital pin. @pin: Pin number. @value: Pin value.") + digitalWrite, F("digitalWrite: Write to a digital pin. @pin: Pin number. @value: Pin value."), + pulseIn, F("pulseIn: Measure duration of pulse on pin. @pin: Pin number. @state: State of pulse to measure. @timeout: Maximum duration of pulse. @return: Pulse duration in microseconds)") ); // clang-format on