Merge upstream changes from Marlin 2.1.1
This commit is contained in:
@@ -21,10 +21,11 @@
|
||||
*/
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||
#if HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
|
||||
|
||||
#include "dwin_api.h"
|
||||
#include "dwin_set.h"
|
||||
#include "dwin_font.h"
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
@@ -89,6 +90,40 @@ bool DWIN_Handshake() {
|
||||
}
|
||||
#endif
|
||||
|
||||
// Get font character width
|
||||
uint8_t fontWidth(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 6;
|
||||
case font8x16 : return 8;
|
||||
case font10x20: return 10;
|
||||
case font12x24: return 12;
|
||||
case font14x28: return 14;
|
||||
case font16x32: return 16;
|
||||
case font20x40: return 20;
|
||||
case font24x48: return 24;
|
||||
case font28x56: return 28;
|
||||
case font32x64: return 32;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Get font character height
|
||||
uint8_t fontHeight(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 12;
|
||||
case font8x16 : return 16;
|
||||
case font10x20: return 20;
|
||||
case font12x24: return 24;
|
||||
case font14x28: return 28;
|
||||
case font16x32: return 32;
|
||||
case font20x40: return 40;
|
||||
case font24x48: return 48;
|
||||
case font28x56: return 56;
|
||||
case font32x64: return 64;
|
||||
default: return 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Set screen display direction
|
||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
||||
@@ -199,6 +234,9 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||
// *string: The string
|
||||
// rlimit: To limit the drawn string length
|
||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit/*=0xFFFF*/) {
|
||||
#if DISABLED(DWIN_LCD_PROUI)
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + (fontWidth(size) * strlen_P(string)), y + fontHeight(size));
|
||||
#endif
|
||||
constexpr uint8_t widthAdjust = 0;
|
||||
size_t i = 0;
|
||||
DWIN_Byte(i, 0x11);
|
||||
@@ -228,6 +266,7 @@ void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor,
|
||||
void DWIN_Draw_IntValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||
uint16_t bColor, uint8_t iNum, uint16_t x, uint16_t y, uint32_t value) {
|
||||
size_t i = 0;
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * iNum + 1, y + fontHeight(size));
|
||||
DWIN_Byte(i, 0x14);
|
||||
// Bit 7: bshow
|
||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
||||
@@ -275,6 +314,7 @@ void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_
|
||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
|
||||
//uint8_t *fvalue = (uint8_t*)&value;
|
||||
size_t i = 0;
|
||||
DWIN_Draw_Rectangle(1, bColor, x, y, x + fontWidth(size) * (iNum+fNum+1), y + fontHeight(size));
|
||||
DWIN_Byte(i, 0x14);
|
||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
||||
DWIN_Word(i, color);
|
||||
|
@@ -23,10 +23,11 @@
|
||||
|
||||
#include "../../../inc/MarlinConfig.h"
|
||||
|
||||
#ifndef DWIN_WIDTH
|
||||
#if ENABLED(DWIN_MARLINUI_LANDSCAPE)
|
||||
#define DWIN_WIDTH 480
|
||||
#define DWIN_HEIGHT 272
|
||||
#else
|
||||
#define DWIN_WIDTH 272
|
||||
#endif
|
||||
#ifndef DWIN_HEIGHT
|
||||
#define DWIN_HEIGHT 480
|
||||
#endif
|
||||
|
||||
@@ -73,7 +74,7 @@ inline void DWIN_Text(size_t &i, const char * const string, uint16_t rlimit=0xFF
|
||||
|
||||
inline void DWIN_Text(size_t &i, FSTR_P string, uint16_t rlimit=0xFFFF) {
|
||||
if (!string) return;
|
||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P((PGM_P)string))); // cast to PGM_P (const char*) measure with strlen_P.
|
||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(rlimit, strlen_P(FTOP(string))));
|
||||
if (len == 0) return;
|
||||
memcpy_P(&DWIN_SendBuf[i+1], string, len);
|
||||
i += len;
|
||||
@@ -174,9 +175,14 @@ void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||
// rlimit: For draw less chars than string length use rlimit
|
||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit=0xFFFF);
|
||||
|
||||
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P title) {
|
||||
// Note that this won't work on AVR, only 32-bit systems!
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, FTOP(title));
|
||||
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, FSTR_P const ftitle) {
|
||||
#ifdef __AVR__
|
||||
char ctitle[strlen_P(FTOP(ftitle)) + 1];
|
||||
strcpy_P(ctitle, FTOP(ftitle));
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, ctitle);
|
||||
#else
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, FTOP(ftitle));
|
||||
#endif
|
||||
}
|
||||
|
||||
// Draw a positive integer
|
||||
|
@@ -21,6 +21,8 @@
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
typedef uint8_t fontid_t;
|
||||
|
||||
/**
|
||||
* 3-.0:The font size, 0x00-0x09, corresponds to the font size below:
|
||||
* 0x00=6*12 0x01=8*16 0x02=10*20 0x03=12*24 0x04=14*28
|
||||
|
@@ -25,7 +25,16 @@
|
||||
#define Language_English 1
|
||||
#define Language_Chinese 2
|
||||
|
||||
#define ICON 7 // Icon set file 7.ICO
|
||||
//#define USE_STOCK_DWIN_SET // Use the Creality stock DWIN_SET instead of Marlin's unified DWIN_SET by The-EG & thinkyhead
|
||||
#ifdef USE_STOCK_DWIN_SET
|
||||
#define ICON 9 // 9.ICO
|
||||
#else
|
||||
#define ICON 7 // 7.ICO
|
||||
#endif
|
||||
|
||||
#ifndef CORP_WEBSITE
|
||||
#define CORP_WEBSITE WEBSITE_URL
|
||||
#endif
|
||||
|
||||
#define ICON_LOGO 0
|
||||
#define ICON_Print_0 1
|
||||
|
@@ -36,7 +36,7 @@
|
||||
#include "../../marlinui.h"
|
||||
#include "../../../HAL/shared/Delay.h"
|
||||
|
||||
#if HAS_BUZZER
|
||||
#if HAS_SOUND
|
||||
#include "../../../libs/buzzer.h"
|
||||
#endif
|
||||
|
||||
@@ -50,13 +50,7 @@ ENCODER_Rate EncoderRate;
|
||||
|
||||
// TODO: Replace with ui.quick_feedback
|
||||
void Encoder_tick() {
|
||||
#if PIN_EXISTS(BEEPER)
|
||||
if (ui.buzzer_enabled) {
|
||||
WRITE(BEEPER_PIN, HIGH);
|
||||
delay(10);
|
||||
WRITE(BEEPER_PIN, LOW);
|
||||
}
|
||||
#endif
|
||||
TERN_(HAS_BEEPER, if (ui.sound_on) buzzer.click(10));
|
||||
}
|
||||
|
||||
// Encoder initialization
|
||||
@@ -70,7 +64,7 @@ void Encoder_Configuration() {
|
||||
#if BUTTON_EXISTS(ENC)
|
||||
SET_INPUT_PULLUP(BTN_ENC);
|
||||
#endif
|
||||
#if PIN_EXISTS(BEEPER)
|
||||
#if HAS_BEEPER
|
||||
SET_OUTPUT(BEEPER_PIN); // TODO: Use buzzer.h which already inits this
|
||||
#endif
|
||||
}
|
||||
|
@@ -45,12 +45,32 @@ typedef enum {
|
||||
ENCODER_DIFF_ENTER = 3 // click
|
||||
} EncoderState;
|
||||
|
||||
#define ENCODER_WAIT_MS 20
|
||||
|
||||
// Encoder initialization
|
||||
void Encoder_Configuration();
|
||||
|
||||
// Analyze encoder value and return state
|
||||
EncoderState Encoder_ReceiveAnalyze();
|
||||
|
||||
inline EncoderState get_encoder_state() {
|
||||
static millis_t Encoder_ms = 0;
|
||||
const millis_t ms = millis();
|
||||
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
||||
const EncoderState state = Encoder_ReceiveAnalyze();
|
||||
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
||||
return state;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
|
||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||
valref += EncoderRate.encoderMoveValue;
|
||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
||||
valref -= EncoderRate.encoderMoveValue;
|
||||
return encoder_diffState == ENCODER_DIFF_ENTER;
|
||||
}
|
||||
|
||||
/*********************** Encoder LED ***********************/
|
||||
|
||||
#if PIN_EXISTS(LCD_LED)
|
||||
|
Reference in New Issue
Block a user