Merge upstream changes from Marlin 2.1.2
This commit is contained in:
@@ -21,7 +21,10 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
/* DGUS implementation written by coldtobi in 2019 for Marlin */
|
||||
/**
|
||||
* DGUS implementation written by coldtobi in 2019.
|
||||
* Updated for STM32G0B1RE by Protomosh in 2022.
|
||||
*/
|
||||
|
||||
#include "config/DGUS_Screen.h"
|
||||
#include "config/DGUS_Control.h"
|
||||
@@ -30,11 +33,13 @@
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "../../../MarlinCore.h"
|
||||
|
||||
//#define DEBUG_DGUSLCD // Uncomment for debug messages
|
||||
#define DEBUG_OUT ENABLED(DEBUG_DGUSLCD)
|
||||
#include "../../../core/debug_out.h"
|
||||
|
||||
#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) |\
|
||||
((uint16_t)(val) << 8)))
|
||||
// New endianness swap for 32bit mcu (tested with STM32G0B1RE)
|
||||
#define BE16_P(V) ( ((uint8_t*)(V))[0] << 8U | ((uint8_t*)(V))[1] )
|
||||
#define BE32_P(V) ( ((uint8_t*)(V))[0] << 24U | ((uint8_t*)(V))[1] << 16U | ((uint8_t*)(V))[2] << 8U | ((uint8_t*)(V))[3] )
|
||||
|
||||
// Low-Level access to the display.
|
||||
class DGUSDisplay {
|
||||
|
@@ -215,7 +215,7 @@ void DGUSRxHandler::PrintResume(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const int16_t feedrate = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t feedrate = BE16_P(data_ptr);
|
||||
|
||||
ExtUI::setFeedrate_percent(feedrate);
|
||||
|
||||
@@ -223,7 +223,7 @@ void DGUSRxHandler::Feedrate(DGUS_VP &vp, void *data_ptr) {
|
||||
}
|
||||
|
||||
void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) {
|
||||
const int16_t flowrate = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t flowrate = BE16_P(data_ptr);
|
||||
|
||||
switch (vp.addr) {
|
||||
default: return;
|
||||
@@ -246,7 +246,7 @@ void DGUSRxHandler::Flowrate(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::BabystepSet(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const int16_t data = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t data = BE16_P(data_ptr);
|
||||
const float offset = dgus_display.FromFixedPoint<int16_t, float, 2>(data);
|
||||
|
||||
const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z);
|
||||
@@ -315,7 +315,7 @@ void DGUSRxHandler::TempPreset(DGUS_VP &vp, void *data_ptr) {
|
||||
}
|
||||
|
||||
void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) {
|
||||
const int16_t temp = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t temp = BE16_P(data_ptr);
|
||||
|
||||
switch (vp.addr) {
|
||||
default: return;
|
||||
@@ -338,7 +338,7 @@ void DGUSRxHandler::TempTarget(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::TempCool(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr);
|
||||
const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr);
|
||||
|
||||
switch (heater) {
|
||||
default: return;
|
||||
@@ -397,7 +397,7 @@ void DGUSRxHandler::ZOffset(DGUS_VP &vp, void *data_ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
const int16_t data = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t data = BE16_P(data_ptr);
|
||||
const float offset = dgus_display.FromFixedPoint<int16_t, float, 2>(data);
|
||||
|
||||
const int16_t steps = ExtUI::mmToWholeSteps(offset - ExtUI::getZOffset_mm(), ExtUI::Z);
|
||||
@@ -546,7 +546,7 @@ void DGUSRxHandler::DisableABL(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)Swap16(*(uint16_t*)data_ptr);
|
||||
const DGUS_Data::Extruder extruder = (DGUS_Data::Extruder)BE16_P(data_ptr);
|
||||
|
||||
switch (extruder) {
|
||||
default: return;
|
||||
@@ -563,7 +563,7 @@ void DGUSRxHandler::FilamentSelect(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::FilamentLength(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const uint16_t length = Swap16(*(uint16_t*)data_ptr);
|
||||
const uint16_t length = BE16_P(data_ptr);
|
||||
|
||||
dgus_screen_handler.filament_length = constrain(length, 0, EXTRUDE_MAXLENGTH);
|
||||
|
||||
@@ -644,7 +644,7 @@ void DGUSRxHandler::Home(DGUS_VP &vp, void *data_ptr) {
|
||||
}
|
||||
|
||||
void DGUSRxHandler::Move(DGUS_VP &vp, void *data_ptr) {
|
||||
const int16_t data = Swap16(*(int16_t*)data_ptr);
|
||||
const int16_t data = BE16_P(data_ptr);
|
||||
const float position = dgus_display.FromFixedPoint<int16_t, float, 1>(data);
|
||||
ExtUI::axis_t axis;
|
||||
|
||||
@@ -816,7 +816,7 @@ void DGUSRxHandler::SettingsExtra(DGUS_VP &vp, void *data_ptr) {
|
||||
void DGUSRxHandler::PIDSelect(DGUS_VP &vp, void *data_ptr) {
|
||||
UNUSED(vp);
|
||||
|
||||
const DGUS_Data::Heater heater = (DGUS_Data::Heater)Swap16(*(uint16_t*)data_ptr);
|
||||
const DGUS_Data::Heater heater = (DGUS_Data::Heater)BE16_P(data_ptr);
|
||||
|
||||
switch (heater) {
|
||||
default: return;
|
||||
@@ -846,7 +846,7 @@ void DGUSRxHandler::PIDSetTemp(DGUS_VP &vp, void *data_ptr) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t temp = Swap16(*(uint16_t*)data_ptr);
|
||||
uint16_t temp = BE16_P(data_ptr);
|
||||
|
||||
switch (dgus_screen_handler.pid_heater) {
|
||||
default: return;
|
||||
|
@@ -107,7 +107,7 @@ namespace DGUSRxHandler {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
const uint16_t data = Swap16(*(uint16_t*)data_ptr);
|
||||
const uint16_t data = BE16_P(data_ptr);
|
||||
*(T*)vp.extra = (T)data;
|
||||
break;
|
||||
}
|
||||
|
@@ -421,16 +421,16 @@ void DGUSTxHandler::PIDKp(DGUS_VP &vp) {
|
||||
default: return;
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
case DGUS_Data::Heater::BED:
|
||||
value = ExtUI::getBedPIDValues_Kp();
|
||||
value = ExtUI::getBedPID_Kp();
|
||||
break;
|
||||
#endif
|
||||
#if ENABLED(PIDTEMP)
|
||||
case DGUS_Data::Heater::H0:
|
||||
value = ExtUI::getPIDValues_Kp(ExtUI::E0);
|
||||
value = ExtUI::getPID_Kp(ExtUI::E0);
|
||||
break;
|
||||
#if HAS_MULTI_HOTEND
|
||||
case DGUS_Data::Heater::H1:
|
||||
value = ExtUI::getPIDValues_Kp(ExtUI::E1);
|
||||
value = ExtUI::getPID_Kp(ExtUI::E1);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
@@ -447,16 +447,16 @@ void DGUSTxHandler::PIDKi(DGUS_VP &vp) {
|
||||
default: return;
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
case DGUS_Data::Heater::BED:
|
||||
value = ExtUI::getBedPIDValues_Ki();
|
||||
value = ExtUI::getBedPID_Ki();
|
||||
break;
|
||||
#endif
|
||||
#if ENABLED(PIDTEMP)
|
||||
case DGUS_Data::Heater::H0:
|
||||
value = ExtUI::getPIDValues_Ki(ExtUI::E0);
|
||||
value = ExtUI::getPID_Ki(ExtUI::E0);
|
||||
break;
|
||||
#if HAS_MULTI_HOTEND
|
||||
case DGUS_Data::Heater::H1:
|
||||
value = ExtUI::getPIDValues_Ki(ExtUI::E1);
|
||||
value = ExtUI::getPID_Ki(ExtUI::E1);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
@@ -473,16 +473,16 @@ void DGUSTxHandler::PIDKd(DGUS_VP &vp) {
|
||||
default: return;
|
||||
#if ENABLED(PIDTEMPBED)
|
||||
case DGUS_Data::Heater::BED:
|
||||
value = ExtUI::getBedPIDValues_Kd();
|
||||
value = ExtUI::getBedPID_Kd();
|
||||
break;
|
||||
#endif
|
||||
#if ENABLED(PIDTEMP)
|
||||
case DGUS_Data::Heater::H0:
|
||||
value = ExtUI::getPIDValues_Kd(ExtUI::E0);
|
||||
value = ExtUI::getPID_Kd(ExtUI::E0);
|
||||
break;
|
||||
#if HAS_MULTI_HOTEND
|
||||
case DGUS_Data::Heater::H1:
|
||||
value = ExtUI::getPIDValues_Kd(ExtUI::E1);
|
||||
value = ExtUI::getPID_Kd(ExtUI::E1);
|
||||
break;
|
||||
#endif
|
||||
#endif
|
||||
|
@@ -24,6 +24,8 @@
|
||||
#include "DGUSDisplay.h"
|
||||
#include "definition/DGUS_VP.h"
|
||||
|
||||
#define Swap16(val) ((uint16_t)(((uint16_t)(val) >> 8) | ((uint16_t)(val) << 8)))
|
||||
|
||||
namespace DGUSTxHandler {
|
||||
|
||||
#if ENABLED(SDSUPPORT)
|
||||
|
Reference in New Issue
Block a user