throw invalid_argument("ArduControl::set_loco_function");
unsigned mask = 1<<func;
- if(loco.funcs.set((loco.funcs&~mask)|(mask*state)))
+ if(loco.funcs.set((loco.funcs.pending&~mask)|(mask*state)))
{
if(func>0 || loco.proto!=MM)
{
if(active_accessory && off_timeout)
{
- bool success = (monitor.get_peak()>0.35f && monitor.get_current()<monitor.get_peak()-0.2f);
+ bool got_peak = monitor.get_peak()>0.0f;
+ bool success = monitor.get_peak()>0.42f;
+ bool complete = (success && monitor.get_current()<monitor.get_peak()-0.2f);
Time::TimeStamp t = Time::now();
- if(t>off_timeout || success)
+ if((t>off_timeout && got_peak) || complete)
{
Accessory &acc = *active_accessory;