当前位置: 首页>>代码示例>>C++>>正文


C++ printFloat函数代码示例

本文整理汇总了C++中printFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ printFloat函数的具体用法?C++ printFloat怎么用?C++ printFloat使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了printFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: printFPRegister

/* FPレジスタ内容表示器 */
void printFPRegister(unsigned int* fpreg) {
// unsigned int rZ, rV, rN, rCarry;	// condition register
	int i=0,j=0;

//	printf("R[Condition] ZVNC = %X/%X/%X/%X \n", rZ, rV, rN, rCarry);
	for(i=0; i<FPREGSIZE; i++) {
		if(i%4 == 0) {
			printf("\tFP[%2d->%2d] : %12X ", i, i+3, fpreg[i]);
		} else if( (i+1)%4 == 0 ) {
			printf("%12X\n",fpreg[i]);
			for(j=i-3;j<i+1;j++) {
				if(j%4 == 0) {
					printf("\t             %12.3f ", printFloat(fpreg[j]));
				} else if( (j+1)%4 == 0 ) {
					printf("%12.3f\n",printFloat(fpreg[j]));
					break;
				} else {
					printf("%12.3f ",printFloat(fpreg[j]));
				}
			}
		} else {
			printf("%12X ",fpreg[i]);
		}


	}

	printf("\n");
}
开发者ID:cpuex2014-4,项目名称:simulator,代码行数:30,代码来源:print.c

示例2: printFloat

size_t Print::print(double n, int digits, int digitsBefore)
{
	if (digitsBefore> 0)
	  return printFloat(n, digits, digitsBefore);
	else
	  return printFloat(n, digits);
}
开发者ID:WindsorTing,项目名称:Luci,代码行数:7,代码来源:Print.cpp

示例3: report_gcode_parameters

// Prints gcode coordinate offset parameters
void report_gcode_parameters()
{
  float coord_data[N_AXIS];
  uint8_t coord_select, i;
  for (coord_select = 0; coord_select <= SETTING_INDEX_NCOORD; coord_select++) { 
    if (!(settings_read_coord_data(coord_select,coord_data))) { 
      report_status_message(STATUS_SETTING_READ_FAIL); 
      return;
    } 
    printPgmString(PSTR("[G"));
    switch (coord_select) {
      case 0: printPgmString(PSTR("54:")); break;
      case 1: printPgmString(PSTR("55:")); break;
      case 2: printPgmString(PSTR("56:")); break;
      case 3: printPgmString(PSTR("57:")); break;
      case 4: printPgmString(PSTR("58:")); break;
      case 5: printPgmString(PSTR("59:")); break;
      case 6: printPgmString(PSTR("28:")); break;
      case 7: printPgmString(PSTR("30:")); break;
      // case 8: printPgmString(PSTR("92:")); break; // G92.2, G92.3 not supported. Hence not stored.  
    }           
    for (i=0; i<N_AXIS; i++) {
      printFloat(coord_data[i]*report_distance_conversion); 
      if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); }
      else { printPgmString(PSTR("]\r\n")); }
    } 
  }
  printPgmString(PSTR("[G92:")); // Print G92,G92.1 which are not persistent in memory
  for (i=0; i<N_AXIS; i++) {
    printFloat(gc.coord_offset[i]*report_distance_conversion);
    if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); }
    else { printPgmString(PSTR("]\r\n")); }
  } 
}
开发者ID:ashelly,项目名称:grbl,代码行数:35,代码来源:report.c

示例4: serialMove

void SerialManager::call(int _mode, int _move, int _lastMove, float _heading, float _lat, float _lon, float _wplat, float _wplon, float _waypointDistance, float _waypointDirection)
{
    if(_mode == 1)
    {
        Serial1.println("");
        Serial1.println("");
        Serial1.println("--------------");
        Serial1.print("move=");
        serialMove(_move);
        Serial1.println("--------------");
        Serial1.print("GPS_lat=");
        printFloat(_lat, 1000000000);
        Serial1.print("GPS_lon=");
        printFloat(_lon, 1000000000);
        Serial1.println("--------------");
        Serial1.print("WAY_currentWaypointLAT=");
        printFloat(_wplat, 1000000000);
        Serial1.print("WAY_currentWaypointLON=");
        printFloat(_wplon, 1000000000);
        Serial1.print("WAY_waypointDistance=");
        printFloat(_waypointDistance, 1000000);
        Serial1.print("WAY_waypointDirection=");
        Serial1.println(_waypointDirection);
        Serial1.println("--------------");
        Serial1.print("COMP_heading=");
        Serial1.println(_heading);
    }
}
开发者ID:RobRight,项目名称:Personal,代码行数:28,代码来源:serialManager.cpp

示例5: printFloat_RateValue

void printFloat_RateValue(float n) {
  if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
    printFloat(n*INCH_PER_MM,N_DECIMAL_RATEVALUE_INCH);
  } else {
    printFloat(n,N_DECIMAL_RATEVALUE_MM);
  }
}
开发者ID:proto3,项目名称:grbl,代码行数:7,代码来源:print.c

示例6: report_realtime_status

 // Prints real-time data. This function grabs a real-time snapshot of the stepper subprogram 
 // and the actual location of the CNC machine. Users may change the following function to their
 // specific needs, but the desired real-time data report must be as short as possible. This is
 // requires as it minimizes the computational overhead and allows grbl to keep running smoothly, 
 // especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz).
void report_realtime_status()
{
  // **Under construction** Bare-bones status report. Provides real-time machine position relative to 
  // the system power on location (0,0,0) and work coordinate position (G54 and G92 applied). Eventually
  // to be added are distance to go on block, processed block id, and feed rate. Also a settings bitmask
  // for a user to select the desired real-time data.
  uint8_t i;
  int32_t current_position[N_AXIS]; // Copy current state of the system position variable
  memcpy(current_position,sys.position,sizeof(sys.position));
  float print_position[N_AXIS];
 
  // Report current machine state
  switch (sys.state) {
    case STATE_IDLE: printPgmString(PSTR("<Idle")); break;
    case STATE_QUEUED: printPgmString(PSTR("<Queue")); break;
    case STATE_CYCLE: printPgmString(PSTR("<Run")); break;
    case STATE_HOLD: printPgmString(PSTR("<Hold")); break;
    case STATE_HOMING: printPgmString(PSTR("<Home")); break;
    case STATE_ALARM: printPgmString(PSTR("<Alarm")); break;
    case STATE_CHECK_MODE: printPgmString(PSTR("<Check")); break;
  }
 
  // Report machine position
  printPgmString(PSTR(",MPos:")); 
  for (i=0; i< N_AXIS; i++) {
    print_position[i] = current_position[i]/settings.steps_per_mm[i];
    if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] *= INCH_PER_MM; }
    printFloat(print_position[i]);
    printPgmString(PSTR(","));
  }
  
  // Report work position
  printPgmString(PSTR("WPos:")); 
  for (i=0; i< N_AXIS; i++) {
    if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
      print_position[i] -= (gc.coord_system[i]+gc.coord_offset[i])*INCH_PER_MM;
    } else {
      print_position[i] -= gc.coord_system[i]+gc.coord_offset[i];
    }
    printFloat(print_position[i]);
    if (i < (N_AXIS-1)) { printPgmString(PSTR(",")); }
  }
    
  #ifdef USE_LINE_NUMBERS
  // Report current line number
  printPgmString(PSTR(",Ln:")); 
  int32_t ln=0;
  plan_block_t * pb = plan_get_current_block();
  if(pb != NULL) {
    ln = pb->line_number;
  } 
  printInteger(ln);
  #endif
    
  printPgmString(PSTR(">\r\n"));
}
开发者ID:rustyoz,项目名称:grbl,代码行数:61,代码来源:report.c

示例7: report_gcode_modes

// Print current gcode parser mode state
void report_gcode_modes()
{
  switch (gc.motion_mode) {
    case MOTION_MODE_SEEK : printPgmString(PSTR("[G0")); break;
    case MOTION_MODE_LINEAR : printPgmString(PSTR("[G1")); break;
    case MOTION_MODE_CW_ARC : printPgmString(PSTR("[G2")); break;
    case MOTION_MODE_CCW_ARC : printPgmString(PSTR("[G3")); break;
    case MOTION_MODE_CANCEL : printPgmString(PSTR("[G80")); break;
  }

  printPgmString(PSTR(" G"));
  printInteger(gc.coord_select+54);
  
  if (gc.plane_axis_0 == X_AXIS) {
    if (gc.plane_axis_1 == Y_AXIS) { printPgmString(PSTR(" G17")); }
    else { printPgmString(PSTR(" G18")); }
  } else { printPgmString(PSTR(" G19")); }
  
  if (gc.inches_mode) { printPgmString(PSTR(" G20")); }
  else { printPgmString(PSTR(" G21")); }
  
  if (gc.absolute_mode) { printPgmString(PSTR(" G90")); }
  else { printPgmString(PSTR(" G91")); }
  
  if (gc.inverse_feed_rate_mode) { printPgmString(PSTR(" G93")); }
  else { printPgmString(PSTR(" G94")); }
    
  switch (gc.program_flow) {
    case PROGRAM_FLOW_RUNNING : printPgmString(PSTR(" M0")); break;
    case PROGRAM_FLOW_PAUSED : printPgmString(PSTR(" M1")); break;
    case PROGRAM_FLOW_COMPLETED : printPgmString(PSTR(" M2")); break;
  }

  switch (gc.spindle_direction) {
    case SPINDLE_ENABLE_CW : printPgmString(PSTR(" M3")); break;
    case SPINDLE_ENABLE_CCW : printPgmString(PSTR(" M4")); break;
    case SPINDLE_DISABLE : printPgmString(PSTR(" M5")); break;
  }
  
  switch (gc.coolant_mode) {
    case COOLANT_DISABLE : printPgmString(PSTR(" M9")); break;
    case COOLANT_FLOOD_ENABLE : printPgmString(PSTR(" M8")); break;
    #ifdef ENABLE_M7
      case COOLANT_MIST_ENABLE : printPgmString(PSTR(" M7")); break;
    #endif
  }
  
  printPgmString(PSTR(" T"));
  printInteger(gc.tool);
  
  printPgmString(PSTR(" F"));
  if (gc.inches_mode) { printFloat(gc.feed_rate*INCH_PER_MM); }
  else { printFloat(gc.feed_rate); }

  printPgmString(PSTR("]\r\n"));
}
开发者ID:rustyoz,项目名称:grbl,代码行数:57,代码来源:report.c

示例8: printStock

void printStock( print_t *settings, char* ticker, size_t length, float value, float open, float close){
    printString(settings,"Ticker: ", 8);
    printString(settings,ticker,length);
    printChar(settings,'\n');
    printString(settings,"Value:  ", 8);
    printFloat(settings,value);
    printChar(settings,'\n');
    printString(settings,"Open:   ", 8);
    printFloat(settings,open);
    printChar(settings,'\n');
    printString(settings,"Close:  ", 8);
    printFloat(settings,close);
    printChar(settings,'\n');
    printChar(settings,'\n');
    printChar(settings,'\n');
}
开发者ID:Kchymet,项目名称:Digistockey,代码行数:16,代码来源:printer.c

示例9: main

int main(void) {

  float voltage;

  // -------- Inits --------- //
  initUSART();
  printString("\r\nDigital Voltmeter\r\n\r\n");
  initADC();
  setupADCSleepmode();

  // ------ Event loop ------ //

  while (1) {

    voltage = oversample16x() * VOLTAGE_DIV_FACTOR * REF_VCC / 4096;
    printFloat(voltage);
    /*  alternatively, just print it out:
     *  printWord(voltage*100);
     *  but then you have to remember the decimal place
     */
    _delay_ms(500);

  }                                                  /* End event loop */
  return 0;                            /* This line is never reached */
}
开发者ID:DanielVercouteren,项目名称:AVR-Programming,代码行数:25,代码来源:voltmeter.c

示例10: switch

// Render a value to text.
char*
aJsonClass::printValue(aJsonObject *item)
{
  char *out = NULL;
  if (!item)
    return NULL;
  switch (item->type)
    {
  case aJson_NULL:
    out = strdup("null");
    break;
  case aJson_False:
    out = strdup("false");
    break;
  case aJson_True:
    out = strdup("true");
    break;
  case aJson_Int:
    out = printInt(item);
    break;
  case aJson_Float:
    out = printFloat(item);
    break;
  case aJson_String:
    out = printString(item);
    break;
  case aJson_Array:
    out = printArray(item);
    break;
  case aJson_Object:
    out = printObject(item);
    break;
    }
  return out;
}
开发者ID:kkowar,项目名称:aJson,代码行数:36,代码来源:aJSON.cpp

示例11: controlled_speed

//translate omega1,2,3,4 to pwm1,2,3,4 and actuate motors accordingly
unsigned int controlled_speed(void)
{
    unsigned int t1;
    unsigned int t2;
    unsigned int t3;
    unsigned int t4;
    if (controller_param->FCS == FCS_MOTOR_TEST) {
        setDutyCycle(test_speed[0], 1);
        setDutyCycle(test_speed[1], 2);
        setDutyCycle(test_speed[2], 3);
        setDutyCycle(test_speed[3], 4);
    } else {
        //actuate the motors
        if (motor_on) {
            t1 = normalize_speed(ctrl_data->omega1square);
            t2 = normalize_speed(ctrl_data->omega2square);
            t3 = normalize_speed(ctrl_data->omega3square);
            t4 = normalize_speed(ctrl_data->omega4square);
            //setDutyCycle(ZERO_SPEED_THROTTLE+normalize_speed(ctrl_data->omega1square), 1);
            //setDutyCycle(ZERO_SPEED_THROTTLE+normalize_speed(ctrl_data->omega2square), 2);
            //setDutyCycle(ZERO_SPEED_THROTTLE+normalize_speed(ctrl_data->omega3square), 3);
            //setDutyCycle(ZERO_SPEED_THROTTLE+normalize_speed(ctrl_data->omega4square), 4);
            if (speed_report_count == SPEED_REPORT_RATE) {
                printf("T1: %u, T2: %u, T3: %u, T4: %u.\n\r", t1, t2, t3, t4);
                 //print the motor speeds
                printf("M1: ");
                printFloat(ctrl_data->omega1square);
                printf(", M2: ");
                printFloat(ctrl_data->omega2square);
                printf(", M3: ");
                printFloat(ctrl_data->omega3square);
                printf(", M4: ");
                printFloat(ctrl_data->omega4square);
                printf(".\n\r");
               
                printf("e_roll: ");
                printFloat(kinetic_errs->roll_error);
                printf("e_pitch: ");
                printFloat(kinetic_errs->pitch_error);
                printf(", e_yaw: ");
                printFloat(kinetic_errs->yaw_error);
                printf(", e_alt: ");
                printFloat(kinetic_errs->altitude_error);
                printf(".\n\r");
                printf(".\n\r");

                speed_report_count = 0;
            } else {
                speed_report_count++;
            }

        } else {
            // gives zero throttle to all
            setDutyCycle(6, 0);
        }
    }
}
开发者ID:Jian117,项目名称:Quadcopter-Michelle,代码行数:58,代码来源:motor_drive.c

示例12: report_realtime_status

 // Prints real-time data. This function grabs a real-time snapshot of the stepper subprogram 
 // and the actual location of the CNC machine. Users may change the following function to their
 // specific needs, but the desired real-time data report must be as short as possible. This is
 // requires as it minimizes the computational overhead and allows grbl to keep running smoothly, 
 // especially during g-code programs with fast, short line segments and high frequency reports (5-20Hz).
void report_realtime_status()
{
  // **Under construction** Bare-bones status report. Provides real-time machine position relative to 
  // the system power on location (0,0,0) and work coordinate position (G54 and G92 applied). Eventually
  // to be added are distance to go on block, processed block id, and feed rate. Also a settings bitmask
  // for a user to select the desired real-time data.
  uint8_t i;
  int32_t current_position[3]; // Copy current state of the system position variable
  float print_position[3];

   memcpy(current_position,sys.position,sizeof(sys.position));
  // Report current machine state
  switch (sys.state) {
    case STATE_IDLE: printPgmString((const char *)("<Idle")); break;
//    case STATE_INIT: printPgmString((const char *)("[Init")); break; // Never observed
    case STATE_QUEUED: printPgmString((const char *)("<Queue")); break;
    case STATE_CYCLE: printPgmString((const char *)("<Run")); break;
    case STATE_HOLD: printPgmString((const char *)("<Hold")); break;
    case STATE_HOMING: printPgmString((const char *)("<Home")); break;
    case STATE_ALARM: printPgmString((const char *)("<Alarm")); break;
    case STATE_CHECK_MODE: printPgmString((const char *)("<Check")); break;
  }
 
  // Report machine position
  printPgmString((const char *)(",MPos:")); 
  for (i=0; i<= 2; i++) {
    print_position[i] = current_position[i]/settings.steps_per_mm[i];
    if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) { print_position[i] *= INCH_PER_MM; }
    printFloat(print_position[i]);
    printPgmString((const char *)(","));
  }
  
  // Report work position
  printPgmString((const char *)("WPos:")); 
  for (i=0; i<= 2; i++) {
    if (bit_istrue(settings.flags,BITFLAG_REPORT_INCHES)) {
      print_position[i] -= (gc.coord_system[i]+gc.coord_offset[i])*INCH_PER_MM;
    } else {
      print_position[i] -= gc.coord_system[i]+gc.coord_offset[i];
    }
    printFloat(print_position[i]);
    if (i < 2) { printPgmString((const char *)(",")); }
  }
    
  printPgmString((const char *)(">\r\n"));
}
开发者ID:wo4fisher,项目名称:GRBL-0.8c-for-STM32,代码行数:51,代码来源:report.c

示例13: main

int main()
{
	float n;
	printf("Enter a floating point number: ");
	scanf("%f", &n);
	int x=printFloat(n);
	printf("\n");
	return 0;
}
开发者ID:nishkarsh-shastri,项目名称:Compilers_assignments_2014,代码行数:9,代码来源:mainPrintFloat.c

示例14: main

int main(void) {

	float voltage1;
	float voltage2;
	float res1;
	float res2;
	// -------- Inits --------- //
	initUSART();
	setupADCSleepmode();
	printString("\r\nDigital Voltmeter\r\n\r\n");
	

	// ------ Event loop ------ //
  
	while (1) {

		initADC(0);
		voltage1 = oversample16x();
		printString("Thermistor 1:\r\n");
		printFloat(voltage1);
		//printVoltage(voltage1);
		res1 = printThermRes(voltage1);
		printTemp(res1);
		printString("\r\n");
		
		_delay_ms(100);

		initADC(1);
		voltage2 = oversample16x();
		printString("Thermistor 2:\r\n");
		printFloat(voltage2);
		//printVoltage(voltage2);
		res2 = printThermRes(voltage2);
		printTemp(res2);
		printString("\r\n");
		_delay_ms(2500);
		
	}                                                  /* End event loop */
	return (0);                            /* This line is never reached */
}
开发者ID:MiamiOH-CSE609-Fall2014,项目名称:Maschino,代码行数:40,代码来源:voltmeter.c

示例15: settings_dump

void settings_dump() {
  printPgmString(PSTR("$0 = ")); printFloat(settings.steps_per_mm[X_AXIS]);
  printPgmString(PSTR(" (steps/mm x)\r\n$1 = ")); printFloat(settings.steps_per_mm[Y_AXIS]);
  printPgmString(PSTR(" (steps/mm y)\r\n$2 = ")); printFloat(settings.steps_per_mm[Z_AXIS]);
  printPgmString(PSTR(" (steps/mm z)\r\n$3 = ")); printInteger(settings.pulse_microseconds);
  printPgmString(PSTR(" (microseconds step pulse)\r\n$4 = ")); printFloat(settings.default_feed_rate);
  printPgmString(PSTR(" (mm/min default feed rate)\r\n$5 = ")); printFloat(settings.default_seek_rate);
  printPgmString(PSTR(" (mm/min default seek rate)\r\n$6 = ")); printFloat(settings.mm_per_arc_segment);
  printPgmString(PSTR(" (mm/arc segment)\r\n$7 = ")); printInteger(settings.invert_mask); 
  printPgmString(PSTR(" (step port invert mask. binary = ")); printIntegerInBase(settings.invert_mask, 2);  
  printPgmString(PSTR(")\r\n$8 = ")); printFloat(settings.acceleration/(60*60)); // Convert from mm/min^2 for human readability
  printPgmString(PSTR(" (acceleration in mm/sec^2)\r\n$9 = ")); printFloat(settings.junction_deviation);
  printPgmString(PSTR(" (cornering junction deviation in mm)"));
  printPgmString(PSTR("\r\n'$x=value' to set parameter or just '$' to dump current settings\r\n"));
}
开发者ID:AVRsteffen,项目名称:grbl,代码行数:15,代码来源:settings.c


注:本文中的printFloat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。