2022-12-18, 04:14 PM
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.
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.