Exemplo n.º 1
0
static int randomDelay(){
  int songDelay = 8000/25;
  songDelay = random_min_max(8000/25, 12000/25); 
  //Serial.print("Song Delay: ");
  //Serial.println(songDelay*25);
  return songDelay;
}
Exemplo n.º 2
0
// ****************************************************************************
static void throttle_neutral(void)
{
    throttle_threshold = config.centre_threshold_high;
    if (global_flags.forward) {
        global_flags.forward = false;

        // Handle ESC where reverse can be engaged after a certain time in
        // neutral
        if (config.esc_mode == ESC_FORWARD_BRAKE_REVERSE_TIMEOUT) {
            drive_mode.brake_disarm = true;
            brake_disarm_counter = config.brake_disarm_counter_value;
        }

        if (config.flags.auto_brake_lights_forward_enabled) {
            global_flags.braking = true;
            // The time the brake lights stay on after going back to neutral
            // is random
            drive_mode.auto_brake = true;
            auto_brake_counter = random_min_max(
                config.auto_brake_counter_value_forward_min,
                config.auto_brake_counter_value_forward_max);
        }
    }
    else if (global_flags.reversing) {
        if (!drive_mode.auto_reverse) {
            drive_mode.auto_reverse = true;
            auto_reverse_counter = random_min_max(
                config.auto_reverse_counter_value_min,
                config.auto_reverse_counter_value_max);

            if (config.flags.auto_brake_lights_reverse_enabled) {
                global_flags.braking = true;
                drive_mode.auto_brake = true;
                auto_brake_counter = random_min_max(
                    config.auto_brake_counter_value_reverse_min,
                    config.auto_brake_counter_value_reverse_max);
            }
        }
    }
    else if (global_flags.braking) {
        if (!drive_mode.auto_brake) {
            drive_mode.brake_armed = false;
            global_flags.braking = false;
        }
    }
}