Browse Source

Adjustments to ui8tostr_percent

pull/1/head
Scott Lahteine 6 years ago
parent
commit
9cb5c57b84
  1. 10
      Marlin/src/core/utility.cpp
  2. 2
      Marlin/src/core/utility.h
  3. 2
      Marlin/src/lcd/menu/menu.h

10
Marlin/src/core/utility.cpp

@ -58,11 +58,11 @@ void safe_delay(millis_t ms) {
#define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-')) #define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
// Convert a full-range unsigned 8bit int to a percentage // Convert a full-range unsigned 8bit int to a percentage
char* ui8tostr_percent(const uint8_t i) { char* ui8tostr4pct(const uint8_t i) {
const uint8_t percent = ui8_to_percent(i); const uint8_t n = ui8_to_percent(i);
conv[3] = RJDIGIT(percent, 100); conv[3] = RJDIGIT(n, 100);
conv[4] = RJDIGIT(percent, 10); conv[4] = RJDIGIT(n, 10);
conv[5] = DIGIMOD(percent, 1); conv[5] = DIGIMOD(n, 1);
conv[6] = '%'; conv[6] = '%';
return &conv[3]; return &conv[3];
} }

2
Marlin/src/core/utility.h

@ -56,7 +56,7 @@ inline void serial_delay(const millis_t ms) {
#if ANY(ULTRA_LCD, DEBUG_LEVELING_FEATURE, EXTENSIBLE_UI) #if ANY(ULTRA_LCD, DEBUG_LEVELING_FEATURE, EXTENSIBLE_UI)
// Convert a full-range unsigned 8bit int to a percentage // Convert a full-range unsigned 8bit int to a percentage
char* ui8tostr_percent(const uint8_t i); char* ui8tostr4pct(const uint8_t i);
// Convert uint8_t to string with 123 format // Convert uint8_t to string with 123 format
char* ui8tostr3(const uint8_t x); char* ui8tostr3(const uint8_t x);

2
Marlin/src/lcd/menu/menu.h

@ -43,7 +43,7 @@ bool printer_busy();
static inline char* strfunc(const float value) { return STRFUNC((TYPE) value); } \ static inline char* strfunc(const float value) { return STRFUNC((TYPE) value); } \
}; };
DECLARE_MENU_EDIT_TYPE(uint8_t, percent, ui8tostr_percent,1 ); // 100% right-justified DECLARE_MENU_EDIT_TYPE(uint8_t, percent, ui8tostr4pct, 1 ); // 100% right-justified
DECLARE_MENU_EDIT_TYPE(int16_t, int3, i16tostr3, 1 ); // 123, -12 right-justified DECLARE_MENU_EDIT_TYPE(int16_t, int3, i16tostr3, 1 ); // 123, -12 right-justified
DECLARE_MENU_EDIT_TYPE(int16_t, int4, i16tostr4sign, 1 ); // 1234, -123 right-justified DECLARE_MENU_EDIT_TYPE(int16_t, int4, i16tostr4sign, 1 ); // 1234, -123 right-justified
DECLARE_MENU_EDIT_TYPE(int8_t, int8, i8tostr3, 1 ); // 123, -12 right-justified DECLARE_MENU_EDIT_TYPE(int8_t, int8, i8tostr3, 1 ); // 123, -12 right-justified

Loading…
Cancel
Save