<commit_before>slug_motor = (function slug_motor () {
  SLUG_PREAMBLE = 0xFE;
  SLUG_OK_CODE  = 0xFA;
  SLUG_NG_CODE  = 0xFB;
  SLUG_GET_AZEL = 0xA0;
  SLUG_SET_PWM  = 0xFC;
  SLUG_EOM      = 0xFD;
  SLUG_EXPECTED_SIZE = 13;

  function move_az_to (connectionId, azimuth, callback){
    var az_pwm  = adjust_az_pwm (azimuth, motor_az);
    update_az_motors (connectionId, az_pwm, callback);
  };

  function move_el_to (connectionId, elevation, callback){
    var el_pwm  = adjust_el_pwm (elevation, motor_el);
    update_el_motors (connectionId, el_pwm, callback);
  };

  function adjust_az_pwm (track_rad, motor_rad){
    var diff = track_rad - motor_rad;
    if (track_rad < 0) { track_rad = 0; };
    if (diff > Math.PI) {
      // If arc_angle is more than 180,
      // don't go the long way around, flip it.
      diff = ( Math.PI * 2 ) - diff;
    };
    var diff_mag = Math.abs(diff);
    var diff_sign = 1;
    if (diff < 0) { diff_sign = -1; }
    var new_pwm = 0;
    if (diff_mag > Math.PI/10) {
      new_pwm = diff_sign*50;
    }
    else if (diff_mag > Math.PI/20) {
      new_pwm = diff_sign*40;
    }
    else if (diff_mag > Math.PI/60) {
      new_pwm = diff_sign*30;
    }
    else if (diff_mag > Math.PI/180) {
      new_pwm = diff_sign*20;
    };
    return new_pwm;
  };

  function adjust_el_pwm (track_rad, motor_rad){
    if (track_rad < 0) { track_rad = 0; };
    var diff = track_rad - motor_rad;
    var diff_mag = Math.abs(diff);
    var diff_sign = 1;
    if (diff > 0) { diff_sign = -1; };<commit_msg>Updated the AZ Motor control a bit, potential bug discovered before the final tests.<commit_after>slug_motor = (function slug_motor () {
  SLUG_PREAMBLE = 0xFE;
  SLUG_OK_CODE  = 0xFA;
  SLUG_NG_CODE  = 0xFB;
  SLUG_GET_AZEL = 0xA0;
  SLUG_SET_PWM  = 0xFC;
  SLUG_EOM      = 0xFD;
  SLUG_EXPECTED_SIZE = 13;

  function move_az_to (connectionId, azimuth, callback){
    var az_pwm  = adjust_az_pwm (azimuth, motor_az);
    update_az_motors (connectionId, az_pwm, callback);
  };

  function move_el_to (connectionId, elevation, callback){
    var el_pwm  = adjust_el_pwm (elevation, motor_el);
    update_el_motors (connectionId, el_pwm, callback);
  };

  function adjust_az_pwm (track_rad, motor_rad){
    if (track_rad < 0) { track_rad = 0; };
    if (track_rad > 359) { track_rad = 359; };
    var diff = track_rad - motor_rad;
    if (diff > Math.PI) {
      // If arc_angle is more than 180,
      // don't go the long way around, flip it.
      //
      // If the track is at 359 and the motor is at 1
      // the diff = 358. Rather than move 358 degrees,
      // 358 - 360 = -2, a much smaller movement.
      diff -= ( Math.PI * 2 );
    }
    else if (diff < -Math.PI){
      // If arc_angle is less than -180,
      // don't go the long way around, flip it.
      //
      // If the track is at 1 and motor is at 359,
      // the diff = -358. Rather than move -358 degrees,
      // -358 + 360 = 2, a much smaller movement.
      diff += ( Math.PI * 2 );
    };

    var diff_mag = Math.abs(diff);
    var diff_sign = 1;
    if (diff < 0) { diff_sign = -1; }
    var new_pwm = 0;
    if (diff_mag > Math.PI/10) {
      new_pwm = diff_sign*50;
    }
    else if (diff_mag > Math.PI/20) {
      new_pwm = diff_sign*40;
    }
    else if (diff_mag > Math.PI/60) {
      new_pwm = diff_sign*30;
    }
    else if (diff_mag > Math.PI/180) {
      new_pwm = diff_sign*20;
    };
    return new_pwm;
  };

  function adjust_el_pwm (track_rad, motor_rad){
    if (track_rad < 0) { track_rad = 0; };
    var diff = track_rad - motor_rad;
    var diff_mag = Math.abs(diff);
    var diff_sign = 1;
    if (diff > 0) { diff_sign = -1; };
{'fraction_non_alphanumeric': 0.11924857065069426, 'fraction_numerical': 0.03430438333787095, 'mean_word_length': 2.4497652582159626, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 16, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3361174', 'n_tokens_mistral': 1535, 'n_tokens_neox': 1410, 'n_words': 375}