Skip to content

Commit

Permalink
Clean up and patch
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Jul 25, 2021
1 parent 86be930 commit 95f7fb3
Show file tree
Hide file tree
Showing 21 changed files with 1,486 additions and 1,975 deletions.
2 changes: 1 addition & 1 deletion Marlin/Configuration_adv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,7 @@

// @section lcd

#if EITHER(IS_ULTIPANEL, EXTENSIBLE_UI)
#if ANY(IS_ULTIPANEL, EXTENSIBLE_UI, DWIN_CREALITY_LCD)
#define MANUAL_FEEDRATE { 50*60, 50*60, 4*60, 2*60 } // (mm/min) Feedrates for manual moves along X, Y, Z, E from panel
#define FINE_MANUAL_MOVE 0.025 // (mm) Smallest manual move (< 0.1mm) applying to Z on most machines
#if IS_ULTIPANEL
Expand Down
5 changes: 3 additions & 2 deletions Marlin/src/MarlinCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#include "lcd/dwin/creality_dwin.h"
#include "lcd/dwin/rotary_encoder.h"
#include "lcd/dwin/e3v2/dwin.h"
#include "lcd/dwin/e3v2/rotary_encoder.h"
#endif

#if ENABLED(EXTENSIBLE_UI)
Expand Down Expand Up @@ -868,6 +868,7 @@ void idle(bool no_stepper_sleep/*=false*/) {
TERN_(AUTO_REPORT_TEMPERATURES, thermalManager.auto_reporter.tick());
TERN_(AUTO_REPORT_SD_STATUS, card.auto_reporter.tick());
TERN_(AUTO_REPORT_POSITION, position_auto_reporter.tick());
TERN_(BUFFER_MONITORING, queue.auto_report_buffer_statistics());
}
#endif

Expand Down
5 changes: 2 additions & 3 deletions Marlin/src/gcode/feature/powerloss/M1000.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@
#include "../../../lcd/marlinui.h"
#if ENABLED(EXTENSIBLE_UI)
#include "../../../lcd/extui/ui_api.h"
#endif
#if ENABLED(DWIN_CREALITY_LCD)
#include "../../../lcd/dwin/creality_dwin.h" // Temporary fix until it can be better implemented
#elif ENABLED(DWIN_CREALITY_LCD)
#include "../../../lcd/dwin/e3v2/dwin.h" // Temporary fix until it can be better implemented
#endif

#define DEBUG_OUT ENABLED(DEBUG_POWER_LOSS_RECOVERY)
Expand Down
2 changes: 2 additions & 0 deletions Marlin/src/gcode/gcode.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
* M553 - Get or set IP netmask. (Requires enabled Ethernet port)
* M554 - Get or set IP gateway. (Requires enabled Ethernet port)
* M569 - Enable stealthChop on an axis. (Requires at least one _DRIVER_TYPE to be TMC2130/2160/2208/2209/5130/5160)
* M575 - Change the serial baud rate. (Requires BAUD_RATE_GCODE)
* M600 - Pause for filament change: "M600 X<pos> Y<pos> Z<raise> E<first_retract> L<later_retract>". (Requires ADVANCED_PAUSE_FEATURE)
* M603 - Configure filament change: "M603 T<tool> U<unload_length> L<load_length>". (Requires ADVANCED_PAUSE_FEATURE)
* M605 - Set Dual X-Carriage movement mode: "M605 S<mode> [X<x_offset>] [R<temp_offset>]". (Requires DUAL_X_CARRIAGE)
Expand Down Expand Up @@ -298,6 +299,7 @@
* M997 - Perform in-application firmware update
* M999 - Restart after being stopped by error
* D... - Custom Development G-code. Add hooks to 'gcode_D.cpp' for developers to test features. (Requires MARLIN_DEV_MODE)
* D576 - Set buffer monitoring options. (Requires BUFFER_MONITORING)
*
* "T" Codes
*
Expand Down
24 changes: 23 additions & 1 deletion Marlin/src/gcode/lcd/M251.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*
*/
#include "../../inc/MarlinConfig.h"

#if HAS_LCD_BRIGHTNESS
Expand All @@ -9,7 +30,8 @@
* M251: Set the LCD brightness
*/
void GcodeSuite::M251() {
if (parser.seen('B')) ui.set_brightness(parser.value_int());
if (parser.seenval('B')) ui.set_brightness(parser.value_int());
SERIAL_ECHOLNPAIR("LCD Brightness: ", ui.brightness);
}

#endif // HAS_LCD_BRIGHTNESS
4 changes: 2 additions & 2 deletions Marlin/src/gcode/lcd/M73.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@
* M73 P25 ; Set progress to 25%
*/
void GcodeSuite::M73() {
if (parser.seen('P'))
if (parser.seenval('P'))
ui.set_progress((PROGRESS_SCALE) > 1
? parser.value_float() * (PROGRESS_SCALE)
: parser.value_byte()
);
#if BOTH(LCD_SET_PROGRESS_MANUALLY, USE_M73_REMAINING_TIME)
if (parser.seen('R')) ui.set_remaining_time(60 * parser.value_ulong());
if (parser.seenval('R')) ui.set_remaining_time(60 * parser.value_ulong());
#endif
}

Expand Down
11 changes: 7 additions & 4 deletions Marlin/src/inc/Conditionals_LCD.h
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
#endif

// Aliases for LCD features
#if EITHER(IS_ULTRA_LCD, EXTENSIBLE_UI)
#if ANY(IS_ULTRA_LCD, EXTENSIBLE_UI, DWIN_CREALITY_LCD)
#define HAS_DISPLAY 1
#endif

Expand All @@ -490,7 +490,7 @@
#endif
#endif

#if ANY(HAS_DISPLAY, DWIN_CREALITY_LCD, GLOBAL_STATUS_MESSAGE)
#if EITHER(HAS_DISPLAY, GLOBAL_STATUS_MESSAGE)
#define HAS_STATUS_MESSAGE 1
#endif

Expand Down Expand Up @@ -1081,10 +1081,13 @@
#endif

#if ENABLED(DWIN_CREALITY_LCD)
#define HAS_DISPLAY 1
#define SERIAL_CATCHALL 0
#ifndef LCD_SERIAL_PORT
#define LCD_SERIAL_PORT 3 // Creality 4.x board
#if MB(BTT_SKR_MINI_E3_V1_0, BTT_SKR_MINI_E3_V1_2, BTT_SKR_MINI_E3_V2_0, BTT_SKR_E3_TURBO)
#define LCD_SERIAL_PORT 1
#else
#define LCD_SERIAL_PORT 3 // Creality 4.x board
#endif
#endif
#endif

Expand Down
9 changes: 6 additions & 3 deletions Marlin/src/inc/Conditionals_post.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,12 @@

#if ENABLED(DWIN_CREALITY_LCD)
#define HAS_LCD_BRIGHTNESS 1
#define MAX_LCD_BRIGHTNESS 255
#define MIN_LCD_BRIGHTNESS 1
#define DEFAULT_LCD_BRIGHTNESS 255
#endif

#if HAS_LCD_BRIGHTNESS
#define MIN_LCD_BRIGHTNESS 1
#define MAX_LCD_BRIGHTNESS 255
#define DEFAULT_LCD_BRIGHTNESS MAX_LCD_BRIGHTNESS
#endif

/**
Expand Down
48 changes: 11 additions & 37 deletions Marlin/src/lcd/dwin/creality_marlinui.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Marlin 3D Printer Firmware
* Copyright (c) 2020 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
*
* Based on Sprinter and grbl.
* Copyright (c) 2011 Camiel Gubbels / Erik van der Zalm
Expand All @@ -22,7 +22,7 @@

/**
* DWIN by Creality3D
* Rewrite and Extui Port by Jacob Myers
* Rewrite by Jacob Myers
*/

#include "../../inc/MarlinConfigPre.h"
Expand All @@ -33,41 +33,17 @@
#include "../../feature/pause.h"
#endif

#include "creality_dwin.h"
#include "e3v2/dwin.h"
#include "../marlinui.h"

uint8_t MarlinUI::brightness = DEFAULT_LCD_BRIGHTNESS;
bool MarlinUI::backlight = true;

void MarlinUI::set_brightness(const uint8_t value) {
if (value == 0) {
backlight = false;
DWIN_Backlight_SetLuminance(0);
}
else {
backlight = true;
brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
DWIN_Backlight_SetLuminance(brightness);
}
}

#if ENABLED(ADVANCED_PAUSE_FEATURE)
void MarlinUI::pause_show_message(const PauseMessage message, const PauseMode mode/*=PAUSE_MODE_SAME*/, const uint8_t extruder/*=active_extruder*/) {
switch(message) {
case PAUSE_MESSAGE_INSERT:
CrealityDWIN.Confirm_Handler(FilInsert);
break;
case PAUSE_MESSAGE_OPTION:
CrealityDWIN.Popup_Handler(PurgeMore);
break;
case PAUSE_MESSAGE_HEAT:
CrealityDWIN.Confirm_Handler(HeaterTime);
break;
case PAUSE_MESSAGE_WAITING:
CrealityDWIN.Draw_Print_Screen();
break;
default:
break;
switch (message) {
case PAUSE_MESSAGE_INSERT: CrealityDWIN.Confirm_Handler(FilInsert); break;
case PAUSE_MESSAGE_OPTION: CrealityDWIN.Popup_Handler(PurgeMore); break;
case PAUSE_MESSAGE_HEAT: CrealityDWIN.Confirm_Handler(HeaterTime); break;
case PAUSE_MESSAGE_WAITING: CrealityDWIN.Draw_Print_Screen(); break;
default: break;
}
}
#endif
Expand All @@ -83,9 +59,7 @@ bool MarlinUI::get_blink() {
return blink != 0;
}

void MarlinUI::update() {
CrealityDWIN.Update();
}
void MarlinUI::update() { CrealityDWIN.Update(); }

void MarlinUI::init() {
delay(800);
Expand All @@ -108,4 +82,4 @@ void MarlinUI::kill_screen(PGM_P const error, PGM_P const component) {
CrealityDWIN.Draw_Popup((char*)"Printer Kill Reason:", error, (char*)"Restart Required", Wait, ICON_BLTouch);
}

#endif
#endif // DWIN_CREALITY_LCD
21 changes: 10 additions & 11 deletions Marlin/src/lcd/dwin/dwin_lcd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ bool DWIN_Handshake(void) {
#endif
LCD_SERIAL.begin(LCD_BAUDRATE);
const millis_t serial_connect_timeout = millis() + 1000UL;
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
while (!LCD_SERIAL && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }

size_t i = 0;
DWIN_Byte(i, 0x00);
Expand Down Expand Up @@ -211,18 +211,17 @@ void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,

//Color: color
//x/y: Upper-left coordinate of the first pixel
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
DWIN_Draw_Point(Color, 1, 1, x + 1, y);
DWIN_Draw_Point(Color, 1, 1, x + 2, y);
DWIN_Draw_Point(Color, 1, 1, x, y + 1);
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 1);
DWIN_Draw_Point(Color, 1, 1, x, y + 2);
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 2);
DWIN_Draw_Point(Color, 1, 1, x + 1, y + 3);
DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3);
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
DWIN_Draw_Point(Color, 1, 1, x + 1, y);
DWIN_Draw_Point(Color, 1, 1, x + 2, y);
DWIN_Draw_Point(Color, 1, 1, x, y + 1);
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 1);
DWIN_Draw_Point(Color, 1, 1, x, y + 2);
DWIN_Draw_Point(Color, 1, 1, x + 3, y + 2);
DWIN_Draw_Point(Color, 1, 1, x + 1, y + 3);
DWIN_Draw_Point(Color, 1, 1, x + 2, y + 3);
}


// Move a screen area
// mode: 0, circle shift; 1, translation
// dir: 0=left, 1=right, 2=up, 3=down
Expand Down
Loading

0 comments on commit 95f7fb3

Please sign in to comment.