     handler.registerCommand("CLOSE", close);
     handler.registerCommand("STOP", stop);
 
+    powerConsumptionLog.setOverloadThreshold(MOTOR_CURRENT_LIMIT_MILLIAMPS);
+
     taskScheduler.init();
     taskScheduler.addTask(motorTask);
     taskScheduler.addTask(buttonTask);

#define PIN_BUTTON_EMERGENCYSTOP 3
#define PIN_LIMITSWITCH_OPEN 18
#define PIN_LIMITSWITCH_CLOSE 19
#define MOTOR_POLARITY 1    // Change to -1 to invert movement direction
#define FULL_SPEED 400
#define RAMP_LENGTH 20      // two seconds

void motorTick();

        }
        case RAMP_DOWN: {
            int power = FULL_SPEED - FULL_SPEED * countSincePhase / RAMP_LENGTH;
            int minimumPower = (roofState == CLOSING ? CLOSING_SPEED : 0);
            if (power < minimumPower)
                power = minimumPower;
            motorShield.setM1Speed(power * direction);
            if (power == minimumPower) {
                phase = IDLE;
                if (roofState == STOPPING)
                    roofState = STOPPED;
                else if (roofState == OPENING)
                    roofState = OPEN;
                else if (roofState == CLOSING)
                    phase = CLOSE_TIGHTLY;
            }
            break;
        }
        case CLOSE_TIGHTLY:
            // just coast ahead, until we trigger current limit when the roof hits the wall
            break;
    }
}

