Smarter MIN, MAX, ABS macros
Use macros that explicitly avoid double-evaluation and can be used for any datatype, replacing `min`, `max`, `abs`, `fabs`, `labs`, and `FABS`. Co-Authored-By: ejtagle <ejtagle@hotmail.com>
This commit is contained in:
parent
bf0fcebfe6
commit
3505d018db
24 changed files with 185 additions and 150 deletions
|
|
@ -492,12 +492,12 @@ void lcd_printPGM_utf(const char *str, uint8_t n=LCD_WIDTH) {
|
|||
// Scroll the PSTR 'text' in a 'len' wide field for 'time' milliseconds at position col,line
|
||||
void lcd_scroll(const int16_t col, const int16_t line, const char* const text, const int16_t len, const int16_t time) {
|
||||
char tmp[LCD_WIDTH + 1] = {0};
|
||||
int16_t n = max(lcd_strlen_P(text) - len, 0);
|
||||
const int16_t n = MAX(lcd_strlen_P(text) - len, 0);
|
||||
for (int16_t i = 0; i <= n; i++) {
|
||||
strncpy_P(tmp, text + i, min(len, LCD_WIDTH));
|
||||
strncpy_P(tmp, text + i, MIN(len, LCD_WIDTH));
|
||||
lcd.setCursor(col, line);
|
||||
lcd_print(tmp);
|
||||
delay(time / max(n, 1));
|
||||
delay(time / MAX(n, 1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1032,7 +1032,7 @@ static void lcd_implementation_status_screen() {
|
|||
name_hash = ((name_hash << 1) | (name_hash >> 7)) ^ filename[l]; // rotate, xor
|
||||
if (filename_scroll_hash != name_hash) { // If the hash changed...
|
||||
filename_scroll_hash = name_hash; // Save the new hash
|
||||
filename_scroll_max = max(0, lcd_strlen(longFilename) - n); // Update the scroll limit
|
||||
filename_scroll_max = MAX(0, lcd_strlen(longFilename) - n); // Update the scroll limit
|
||||
filename_scroll_pos = 0; // Reset scroll to the start
|
||||
lcd_status_update_delay = 8; // Don't scroll right away
|
||||
}
|
||||
|
|
@ -1345,7 +1345,7 @@ static void lcd_implementation_status_screen() {
|
|||
//dump_custom_char("at entry:", &new_char);
|
||||
|
||||
clear_custom_char(&new_char);
|
||||
const uint8_t ypix = min(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, ULTRA_Y_PIXELS_PER_CHAR);
|
||||
const uint8_t ypix = MIN(upper_left.y_pixel_offset + pixels_per_y_mesh_pnt, ULTRA_Y_PIXELS_PER_CHAR);
|
||||
for (j = upper_left.y_pixel_offset; j < ypix; j++) {
|
||||
i = upper_left.x_pixel_mask;
|
||||
for (k = 0; k < pixels_per_x_mesh_pnt; k++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue