1
0
mirror of https://github.com/MarlinFirmware/Marlin.git synced 2024-11-29 23:07:42 +00:00

🚸 Fixes for ProUI, JyersUI, backlight, etc. (#26086)

Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
This commit is contained in:
Andrew 2023-08-25 19:33:49 -04:00 committed by GitHub
parent 4613f85bb7
commit 8fa6a4da2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 177 additions and 177 deletions

View File

@ -772,6 +772,7 @@ void unified_bed_leveling::shift_mesh_height() {
const grid_count_t point_num = (GRID_MAX_POINTS - count) + 1;
SERIAL_ECHOLNPGM("Probing mesh point ", point_num, "/", GRID_MAX_POINTS, ".");
TERN_(HAS_STATUS_MESSAGE, ui.status_printf(0, F(S_FMT " %i/%i"), GET_TEXT(MSG_PROBING_POINT), point_num, int(GRID_MAX_POINTS)));
TERN_(LCD_BACKLIGHT_TIMEOUT_MINS, ui.refresh_backlight_timeout());
#if HAS_MARLINUI_MENU
if (ui.button_pressed()) {

View File

@ -2722,7 +2722,7 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#endif
#if LCD_BACKLIGHT_TIMEOUT_MINS
#if !HAS_ENCODER_ACTION
#if !HAS_ENCODER_ACTION && DISABLED(HAS_DWIN_E3V2)
#error "LCD_BACKLIGHT_TIMEOUT_MINS requires an LCD with encoder or keypad."
#elif ENABLED(NEOPIXEL_BKGD_INDEX_FIRST)
#if PIN_EXISTS(LCD_BACKLIGHT)
@ -2730,8 +2730,8 @@ static_assert(COUNT(arm) == LOGICAL_AXES, "AXIS_RELATIVE_MODES must contain " _L
#elif ENABLED(NEOPIXEL_BKGD_ALWAYS_ON)
#error "LCD_BACKLIGHT_TIMEOUT is not compatible with NEOPIXEL_BKGD_ALWAYS_ON."
#endif
#elif !PIN_EXISTS(LCD_BACKLIGHT)
#error "LCD_BACKLIGHT_TIMEOUT_MINS requires either LCD_BACKLIGHT_PIN or NEOPIXEL_BKGD_INDEX_FIRST."
#elif !PIN_EXISTS(LCD_BACKLIGHT) && DISABLED(HAS_DWIN_E3V2)
#error "LCD_BACKLIGHT_TIMEOUT_MINS requires LCD_BACKLIGHT_PIN, NEOPIXEL_BKGD_INDEX_FIRST, or an Ender-3 V2 DWIN LCD."
#endif
#endif

View File

@ -87,7 +87,13 @@ EncoderState encoderReceiveAnalyze() {
#if PIN_EXISTS(LCD_LED)
//LED_Action();
#endif
if (!ui.backlight) ui.refresh_brightness();
#if LCD_BACKLIGHT_TIMEOUT_MINS
ui.refresh_backlight_timeout();
#endif
if (!ui.backlight) {
ui.refresh_brightness();
return ENCODER_DIFF_NO;
}
const bool was_waiting = wait_for_user;
wait_for_user = false;
return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
@ -154,6 +160,12 @@ EncoderState encoderReceiveAnalyze() {
temp_diff = 0;
}
if (temp_diffState != ENCODER_DIFF_NO) {
#if LCD_BACKLIGHT_TIMEOUT_MINS
ui.refresh_backlight_timeout();
#endif
if (!ui.backlight) ui.refresh_brightness();
}
return temp_diffState;
}

View File

@ -341,20 +341,14 @@ private:
}
float getMaxValue() {
float max = __FLT_MIN__;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
max = bedlevel.z_values[x][y];
}
float max = -(__FLT_MAX__);
GRID_LOOP(x, y) { const float z = bedlevel.z_values[x][y]; if (!isnan(z)) NOLESS(max, z); }
return max;
}
float getMinValue() {
float min = __FLT_MAX__;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
min = bedlevel.z_values[x][y];
}
GRID_LOOP(x, y) { const float z = bedlevel.z_values[x][y]; if (!isnan(z)) NOMORE(min, z); }
return min;
}
@ -363,7 +357,7 @@ private:
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x,
cell_width_px = total_width_px / (GRID_MAX_POINTS_X),
cell_height_px = total_width_px / (GRID_MAX_POINTS_Y);
const float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), range = _MAX(v_min, v_max);
const float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), rmax = _MAX(v_min, v_max);
// Clear background from previous selection and select new square
dwinDrawRectangle(1, COLOR_BG_BLACK, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
@ -384,8 +378,8 @@ private:
dwinDrawRectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
isnan(bedlevel.z_values[x][y]) ? COLOR_GREY : ( // gray if undefined
(bedlevel.z_values[x][y] < 0 ?
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? rmax : v_min)) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? rmax : v_max)) << 5) | // green if mesh point value is positive
_MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
start_x_px, start_y_px, end_x_px, end_y_px
);
@ -421,16 +415,17 @@ private:
v_min = abs(getMinValue()),
v_max = abs(getMaxValue());
if (viewer_asymmetric_range) {
if (v_min > 3e+10F) v_min = 0.0000001;
if (v_max > 3e+10F) v_max = 0.0000001;
if (v_min > 3e+10f) v_min = 0.0000001;
if (v_max > 3e+10f) v_max = 0.0000001;
v1 = -v_min;
v2 = v_max;
}
else {
float range = _MAX(v_min, v_max);
if (range > 3e+10F) range = 0.0000001;
v1 = -range;
v2 = range;
float rmax = _MAX(v_min, v_max), rmin = _MIN(v_min, v_max);
if (rmax > 3e+10f) rmax = 0.0000001;
if (rmin > 3e+10f) rmin = 0.0000001;
v1 = -rmax;
v2 = rmin;
}
jyersDWIN.updateStatus(TS(F("Red "), p_float_t(v1, 3) , F("..0.."), p_float_t(v2, 3), F(" Green")));
drawing_mesh = false;

View File

@ -8,9 +8,7 @@
* Changed unsigned int to uint16_t for use in the professional Ender-3V2/S1 firmware
* Url: https://www.arduino.cc/reference/en/libraries/base64/
*/
#ifndef BASE64_H_INCLUDED
#define BASE64_H_INCLUDED
#pragma once
/* binary_to_base64:
* Description:
@ -204,5 +202,3 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
return output_length;
}
#endif // ifndef

View File

@ -66,7 +66,6 @@
BedLevelTools bedLevelTools;
#if ENABLED(USE_GRID_MESHVIEWER)
bool BedLevelTools::viewer_asymmetric_range = false;
bool BedLevelTools::viewer_print_value = false;
#endif
bool BedLevelTools::goto_mesh_value = false;
@ -186,20 +185,14 @@ void BedLevelTools::meshReset() {
// Accessors
float BedLevelTools::getMaxValue() {
float max = __FLT_MAX__ * -1;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] > max)
max = bedlevel.z_values[x][y];
}
float max = -(__FLT_MAX__);
GRID_LOOP(x, y) { const float z = bedlevel.z_values[x][y]; if (!isnan(z)) NOLESS(max, z); }
return max;
}
float BedLevelTools::getMinValue() {
float min = __FLT_MAX__;
GRID_LOOP(x, y) {
if (!isnan(bedlevel.z_values[x][y]) && bedlevel.z_values[x][y] < min)
min = bedlevel.z_values[x][y];
}
GRID_LOOP(x, y) { const float z = bedlevel.z_values[x][y]; if (!isnan(z)) NOMORE(min, z); }
return min;
}
@ -221,7 +214,7 @@ bool BedLevelTools::meshValidate() {
const uint16_t total_width_px = DWIN_WIDTH - padding_x - padding_x;
const uint16_t cell_width_px = total_width_px / (GRID_MAX_POINTS_X);
const uint16_t cell_height_px = total_width_px / (GRID_MAX_POINTS_Y);
const float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), range = _MAX(v_min, v_max);
const float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), rmax = _MAX(v_min, v_max);
// Clear background from previous selection and select new square
dwinDrawRectangle(1, COLOR_BG_BLACK, _MAX(0, padding_x - gridline_width), _MAX(0, padding_y_top - gridline_width), padding_x + total_width_px, padding_y_top + total_width_px);
@ -242,8 +235,8 @@ bool BedLevelTools::meshValidate() {
dwinDrawRectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
isnan(bedlevel.z_values[x][y]) ? COLOR_GREY : ( // gray if undefined
(bedlevel.z_values[x][y] < 0 ?
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
(uint16_t)round(0x1F * -bedlevel.z_values[x][y] / rmax) << 11 : // red if mesh point value is negative
(uint16_t)round(0x3F * bedlevel.z_values[x][y] / rmax) << 5) | // green if mesh point value is positive
_MIN(0x1F, (((uint8_t)abs(bedlevel.z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
start_x_px, start_y_px, end_x_px, end_y_px
);
@ -252,7 +245,6 @@ bool BedLevelTools::meshValidate() {
LCD_SERIAL.flushTX();
// Draw value text on
char buf[8];
const uint8_t fs = DWINUI::fontWidth(meshfont);
if (viewer_print_value) {
int8_t offset_x, offset_y = cell_height_px / 2 - fs;
@ -260,14 +252,15 @@ bool BedLevelTools::meshValidate() {
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
}
else { // has value
if (GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10))
sprintf_P(buf, PSTR("%s"), dtostrf(abs(bedlevel.z_values[x][y]), 1, 2, str_1));
MString<12> msg;
if ((GRID_MAX_POINTS_X) < TERN(TJC_DISPLAY, 8, 10))
msg.set(p_float_t(abs(bedlevel.z_values[x][y]), 2));
else
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(bedlevel.z_values[x][y] - (int16_t)bedlevel.z_values[x][y]) * 100));
offset_x = cell_width_px / 2 - (fs/2) * (strlen(buf)) - 2;
if (!(GRID_MAX_POINTS_X < (ENABLED(TJC_DISPLAY) ? 8 : 10)))
msg.setf(F("%02i"), uint16_t(abs(bedlevel.z_values[x][y] - int16_t(bedlevel.z_values[x][y])) * 100));
offset_x = cell_width_px / 2 - (fs / 2) * msg.length() - 2;
if ((GRID_MAX_POINTS_X) >= TERN(TJC_DISPLAY, 8, 10))
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px - 2 + offset_x, start_y_px + offset_y, F("."));
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + 1 + offset_x, start_y_px + offset_y, buf);
dwinDrawString(false, meshfont, COLOR_WHITE, COLOR_BG_BLUE, start_x_px + 1 + offset_x, start_y_px + offset_y, msg);
}
safe_delay(10);
LCD_SERIAL.flushTX();
@ -276,17 +269,10 @@ bool BedLevelTools::meshValidate() {
}
void BedLevelTools::setMeshViewerStatus() { // TODO: draw gradient with values as a legend instead
float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), range = _MAX(v_min, v_max);
if (v_min > 3e+10f) v_min = 0.0000001;
if (v_max > 3e+10f) v_max = 0.0000001;
if (range > 3e+10f) range = 0.0000001;
ui.set_status(
&MString<45>(
F("Red "), p_float_t(viewer_asymmetric_range ? -v_min : -range, 3),
F("..0.."), p_float_t(viewer_asymmetric_range ? v_max : range, 3),
F(" Green")
)
);
float v_max = abs(getMaxValue()), v_min = abs(getMinValue()), rmax = _MAX(v_min, v_max), rmin = _MIN(v_min, v_max);
if (rmax > 3e+10f) rmax = 0.0000001;
if (rmin > 3e+10f) rmin = 0.0000001;
ui.set_status(&MString<47>(F("Red "), p_float_t(-rmax, 3), F("..0.."), p_float_t(rmin, 3), F(" Green")));
drawing_mesh = false;
}

View File

@ -161,8 +161,8 @@
#define MIN_BEDTEMP 0
#define MAX_BEDTEMP BED_MAX_TARGET
#define DWIN_VAR_UPDATE_INTERVAL 1024
#define DWIN_UPDATE_INTERVAL 1024
#define DWIN_VAR_UPDATE_INTERVAL 500
#define DWIN_UPDATE_INTERVAL 1000
#if HAS_MESH && HAS_BED_PROBE
#define BABY_Z_VAR probe.offset.z
@ -1253,6 +1253,13 @@ void eachMomentUpdate() {
static millis_t next_var_update_ms = 0, next_rts_update_ms = 0, next_status_update_ms = 0;
const millis_t ms = millis();
#if LCD_BACKLIGHT_TIMEOUT_MINS
if (ui.backlight_off_ms && ELAPSED(ms, ui.backlight_off_ms)) {
turnOffBacklight(); // Backlight off
ui.backlight_off_ms = 0;
}
#endif
if (ELAPSED(ms, next_var_update_ms)) {
next_var_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL;
blink = !blink;
@ -1276,7 +1283,7 @@ void eachMomentUpdate() {
#endif
if (ELAPSED(ms, next_status_update_ms)) {
next_status_update_ms = ms + 500;
next_status_update_ms = ms + DWIN_VAR_UPDATE_INTERVAL;
dwinDrawStatusMessage();
#if ENABLED(SCROLL_LONG_FILENAMES)
if (isMenu(fileMenu)) fileMenuIdle();
@ -2220,6 +2227,10 @@ void setMoveZ() { hmiValue.axis = Z_AXIS; setPFloatOnClick(Z_MIN_POS, Z_MAX_POS,
#endif
#if LCD_BACKLIGHT_TIMEOUT_MINS
void setTimer() { setPIntOnClick(ui.backlight_timeout_min, ui.backlight_timeout_max); }
#endif
#if HAS_FILAMENT_SENSOR
void setRunoutEnable() {
runout.reset();
@ -2258,13 +2269,6 @@ void setSpeed() { setPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); }
void setFanSpeed() { setIntOnClick(0, 255, thermalManager.fan_speed[0], applyFanSpeed); }
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void changeFilament() {
hmiSaveProcessID(ID_NothingToDo);
queue.inject(F("M600 B2"));
}
#if ENABLED(NOZZLE_PARK_FEATURE)
void parkHead() {
LCD_MESSAGE(MSG_FILAMENT_PARK_ENABLED);
@ -2272,6 +2276,13 @@ void setSpeed() { setPIntOnClick(MIN_PRINT_SPEED, MAX_PRINT_SPEED); }
}
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void changeFilament() {
hmiSaveProcessID(ID_NothingToDo);
queue.inject(F("M600 B2"));
}
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
void unloadFilament() {
LCD_MESSAGE(MSG_FILAMENTUNLOAD);
@ -2979,9 +2990,7 @@ void drawPrepareMenu() {
checkkey = ID_Menu;
if (SET_MENU_R(prepareMenu, selrect({133, 1, 28, 13}), MSG_PREPARE, 10 + PREHEAT_COUNT)) {
BACK_ITEM(gotoMainMenu);
#if ENABLED(ADVANCED_PAUSE_FEATURE)
MENU_ITEM(ICON_FilMan, MSG_FILAMENT_MAN, onDrawSubMenu, drawFilamentManMenu);
#endif
MENU_ITEM(ICON_Axis, MSG_MOVE_AXIS, onDrawMoveSubMenu, drawMoveMenu);
#if ENABLED(LCD_BED_TRAMMING)
MENU_ITEM(ICON_Tram, MSG_BED_TRAMMING, onDrawSubMenu, drawTrammingMenu);
@ -3072,7 +3081,7 @@ void drawControlMenu() {
void drawAdvancedSettingsMenu() {
checkkey = ID_Menu;
if (SET_MENU(advancedSettingsMenu, MSG_ADVANCED_SETTINGS, 23)) {
if (SET_MENU(advancedSettingsMenu, MSG_ADVANCED_SETTINGS, 24)) {
BACK_ITEM(gotoMainMenu);
#if ENABLED(EEPROM_SETTINGS)
MENU_ITEM(ICON_WriteEEPROM, MSG_STORE_EEPROM, onDrawMenuItem, writeEEPROM);
@ -3109,6 +3118,9 @@ void drawAdvancedSettingsMenu() {
#if HAS_LOCKSCREEN
MENU_ITEM(ICON_Lock, MSG_LOCKSCREEN, onDrawMenuItem, dwinLockScreen);
#endif
#if LCD_BACKLIGHT_TIMEOUT_MINS
EDIT_ITEM(ICON_Brightness, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, setTimer, &ui.backlight_timeout_minutes);
#endif
#if ENABLED(SOUND_MENU_ITEM)
EDIT_ITEM(ICON_Sound, MSG_SOUND_ENABLE, onDrawChkbMenu, setEnableSound, &ui.sound_on);
#endif
@ -3330,6 +3342,9 @@ void drawTuneMenu() {
EDIT_ITEM(ICON_Brightness, MSG_BRIGHTNESS, onDrawPInt8Menu, setBrightness, &ui.brightness);
MENU_ITEM(ICON_Brightness, MSG_BRIGHTNESS_OFF, onDrawMenuItem, turnOffBacklight);
#endif
#if LCD_BACKLIGHT_TIMEOUT_MINS
EDIT_ITEM(ICON_Brightness, MSG_SCREEN_TIMEOUT, onDrawPIntMenu, setTimer, &ui.backlight_timeout_minutes);
#endif
#if ENABLED(CASE_LIGHT_MENU)
EDIT_ITEM(ICON_CaseLight, MSG_CASE_LIGHT, onDrawChkbMenu, setCaseLight, &caselight.on);
#if CASELIGHT_USES_BRIGHTNESS
@ -3452,9 +3467,7 @@ void drawMotionMenu() {
updateMenu(motionMenu);
}
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if HAS_PREHEAT
#if ALL(ADVANCED_PAUSE_FEATURE, HAS_PREHEAT)
void drawPreheatHotendMenu() {
checkkey = ID_Menu;
@ -3475,10 +3488,12 @@ void drawMotionMenu() {
#if ENABLED(NOZZLE_PARK_FEATURE)
MENU_ITEM(ICON_Park, MSG_FILAMENT_PARK_ENABLED, onDrawMenuItem, parkHead);
#endif
#if ENABLED(ADVANCED_PAUSE_FEATURE)
#if HAS_PREHEAT
MENU_ITEM(ICON_SetEndTemp, MSG_PREHEAT_HOTEND, onDrawSubMenu, drawPreheatHotendMenu);
#endif
MENU_ITEM(ICON_FilMan, MSG_FILAMENTCHANGE, onDrawMenuItem, changeFilament);
#endif
#if ENABLED(FILAMENT_LOAD_UNLOAD_GCODES)
MENU_ITEM(ICON_FilUnload, MSG_FILAMENTUNLOAD, onDrawMenuItem, unloadFilament);
MENU_ITEM(ICON_FilLoad, MSG_FILAMENTLOAD, onDrawMenuItem, loadFilament);
@ -3487,8 +3502,6 @@ void drawMotionMenu() {
updateMenu(filamentMenu);
}
#endif
#if ENABLED(MESH_BED_LEVELING)
void drawManualMeshMenu() {

View File

@ -321,9 +321,7 @@ void drawFilSetMenu();
#endif
void drawTuneMenu();
void drawMotionMenu();
#if ENABLED(ADVANCED_PAUSE_FEATURE)
void drawFilamentManMenu();
#endif
#if ENABLED(MESH_BED_LEVELING)
void drawManualMeshMenu();
#endif

View File

@ -280,12 +280,12 @@ void DWINUI::drawFillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
// maxv : Maximum value
// color1 : Start color
// color2 : End color
uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
uint16_t DWINUI::colorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2) {
uint8_t B, G, R;
const float n = float(val - minv) / (maxv - minv);
R = (1 - n) * GetRColor(color1) + n * GetRColor(color2);
G = (1 - n) * GetGColor(color1) + n * GetGColor(color2);
B = (1 - n) * GetBColor(color1) + n * GetBColor(color2);
const float n = float(val - minv) / (maxv - minv + 1);
R = (1.0f - n) * GetRColor(color1) + n * GetRColor(color2);
G = (1.0f - n) * GetGColor(color1) + n * GetGColor(color2);
B = (1.0f - n) * GetBColor(color1) + n * GetBColor(color2);
return RGB(R, G, B);
}
@ -293,27 +293,17 @@ uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t colo
// val : Interpolator minv..maxv
// minv : Minimum value
// maxv : Maximum value
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
uint8_t B, G, R;
const uint8_t maxB = 28, maxR = 28, maxG = 38;
uint16_t DWINUI::rainbowInt(int16_t val, int16_t minv, int16_t maxv) {
const int16_t limv = _MAX(abs(minv), abs(maxv));
float n = minv >= 0 ? float(val - minv) / (maxv - minv) : (float)val / limv;
float n = (minv >= 0) ? float(val - minv) / (maxv - minv + 1) : (float)val / limv;
LIMIT(n, -1, 1);
if (n < 0) {
R = 0;
G = (1 + n) * maxG;
B = (-n) * maxB;
}
else if (n < 0.5) {
R = maxR * n * 2;
G = maxG;
B = 0;
}
else {
R = maxR;
G = maxG * (1 - n);
B = 0;
}
constexpr uint8_t maxB = 28, maxR = 28, maxG = 38;
uint8_t R, G, B;
if (n <= -0.5f) { R = 0; G = maxG * (1.0f + n); B = maxB; }
else if (n <= 0.0f) { R = 0; G = maxG; B = maxB * (-n) * 2; }
else if (n < 0.5f) { R = maxR * n * 2; G = maxG; B = 0; }
else { R = maxR; G = maxG * (1.0f - n); B = 0; }
return RGB(R, G, B);
}

View File

@ -564,7 +564,7 @@ namespace DWINUI {
// maxv : Maximum value
// color1 : Start color
// color2 : End color
uint16_t ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
uint16_t colorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t color1, uint16_t color2);
// ------------------------- Buttons ------------------------------//
@ -593,13 +593,13 @@ namespace DWINUI {
// val : Interpolator minv..maxv
// minv : Minimum value
// maxv : Maximum value
uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
uint16_t rainbowInt(int16_t val, int16_t minv, int16_t maxv);
// Write buffer data to the SRAM
// addr: SRAM start address 0x0000-0x7FFF
// length: Bytes to write
// data: address of the buffer with data
inline void WriteToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
inline void writeToSRAM(uint16_t addr, uint16_t length, uint8_t *data) {
dwinWriteToMem(0x5A, addr, length, data);
}
@ -607,7 +607,7 @@ namespace DWINUI {
// addr: Flash start address 0x0000-0x3FFF
// length: Bytes to write
// data: address of the buffer with data
inline void WriteToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
inline void writeToFlash(uint16_t addr, uint16_t length, uint8_t *data) {
dwinWriteToMem(0xA5, addr, length, data);
}

View File

@ -39,7 +39,7 @@
#include "../../../MarlinCore.h" // for wait_for_user
#include "dwin.h"
#include "dwin_popup.h"
#include "base64.hpp"
#include "base64.h"
#define THUMBWIDTH 230
#define THUMBHEIGHT 180
@ -160,7 +160,7 @@ bool Preview::hasPreview() {
return false;
}
uint8_t buf64[fileprop.thumbsize];
uint8_t buf64[fileprop.thumbsize + 1];
uint16_t nread = 0;
while (nread < fileprop.thumbsize) {
const uint8_t c = card.get();

View File

@ -75,37 +75,29 @@ void MeshViewer::drawMeshGrid(const uint8_t csizex, const uint8_t csizey) {
void MeshViewer::drawMeshPoint(const uint8_t x, const uint8_t y, const float z) {
const uint8_t fs = DWINUI::fontWidth(meshfont);
const int16_t v = isnan(z) ? 0 : round(z * 100);
NOLESS(max, z);
NOMORE(min, z);
const uint16_t color = DWINUI::RainbowInt(v, zmin, zmax);
NOLESS(max, z); NOMORE(min, z);
const uint16_t color = DWINUI::rainbowInt(v, zmin, zmax);
DWINUI::drawFillCircle(color, px(x), py(y), r(_MAX(_MIN(v, zmax), zmin)));
TERN_(TJC_DISPLAY, delay(100));
if (sizex < (ENABLED(TJC_DISPLAY) ? 8 : 9)) {
if (v == 0) DWINUI::drawFloat(meshfont, 1, 2, px(x) - 2*fs, py(y) - fs, 0);
else DWINUI::drawSignedFloat(meshfont, 1, 2, px(x) - 3*fs, py(y) - fs, z);
const uint16_t fy = py(y) - fs;
if (sizex < TERN(TJC_DISPLAY, 8, 9)) {
if (v == 0) DWINUI::drawFloat(meshfont, 1, 2, px(x) - 2 * fs, fy, 0);
else DWINUI::drawSignedFloat(meshfont, 1, 2, px(x) - 3 * fs, fy, z);
}
else {
char str_1[9];
str_1[0] = '\0';
char msg[9]; msg[0] = '\0';
switch (v) {
case -999 ... -100:
DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3*fs, py(y) - fs, z);
break;
case -99 ... -1:
sprintf_P(str_1, PSTR("-.%02i"), -v);
break;
case 0:
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 4, py(y) - fs, "0");
break;
case 1 ... 99:
sprintf_P(str_1, PSTR(".%02i"), v);
break;
case 100 ... 999:
DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3 * fs, py(y) - fs, z);
break;
case 100 ... 999: DWINUI::drawSignedFloat(meshfont, 1, 1, px(x) - 3 * fs, fy, z); break;
case -99 ... -1: sprintf_P(msg, PSTR("-.%2i"), -v); break;
case 1 ... 99: sprintf_P(msg, PSTR( ".%2i"), v); break;
default:
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 4, fy, "0");
return;
}
if (str_1[0])
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 2 * fs, py(y) - fs, str_1);
dwinDrawString(false, meshfont, DWINUI::textColor, DWINUI::backColor, px(x) - 2 * fs, fy, msg);
}
}

View File

@ -38,38 +38,41 @@
#define Plot_Bg_Color RGB( 1, 12, 8)
PlotClass plot;
Plot plot;
uint16_t grphpoints, r, x2, y2 = 0;
frame_rect_t grphframe = {0};
uint16_t graphpoints, r, x2, y2 = 0;
frame_rect_t graphframe = {0};
float scale = 0;
void PlotClass::draw(const frame_rect_t &frame, const_float_t max, const_float_t ref/*=0*/) {
grphframe = frame;
grphpoints = 0;
void Plot::draw(const frame_rect_t &frame, const_celsius_float_t max, const_float_t ref/*=0*/) {
graphframe = frame;
graphpoints = 0;
scale = frame.h / max;
x2 = frame.x + frame.w - 1;
y2 = frame.y + frame.h - 1;
r = round((y2) - ref * scale);
DWINUI::drawBox(1, Plot_Bg_Color, frame);
for (uint8_t i = 1; i < 4; i++) if (i * 50 < frame.w) dwinDrawVLine(COLOR_LINE, i * 50 + frame.x, frame.y, frame.h);
for (uint8_t i = 1; i < 4; i++) if (i * 60 < frame.w) dwinDrawVLine(COLOR_LINE, i * 60 + frame.x, frame.y, frame.h);
DWINUI::drawBox(0, COLOR_WHITE, DWINUI::extendFrame(frame, 1));
dwinDrawHLine(COLOR_RED, frame.x, r, frame.w);
}
void PlotClass::update(const_float_t value) {
void Plot::update(const_float_t value) {
if (!scale) return;
const uint16_t y = round((y2) - value * scale);
if (grphpoints < grphframe.w) {
dwinDrawPoint(COLOR_YELLOW, 1, 1, grphpoints + grphframe.x, y);
if (graphpoints < graphframe.w) {
dwinDrawPoint(COLOR_YELLOW, 1, 1, graphpoints + graphframe.x, y);
}
else {
dwinFrameAreaMove(1, 0, 1, Plot_Bg_Color, grphframe.x, grphframe.y, x2, y2);
if ((grphpoints % 50) == 0) dwinDrawVLine(COLOR_LINE, x2 - 1, grphframe.y + 1, grphframe.h - 2);
dwinFrameAreaMove(1, 0, 1, Plot_Bg_Color, graphframe.x, graphframe.y, x2, y2);
if ((graphpoints % 60) == 0) dwinDrawVLine(COLOR_LINE, x2 - 1, graphframe.y + 1, graphframe.h - 2);
dwinDrawPoint(COLOR_RED, 1, 1, x2 - 1, r);
dwinDrawPoint(COLOR_YELLOW, 1, 1, x2 - 1, y);
}
grphpoints++;
graphpoints++;
#if LCD_BACKLIGHT_TIMEOUT_MINS
ui.refresh_backlight_timeout();
#endif
}
#endif // DWIN_LCD_PROUI && PROUI_TUNING_GRAPH

View File

@ -30,10 +30,10 @@
#include "dwinui.h"
class PlotClass {
class Plot {
public:
static void draw(const frame_rect_t &frame, const_float_t max, const_float_t ref=0);
static void draw(const frame_rect_t &frame, const_celsius_float_t max, const_float_t ref=0);
static void update(const_float_t value);
};
extern PlotClass plot;
extern Plot plot;

View File

@ -190,7 +190,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
millis_t MarlinUI::backlight_off_ms = 0;
void MarlinUI::refresh_backlight_timeout() {
backlight_off_ms = backlight_timeout_minutes ? millis() + backlight_timeout_minutes * 60UL * 1000UL : 0;
backlight_off_ms = backlight_timeout_minutes ? millis() + MIN_TO_MS(backlight_timeout_minutes) : 0;
#ifdef NEOPIXEL_BKGD_INDEX_FIRST
neo.reset_background_color();
neo.show();

View File

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.5)
#====================================================================#
# Usage under Linux: #
# #
@ -82,7 +82,7 @@ message("-- Running CMake version: " ${CMAKE_VERSION})
# Replace the CMake Ver. in the Arduino.cmake
file(READ "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" ORIGINAL_FILE_CONTENTS)
string(REPLACE "cmake_minimum_required(VERSION 2.8.5)" "cmake_minimum_required(VERSION 2.8.12)" NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}")
string(REPLACE "cmake_minimum_required(VERSION 2.8.5)" "cmake_minimum_required(VERSION 3.5)" NEW_FILE_CONTENTS "${ORIGINAL_FILE_CONTENTS}")
file(WRITE "${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/Platform/Arduino.cmake" "${NEW_FILE_CONTENTS}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/modules)
@ -95,6 +95,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_LIST_DIR}/marlin-cma
set(ARDUINO_SDK_PATH ${CMAKE_CURRENT_LIST_DIR}/arduino-1.8.19)
#set(ARDUINO_SDK_PATH /Applications/Arduino.app/Contents/Java)
#set(ARDUINO_SDK_PATH $HOME/ArduinoAddons/Arduino_1.6.x)
#====================================================================#
# Set included cmake files #
#====================================================================#
@ -108,6 +109,19 @@ set(CMAKE_TOOLCHAIN_FILE ${CMAKE_CURRENT_LIST_DIR}/marlin-cmake/toolchain/Arduin
#====================================================================#
# Setup Project #
# #
# If you receive this error: #
# 'Unknown CMake command "_cmake_record_install_prefix".' #
# #
# Go to the file in your CMake directory. #
# #
# For Windows: cmake\Modules\Platform\WindowsPaths.cmake #
# For Linux: cmake/Modules/Platform/UnixPaths.cmake #
# #
# Comment out "_cmake_record_install_prefix()" #
# - OR - #
# Add "include(CMakeSystemSpecificInformation)" above the line. #
# #
#====================================================================#
project(Marlin C CXX)