This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Digitise an older engine - ESP32
#30
Hi,

I've now added a bilge monitor to this using a cheap float switch. The code on the website and in the video returns true or false, but thanks to a subscriber i'm updating that with the below so that i can return a string of text. Here is the updated code:

auto* bilge = new DigitalInputState(25, INPUT_PULLUP, 5000);

auto int_to_string_function = [](int input) ->String {
    if (input == 1) {
      return "Water present!";
    }
    else { // input == 0
      return "bilge clear";
    }
};

auto int_to_string_transform = new LambdaTransform<int, String>(int_to_string_function);

bilge->connect_to(int_to_string_transform)
     ->connect_to(new SKOutputString("propulsion.engine.bilge"));




Hope this is helpful.
Reply


Messages In This Thread
RE: Digitise an older engine - ESP32 - by MigGat - 2022-03-24, 10:11 AM
RE: Digitise an older engine - ESP32 - by Sailoog - 2022-03-25, 08:08 PM
RE: Digitise an older engine - ESP32 - by Paul M - 2022-03-26, 03:22 PM
RE: Digitise an older engine - ESP32 - by PaddyB - 2022-03-28, 11:30 AM
RE: Digitise an older engine - ESP32 - by PaddyB - 2022-03-26, 09:21 PM
RE: Digitise an older engine - ESP32 - by Sailoog - 2022-03-31, 11:59 AM
RE: Digitise an older engine - ESP32 - by tYuoAz - 2022-04-01, 10:40 PM
RE: Digitise an older engine - ESP32 - by Paul M - 2022-09-13, 03:03 PM
RE: Digitise an older engine - ESP32 - by SCarns - 2022-04-04, 03:48 PM
RE: Digitise an older engine - ESP32 - by MigGat - 2022-04-03, 06:08 PM
RE: Digitise an older engine - ESP32 - by Boatingbaileys - 2022-12-18, 04:14 PM
RE: Digitise an older engine - ESP32 - by MigGat - 2023-03-25, 01:18 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)