optimisation: remove conv2str.cpp
Change in memory: Flash: -288 bytes SRAM: -8 bytes
This commit is contained in:
parent
79a10868fe
commit
17e6f1b75e
|
|
@ -131,7 +131,6 @@ set(FW_SOURCES
|
|||
cmdqueue.cpp
|
||||
Configuration.cpp
|
||||
ConfigurationStore.cpp
|
||||
conv2str.cpp
|
||||
Dcodes.cpp
|
||||
eeprom.cpp
|
||||
fancheck.cpp
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
#include "cmdqueue.h"
|
||||
#include "temperature.h"
|
||||
#include "cardreader.h"
|
||||
#include "conv2str.h"
|
||||
#include "util.h"
|
||||
#include "ultralcd.h"
|
||||
#include "Filament_sensor.h"
|
||||
|
|
@ -86,9 +85,9 @@ static void prusa_stat_printinfo() {
|
|||
SERIAL_ECHOPGM("[TFU:");
|
||||
SERIAL_ECHO(total_filament_used);
|
||||
SERIAL_ECHOPGM("][PCD:");
|
||||
SERIAL_ECHO(itostr3(card.percentDone()));
|
||||
SERIAL_ECHO((int)card.percentDone());
|
||||
SERIAL_ECHOPGM("][FEM:");
|
||||
SERIAL_ECHO(itostr3(feedmultiply));
|
||||
SERIAL_ECHO(feedmultiply);
|
||||
SERIAL_ECHOPGM("][FNM:");
|
||||
SERIAL_ECHO(card.longFilename[0] ? card.longFilename : card.filename);
|
||||
SERIAL_ECHOPGM("][TIM:");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
#include "cmdqueue.h"
|
||||
#include "cardreader.h"
|
||||
#include "ultralcd.h"
|
||||
#include "conv2str.h"
|
||||
#include "menu.h"
|
||||
#include "stepper.h"
|
||||
#include "temperature.h"
|
||||
|
|
@ -578,9 +577,9 @@ void CardReader::getStatus(bool arg_P)
|
|||
SERIAL_PROTOCOL('/');
|
||||
SERIAL_PROTOCOLLN(filesize);
|
||||
uint16_t time = ( _millis() - starttime ) / 60000U;
|
||||
SERIAL_PROTOCOL(itostr2(time/60));
|
||||
SERIAL_PROTOCOL((int)(time / 60));
|
||||
SERIAL_PROTOCOL(':');
|
||||
SERIAL_PROTOCOLLN(itostr2(time%60));
|
||||
SERIAL_PROTOCOLLN((int)(time % 60));
|
||||
}
|
||||
else
|
||||
SERIAL_PROTOCOLLNPGM("Not SD printing");
|
||||
|
|
|
|||
|
|
@ -1,292 +0,0 @@
|
|||
//conv2str.cpp - Float conversion utilities
|
||||
|
||||
#include "conv2str.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
// convert float to string with +123.4 format
|
||||
char conv[8];
|
||||
|
||||
char *ftostr3(const float &x)
|
||||
{
|
||||
return itostr3((int)x);
|
||||
}
|
||||
|
||||
char *itostr2(const uint8_t &x)
|
||||
{
|
||||
//sprintf(conv,"%5.1f",x);
|
||||
int xx = x;
|
||||
conv[0] = (xx / 10) % 10 + '0';
|
||||
conv[1] = (xx) % 10 + '0';
|
||||
conv[2] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to string with 123.4 format, dropping sign
|
||||
char *ftostr31(const float &x)
|
||||
{
|
||||
int xx = x * 10;
|
||||
conv[0] = (xx >= 0) ? '+' : '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
conv[2] = (xx / 100) % 10 + '0';
|
||||
conv[3] = (xx / 10) % 10 + '0';
|
||||
conv[4] = '.';
|
||||
conv[5] = (xx) % 10 + '0';
|
||||
conv[6] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to string with 123.4 format
|
||||
char *ftostr31ns(const float &x)
|
||||
{
|
||||
int xx = x * 10;
|
||||
//conv[0]=(xx>=0)?'+':'-';
|
||||
xx = abs(xx);
|
||||
conv[0] = (xx / 1000) % 10 + '0';
|
||||
conv[1] = (xx / 100) % 10 + '0';
|
||||
conv[2] = (xx / 10) % 10 + '0';
|
||||
conv[3] = '.';
|
||||
conv[4] = (xx) % 10 + '0';
|
||||
conv[5] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
char *ftostr32(const float &x)
|
||||
{
|
||||
long xx = x * 100;
|
||||
if (xx >= 0)
|
||||
conv[0] = (xx / 10000) % 10 + '0';
|
||||
else
|
||||
conv[0] = '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
conv[2] = (xx / 100) % 10 + '0';
|
||||
conv[3] = '.';
|
||||
conv[4] = (xx / 10) % 10 + '0';
|
||||
conv[5] = (xx) % 10 + '0';
|
||||
conv[6] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
//// Convert float to rj string with 123.45 format
|
||||
char *ftostr32ns(const float &x) {
|
||||
long xx = abs(x);
|
||||
conv[0] = xx >= 10000 ? (xx / 10000) % 10 + '0' : ' ';
|
||||
conv[1] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
|
||||
conv[2] = xx >= 100 ? (xx / 100) % 10 + '0' : '0';
|
||||
conv[3] = '.';
|
||||
conv[4] = (xx / 10) % 10 + '0';
|
||||
conv[5] = xx % 10 + '0';
|
||||
return conv;
|
||||
}
|
||||
|
||||
|
||||
// Convert float to string with 1.234 format
|
||||
char *ftostr43(const float &x, uint8_t offset)
|
||||
{
|
||||
const size_t maxOffset = sizeof(conv)/sizeof(conv[0]) - 6;
|
||||
if (offset>maxOffset) offset = maxOffset;
|
||||
long xx = x * 1000;
|
||||
if (xx >= 0)
|
||||
conv[offset] = (xx / 1000) % 10 + '0';
|
||||
else
|
||||
conv[offset] = '-';
|
||||
xx = abs(xx);
|
||||
conv[offset + 1] = '.';
|
||||
conv[offset + 2] = (xx / 100) % 10 + '0';
|
||||
conv[offset + 3] = (xx / 10) % 10 + '0';
|
||||
conv[offset + 4] = (xx) % 10 + '0';
|
||||
conv[offset + 5] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
//Float to string with 1.23 format
|
||||
char *ftostr12ns(const float &x)
|
||||
{
|
||||
int xx = x * 100;
|
||||
|
||||
xx = abs(xx);
|
||||
conv[0] = (xx / 100) % 10 + '0';
|
||||
conv[1] = '.';
|
||||
conv[2] = (xx / 10) % 10 + '0';
|
||||
conv[3] = (xx) % 10 + '0';
|
||||
conv[4] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
//Float to string with 1.234 format
|
||||
char *ftostr13ns(const float &x)
|
||||
{
|
||||
long xx = x * 1000;
|
||||
if (xx >= 0)
|
||||
conv[0] = ' ';
|
||||
else
|
||||
conv[0] = '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
conv[2] = '.';
|
||||
conv[3] = (xx / 100) % 10 + '0';
|
||||
conv[4] = (xx / 10) % 10 + '0';
|
||||
conv[5] = (xx) % 10 + '0';
|
||||
conv[6] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// convert float to space-padded string with -_23.4_ format
|
||||
char *ftostr32sp(const float &x) {
|
||||
long xx = abs(x * 100);
|
||||
uint8_t dig;
|
||||
|
||||
if (x < 0) { // negative val = -_0
|
||||
conv[0] = '-';
|
||||
dig = (xx / 1000) % 10;
|
||||
conv[1] = dig ? '0' + dig : ' ';
|
||||
}
|
||||
else { // positive val = __0
|
||||
dig = (xx / 10000) % 10;
|
||||
if (dig) {
|
||||
conv[0] = '0' + dig;
|
||||
conv[1] = '0' + (xx / 1000) % 10;
|
||||
}
|
||||
else {
|
||||
conv[0] = ' ';
|
||||
dig = (xx / 1000) % 10;
|
||||
conv[1] = dig ? '0' + dig : ' ';
|
||||
}
|
||||
}
|
||||
|
||||
conv[2] = '0' + (xx / 100) % 10; // lsd always
|
||||
|
||||
dig = xx % 10;
|
||||
if (dig) { // 2 decimal places
|
||||
conv[5] = '0' + dig;
|
||||
conv[4] = '0' + (xx / 10) % 10;
|
||||
conv[3] = '.';
|
||||
}
|
||||
else { // 1 or 0 decimal place
|
||||
dig = (xx / 10) % 10;
|
||||
if (dig) {
|
||||
conv[4] = '0' + dig;
|
||||
conv[3] = '.';
|
||||
}
|
||||
else {
|
||||
conv[3] = conv[4] = ' ';
|
||||
}
|
||||
conv[5] = ' ';
|
||||
}
|
||||
conv[6] = '\0';
|
||||
return conv;
|
||||
}
|
||||
|
||||
char *itostr31(const int &xx)
|
||||
{
|
||||
conv[0] = (xx >= 0) ? '+' : '-';
|
||||
conv[1] = (xx / 1000) % 10 + '0';
|
||||
conv[2] = (xx / 100) % 10 + '0';
|
||||
conv[3] = (xx / 10) % 10 + '0';
|
||||
conv[4] = '.';
|
||||
conv[5] = (xx) % 10 + '0';
|
||||
conv[6] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert int to rj string with 123 or -12 format
|
||||
char *itostr3(const int &x)
|
||||
{
|
||||
int xx = x;
|
||||
if (xx < 0) {
|
||||
conv[0] = '-';
|
||||
xx = -xx;
|
||||
} else if (xx >= 100)
|
||||
conv[0] = (xx / 100) % 10 + '0';
|
||||
else
|
||||
conv[0] = ' ';
|
||||
if (xx >= 10)
|
||||
conv[1] = (xx / 10) % 10 + '0';
|
||||
else
|
||||
conv[1] = ' ';
|
||||
conv[2] = (xx) % 10 + '0';
|
||||
conv[3] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert int to lj string with 123 format
|
||||
char *itostr3left(const int &xx)
|
||||
{
|
||||
if (xx >= 100)
|
||||
{
|
||||
conv[0] = (xx / 100) % 10 + '0';
|
||||
conv[1] = (xx / 10) % 10 + '0';
|
||||
conv[2] = (xx) % 10 + '0';
|
||||
conv[3] = 0;
|
||||
}
|
||||
else if (xx >= 10)
|
||||
{
|
||||
conv[0] = (xx / 10) % 10 + '0';
|
||||
conv[1] = (xx) % 10 + '0';
|
||||
conv[2] = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
conv[0] = (xx) % 10 + '0';
|
||||
conv[1] = 0;
|
||||
}
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert int to rj string with 1234 format
|
||||
char *itostr4(const int &xx) {
|
||||
conv[0] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
|
||||
conv[1] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
|
||||
conv[2] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
|
||||
conv[3] = xx % 10 + '0';
|
||||
conv[4] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to rj string with 12345 format
|
||||
char *ftostr5(const float &x) {
|
||||
long xx = abs(x);
|
||||
conv[0] = xx >= 10000 ? (xx / 10000) % 10 + '0' : ' ';
|
||||
conv[1] = xx >= 1000 ? (xx / 1000) % 10 + '0' : ' ';
|
||||
conv[2] = xx >= 100 ? (xx / 100) % 10 + '0' : ' ';
|
||||
conv[3] = xx >= 10 ? (xx / 10) % 10 + '0' : ' ';
|
||||
conv[4] = xx % 10 + '0';
|
||||
conv[5] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to string with +1234.5 format
|
||||
char *ftostr51(const float &x)
|
||||
{
|
||||
long xx = x * 10;
|
||||
conv[0] = (xx >= 0) ? '+' : '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = (xx / 10000) % 10 + '0';
|
||||
conv[2] = (xx / 1000) % 10 + '0';
|
||||
conv[3] = (xx / 100) % 10 + '0';
|
||||
conv[4] = (xx / 10) % 10 + '0';
|
||||
conv[5] = '.';
|
||||
conv[6] = (xx) % 10 + '0';
|
||||
conv[7] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
// Convert float to string with +123.45 format
|
||||
char *ftostr52(const float &x)
|
||||
{
|
||||
long xx = x * 100;
|
||||
conv[0] = (xx >= 0) ? '+' : '-';
|
||||
xx = abs(xx);
|
||||
conv[1] = (xx / 10000) % 10 + '0';
|
||||
conv[2] = (xx / 1000) % 10 + '0';
|
||||
conv[3] = (xx / 100) % 10 + '0';
|
||||
conv[4] = '.';
|
||||
conv[5] = (xx / 10) % 10 + '0';
|
||||
conv[6] = (xx) % 10 + '0';
|
||||
conv[7] = 0;
|
||||
return conv;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
//conv2str.h - Float conversion utilities
|
||||
#ifndef _CONV2STR_H
|
||||
#define _CONV2STR_H
|
||||
|
||||
#include <inttypes.h>
|
||||
|
||||
|
||||
char *itostr2(const uint8_t &x);
|
||||
char *itostr31(const int &xx);
|
||||
char *itostr3(const int &xx);
|
||||
char *itostr3left(const int &xx);
|
||||
char *itostr4(const int &xx);
|
||||
|
||||
char *ftostr3(const float &x);
|
||||
char *ftostr31ns(const float &x); // float to string without sign character
|
||||
char *ftostr31(const float &x);
|
||||
char *ftostr32(const float &x);
|
||||
char *ftostr32ns(const float &x);
|
||||
char *ftostr43(const float &x, uint8_t offset = 0);
|
||||
char *ftostr12ns(const float &x);
|
||||
char *ftostr13ns(const float &x);
|
||||
char *ftostr32sp(const float &x); // remove zero-padding from ftostr32
|
||||
char *ftostr5(const float &x);
|
||||
char *ftostr51(const float &x);
|
||||
char *ftostr52(const float &x);
|
||||
|
||||
|
||||
#endif //_CONV2STR_H
|
||||
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
#include "temperature.h"
|
||||
#include "ultralcd.h"
|
||||
#include "conv2str.h"
|
||||
#include "Marlin.h"
|
||||
#include "language.h"
|
||||
#include "cardreader.h"
|
||||
|
|
@ -628,9 +627,7 @@ void lcdui_print_status_line(void) {
|
|||
lcd_print_pad(lcd_status_message, LCD_WIDTH);
|
||||
if (pid_cycle <= pid_number_of_cycles && custom_message_state > 0) {
|
||||
lcd_set_cursor(10, 3);
|
||||
lcd_print(itostr3(pid_cycle));
|
||||
lcd_print('/');
|
||||
lcd_print(itostr3left(pid_number_of_cycles));
|
||||
lcd_printf_P(PSTR("%3d/%-3d"), pid_cycle, pid_number_of_cycles);
|
||||
}
|
||||
break;
|
||||
case CustomMsg::TempCal: // PINDA temp calibration in progress
|
||||
|
|
@ -4490,16 +4487,14 @@ static void lcd_nozzle_diameter_cycle(void) {
|
|||
#define SETTINGS_NOZZLE \
|
||||
do\
|
||||
{\
|
||||
float fNozzleDiam;\
|
||||
switch(oNozzleDiameter)\
|
||||
{\
|
||||
case ClNozzleDiameter::_Diameter_250: fNozzleDiam = 0.25f; break;\
|
||||
case ClNozzleDiameter::_Diameter_400: fNozzleDiam = 0.4f; break;\
|
||||
case ClNozzleDiameter::_Diameter_600: fNozzleDiam = 0.6f; break;\
|
||||
case ClNozzleDiameter::_Diameter_800: fNozzleDiam = 0.8f; break;\
|
||||
default: fNozzleDiam = 0.4f; break;\
|
||||
case ClNozzleDiameter::_Diameter_250: MENU_ITEM_TOGGLE_P(_T(MSG_NOZZLE_DIAMETER), PSTR("0.25"), lcd_nozzle_diameter_cycle); break;\
|
||||
case ClNozzleDiameter::_Diameter_Undef: \
|
||||
case ClNozzleDiameter::_Diameter_400: MENU_ITEM_TOGGLE_P(_T(MSG_NOZZLE_DIAMETER), PSTR("0.40"), lcd_nozzle_diameter_cycle); break;\
|
||||
case ClNozzleDiameter::_Diameter_600: MENU_ITEM_TOGGLE_P(_T(MSG_NOZZLE_DIAMETER), PSTR("0.60"), lcd_nozzle_diameter_cycle); break;\
|
||||
case ClNozzleDiameter::_Diameter_800: MENU_ITEM_TOGGLE_P(_T(MSG_NOZZLE_DIAMETER), PSTR("0.80"), lcd_nozzle_diameter_cycle); break;\
|
||||
}\
|
||||
MENU_ITEM_TOGGLE(_T(MSG_NOZZLE_DIAMETER), ftostr12ns(fNozzleDiam), lcd_nozzle_diameter_cycle);\
|
||||
}\
|
||||
while (0)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue