Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various LCD / backlight adjustments #26086

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
5d871ee
Fix JyersUI setMeshViewerStatus()
classicrocker883 Jul 14, 2023
f2b9754
Fix ProUI functions not used
classicrocker883 Jul 14, 2023
125451e
Add, rename hostShutDown
classicrocker883 Jul 14, 2023
f65e52a
Update dwin.cpp
classicrocker883 Jul 14, 2023
3e1bfd1
Revert dwin.cpp, Remove setMeshViewerStatus dwin.h
classicrocker883 Jul 14, 2023
9067105
cleanup
thinkyhead Jul 15, 2023
d57ff7f
Defer until later
thinkyhead Jul 15, 2023
9385663
declare mesh_conf in place
thinkyhead Jul 15, 2023
feba819
toggle with xor
thinkyhead Jul 15, 2023
7b7efda
use targetTooColdToExtrude
thinkyhead Jul 15, 2023
ef776f1
cleanup
thinkyhead Jul 15, 2023
cb171c3
use getters
thinkyhead Jul 15, 2023
dfe61d0
Fix view mesh range
classicrocker883 Jul 16, 2023
7ee1605
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 16, 2023
0444c61
Remove asymmetric (unused), same fix with range
classicrocker883 Jul 16, 2023
2f6f663
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 17, 2023
0d59183
revert unwanted changes
classicrocker883 Jul 17, 2023
5ed838b
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 23, 2023
c282a4f
LCD_BACKLIGHT_TIMEOUT_MINS to work w/DWIN displays
classicrocker883 Jul 23, 2023
f463a1f
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 25, 2023
dfaf0b1
proui/meshviewer.cpp draws actual value
classicrocker883 Jul 25, 2023
05e3100
proui/meshviewer draws gradiant "rainbow-y" colors
classicrocker883 Jul 25, 2023
253cb97
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 27, 2023
eee44d8
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 28, 2023
f8adcdf
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 28, 2023
9baf92c
Fix missing `str_1` error
classicrocker883 Jul 28, 2023
32d5759
Rearrange ProUI dwin.cpp to fix Adv_Pause_Feat.
classicrocker883 Jul 28, 2023
4d3e812
Update CMakeLists.txt cmake_min v3.5, fix warning
classicrocker883 Jul 29, 2023
85d1be3
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Jul 30, 2023
a632cbd
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Aug 3, 2023
f39ad7d
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Aug 4, 2023
821fde0
Merge branch 'MarlinFirmware:bugfix-2.1.x' into bugfix-2.1.x-fix
classicrocker883 Aug 5, 2023
a6a1e1c
misc. adjustments
thinkyhead Aug 7, 2023
3b0d5fb
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Aug 7, 2023
b3e6a53
small updates
classicrocker883 Aug 7, 2023
d742ed1
Merge branch 'bugfix-2.1.x' of https://github.com/MarlinFirmware/Marl…
classicrocker883 Aug 8, 2023
0345295
Update SanityCheck.h
classicrocker883 Aug 10, 2023
5425fb6
Update ubl_G29.cpp
classicrocker883 Aug 10, 2023
b8fa4bf
Update bedlevel_tools.cpp
classicrocker883 Aug 11, 2023
b9c9fd8
Update dwin.cpp
classicrocker883 Aug 12, 2023
7c87e3a
Update meshviewer.cpp
classicrocker883 Aug 13, 2023
05713f5
revert unwanted changes in meshviewer.cpp
classicrocker883 Aug 13, 2023
6174b2b
Update meshviewer.cpp - tested: works!
classicrocker883 Aug 16, 2023
b8e0436
revert meshviewer.cpp
classicrocker883 Aug 16, 2023
429ae63
etc
thinkyhead Aug 23, 2023
1e89856
Merge remote-tracking branch 'upstream/bugfix-2.1.x' into pr/26086
thinkyhead Aug 23, 2023
5e0c0a1
squash, range + 1
thinkyhead Aug 23, 2023
8298732
fixes and rename
classicrocker883 Aug 23, 2023
7c07504
roll back range/ omit `rmin` for color gradiant
classicrocker883 Aug 23, 2023
74c7f3a
Preview updates
thinkyhead Aug 24, 2023
33aff88
Rename Class Plot, fixes
classicrocker883 Aug 25, 2023
48a325e
Update Interval fix
classicrocker883 Aug 25, 2023
32649cb
Merge branch 'bugfix-2.1.x' into pr/26086
thinkyhead Aug 25, 2023
4fbcd45
Fix stack corruption
thinkyhead Aug 25, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Marlin/src/feature/bedlevel/ubl/ubl_G29.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Expand Down
6 changes: 3 additions & 3 deletions Marlin/src/inc/SanityCheck.h
Original file line number Diff line number Diff line change
Expand Up @@ -2722,16 +2722,16 @@ 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)
#error "LCD_BACKLIGHT_PIN and NEOPIXEL_BKGD_INDEX_FIRST are not supported at the same time."
#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

Expand Down
18 changes: 15 additions & 3 deletions Marlin/src/lcd/e3v2/common/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -164,9 +176,9 @@ EncoderState encoderReceiveAnalyze() {

// LED light operation
void LED_Action() {
LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
LED_Control(RGB_SCALE_WARM_WHITE, 0x0F);
delay(30);
LED_Control(RGB_SCALE_WARM_WHITE,0x00);
LED_Control(RGB_SCALE_WARM_WHITE, 0x00);
}

// LED initialization
Expand Down
35 changes: 15 additions & 20 deletions Marlin/src/lcd/e3v2/jyersui/dwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,20 +341,14 @@ class TextScroller {
}

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;
}

Expand All @@ -363,7 +357,7 @@ class TextScroller {
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);
Expand All @@ -381,11 +375,11 @@ class TextScroller {
const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
const auto start_y_px = padding_y_top + (GRID_MAX_POINTS_Y - y - 1) * cell_height_px;
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
dwinDrawRectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
isnan(bedlevel.z_values[x][y]) ? COLOR_GREY : ( // gray if undefined
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
);
Expand Down Expand Up @@ -421,16 +415,17 @@ class TextScroller {
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -135,11 +133,11 @@ uint16_t decode_base64_length(unsigned char input[], uint16_t input_length) {
}

input_length = input - start;
return input_length/4*3 + (input_length % 4 ? input_length % 4 - 1 : 0);
return input_length / 4 * 3 + (input_length % 4 ? input_length % 4 - 1 : 0);
}

uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned char output[]) {
uint16_t full_sets = input_length/3;
uint16_t full_sets = input_length / 3;

// While there are still full sets of 24 bits...
for (uint16_t i = 0; i < full_sets; ++i) {
Expand All @@ -152,7 +150,7 @@ uint16_t encode_base64(unsigned char input[], uint16_t input_length, unsigned ch
output += 4;
}

switch(input_length % 3) {
switch (input_length % 3) {
case 0:
output[0] = '\0';
break;
Expand Down Expand Up @@ -192,7 +190,7 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch
output += 3;
}

switch(output_length % 3) {
switch (output_length % 3) {
case 1:
output[0] = base64_to_binary(input[0]) << 2 | base64_to_binary(input[1]) >> 4;
break;
Expand All @@ -204,5 +202,3 @@ uint16_t decode_base64(unsigned char input[], uint16_t input_length, unsigned ch

return output_length;
}

#endif // ifndef
48 changes: 17 additions & 31 deletions Marlin/src/lcd/e3v2/proui/bedlevel_tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}

Expand All @@ -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);
Expand All @@ -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
);
Expand All @@ -252,22 +245,22 @@ 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;
if (isnan(bedlevel.z_values[x][y])) { // undefined
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();
Expand All @@ -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;
}

Expand Down
Loading
Loading