I was already doing this with function pointers:
task[0] = readAirFlow; ms_freq_of_task[0] = 50;
task[1] = readO2Sensor; ms_freq_of_task[1] = 50;
But now I'm also doing this:
ESerial.addCommand(F("Winj"), Map::write, &inj_map);
ESerial.addCommand(F("rinj"), Map::read, &inj_map);
ESerial.addCommand(F("Sinj"), Map::save, &inj_map);
ESerial.addCommand(F("linj"), Map::load, &inj_map);
It adds a serial command that gets executed on a specific object (in the above example the object is "inj_map" ).
So after calling the above, when I type: rinj into the serial monitor window, the Arduino runs the "Map::read" function on the "inj_map" object. In this case, that prints the injector map out on the serial port, so you can see what's there.
So far I have almost 50 commands, which is why I needed to get it down to a 1-liner.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.