سنسور و رله
مدل را با دو دیتاستریم بسازید:report و رله را با onWrite وصل کنید:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
یک الگوی واقعی برای گزارش سنسور و کنترل خروجی.
temperature: double, readable
relay: boolean, readable + writable
report و رله را با onWrite وصل کنید:
auto temperature = device.datastream<double>("temperature");
auto relay = device.datastream<bool>("relay");
relay.onWrite([](bool enabled) {
if (!safeToSwitch()) return FlovaWriteResult::reject("interlock_open");
digitalWrite(RELAY_PIN, enabled ? HIGH : LOW);
return FlovaWriteResult::accept();
});
temperature.report(readTemperature());
Was this page helpful?
