LCD menu optimalization - conversion functions - source separation
This commit is contained in:
parent
0924ad50d5
commit
fd3fc31304
5 changed files with 328 additions and 323 deletions
292
Firmware/conv2str.cpp
Normal file
292
Firmware/conv2str.cpp
Normal file
|
@ -0,0 +1,292 @@
|
|||
//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)
|
||||
{
|
||||
long 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;
|
||||
}
|
||||
|
||||
|
28
Firmware/conv2str.h
Normal file
28
Firmware/conv2str.h
Normal file
|
@ -0,0 +1,28 @@
|
|||
//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
|
|
@ -246,7 +246,7 @@ void lcd_implementation_init_noclear(void)
|
|||
}
|
||||
|
||||
|
||||
void lcd_implementation_clear(void)
|
||||
void lcd_implementation_clear(void)
|
||||
{
|
||||
lcd.clear();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include "util.h"
|
||||
#include "mesh_bed_leveling.h"
|
||||
#include "mesh_bed_calibration.h"
|
||||
|
||||
//#include "Configuration.h"
|
||||
#include "cmdqueue.h"
|
||||
|
||||
|
@ -3480,7 +3482,7 @@ int8_t lcd_show_fullscreen_message_yes_no_and_wait_P(const char *msg, bool allow
|
|||
}
|
||||
}
|
||||
|
||||
void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask)
|
||||
void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask)
|
||||
{
|
||||
const char *msg = NULL;
|
||||
if (result == BED_SKEW_OFFSET_DETECTION_POINT_NOT_FOUND) {
|
||||
|
@ -7363,294 +7365,6 @@ uint8_t get_message_level()
|
|||
|
||||
|
||||
|
||||
/********************************/
|
||||
/** Float conversion utilities **/
|
||||
/********************************/
|
||||
// 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)
|
||||
{
|
||||
long 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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -2,7 +2,8 @@
|
|||
#define ULTRALCD_H
|
||||
|
||||
#include "Marlin.h"
|
||||
#include "mesh_bed_calibration.h"
|
||||
//#include "mesh_bed_calibration.h"
|
||||
#include "conv2str.h"
|
||||
|
||||
extern int lcd_puts_P(const char* str);
|
||||
extern int lcd_printf_P(const char* format, ...);
|
||||
|
@ -75,8 +76,9 @@ extern void menu_lcd_lcdupdate_func(void);
|
|||
#ifndef TMC2130
|
||||
extern bool lcd_calibrate_z_end_stop_manual(bool only_z);
|
||||
#endif
|
||||
|
||||
// Show the result of the calibration process on the LCD screen.
|
||||
extern void lcd_bed_calibration_show_result(BedSkewOffsetDetectionResultType result, uint8_t point_too_far_mask);
|
||||
extern void lcd_bed_calibration_show_result(uint8_t result, uint8_t point_too_far_mask);
|
||||
|
||||
extern void lcd_diag_show_end_stops();
|
||||
|
||||
|
@ -132,37 +134,6 @@ extern void menu_lcd_lcdupdate_func(void);
|
|||
void lcd_commands();
|
||||
|
||||
|
||||
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);
|
||||
|
||||
|
||||
extern void lcd_implementation_clear();
|
||||
extern void lcd_printPGM(const char* str);
|
||||
extern void lcd_print_at_PGM(uint8_t x, uint8_t y, const char* str);
|
||||
extern void lcd_print(const char *str);
|
||||
extern void lcd_print(int8_t i);
|
||||
extern void lcd_print_at(uint8_t x, uint8_t y, int8_t i);
|
||||
extern void lcd_print(int i);
|
||||
extern void lcd_print_at(uint8_t x, uint8_t y, int i);
|
||||
extern void lcd_print(float f);
|
||||
extern void lcd_print_at(uint8_t x, uint8_t y, const char *str);
|
||||
|
||||
|
||||
void change_extr(int extr);
|
||||
static void lcd_colorprint_change();
|
||||
|
|
Loading…
Add table
Reference in a new issue