UltraLCD enhancements (lower fan resolution, backlash menu) (#13519)
This commit is contained in:
committed by
Scott Lahteine
parent
de0f35f2d9
commit
5679fae11e
@ -57,6 +57,16 @@ void safe_delay(millis_t ms) {
|
||||
#define RJDIGIT(n, f) ((n) >= (f) ? DIGIMOD(n, f) : ' ')
|
||||
#define MINUSOR(n, alt) (n >= 0 ? (alt) : (n = -n, '-'))
|
||||
|
||||
// Convert a full-range unsigned 8bit int to a percentage
|
||||
char* ui8tostr_percent(const uint8_t i) {
|
||||
const uint16_t percent = 100 * i / 255;
|
||||
conv[3] = RJDIGIT(percent, 100);
|
||||
conv[4] = RJDIGIT(percent, 10);
|
||||
conv[5] = DIGIMOD(percent, 1);
|
||||
conv[6] = '%';
|
||||
return &conv[3];
|
||||
}
|
||||
|
||||
// Convert unsigned 8bit int to string 123 format
|
||||
char* ui8tostr3(const uint8_t i) {
|
||||
conv[4] = RJDIGIT(i, 100);
|
||||
|
@ -55,6 +55,9 @@ inline void serial_delay(const millis_t ms) {
|
||||
|
||||
#if ANY(ULTRA_LCD, DEBUG_LEVELING_FEATURE, EXTENSIBLE_UI)
|
||||
|
||||
// Convert a full-range unsigned 8bit int to a percentage
|
||||
char* ui8tostr_percent(const uint8_t i);
|
||||
|
||||
// Convert uint8_t to string with 123 format
|
||||
char* ui8tostr3(const uint8_t x);
|
||||
|
||||
@ -135,3 +138,8 @@ public:
|
||||
|
||||
#define REMEMBER(N,X, ...) restorer<typeof(X)> restorer_##N(X, ##__VA_ARGS__)
|
||||
#define RESTORE(N) restorer_##N.restore()
|
||||
|
||||
// Converts from an uint8_t in the range of 0-255 to an uint8_t
|
||||
// in the range 0-100 while avoiding rounding artifacts
|
||||
constexpr uint8_t ui8_to_percent(const uint8_t i) { return (int(i) * 100 + 127) / 255; }
|
||||
constexpr uint8_t all_on = 0xFF, all_off = 0x00;
|
||||
|
Reference in New Issue
Block a user