コード例 #1
0
ファイル: ground_map.cpp プロジェクト: galoompa/pl
void ground_map_loop()
{
  // check for new position
  int pos = (int)( get_lat_position_cm() / MAP_RESOLUTION );

  if( pos > last_pos ) {
    //map_sensor_to_index( RIGHT_DISTANCE_SENSOR, mod_pos( pos + MAP_SIZE/2, MAP_SIZE ) );
    ground_map_buffer[mod_pos( pos + MAP_SIZE/2, MAP_SIZE )] = get_distance( RIGHT_DISTANCE_SENSOR );
  } else if( pos < last_pos ) {
    ground_map_buffer[mod_pos( pos - MAP_SIZE/2, MAP_SIZE )] = get_distance( LEFT_DISTANCE_SENSOR );
    //map_sensor_to_index( LEFT_DISTANCE_SENSOR, mod_pos( pos - MAP_SIZE/2, MAP_SIZE ) );
  }
  
  // check if in safe zone
  static bool cur_safe = false;
  
  if( last_pos != pos ) {
    bool new_safe = safe_zone();
    if( new_safe != cur_safe ) {
      cur_safe = new_safe;
      if( new_safe ) {
        Serial.println( "Safe" );
        digitalWrite( 13, HIGH );
        set_lat_action( MOTOR_STOP );
      } else {
        Serial.println( "Not safe" );
        digitalWrite( 13, LOW );
      }
    }
  }
  
  last_pos = pos;
}
コード例 #2
0
/*
 * Main CPU Thermal Governor:
 * It defines various thermal zones (safe, monitoring, alert, panic and fatal)
 * with associated thermal Thresholds including the hysteresis effect.
 */
int cpu_thermal_governor(u32 omap_sensor_temp)
{
    cpu_temp = convert_omap_sensor_temp_to_hotspot_temp(OMAP_CPU, omap_sensor_temp);

    if (cpu_temp >= OMAP_CPU_THRESHOLD_FATAL) {
        fatal_zone();
        return FATAL_ZONE;
    } else if (cpu_temp >= config_file.omap_cpu_threshold_panic) {
        panic_zone();
        return PANIC_ZONE;
    } else if (cpu_temp < (config_file.omap_cpu_threshold_panic - HYSTERESIS_VALUE)) {
        if (cpu_temp >= config_file.omap_cpu_threshold_alert) {
            alert_zone();
            return ALERT_ZONE;
        } else if (cpu_temp < (config_file.omap_cpu_threshold_alert - HYSTERESIS_VALUE)) {
            if (cpu_temp >= config_file.omap_cpu_threshold_monitoring) {
                monitoring_zone();
                return MONITOR_ZONE;
            } else {
                /*
                 * this includes the case where :
                 * MONITORING_LOW <= T < MONITORING_HIGH
                 */
                safe_zone();
                return SAFE_ZONE;
            }
        } else {
               /*
                * this includes the case where :
                * ALERT_LOW <= T < ALERT_HIGH
                */
               monitoring_zone();
               return MONITOR_ZONE;
        }
    } else {
           /*
            * this includes the case where :
            * PANIC_LOW <= T < PANIC_HIGH
            */
           alert_zone();
           return ALERT_ZONE;
    }
}