-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback function after Arduino was initialized #14
Comments
Please post a snipped showing what you are trying to do and I will take a look. |
I have a set of input pins. After the program start I would like to know the exact state of all pins. It can be different, because the devices, which are connected to the pins, work stand-alone, and already have their own state, not depending on the program. The probem is that the event on_state_change is only called when the state was changed, but the event is not called for the initial state after the program start. So, how can I get the initial state of a pin after the program start? Is there a callback function, which is called, when the Firmata client is completely initialized to be able to get the current pin states? I suppose, that after the first time the Arduino is queried in the constructor, and the library receives all the responses, a user callback could be called - see below. What do you think? client::client(io_base* io, bool dont_reset) : io_(io)
{
using namespace std::placeholders;
delegate_.report_digital = std::bind(&client::report_digital, this, _1, _2);
delegate_.report_analog = std::bind(&client::report_analog, this, _1, _2);
delegate_.digital_value = std::bind(&client::digital_value, this, _1, _2);
delegate_.analog_value = std::bind(&client::analog_value, this, _1, _2);
delegate_.pin_mode = std::bind(&client::pin_mode, this, _1, _2);
if(!dont_reset) reset_();
query_version();
query_firmware();
query_capability();
query_analog_mapping();
query_state();
set_report();
/*****************************************************************/
/*********** User callback somehow after this point??? ***********/
/*****************************************************************/
id_ = io_->on_read(std::bind(&client::async_read, this, _1, _2));
} |
Hello Dimitry,
I am trying to configure a set of pins as input pullups. I want a function to be called when a pin becomes low or is already low in the beginning.
So I have created a debounce object and registered on_state_changed callbacks for every pin. The problem is, if the pin is already low, the callback is not called.
How should I program it correctly?
The text was updated successfully, but these errors were encountered: