Browse Source

Allow POWER_SUPPLY 0 for no power switch

Scott Lahteine 10 years ago
parent
commit
2faed961ce
3 changed files with 147 additions and 165 deletions
  1. 3
    4
      Marlin/Conditionals.h
  2. 41
    41
      Marlin/Marlin_main.cpp
  3. 103
    120
      Marlin/ultralcd.cpp

+ 3
- 4
Marlin/Conditionals.h View File

265
   #ifndef POWER_SUPPLY
265
   #ifndef POWER_SUPPLY
266
     #define POWER_SUPPLY 1
266
     #define POWER_SUPPLY 1
267
   #endif
267
   #endif
268
-  // 1 = ATX
269
-  #if (POWER_SUPPLY == 1)
268
+  #if (POWER_SUPPLY == 1)   // 1 = ATX
270
     #define PS_ON_AWAKE  LOW
269
     #define PS_ON_AWAKE  LOW
271
     #define PS_ON_ASLEEP HIGH
270
     #define PS_ON_ASLEEP HIGH
272
   #endif
271
   #endif
273
-  // 2 = X-Box 360 203W
274
-  #if (POWER_SUPPLY == 2)
272
+  #if (POWER_SUPPLY == 2)   // 2 = X-Box 360 203W
275
     #define PS_ON_AWAKE  HIGH
273
     #define PS_ON_AWAKE  HIGH
276
     #define PS_ON_ASLEEP LOW
274
     #define PS_ON_ASLEEP LOW
277
   #endif
275
   #endif
276
+  HAS_POWER_SWITCH = POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN >= 0
278
 
277
 
279
   /**
278
   /**
280
    * Temp Sensor defines
279
    * Temp Sensor defines

+ 41
- 41
Marlin/Marlin_main.cpp View File

168
 // M401 - Lower z-probe if present
168
 // M401 - Lower z-probe if present
169
 // M402 - Raise z-probe if present
169
 // M402 - Raise z-probe if present
170
 // M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters
170
 // M404 - N<dia in mm> Enter the nominal filament width (3mm, 1.75mm ) or will display nominal filament width without parameters
171
-// M405 - Turn on Filament Sensor extrusion control.  Optional D<delay in cm> to set delay in centimeters between sensor and extruder 
172
-// M406 - Turn off Filament Sensor extrusion control 
173
-// M407 - Displays measured filament diameter 
171
+// M405 - Turn on Filament Sensor extrusion control.  Optional D<delay in cm> to set delay in centimeters between sensor and extruder
172
+// M406 - Turn off Filament Sensor extrusion control
173
+// M407 - Display measured filament diameter
174
 // M500 - Store parameters in EEPROM
174
 // M500 - Store parameters in EEPROM
175
 // M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
175
 // M501 - Read parameters from EEPROM (if you need reset them after you changed them temporarily).
176
-// M502 - Revert to the default "factory settings".  You still need to store them in EEPROM afterwards if you want to.
176
+// M502 - Revert to the default "factory settings". You still need to store them in EEPROM afterwards if you want to.
177
 // M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings.
177
 // M503 - Print the current settings (from memory not from EEPROM). Use S0 to leave off headings.
178
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
178
 // M540 - Use S[0|1] to enable or disable the stop SD card print on endstop hit (requires ABORT_ON_ENDSTOP_HIT_FEATURE_ENABLED)
179
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
179
 // M600 - Pause for filament change X[pos] Y[pos] Z[relative lift] E[initial retract] L[later retract distance for removal]
310
 bool cancel_heatup = false;
310
 bool cancel_heatup = false;
311
 
311
 
312
 #ifdef FILAMENT_SENSOR
312
 #ifdef FILAMENT_SENSOR
313
-  //Variables for Filament Sensor input 
314
-  float filament_width_nominal=DEFAULT_NOMINAL_FILAMENT_DIA;  //Set nominal filament width, can be changed with M404 
315
-  bool filament_sensor=false;  //M405 turns on filament_sensor control, M406 turns it off 
316
-  float filament_width_meas=DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter 
317
-  signed char measurement_delay[MAX_MEASUREMENT_DELAY+1];  //ring buffer to delay measurement  store extruder factor after subtracting 100 
318
-  int delay_index1=0;  //index into ring buffer
319
-  int delay_index2=-1;  //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
320
-  float delay_dist=0; //delay distance counter  
313
+  //Variables for Filament Sensor input
314
+  float filament_width_nominal = DEFAULT_NOMINAL_FILAMENT_DIA;  //Set nominal filament width, can be changed with M404
315
+  bool filament_sensor = false;  //M405 turns on filament_sensor control, M406 turns it off
316
+  float filament_width_meas = DEFAULT_MEASURED_FILAMENT_DIA; //Stores the measured filament diameter
317
+  signed char measurement_delay[MAX_MEASUREMENT_DELAY+1];  //ring buffer to delay measurement  store extruder factor after subtracting 100
318
+  int delay_index1 = 0;  //index into ring buffer
319
+  int delay_index2 = -1;  //index into ring buffer - set to -1 on startup to indicate ring buffer needs to be initialized
320
+  float delay_dist = 0; //delay distance counter
321
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
321
   int meas_delay_cm = MEASUREMENT_DELAY_CM;  //distance delay setting
322
 #endif
322
 #endif
323
 
323
 
516
   #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
516
   #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
517
     OUT_WRITE(SUICIDE_PIN, HIGH);
517
     OUT_WRITE(SUICIDE_PIN, HIGH);
518
   #endif
518
   #endif
519
-  #if defined(PS_ON_PIN) && PS_ON_PIN > -1
519
+  #if HAS_POWER_SWITCH
520
     #if defined(PS_DEFAULT_OFF)
520
     #if defined(PS_DEFAULT_OFF)
521
       OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
521
       OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
522
     #else
522
     #else
898
   strchr_pointer = strchr(cmdbuffer[bufindr], code);
898
   strchr_pointer = strchr(cmdbuffer[bufindr], code);
899
   return (strchr_pointer != NULL);  //Return True if a character was found
899
   return (strchr_pointer != NULL);  //Return True if a character was found
900
 }
900
 }
901
-  
901
+
902
 #define DEFINE_PGM_READ_ANY(type, reader)       \
902
 #define DEFINE_PGM_READ_ANY(type, reader)       \
903
     static inline type pgm_read_any(const type *p)  \
903
     static inline type pgm_read_any(const type *p)  \
904
     { return pgm_read_##reader##_near(p); }
904
     { return pgm_read_##reader##_near(p); }
3291
   if (code_seen('S')) setTargetBed(code_value());
3291
   if (code_seen('S')) setTargetBed(code_value());
3292
 }
3292
 }
3293
 
3293
 
3294
-#if defined(PS_ON_PIN) && PS_ON_PIN > -1
3294
+#if HAS_POWER_SWITCH
3295
 
3295
 
3296
   /**
3296
   /**
3297
    * M80: Turn on Power Supply
3297
    * M80: Turn on Power Supply
3313
     #endif
3313
     #endif
3314
   }
3314
   }
3315
 
3315
 
3316
-#endif // PS_ON_PIN
3317
-
3318
-/**
3319
- * M81: Turn off Power Supply
3320
- */
3321
-inline void gcode_M81() {
3322
-  disable_heater();
3323
-  st_synchronize();
3324
-  disable_e0();
3325
-  disable_e1();
3326
-  disable_e2();
3327
-  disable_e3();
3328
-  finishAndDisableSteppers();
3329
-  fanSpeed = 0;
3330
-  delay(1000); // Wait 1 second before switching off
3331
-  #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
3316
+  /**
3317
+   * M81: Turn off Power Supply
3318
+   */
3319
+  inline void gcode_M81() {
3320
+    disable_heater();
3332
     st_synchronize();
3321
     st_synchronize();
3333
-    suicide();
3334
-  #elif defined(PS_ON_PIN) && PS_ON_PIN > -1
3335
-    OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
3336
-  #endif
3337
-  #ifdef ULTIPANEL
3338
-    powersupply = false;
3339
-    LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
3340
-    lcd_update();
3341
-  #endif
3342
-}
3322
+    disable_e0();
3323
+    disable_e1();
3324
+    disable_e2();
3325
+    disable_e3();
3326
+    finishAndDisableSteppers();
3327
+    fanSpeed = 0;
3328
+    delay(1000); // Wait 1 second before switching off
3329
+    #if defined(SUICIDE_PIN) && SUICIDE_PIN > -1
3330
+      st_synchronize();
3331
+      suicide();
3332
+    #elif HAS_POWER_SWITCH
3333
+      OUT_WRITE(PS_ON_PIN, PS_ON_ASLEEP);
3334
+    #endif
3335
+    #ifdef ULTIPANEL
3336
+      powersupply = false;
3337
+      LCD_MESSAGEPGM(MACHINE_NAME " " MSG_OFF ".");
3338
+      lcd_update();
3339
+    #endif
3340
+  }
3341
+
3342
+#endif // PS_ON_PIN
3343
 
3343
 
3344
 /**
3344
 /**
3345
  * M82: Set E codes absolute (default)
3345
  * M82: Set E codes absolute (default)

+ 103
- 120
Marlin/ultralcd.cpp View File

616
   MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
616
   MENU_ITEM(gcode, MSG_AUTO_HOME, PSTR("G28"));
617
   MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
617
   MENU_ITEM(function, MSG_SET_HOME_OFFSETS, lcd_set_home_offsets);
618
   //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
618
   //MENU_ITEM(gcode, MSG_SET_ORIGIN, PSTR("G92 X0 Y0 Z0"));
619
+
619
   #if TEMP_SENSOR_0 != 0
620
   #if TEMP_SENSOR_0 != 0
620
     #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0
621
     #if TEMP_SENSOR_1 != 0 || TEMP_SENSOR_2 != 0 || TEMP_SENSOR_3 != 0 || TEMP_SENSOR_BED != 0
621
       MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
622
       MENU_ITEM(submenu, MSG_PREHEAT_PLA, lcd_preheat_pla_menu);
625
       MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0);
626
       MENU_ITEM(function, MSG_PREHEAT_ABS, lcd_preheat_abs0);
626
     #endif
627
     #endif
627
   #endif
628
   #endif
629
+
628
   MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
630
   MENU_ITEM(function, MSG_COOLDOWN, lcd_cooldown);
629
-  #if defined(POWER_SUPPLY) && POWER_SUPPLY > 0 && defined(PS_ON_PIN) && PS_ON_PIN > -1
630
-    if (powersupply) {
631
+
632
+  #if HAS_POWER_SWITCH
633
+    if (powersupply)
631
       MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
634
       MENU_ITEM(gcode, MSG_SWITCH_PS_OFF, PSTR("M81"));
632
-    }
633
-    else {
635
+    else
634
       MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
636
       MENU_ITEM(gcode, MSG_SWITCH_PS_ON, PSTR("M80"));
635
-    }
636
   #endif
637
   #endif
638
+
637
   MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
639
   MENU_ITEM(submenu, MSG_MOVE_AXIS, lcd_move_menu);
638
 
640
 
639
   #if defined(MANUAL_BED_LEVELING)
641
   #if defined(MANUAL_BED_LEVELING)
1338
               }
1340
               }
1339
 
1341
 
1340
               lastEncoderMovementMillis = ms;
1342
               lastEncoderMovementMillis = ms;
1341
-            }
1343
+            } // encoderRateMultiplierEnabled
1342
           #endif //ENCODER_RATE_MULTIPLIER
1344
           #endif //ENCODER_RATE_MULTIPLIER
1343
 
1345
 
1344
           lcdDrawUpdate = 1;
1346
           lcdDrawUpdate = 1;
1541
 
1543
 
1542
 #endif //ULTIPANEL
1544
 #endif //ULTIPANEL
1543
 
1545
 
1544
-/********************************/
1545
-/** Float conversion utilities **/
1546
-/********************************/
1547
-//  convert float to string with +123.4 format
1546
+/*********************************/
1547
+/** Number to string conversion **/
1548
+/*********************************/
1549
+
1548
 char conv[8];
1550
 char conv[8];
1549
-char *ftostr3(const float &x)
1550
-{
1551
+
1552
+// Convert float to string with +123.4 format
1553
+char *ftostr3(const float &x) {
1551
   return itostr3((int)x);
1554
   return itostr3((int)x);
1552
 }
1555
 }
1553
 
1556
 
1554
-char *itostr2(const uint8_t &x)
1555
-{
1557
+// Convert int to string with 12 format
1558
+char *itostr2(const uint8_t &x) {
1556
   //sprintf(conv,"%5.1f",x);
1559
   //sprintf(conv,"%5.1f",x);
1557
-  int xx=x;
1558
-  conv[0]=(xx/10)%10+'0';
1559
-  conv[1]=(xx)%10+'0';
1560
-  conv[2]=0;
1560
+  int xx = x;
1561
+  conv[0] = (xx / 10) % 10 + '0';
1562
+  conv[1] = xx % 10 + '0';
1563
+  conv[2] = 0;
1561
   return conv;
1564
   return conv;
1562
 }
1565
 }
1563
 
1566
 
1564
-// Convert float to string with 123.4 format, dropping sign
1565
-char *ftostr31(const float &x)
1566
-{
1567
-  int xx=x*10;
1568
-  conv[0]=(xx>=0)?'+':'-';
1569
-  xx=abs(xx);
1570
-  conv[1]=(xx/1000)%10+'0';
1571
-  conv[2]=(xx/100)%10+'0';
1572
-  conv[3]=(xx/10)%10+'0';
1573
-  conv[4]='.';
1574
-  conv[5]=(xx)%10+'0';
1575
-  conv[6]=0;
1567
+// Convert float to string with +123.4 format
1568
+char *ftostr31(const float &x) {
1569
+  int xx = abs(x * 10);
1570
+  conv[0] = (x >= 0) ? '+' : '-';
1571
+  conv[1] = (xx / 1000) % 10 + '0';
1572
+  conv[2] = (xx / 100) % 10 + '0';
1573
+  conv[3] = (xx / 10) % 10 + '0';
1574
+  conv[4] = '.';
1575
+  conv[5] = xx % 10 + '0';
1576
+  conv[6] = 0;
1576
   return conv;
1577
   return conv;
1577
 }
1578
 }
1578
 
1579
 
1579
-// Convert float to string with 123.4 format
1580
-char *ftostr31ns(const float &x)
1581
-{
1582
-  int xx=x*10;
1583
-  //conv[0]=(xx>=0)?'+':'-';
1584
-  xx=abs(xx);
1585
-  conv[0]=(xx/1000)%10+'0';
1586
-  conv[1]=(xx/100)%10+'0';
1587
-  conv[2]=(xx/10)%10+'0';
1588
-  conv[3]='.';
1589
-  conv[4]=(xx)%10+'0';
1590
-  conv[5]=0;
1580
+// Convert float to string with 123.4 format, dropping sign
1581
+char *ftostr31ns(const float &x) {
1582
+  int xx = abs(x * 10);
1583
+  conv[0] = (xx / 1000) % 10 + '0';
1584
+  conv[1] = (xx / 100) % 10 + '0';
1585
+  conv[2] = (xx / 10) % 10 + '0';
1586
+  conv[3] = '.';
1587
+  conv[4] = xx % 10 + '0';
1588
+  conv[5] = 0;
1591
   return conv;
1589
   return conv;
1592
 }
1590
 }
1593
 
1591
 
1594
-char *ftostr32(const float &x)
1595
-{
1596
-  long xx=x*100;
1597
-  if (xx >= 0)
1598
-    conv[0]=(xx/10000)%10+'0';
1599
-  else
1600
-    conv[0]='-';
1601
-  xx=abs(xx);
1602
-  conv[1]=(xx/1000)%10+'0';
1603
-  conv[2]=(xx/100)%10+'0';
1604
-  conv[3]='.';
1605
-  conv[4]=(xx/10)%10+'0';
1606
-  conv[5]=(xx)%10+'0';
1607
-  conv[6]=0;
1592
+// Convert float to string with 123.4 format
1593
+char *ftostr32(const float &x) {
1594
+  long xx = abs(x * 100);
1595
+  conv[0] = x >= 0 ? (xx / 10000) % 10 + '0' : '-';
1596
+  conv[1] = (xx / 1000) % 10 + '0';
1597
+  conv[2] = (xx / 100) % 10 + '0';
1598
+  conv[3] = '.';
1599
+  conv[4] = (xx / 10) % 10 + '0';
1600
+  conv[5] = xx % 10 + '0';
1601
+  conv[6] = 0;
1608
   return conv;
1602
   return conv;
1609
 }
1603
 }
1610
 
1604
 
1625
 	return conv;
1619
 	return conv;
1626
 }
1620
 }
1627
 
1621
 
1628
-//Float to string with 1.23 format
1622
+// Convert float to string with 1.23 format
1629
 char *ftostr12ns(const float &x)
1623
 char *ftostr12ns(const float &x)
1630
 {
1624
 {
1631
   long xx=x*100;
1625
   long xx=x*100;
1639
   return conv;
1633
   return conv;
1640
 }
1634
 }
1641
 
1635
 
1642
-//  convert float to space-padded string with -_23.4_ format
1636
+// Convert float to space-padded string with -_23.4_ format
1643
 char *ftostr32sp(const float &x) {
1637
 char *ftostr32sp(const float &x) {
1644
   long xx = abs(x * 100);
1638
   long xx = abs(x * 100);
1645
   uint8_t dig;
1639
   uint8_t dig;
1685
   return conv;
1679
   return conv;
1686
 }
1680
 }
1687
 
1681
 
1688
-char *itostr31(const int &xx)
1689
-{
1690
-  conv[0]=(xx>=0)?'+':'-';
1691
-  conv[1]=(xx/1000)%10+'0';
1692
-  conv[2]=(xx/100)%10+'0';
1693
-  conv[3]=(xx/10)%10+'0';
1694
-  conv[4]='.';
1695
-  conv[5]=(xx)%10+'0';
1696
-  conv[6]=0;
1682
+// Convert int to lj string with +123.0 format
1683
+char *itostr31(const int &x) {
1684
+  conv[0] = x >= 0 ? '+' : '-';
1685
+  int xx = abs(x);
1686
+  conv[1] = (xx / 100) % 10 + '0';
1687
+  conv[2] = (xx / 10) % 10 + '0';
1688
+  conv[3] = xx % 10 + '0';
1689
+  conv[4] = '.';
1690
+  conv[5] = '0';
1691
+  conv[6] = 0;
1697
   return conv;
1692
   return conv;
1698
 }
1693
 }
1699
 
1694
 
1700
 // Convert int to rj string with 123 or -12 format
1695
 // Convert int to rj string with 123 or -12 format
1701
-char *itostr3(const int &x)
1702
-{
1696
+char *itostr3(const int &x) {
1703
   int xx = x;
1697
   int xx = x;
1704
   if (xx < 0) {
1698
   if (xx < 0) {
1705
-     conv[0]='-';
1699
+     conv[0] = '-';
1706
      xx = -xx;
1700
      xx = -xx;
1707
-  } else if (xx >= 100)
1708
-    conv[0]=(xx/100)%10+'0';
1709
-  else
1710
-    conv[0]=' ';
1711
-  if (xx >= 10)
1712
-    conv[1]=(xx/10)%10+'0';
1701
+  }
1713
   else
1702
   else
1714
-    conv[1]=' ';
1715
-  conv[2]=(xx)%10+'0';
1716
-  conv[3]=0;
1703
+    conv[0] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
1704
+
1705
+  conv[1] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
1706
+  conv[2] = xx % 10 + '0';
1707
+  conv[3] = 0;
1717
   return conv;
1708
   return conv;
1718
 }
1709
 }
1719
 
1710
 
1720
 // Convert int to lj string with 123 format
1711
 // Convert int to lj string with 123 format
1721
-char *itostr3left(const int &xx)
1722
-{
1723
-  if (xx >= 100)
1724
-  {
1725
-    conv[0]=(xx/100)%10+'0';
1726
-    conv[1]=(xx/10)%10+'0';
1727
-    conv[2]=(xx)%10+'0';
1728
-    conv[3]=0;
1712
+char *itostr3left(const int &xx) {
1713
+  if (xx >= 100) {
1714
+    conv[0] = (xx / 100) % 10 + '0';
1715
+    conv[1] = (xx / 10) % 10 + '0';
1716
+    conv[2] = xx % 10 + '0';
1717
+    conv[3] = 0;
1729
   }
1718
   }
1730
-  else if (xx >= 10)
1731
-  {
1732
-    conv[0]=(xx/10)%10+'0';
1733
-    conv[1]=(xx)%10+'0';
1734
-    conv[2]=0;
1719
+  else if (xx >= 10) {
1720
+    conv[0] = (xx / 10) % 10 + '0';
1721
+    conv[1] = xx % 10 + '0';
1722
+    conv[2] = 0;
1735
   }
1723
   }
1736
-  else
1737
-  {
1738
-    conv[0]=(xx)%10+'0';
1739
-    conv[1]=0;
1724
+  else {
1725
+    conv[0] = xx % 10 + '0';
1726
+    conv[1] = 0;
1740
   }
1727
   }
1741
   return conv;
1728
   return conv;
1742
 }
1729
 }
1764
 }
1751
 }
1765
 
1752
 
1766
 // Convert float to string with +1234.5 format
1753
 // Convert float to string with +1234.5 format
1767
-char *ftostr51(const float &x)
1768
-{
1769
-  long xx=x*10;
1770
-  conv[0]=(xx>=0)?'+':'-';
1771
-  xx=abs(xx);
1772
-  conv[1]=(xx/10000)%10+'0';
1773
-  conv[2]=(xx/1000)%10+'0';
1774
-  conv[3]=(xx/100)%10+'0';
1775
-  conv[4]=(xx/10)%10+'0';
1776
-  conv[5]='.';
1777
-  conv[6]=(xx)%10+'0';
1778
-  conv[7]=0;
1754
+char *ftostr51(const float &x) {
1755
+  long xx = abs(x * 10);
1756
+  conv[0] = (x >= 0) ? '+' : '-';
1757
+  conv[1] = (xx / 10000) % 10 + '0';
1758
+  conv[2] = (xx / 1000) % 10 + '0';
1759
+  conv[3] = (xx / 100) % 10 + '0';
1760
+  conv[4] = (xx / 10) % 10 + '0';
1761
+  conv[5] = '.';
1762
+  conv[6] = xx % 10 + '0';
1763
+  conv[7] = 0;
1779
   return conv;
1764
   return conv;
1780
 }
1765
 }
1781
 
1766
 
1782
 // Convert float to string with +123.45 format
1767
 // Convert float to string with +123.45 format
1783
-char *ftostr52(const float &x)
1784
-{
1785
-  long xx=x*100;
1786
-  conv[0]=(xx>=0)?'+':'-';
1787
-  xx=abs(xx);
1788
-  conv[1]=(xx/10000)%10+'0';
1789
-  conv[2]=(xx/1000)%10+'0';
1790
-  conv[3]=(xx/100)%10+'0';
1791
-  conv[4]='.';
1792
-  conv[5]=(xx/10)%10+'0';
1793
-  conv[6]=(xx)%10+'0';
1794
-  conv[7]=0;
1768
+char *ftostr52(const float &x) {
1769
+  conv[0] = (x >= 0) ? '+' : '-';
1770
+  long xx = abs(x * 100);
1771
+  conv[1] = (xx / 10000) % 10 + '0';
1772
+  conv[2] = (xx / 1000) % 10 + '0';
1773
+  conv[3] = (xx / 100) % 10 + '0';
1774
+  conv[4] = '.';
1775
+  conv[5] = (xx / 10) % 10 + '0';
1776
+  conv[6] = xx % 10 + '0';
1777
+  conv[7] = 0;
1795
   return conv;
1778
   return conv;
1796
 }
1779
 }
1797
 
1780
 

Loading…
Cancel
Save