/* Extract angle from the Message */
void can_proc_move_to_angle_msg ( sCAN* mMsg )
{
	// Angle is a 4 byte signed integer.  It is degrees * 100
	float tmp_angle 	 = extract_float_msg( mMsg->data );
	Destination.position = convert_to_value( convert_to_fixedpoint(tmp_angle) );
	Destination.speed 	 = extract_long_int( &(mMsg->data[4]) );	// [0..100%]
	motor_set_duty( Destination.speed );
}
Beispiel #2
0
// Find a conversion from e to t. If no such
// conversion exists, return nullptr. Diagnostics
// a better handled in the calling context.
Expr*
convert(Expr* e, Type const* t)
{
  // If e has type t, no conversions are needed.
  if (e->type() == t)
    return e;

  // Try lvalue to rvalue conversion.
  Expr* c1 =  convert_to_value(e);
  if (c1->type() == t)
    return c1;

  return nullptr;
}
Beispiel #3
0
/*---------------------------------------------------------------------------*/
static int
value(int type)
{
  uint8_t index;
  uint16_t sensor_value;

  index = is_sensor_in_list(type);

  if(!index) {
    PRINTF("ADC sensors: sensor not registered\n");
    return ADC_WRAPPER_SUCCESS;
  }

  /* Restore index value after the check */
  index -= 1;
  sensor_value = convert_to_value(index);

  return sensor_value;
}