🎨 Consolidate Ender-3 V2 DWIN common code (#22778)
This commit is contained in:
parent
cca3250c3f
commit
5b5a8798f8
|
@ -74,15 +74,15 @@
|
||||||
#include <lvgl.h>
|
#include <lvgl.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD)
|
#if HAS_DWIN_E3V2
|
||||||
#include "lcd/e3v2/creality/dwin.h"
|
#include "lcd/e3v2/common/encoder.h"
|
||||||
#include "lcd/e3v2/creality/rotary_encoder.h"
|
#if ENABLED(DWIN_CREALITY_LCD)
|
||||||
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
#include "lcd/e3v2/creality/dwin.h"
|
||||||
#include "lcd/e3v2/enhanced/dwin.h"
|
#elif ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||||
#include "lcd/e3v2/enhanced/rotary_encoder.h"
|
#include "lcd/e3v2/enhanced/dwin.h"
|
||||||
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
#elif ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
||||||
#include "lcd/e3v2/jyersui/dwin.h"
|
#include "lcd/e3v2/jyersui/dwin.h"
|
||||||
#include "lcd/e3v2/jyersui/rotary_encoder.h"
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if ENABLED(EXTENSIBLE_UI)
|
#if ENABLED(EXTENSIBLE_UI)
|
||||||
|
|
|
@ -421,8 +421,9 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if EITHER(DWIN_CREALITY_LCD_ENHANCED, DWIN_CREALITY_LCD_JYERSUI)
|
#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||||
#define HAS_LCD_BRIGHTNESS 1
|
#define HAS_LCD_BRIGHTNESS 1
|
||||||
|
#define MAX_LCD_BRIGHTNESS 31
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
429
Marlin/src/lcd/e3v2/common/dwin_api.cpp
Normal file
429
Marlin/src/lcd/e3v2/common/dwin_api.cpp
Normal file
|
@ -0,0 +1,429 @@
|
||||||
|
/**
|
||||||
|
* 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/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
#if EITHER(HAS_DWIN_E3V2, IS_DWIN_MARLINUI)
|
||||||
|
|
||||||
|
#include "dwin_api.h"
|
||||||
|
#include "dwin_set.h"
|
||||||
|
|
||||||
|
#include "../../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
|
#include <string.h> // for memset
|
||||||
|
|
||||||
|
uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
|
||||||
|
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
||||||
|
uint8_t databuf[26] = { 0 };
|
||||||
|
|
||||||
|
// Send the data in the buffer plus the packet tail
|
||||||
|
void DWIN_Send(size_t &i) {
|
||||||
|
++i;
|
||||||
|
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
||||||
|
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
|
// Handshake (1: Success, 0: Fail)
|
||||||
|
bool DWIN_Handshake() {
|
||||||
|
static int recnum = 0;
|
||||||
|
#ifndef LCD_BAUDRATE
|
||||||
|
#define LCD_BAUDRATE 115200
|
||||||
|
#endif
|
||||||
|
LCD_SERIAL.begin(LCD_BAUDRATE);
|
||||||
|
const millis_t serial_connect_timeout = millis() + 1000UL;
|
||||||
|
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
||||||
|
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x00);
|
||||||
|
DWIN_Send(i);
|
||||||
|
|
||||||
|
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
||||||
|
databuf[recnum] = LCD_SERIAL.read();
|
||||||
|
// ignore the invalid data
|
||||||
|
if (databuf[0] != FHONE) { // prevent the program from running.
|
||||||
|
if (recnum > 0) {
|
||||||
|
recnum = 0;
|
||||||
|
ZERO(databuf);
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
delay(10);
|
||||||
|
recnum++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ( recnum >= 3
|
||||||
|
&& databuf[0] == FHONE
|
||||||
|
&& databuf[1] == '\0'
|
||||||
|
&& databuf[2] == 'O'
|
||||||
|
&& databuf[3] == 'K' );
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the backlight brightness
|
||||||
|
// brightness: (0x00-0x1F)
|
||||||
|
void DWIN_LCD_Brightness(const uint8_t brightness) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x30);
|
||||||
|
DWIN_Byte(i, _MAX(brightness, 0x1F));
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set screen display direction
|
||||||
|
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||||
|
void DWIN_Frame_SetDir(uint8_t dir) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x34);
|
||||||
|
DWIN_Byte(i, 0x5A);
|
||||||
|
DWIN_Byte(i, 0xA5);
|
||||||
|
DWIN_Byte(i, dir);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update display
|
||||||
|
void DWIN_UpdateLCD() {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x3D);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Clear screen
|
||||||
|
// color: Clear screen color
|
||||||
|
void DWIN_Frame_Clear(const uint16_t color) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x01);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a point
|
||||||
|
// color: point color
|
||||||
|
// width: point width 0x01-0x0F
|
||||||
|
// height: point height 0x01-0x0F
|
||||||
|
// x,y: upper left point
|
||||||
|
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x02);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Byte(i, width);
|
||||||
|
DWIN_Byte(i, height);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a line
|
||||||
|
// color: Line segment color
|
||||||
|
// xStart/yStart: Start point
|
||||||
|
// xEnd/yEnd: End point
|
||||||
|
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x03);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, xStart);
|
||||||
|
DWIN_Word(i, yStart);
|
||||||
|
DWIN_Word(i, xEnd);
|
||||||
|
DWIN_Word(i, yEnd);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a rectangle
|
||||||
|
// mode: 0=frame, 1=fill, 2=XOR fill
|
||||||
|
// color: Rectangle color
|
||||||
|
// xStart/yStart: upper left point
|
||||||
|
// xEnd/yEnd: lower right point
|
||||||
|
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x05);
|
||||||
|
DWIN_Byte(i, mode);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, xStart);
|
||||||
|
DWIN_Word(i, yStart);
|
||||||
|
DWIN_Word(i, xEnd);
|
||||||
|
DWIN_Word(i, yEnd);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move a screen area
|
||||||
|
// mode: 0, circle shift; 1, translation
|
||||||
|
// dir: 0=left, 1=right, 2=up, 3=down
|
||||||
|
// dis: Distance
|
||||||
|
// color: Fill color
|
||||||
|
// xStart/yStart: upper left point
|
||||||
|
// xEnd/yEnd: bottom right point
|
||||||
|
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||||
|
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x09);
|
||||||
|
DWIN_Byte(i, (mode << 7) | dir);
|
||||||
|
DWIN_Word(i, dis);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, xStart);
|
||||||
|
DWIN_Word(i, yStart);
|
||||||
|
DWIN_Word(i, xEnd);
|
||||||
|
DWIN_Word(i, yEnd);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------- Text related functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Draw a string
|
||||||
|
// widthAdjust: true=self-adjust character width; false=no adjustment
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// x/y: Upper-left coordinate of the string
|
||||||
|
// *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*/) {
|
||||||
|
constexpr uint8_t widthAdjust = 0;
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x11);
|
||||||
|
// Bit 7: widthAdjust
|
||||||
|
// Bit 6: bShow
|
||||||
|
// Bit 5-4: Unused (0)
|
||||||
|
// Bit 3-0: size
|
||||||
|
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, bColor);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
DWIN_Text(i, string, rlimit);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a positive integer
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// zeroFill: true=zero fill; false=no zero fill
|
||||||
|
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// iNum: Number of digits
|
||||||
|
// x/y: Upper-left coordinate
|
||||||
|
// value: Integer value
|
||||||
|
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_Byte(i, 0x14);
|
||||||
|
// Bit 7: bshow
|
||||||
|
// Bit 6: 1 = signed; 0 = unsigned number;
|
||||||
|
// Bit 5: zeroFill
|
||||||
|
// Bit 4: zeroMode
|
||||||
|
// Bit 3-0: size
|
||||||
|
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, bColor);
|
||||||
|
DWIN_Byte(i, iNum);
|
||||||
|
DWIN_Byte(i, 0); // fNum
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
#if 0
|
||||||
|
for (char count = 0; count < 8; count++) {
|
||||||
|
DWIN_Byte(i, value);
|
||||||
|
value >>= 8;
|
||||||
|
if (!(value & 0xFF)) break;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
// Write a big-endian 64 bit integer
|
||||||
|
const size_t p = i + 1;
|
||||||
|
for (char count = 8; count--;) { // 7..0
|
||||||
|
++i;
|
||||||
|
DWIN_SendBuf[p + count] = value;
|
||||||
|
value >>= 8;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a floating point number
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// zeroFill: true=zero fill; false=no zero fill
|
||||||
|
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// iNum: Number of whole digits
|
||||||
|
// fNum: Number of decimal digits
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// value: Float value
|
||||||
|
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||||
|
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_Byte(i, 0x14);
|
||||||
|
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
||||||
|
DWIN_Word(i, color);
|
||||||
|
DWIN_Word(i, bColor);
|
||||||
|
DWIN_Byte(i, iNum);
|
||||||
|
DWIN_Byte(i, fNum);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
DWIN_Long(i, value);
|
||||||
|
/*
|
||||||
|
DWIN_Byte(i, fvalue[3]);
|
||||||
|
DWIN_Byte(i, fvalue[2]);
|
||||||
|
DWIN_Byte(i, fvalue[1]);
|
||||||
|
DWIN_Byte(i, fvalue[0]);
|
||||||
|
*/
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a floating point number
|
||||||
|
// value: positive unscaled float value
|
||||||
|
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||||
|
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||||
|
const int32_t val = round(value * POW(10, fNum));
|
||||||
|
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Draw JPG and cached in #0 virtual display area
|
||||||
|
// id: Picture ID
|
||||||
|
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Word(i, 0x2200);
|
||||||
|
DWIN_Byte(i, id);
|
||||||
|
DWIN_Send(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw an Icon
|
||||||
|
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
||||||
|
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||||
|
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||||
|
// libID: Icon library ID
|
||||||
|
// picID: Icon ID
|
||||||
|
// x/y: Upper-left point
|
||||||
|
void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||||
|
NOMORE(x, DWIN_WIDTH - 1);
|
||||||
|
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x23);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
DWIN_Byte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | libID);
|
||||||
|
DWIN_Byte(i, picID);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw an Icon from SRAM
|
||||||
|
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
||||||
|
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||||
|
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// addr: SRAM address
|
||||||
|
void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr) {
|
||||||
|
NOMORE(x, DWIN_WIDTH - 1);
|
||||||
|
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x24);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
DWIN_Byte(i, (IBD << 7) | (BIR << 6) | (BFI << 5) | 0x00);
|
||||||
|
DWIN_Word(i, addr);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unzip the JPG picture to a virtual display area
|
||||||
|
// n: Cache index
|
||||||
|
// id: Picture ID
|
||||||
|
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x25);
|
||||||
|
DWIN_Byte(i, n);
|
||||||
|
DWIN_Byte(i, id);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animate a series of icons
|
||||||
|
// animID: Animation ID; 0x00-0x0F
|
||||||
|
// animate: true on; false off;
|
||||||
|
// libID: Icon library ID
|
||||||
|
// picIDs: Icon starting ID
|
||||||
|
// picIDe: Icon ending ID
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// interval: Display time interval, unit 10mS
|
||||||
|
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
|
||||||
|
NOMORE(x, DWIN_WIDTH - 1);
|
||||||
|
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x28);
|
||||||
|
DWIN_Word(i, x);
|
||||||
|
DWIN_Word(i, y);
|
||||||
|
// Bit 7: animation on or off
|
||||||
|
// Bit 6: start from begin or end
|
||||||
|
// Bit 5-4: unused (0)
|
||||||
|
// Bit 3-0: animID
|
||||||
|
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
|
||||||
|
DWIN_Byte(i, libID);
|
||||||
|
DWIN_Byte(i, picIDs);
|
||||||
|
DWIN_Byte(i, picIDe);
|
||||||
|
DWIN_Byte(i, interval);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Animation Control
|
||||||
|
// state: 16 bits, each bit is the state of an animation id
|
||||||
|
void DWIN_ICON_AnimationControl(uint16_t state) {
|
||||||
|
size_t i = 0;
|
||||||
|
DWIN_Byte(i, 0x29);
|
||||||
|
DWIN_Word(i, state);
|
||||||
|
DWIN_Send(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*---------------------------------------- Memory functions ----------------------------------------*/
|
||||||
|
// The LCD has an additional 32KB SRAM and 16KB Flash
|
||||||
|
// Data can be written to the SRAM and saved to one of the jpeg page files
|
||||||
|
|
||||||
|
// Write Data Memory
|
||||||
|
// command 0x31
|
||||||
|
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
|
||||||
|
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
||||||
|
// Data: data
|
||||||
|
//
|
||||||
|
// Flash writing returns 0xA5 0x4F 0x4B
|
||||||
|
|
||||||
|
// Read Data Memory
|
||||||
|
// command 0x32
|
||||||
|
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
|
||||||
|
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
||||||
|
// Length: leangth of data to read; 0x01-0xF0
|
||||||
|
//
|
||||||
|
// Response:
|
||||||
|
// Type, Address, Length, Data
|
||||||
|
|
||||||
|
// Write Picture Memory
|
||||||
|
// Write the contents of the 32KB SRAM data memory into the designated image memory space
|
||||||
|
// Issued: 0x5A, 0xA5, PIC_ID
|
||||||
|
// Response: 0xA5 0x4F 0x4B
|
||||||
|
//
|
||||||
|
// command 0x33
|
||||||
|
// 0x5A, 0xA5
|
||||||
|
// PicId: Picture Memory location, 0x00-0x0F
|
||||||
|
//
|
||||||
|
// Flash writing returns 0xA5 0x4F 0x4B
|
||||||
|
|
||||||
|
#endif // HAS_DWIN_E3V2 || IS_DWIN_MARLINUI
|
265
Marlin/src/lcd/e3v2/common/dwin_api.h
Normal file
265
Marlin/src/lcd/e3v2/common/dwin_api.h
Normal file
|
@ -0,0 +1,265 @@
|
||||||
|
/**
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include "../../../HAL/shared/Marduino.h"
|
||||||
|
|
||||||
|
#ifndef DWIN_WIDTH
|
||||||
|
#define DWIN_WIDTH 272
|
||||||
|
#endif
|
||||||
|
#ifndef DWIN_HEIGHT
|
||||||
|
#define DWIN_HEIGHT 480
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define RECEIVED_NO_DATA 0x00
|
||||||
|
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
||||||
|
|
||||||
|
#define FHONE 0xAA
|
||||||
|
|
||||||
|
#define DWIN_SCROLL_UP 2
|
||||||
|
#define DWIN_SCROLL_DOWN 3
|
||||||
|
|
||||||
|
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
||||||
|
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
||||||
|
extern uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2];
|
||||||
|
extern uint8_t DWIN_BufTail[4];
|
||||||
|
extern uint8_t databuf[26];
|
||||||
|
|
||||||
|
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
||||||
|
DWIN_SendBuf[++i] = bval;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
||||||
|
DWIN_SendBuf[++i] = wval >> 8;
|
||||||
|
DWIN_SendBuf[++i] = wval & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
||||||
|
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
||||||
|
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
||||||
|
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
||||||
|
DWIN_SendBuf[++i] = lval & 0xFF;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Send the data in the buffer plus the packet tail
|
||||||
|
void DWIN_Send(size_t &i);
|
||||||
|
|
||||||
|
inline void DWIN_Text(size_t &i, const char * const string, uint16_t rlimit=0xFFFF) {
|
||||||
|
if (!string) return;
|
||||||
|
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit));
|
||||||
|
if (len == 0) return;
|
||||||
|
memcpy(&DWIN_SendBuf[i+1], string, len);
|
||||||
|
i += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void DWIN_Text(size_t &i, const __FlashStringHelper * 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.
|
||||||
|
if (len == 0) return;
|
||||||
|
memcpy_P(&DWIN_SendBuf[i+1], string, len);
|
||||||
|
i += len;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
|
// Handshake (1: Success, 0: Fail)
|
||||||
|
bool DWIN_Handshake();
|
||||||
|
|
||||||
|
// DWIN startup
|
||||||
|
void DWIN_Startup();
|
||||||
|
|
||||||
|
// Set the backlight brightness
|
||||||
|
// brightness: (0x00-0xFF)
|
||||||
|
void DWIN_LCD_Brightness(const uint8_t brightness);
|
||||||
|
|
||||||
|
// Set screen display direction
|
||||||
|
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
||||||
|
void DWIN_Frame_SetDir(uint8_t dir);
|
||||||
|
|
||||||
|
// Update display
|
||||||
|
void DWIN_UpdateLCD();
|
||||||
|
|
||||||
|
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Clear screen
|
||||||
|
// color: Clear screen color
|
||||||
|
void DWIN_Frame_Clear(const uint16_t color);
|
||||||
|
|
||||||
|
// Draw a point
|
||||||
|
// color: point color
|
||||||
|
// width: point width 0x01-0x0F
|
||||||
|
// height: point height 0x01-0x0F
|
||||||
|
// x,y: upper left point
|
||||||
|
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
// Draw a line
|
||||||
|
// color: Line segment color
|
||||||
|
// xStart/yStart: Start point
|
||||||
|
// xEnd/yEnd: End point
|
||||||
|
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||||
|
|
||||||
|
// Draw a Horizontal line
|
||||||
|
// color: Line segment color
|
||||||
|
// xStart/yStart: Start point
|
||||||
|
// xLength: Line Length
|
||||||
|
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
|
||||||
|
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a Vertical line
|
||||||
|
// color: Line segment color
|
||||||
|
// xStart/yStart: Start point
|
||||||
|
// yLength: Line Length
|
||||||
|
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
|
||||||
|
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a rectangle
|
||||||
|
// mode: 0=frame, 1=fill, 2=XOR fill
|
||||||
|
// color: Rectangle color
|
||||||
|
// xStart/yStart: upper left point
|
||||||
|
// xEnd/yEnd: lower right point
|
||||||
|
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||||
|
|
||||||
|
// Draw a box
|
||||||
|
// mode: 0=frame, 1=fill, 2=XOR fill
|
||||||
|
// color: Rectangle color
|
||||||
|
// xStart/yStart: upper left point
|
||||||
|
// xSize/ySize: box size
|
||||||
|
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
|
||||||
|
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move a screen area
|
||||||
|
// mode: 0, circle shift; 1, translation
|
||||||
|
// dir: 0=left, 1=right, 2=up, 3=down
|
||||||
|
// dis: Distance
|
||||||
|
// color: Fill color
|
||||||
|
// xStart/yStart: upper left point
|
||||||
|
// xEnd/yEnd: bottom right point
|
||||||
|
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
||||||
|
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
||||||
|
|
||||||
|
|
||||||
|
/*---------------------------------------- Text related functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Draw a string
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// x/y: Upper-left coordinate of the string
|
||||||
|
// *string: The string
|
||||||
|
// 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, const __FlashStringHelper *title) {
|
||||||
|
// Note that this won't work on AVR, only 32-bit systems!
|
||||||
|
DWIN_Draw_String(bShow, size, color, bColor, x, y, reinterpret_cast<const char*>(title));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Draw a positive integer
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// zeroFill: true=zero fill; false=no zero fill
|
||||||
|
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// iNum: Number of digits
|
||||||
|
// x/y: Upper-left coordinate
|
||||||
|
// value: Integer value
|
||||||
|
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);
|
||||||
|
|
||||||
|
// Draw a floating point number
|
||||||
|
// bShow: true=display background color; false=don't display background color
|
||||||
|
// zeroFill: true=zero fill; false=no zero fill
|
||||||
|
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
||||||
|
// size: Font size
|
||||||
|
// color: Character color
|
||||||
|
// bColor: Background color
|
||||||
|
// iNum: Number of whole digits
|
||||||
|
// fNum: Number of decimal digits
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// value: Float value
|
||||||
|
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||||
|
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value);
|
||||||
|
|
||||||
|
// Draw a floating point number
|
||||||
|
// value: positive unscaled float value
|
||||||
|
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
||||||
|
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
|
||||||
|
|
||||||
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
|
// Draw JPG and cached in #0 virtual display area
|
||||||
|
// id: Picture ID
|
||||||
|
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
||||||
|
|
||||||
|
// Draw an Icon
|
||||||
|
// libID: Icon library ID
|
||||||
|
// picID: Icon ID
|
||||||
|
// x/y: Upper-left point
|
||||||
|
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
// Draw an Icon
|
||||||
|
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
||||||
|
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||||
|
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||||
|
// libID: Icon library ID
|
||||||
|
// picID: Icon ID
|
||||||
|
// x/y: Upper-left point
|
||||||
|
void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
|
// Draw an Icon from SRAM
|
||||||
|
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
||||||
|
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
||||||
|
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// addr: SRAM address
|
||||||
|
void DWIN_ICON_Show(bool IBD, bool BIR, bool BFI, uint16_t x, uint16_t y, uint16_t addr);
|
||||||
|
|
||||||
|
// Unzip the JPG picture to a virtual display area
|
||||||
|
// n: Cache index
|
||||||
|
// id: Picture ID
|
||||||
|
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
||||||
|
|
||||||
|
// Unzip the JPG picture to virtual display area #1
|
||||||
|
// id: Picture ID
|
||||||
|
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
||||||
|
|
||||||
|
// Animate a series of icons
|
||||||
|
// animID: Animation ID up to 16
|
||||||
|
// animate: animation on or off
|
||||||
|
// libID: Icon library ID
|
||||||
|
// picIDs: Icon starting ID
|
||||||
|
// picIDe: Icon ending ID
|
||||||
|
// x/y: Upper-left point
|
||||||
|
// interval: Display time interval, unit 10mS
|
||||||
|
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
|
||||||
|
|
||||||
|
// Animation Control
|
||||||
|
// state: 16 bits, each bit is the state of an animation id
|
||||||
|
void DWIN_ICON_AnimationControl(uint16_t state);
|
44
Marlin/src/lcd/e3v2/common/dwin_color.h
Normal file
44
Marlin/src/lcd/e3v2/common/dwin_color.h
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/**
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Extended and default UI Colors
|
||||||
|
#define RGB(R,G,B) (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
|
||||||
|
#define GetRColor(color) ((color >> 11) & 0x1F)
|
||||||
|
#define GetGColor(color) ((color >> 5) & 0x3F)
|
||||||
|
#define GetBColor(color) ((color >> 0) & 0x1F)
|
||||||
|
|
||||||
|
#define Color_White 0xFFFF
|
||||||
|
#define Color_Yellow RGB(0x1F,0x3F,0x00)
|
||||||
|
#define Color_Red RGB(0x1F,0x00,0x00)
|
||||||
|
#define Color_Error_Red 0xB000 // Error!
|
||||||
|
#define Color_Bg_Red 0xF00F // Red background color
|
||||||
|
#define Color_Bg_Window 0x31E8 // Popup background color
|
||||||
|
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
||||||
|
#define Color_Bg_Black 0x0841 // Black background color
|
||||||
|
#define Color_IconBlue 0x45FA // Lighter blue that matches icons/accents
|
||||||
|
#define Popup_Text_Color 0xD6BA // Popup font background color
|
||||||
|
#define Line_Color 0x3A6A // Split line color
|
||||||
|
#define Rectangle_Color 0xEE2F // Blue square cursor color
|
||||||
|
#define Percent_Color 0xFE29 // Percentage color
|
||||||
|
#define BarFill_Color 0x10E4 // Fill color of progress bar
|
||||||
|
#define Select_Color 0x33BB // Selected color
|
38
Marlin/src/lcd/e3v2/common/dwin_font.h
Normal file
38
Marlin/src/lcd/e3v2/common/dwin_font.h
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
/**
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
|
||||||
|
*/
|
||||||
|
#define font6x12 0x00
|
||||||
|
#define font8x16 0x01
|
||||||
|
#define font10x20 0x02
|
||||||
|
#define font12x24 0x03
|
||||||
|
#define font14x28 0x04
|
||||||
|
#define font16x32 0x05
|
||||||
|
#define font20x40 0x06
|
||||||
|
#define font24x48 0x07
|
||||||
|
#define font28x56 0x08
|
||||||
|
#define font32x64 0x09
|
138
Marlin/src/lcd/e3v2/common/dwin_set.h
Normal file
138
Marlin/src/lcd/e3v2/common/dwin_set.h
Normal file
|
@ -0,0 +1,138 @@
|
||||||
|
/**
|
||||||
|
* 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/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Picture ID
|
||||||
|
#define Language_English 1
|
||||||
|
#define Language_Chinese 2
|
||||||
|
|
||||||
|
#define ICON 7 // Icon set file 7.ICO
|
||||||
|
|
||||||
|
#define ICON_LOGO 0
|
||||||
|
#define ICON_Print_0 1
|
||||||
|
#define ICON_Print_1 2
|
||||||
|
#define ICON_Prepare_0 3
|
||||||
|
#define ICON_Prepare_1 4
|
||||||
|
#define ICON_Control_0 5
|
||||||
|
#define ICON_Control_1 6
|
||||||
|
#define ICON_Leveling_0 7
|
||||||
|
#define ICON_Leveling_1 8
|
||||||
|
#define ICON_HotendTemp 9
|
||||||
|
#define ICON_BedTemp 10
|
||||||
|
#define ICON_Speed 11
|
||||||
|
#define ICON_Zoffset 12
|
||||||
|
#define ICON_Back 13
|
||||||
|
#define ICON_File 14
|
||||||
|
#define ICON_PrintTime 15
|
||||||
|
#define ICON_RemainTime 16
|
||||||
|
#define ICON_Setup_0 17
|
||||||
|
#define ICON_Setup_1 18
|
||||||
|
#define ICON_Pause_0 19
|
||||||
|
#define ICON_Pause_1 20
|
||||||
|
#define ICON_Continue_0 21
|
||||||
|
#define ICON_Continue_1 22
|
||||||
|
#define ICON_Stop_0 23
|
||||||
|
#define ICON_Stop_1 24
|
||||||
|
#define ICON_Bar 25
|
||||||
|
#define ICON_More 26
|
||||||
|
|
||||||
|
#define ICON_Axis 27
|
||||||
|
#define ICON_CloseMotor 28
|
||||||
|
#define ICON_Homing 29
|
||||||
|
#define ICON_SetHome 30
|
||||||
|
#define ICON_PLAPreheat 31
|
||||||
|
#define ICON_ABSPreheat 32
|
||||||
|
#define ICON_Cool 33
|
||||||
|
#define ICON_Language 34
|
||||||
|
|
||||||
|
#define ICON_MoveX 35
|
||||||
|
#define ICON_MoveY 36
|
||||||
|
#define ICON_MoveZ 37
|
||||||
|
#define ICON_Extruder 38
|
||||||
|
|
||||||
|
#define ICON_Temperature 40
|
||||||
|
#define ICON_Motion 41
|
||||||
|
#define ICON_WriteEEPROM 42
|
||||||
|
#define ICON_ReadEEPROM 43
|
||||||
|
#define ICON_ResumeEEPROM 44
|
||||||
|
#define ICON_Info 45
|
||||||
|
|
||||||
|
#define ICON_SetEndTemp 46
|
||||||
|
#define ICON_SetBedTemp 47
|
||||||
|
#define ICON_FanSpeed 48
|
||||||
|
#define ICON_SetPLAPreheat 49
|
||||||
|
#define ICON_SetABSPreheat 50
|
||||||
|
|
||||||
|
#define ICON_MaxSpeed 51
|
||||||
|
#define ICON_MaxAccelerated 52
|
||||||
|
#define ICON_MaxJerk 53
|
||||||
|
#define ICON_Step 54
|
||||||
|
#define ICON_PrintSize 55
|
||||||
|
#define ICON_Version 56
|
||||||
|
#define ICON_Contact 57
|
||||||
|
#define ICON_StockConfiguration 58
|
||||||
|
#define ICON_MaxSpeedX 59
|
||||||
|
#define ICON_MaxSpeedY 60
|
||||||
|
#define ICON_MaxSpeedZ 61
|
||||||
|
#define ICON_MaxSpeedE 62
|
||||||
|
#define ICON_MaxAccX 63
|
||||||
|
#define ICON_MaxAccY 64
|
||||||
|
#define ICON_MaxAccZ 65
|
||||||
|
#define ICON_MaxAccE 66
|
||||||
|
#define ICON_MaxSpeedJerkX 67
|
||||||
|
#define ICON_MaxSpeedJerkY 68
|
||||||
|
#define ICON_MaxSpeedJerkZ 69
|
||||||
|
#define ICON_MaxSpeedJerkE 70
|
||||||
|
#define ICON_StepX 71
|
||||||
|
#define ICON_StepY 72
|
||||||
|
#define ICON_StepZ 73
|
||||||
|
#define ICON_StepE 74
|
||||||
|
#define ICON_Setspeed 75
|
||||||
|
#define ICON_SetZOffset 76
|
||||||
|
#define ICON_Rectangle 77
|
||||||
|
#define ICON_BLTouch 78
|
||||||
|
#define ICON_TempTooLow 79
|
||||||
|
#define ICON_AutoLeveling 80
|
||||||
|
#define ICON_TempTooHigh 81
|
||||||
|
#define ICON_NoTips_C 82
|
||||||
|
#define ICON_NoTips_E 83
|
||||||
|
#define ICON_Continue_C 84
|
||||||
|
#define ICON_Continue_E 85
|
||||||
|
#define ICON_Cancel_C 86
|
||||||
|
#define ICON_Cancel_E 87
|
||||||
|
#define ICON_Confirm_C 88
|
||||||
|
#define ICON_Confirm_E 89
|
||||||
|
#define ICON_Info_0 90
|
||||||
|
#define ICON_Info_1 91
|
||||||
|
|
||||||
|
#define ICON_Folder ICON_More
|
||||||
|
#define ICON_AdvSet ICON_Language
|
||||||
|
#define ICON_HomeOffset ICON_AdvSet
|
||||||
|
#define ICON_HomeOffsetX ICON_StepX
|
||||||
|
#define ICON_HomeOffsetY ICON_StepY
|
||||||
|
#define ICON_HomeOffsetZ ICON_StepZ
|
||||||
|
#define ICON_ProbeOffset ICON_AdvSet
|
||||||
|
#define ICON_ProbeOffsetX ICON_StepX
|
||||||
|
#define ICON_ProbeOffsetY ICON_StepY
|
||||||
|
#define ICON_ProbeOffsetZ ICON_StepZ
|
||||||
|
#define ICON_PIDNozzle ICON_SetEndTemp
|
||||||
|
#define ICON_PIDbed ICON_SetBedTemp
|
|
@ -21,15 +21,15 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* @file lcd/e3v2/jyersui/rotary_encoder.cpp
|
* @file lcd/e3v2/common/encoder.cpp
|
||||||
* @brief Rotary encoder functions
|
* @brief Rotary encoder functions
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
#if HAS_DWIN_E3V2
|
||||||
|
|
||||||
#include "rotary_encoder.h"
|
#include "encoder.h"
|
||||||
#include "../../buttons.h"
|
#include "../../buttons.h"
|
||||||
|
|
||||||
#include "../../../MarlinCore.h"
|
#include "../../../MarlinCore.h"
|
||||||
|
@ -38,7 +38,6 @@
|
||||||
|
|
||||||
#if HAS_BUZZER
|
#if HAS_BUZZER
|
||||||
#include "../../../libs/buzzer.h"
|
#include "../../../libs/buzzer.h"
|
||||||
#include "dwin.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -49,10 +48,10 @@
|
||||||
|
|
||||||
ENCODER_Rate EncoderRate;
|
ENCODER_Rate EncoderRate;
|
||||||
|
|
||||||
// Buzzer
|
// TODO: Replace with ui.quick_feedback
|
||||||
void Encoder_tick() {
|
void Encoder_tick() {
|
||||||
#if PIN_EXISTS(BEEPER)
|
#if PIN_EXISTS(BEEPER)
|
||||||
if (CrealityDWIN.eeprom_settings.beeperenable) {
|
if (ui.buzzer_enabled) {
|
||||||
WRITE(BEEPER_PIN, HIGH);
|
WRITE(BEEPER_PIN, HIGH);
|
||||||
delay(10);
|
delay(10);
|
||||||
WRITE(BEEPER_PIN, LOW);
|
WRITE(BEEPER_PIN, LOW);
|
||||||
|
@ -72,18 +71,18 @@ void Encoder_Configuration() {
|
||||||
SET_INPUT_PULLUP(BTN_ENC);
|
SET_INPUT_PULLUP(BTN_ENC);
|
||||||
#endif
|
#endif
|
||||||
#if PIN_EXISTS(BEEPER)
|
#if PIN_EXISTS(BEEPER)
|
||||||
SET_OUTPUT(BEEPER_PIN);
|
SET_OUTPUT(BEEPER_PIN); // TODO: Use buzzer.h which already inits this
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
// Analyze encoder value and return state
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
EncoderState Encoder_ReceiveAnalyze() {
|
||||||
const millis_t now = millis();
|
const millis_t now = millis();
|
||||||
static uint8_t lastEncoderBits;
|
static uint8_t lastEncoderBits;
|
||||||
uint8_t newbutton = 0;
|
uint8_t newbutton = 0;
|
||||||
static signed char temp_diff = 0;
|
static signed char temp_diff = 0;
|
||||||
|
|
||||||
ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
|
EncoderState temp_diffState = ENCODER_DIFF_NO;
|
||||||
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
||||||
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
||||||
if (BUTTON_PRESSED(ENC)) {
|
if (BUTTON_PRESSED(ENC)) {
|
||||||
|
@ -94,8 +93,10 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
||||||
#if PIN_EXISTS(LCD_LED)
|
#if PIN_EXISTS(LCD_LED)
|
||||||
//LED_Action();
|
//LED_Action();
|
||||||
#endif
|
#endif
|
||||||
if (ui.backlight) return ENCODER_DIFF_ENTER;
|
if (!ui.backlight) ui.refresh_brightness();
|
||||||
ui.refresh_brightness();
|
const bool was_waiting = wait_for_user;
|
||||||
|
wait_for_user = false;
|
||||||
|
return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
|
||||||
}
|
}
|
||||||
else return ENCODER_DIFF_NO;
|
else return ENCODER_DIFF_NO;
|
||||||
}
|
}
|
||||||
|
@ -122,13 +123,8 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
|
if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
|
||||||
#if ENABLED(REVERSE_ENCODER_DIRECTION)
|
if (temp_diff > 0) temp_diffState = TERN(REVERSE_ENCODER_DIRECTION, ENCODER_DIFF_CCW, ENCODER_DIFF_CW);
|
||||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CCW;
|
else temp_diffState = TERN(REVERSE_ENCODER_DIRECTION, ENCODER_DIFF_CW, ENCODER_DIFF_CCW);
|
||||||
else temp_diffState = ENCODER_DIFF_CW;
|
|
||||||
#else
|
|
||||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
|
|
||||||
else temp_diffState = ENCODER_DIFF_CCW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
||||||
|
|
||||||
|
@ -260,4 +256,4 @@ ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
||||||
|
|
||||||
#endif // LCD_LED
|
#endif // LCD_LED
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD_JYERSUI
|
#endif // HAS_DWIN_E3V2
|
|
@ -22,7 +22,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* @file lcd/e3v2/jyersui/rotary_encoder.h
|
* @file lcd/e3v2/common/encoder.h
|
||||||
* @brief Rotary encoder functions
|
* @brief Rotary encoder functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
@ -43,13 +43,13 @@ typedef enum {
|
||||||
ENCODER_DIFF_CW = 1, // clockwise rotation
|
ENCODER_DIFF_CW = 1, // clockwise rotation
|
||||||
ENCODER_DIFF_CCW = 2, // counterclockwise rotation
|
ENCODER_DIFF_CCW = 2, // counterclockwise rotation
|
||||||
ENCODER_DIFF_ENTER = 3 // click
|
ENCODER_DIFF_ENTER = 3 // click
|
||||||
} ENCODER_DiffState;
|
} EncoderState;
|
||||||
|
|
||||||
// Encoder initialization
|
// Encoder initialization
|
||||||
void Encoder_Configuration();
|
void Encoder_Configuration();
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
// Analyze encoder value and return state
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze();
|
EncoderState Encoder_ReceiveAnalyze();
|
||||||
|
|
||||||
/*********************** Encoder LED ***********************/
|
/*********************** Encoder LED ***********************/
|
||||||
|
|
|
@ -138,7 +138,7 @@ constexpr uint16_t MROWS = TROWS - 1, // Last Row Index
|
||||||
|
|
||||||
// Value Init
|
// Value Init
|
||||||
HMI_value_t HMI_ValueStruct;
|
HMI_value_t HMI_ValueStruct;
|
||||||
HMI_Flag_t HMI_flag{0};
|
HMI_flag_t HMI_flag{0};
|
||||||
|
|
||||||
millis_t dwin_heat_time = 0;
|
millis_t dwin_heat_time = 0;
|
||||||
|
|
||||||
|
@ -470,7 +470,7 @@ void Draw_Back_First(const bool is_sel=true) {
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) {
|
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
valref += EncoderRate.encoderMoveValue;
|
valref += EncoderRate.encoderMoveValue;
|
||||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
||||||
|
@ -593,7 +593,7 @@ void DWIN_Draw_Label(const uint8_t row, const __FlashStringHelper *title) {
|
||||||
DWIN_Draw_Label(row, (char*)title);
|
DWIN_Draw_Label(row, (char*)title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
void DWIN_Draw_Signed_Float(uint8_t size, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, int32_t value) {
|
||||||
DWIN_Draw_String(true, size, Color_White, bColor, x - 8, y, value < 0 ? F("-") : F(" "));
|
DWIN_Draw_String(true, size, Color_White, bColor, x - 8, y, value < 0 ? F("-") : F(" "));
|
||||||
DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
|
DWIN_Draw_FloatValue(true, true, 0, size, Color_White, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
|
||||||
}
|
}
|
||||||
|
@ -607,7 +607,7 @@ void Draw_Edit_Integer4(const uint8_t row, const uint16_t value, const bool acti
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Edit_Float3(const uint8_t row, const uint16_t value, const bool active=false) {
|
void Draw_Edit_Float3(const uint8_t row, const uint16_t value, const bool active=false) {
|
||||||
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, active ? Select_Color : Color_Bg_Black, 3, UNITFDIGITS, 220 - UNITFDIGITS * 8, EBASE(row), value);
|
DWIN_Draw_FloatValue(true, true, 0, font8x16, Color_White, active ? Select_Color : Color_Bg_Black, 3, UNITFDIGITS, 220 - UNITFDIGITS * 8, EBASE(row), (int32_t)value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Edit_Signed_Float2(const uint8_t row, const float value, const bool active=false) {
|
void Draw_Edit_Signed_Float2(const uint8_t row, const float value, const bool active=false) {
|
||||||
|
@ -1292,11 +1292,11 @@ void Goto_MainMenu() {
|
||||||
TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
|
TERN(HAS_ONESTEP_LEVELING, ICON_Leveling, ICON_StartInfo)();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ENCODER_DiffState get_encoder_state() {
|
inline EncoderState get_encoder_state() {
|
||||||
static millis_t Encoder_ms = 0;
|
static millis_t Encoder_ms = 0;
|
||||||
const millis_t ms = millis();
|
const millis_t ms = millis();
|
||||||
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
||||||
const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
|
const EncoderState state = Encoder_ReceiveAnalyze();
|
||||||
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
@ -1317,7 +1317,7 @@ void HMI_Move_Done(const AxisEnum axis) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_Move_X() {
|
void HMI_Move_X() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_X_scaled)) {
|
||||||
Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
|
Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
|
||||||
|
@ -1331,7 +1331,7 @@ void HMI_Move_X() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_Move_Y() {
|
void HMI_Move_Y() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Y_scaled)) {
|
||||||
Draw_Edit_Float3(2, HMI_ValueStruct.Move_Y_scaled);
|
Draw_Edit_Float3(2, HMI_ValueStruct.Move_Y_scaled);
|
||||||
|
@ -1345,7 +1345,7 @@ void HMI_Move_Y() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_Move_Z() {
|
void HMI_Move_Z() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_Z_scaled)) {
|
||||||
Draw_Edit_Float3(3, HMI_ValueStruct.Move_Z_scaled);
|
Draw_Edit_Float3(3, HMI_ValueStruct.Move_Z_scaled);
|
||||||
|
@ -1362,7 +1362,7 @@ void HMI_Move_Z() {
|
||||||
|
|
||||||
void HMI_Move_E() {
|
void HMI_Move_E() {
|
||||||
static float last_E_scaled = 0;
|
static float last_E_scaled = 0;
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Move_E_scaled)) {
|
||||||
last_E_scaled = HMI_ValueStruct.Move_E_scaled;
|
last_E_scaled = HMI_ValueStruct.Move_E_scaled;
|
||||||
|
@ -1383,7 +1383,7 @@ void HMI_Move_Z() {
|
||||||
bool printer_busy() { return planner.movesplanned() || printingIsActive(); }
|
bool printer_busy() { return planner.movesplanned() || printingIsActive(); }
|
||||||
|
|
||||||
void HMI_Zoffset() {
|
void HMI_Zoffset() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
uint8_t zoff_line;
|
uint8_t zoff_line;
|
||||||
switch (HMI_ValueStruct.show_mode) {
|
switch (HMI_ValueStruct.show_mode) {
|
||||||
|
@ -1416,7 +1416,7 @@ void HMI_Move_Z() {
|
||||||
#if HAS_HOTEND
|
#if HAS_HOTEND
|
||||||
|
|
||||||
void HMI_ETemp() {
|
void HMI_ETemp() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
uint8_t temp_line;
|
uint8_t temp_line;
|
||||||
switch (HMI_ValueStruct.show_mode) {
|
switch (HMI_ValueStruct.show_mode) {
|
||||||
|
@ -1458,7 +1458,7 @@ void HMI_Move_Z() {
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
|
|
||||||
void HMI_BedTemp() {
|
void HMI_BedTemp() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
uint8_t bed_line;
|
uint8_t bed_line;
|
||||||
switch (HMI_ValueStruct.show_mode) {
|
switch (HMI_ValueStruct.show_mode) {
|
||||||
|
@ -1500,7 +1500,7 @@ void HMI_Move_Z() {
|
||||||
#if HAS_PREHEAT && HAS_FAN
|
#if HAS_PREHEAT && HAS_FAN
|
||||||
|
|
||||||
void HMI_FanSpeed() {
|
void HMI_FanSpeed() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
uint8_t fan_line;
|
uint8_t fan_line;
|
||||||
switch (HMI_ValueStruct.show_mode) {
|
switch (HMI_ValueStruct.show_mode) {
|
||||||
|
@ -1541,7 +1541,7 @@ void HMI_Move_Z() {
|
||||||
#endif // HAS_PREHEAT && HAS_FAN
|
#endif // HAS_PREHEAT && HAS_FAN
|
||||||
|
|
||||||
void HMI_PrintSpeed() {
|
void HMI_PrintSpeed() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.print_speed)) {
|
||||||
checkkey = Tune;
|
checkkey = Tune;
|
||||||
|
@ -1559,7 +1559,7 @@ void HMI_PrintSpeed() {
|
||||||
#define LAST_AXIS TERN(HAS_HOTEND, E_AXIS, Z_AXIS)
|
#define LAST_AXIS TERN(HAS_HOTEND, E_AXIS, Z_AXIS)
|
||||||
|
|
||||||
void HMI_MaxFeedspeedXYZE() {
|
void HMI_MaxFeedspeedXYZE() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Feedspeed)) {
|
||||||
checkkey = MaxSpeed;
|
checkkey = MaxSpeed;
|
||||||
|
@ -1578,7 +1578,7 @@ void HMI_MaxFeedspeedXYZE() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_MaxAccelerationXYZE() {
|
void HMI_MaxAccelerationXYZE() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Acceleration)) {
|
||||||
checkkey = MaxAcceleration;
|
checkkey = MaxAcceleration;
|
||||||
|
@ -1599,7 +1599,7 @@ void HMI_MaxAccelerationXYZE() {
|
||||||
#if HAS_CLASSIC_JERK
|
#if HAS_CLASSIC_JERK
|
||||||
|
|
||||||
void HMI_MaxJerkXYZE() {
|
void HMI_MaxJerkXYZE() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Jerk_scaled)) {
|
||||||
checkkey = MaxJerk;
|
checkkey = MaxJerk;
|
||||||
|
@ -1620,7 +1620,7 @@ void HMI_MaxAccelerationXYZE() {
|
||||||
#endif // HAS_CLASSIC_JERK
|
#endif // HAS_CLASSIC_JERK
|
||||||
|
|
||||||
void HMI_StepXYZE() {
|
void HMI_StepXYZE() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) {
|
if (Apply_Encoder(encoder_diffState, HMI_ValueStruct.Max_Step_scaled)) {
|
||||||
checkkey = Step;
|
checkkey = Step;
|
||||||
|
@ -1816,8 +1816,6 @@ void HMI_SDCardInit() { card.cdroot(); }
|
||||||
|
|
||||||
void MarlinUI::refresh() { /* Nothing to see here */ }
|
void MarlinUI::refresh() { /* Nothing to see here */ }
|
||||||
|
|
||||||
#define ICON_Folder ICON_More
|
|
||||||
|
|
||||||
#if ENABLED(SCROLL_LONG_FILENAMES)
|
#if ENABLED(SCROLL_LONG_FILENAMES)
|
||||||
|
|
||||||
char shift_name[LONG_FILENAME_LENGTH + 1];
|
char shift_name[LONG_FILENAME_LENGTH + 1];
|
||||||
|
@ -2077,7 +2075,7 @@ void Draw_Print_File_Menu() {
|
||||||
|
|
||||||
// Main Process
|
// Main Process
|
||||||
void HMI_MainMenu() {
|
void HMI_MainMenu() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
if (encoder_diffState == ENCODER_DIFF_CW) {
|
||||||
|
@ -2137,7 +2135,7 @@ void HMI_MainMenu() {
|
||||||
|
|
||||||
// Select (and Print) File
|
// Select (and Print) File
|
||||||
void HMI_SelectFile() {
|
void HMI_SelectFile() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
|
|
||||||
const uint16_t hasUpDir = !card.flag.workDirIsRoot;
|
const uint16_t hasUpDir = !card.flag.workDirIsRoot;
|
||||||
|
|
||||||
|
@ -2257,7 +2255,7 @@ void HMI_SelectFile() {
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
void HMI_Printing() {
|
void HMI_Printing() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (HMI_flag.done_confirm_flag) {
|
if (HMI_flag.done_confirm_flag) {
|
||||||
|
@ -2335,7 +2333,7 @@ void HMI_Printing() {
|
||||||
|
|
||||||
// Pause and Stop window
|
// Pause and Stop window
|
||||||
void HMI_PauseOrStop() {
|
void HMI_PauseOrStop() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
|
@ -2417,7 +2415,7 @@ void Item_Adv_HomeOffsets(const uint8_t row) {
|
||||||
Item_AreaCopy(1, 76, 102, 87, row); // "Set Home Offsets"
|
Item_AreaCopy(1, 76, 102, 87, row); // "Set Home Offsets"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Draw_Menu_Line(row, ICON_HomeOff);
|
Draw_Menu_Line(row, ICON_HomeOffset);
|
||||||
Draw_More_Icon(row);
|
Draw_More_Icon(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2434,7 +2432,7 @@ void Item_Adv_HomeOffsets(const uint8_t row) {
|
||||||
say_probe_offs_en(row);
|
say_probe_offs_en(row);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Draw_Menu_Line(row, ICON_ProbeOff);
|
Draw_Menu_Line(row, ICON_ProbeOffset);
|
||||||
Draw_More_Icon(row);
|
Draw_More_Icon(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2529,12 +2527,12 @@ void Item_HomeOffs_X(const uint8_t row) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef USE_STRING_TITLES
|
#ifdef USE_STRING_TITLES
|
||||||
Draw_Menu_LineF(row, ICON_HomeOffX, GET_TEXT_F(MSG_HOME_OFFSET_X));
|
Draw_Menu_LineF(row, ICON_HomeOffsetX, GET_TEXT_F(MSG_HOME_OFFSET_X));
|
||||||
#else
|
#else
|
||||||
say_home_offs_en(row); say_x_en(75, row); // "Home Offset X"
|
say_home_offs_en(row); say_x_en(75, row); // "Home Offset X"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Draw_Menu_Line(row, ICON_HomeOff);
|
Draw_Menu_Line(row, ICON_HomeOffset);
|
||||||
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffX_scaled);
|
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffX_scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2544,12 +2542,12 @@ void Item_HomeOffs_Y(const uint8_t row) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef USE_STRING_TITLES
|
#ifdef USE_STRING_TITLES
|
||||||
Draw_Menu_LineF(row, ICON_HomeOffY, GET_TEXT_F(MSG_HOME_OFFSET_Y));
|
Draw_Menu_LineF(row, ICON_HomeOffsetY, GET_TEXT_F(MSG_HOME_OFFSET_Y));
|
||||||
#else
|
#else
|
||||||
say_home_offs_en(row); say_y_en(75, row); // "Home Offset X"
|
say_home_offs_en(row); say_y_en(75, row); // "Home Offset X"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Draw_Menu_Line(row, ICON_HomeOff);
|
Draw_Menu_Line(row, ICON_HomeOffset);
|
||||||
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffY_scaled);
|
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffY_scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2559,12 +2557,12 @@ void Item_HomeOffs_Z(const uint8_t row) {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef USE_STRING_TITLES
|
#ifdef USE_STRING_TITLES
|
||||||
Draw_Menu_LineF(row, ICON_HomeOffZ, GET_TEXT_F(MSG_HOME_OFFSET_Z));
|
Draw_Menu_LineF(row, ICON_HomeOffsetZ, GET_TEXT_F(MSG_HOME_OFFSET_Z));
|
||||||
#else
|
#else
|
||||||
say_home_offs_en(row); say_z_en(75, row); // "Home Offset Z"
|
say_home_offs_en(row); say_z_en(75, row); // "Home Offset Z"
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
Draw_Menu_Line(row, ICON_HomeOff);
|
Draw_Menu_Line(row, ICON_HomeOffset);
|
||||||
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffZ_scaled);
|
Draw_Edit_Signed_Float3(row, HMI_ValueStruct.Home_OffZ_scaled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2602,8 +2600,8 @@ void Draw_HomeOff_Menu() {
|
||||||
DWIN_Frame_TitleCopy(124, 431, 91, 12); // "Probe Offsets"
|
DWIN_Frame_TitleCopy(124, 431, 91, 12); // "Probe Offsets"
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_STRING_TITLES
|
#ifdef USE_STRING_TITLES
|
||||||
Draw_Menu_LineF(1, ICON_ProbeOffX, GET_TEXT_F(MSG_ZPROBE_XOFFSET)); // Probe X Offset
|
Draw_Menu_LineF(1, ICON_ProbeOffsetX, GET_TEXT_F(MSG_ZPROBE_XOFFSET)); // Probe X Offset
|
||||||
Draw_Menu_LineF(2, ICON_ProbeOffY, GET_TEXT_F(MSG_ZPROBE_YOFFSET)); // Probe Y Offset
|
Draw_Menu_LineF(2, ICON_ProbeOffsetY, GET_TEXT_F(MSG_ZPROBE_YOFFSET)); // Probe Y Offset
|
||||||
#else
|
#else
|
||||||
say_probe_offs_en(1); say_x_en(75, 1); // "Probe Offset X"
|
say_probe_offs_en(1); say_x_en(75, 1); // "Probe Offset X"
|
||||||
say_probe_offs_en(2); say_y_en(75, 2); // "Probe Offset Y"
|
say_probe_offs_en(2); say_y_en(75, 2); // "Probe Offset Y"
|
||||||
|
@ -2615,6 +2613,7 @@ void Draw_HomeOff_Menu() {
|
||||||
|
|
||||||
if (select_item.now != CASE_BACK) Draw_Menu_Cursor(select_item.now);
|
if (select_item.now != CASE_BACK) Draw_Menu_Cursor(select_item.now);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "../../../libs/buzzer.h"
|
#include "../../../libs/buzzer.h"
|
||||||
|
@ -2633,7 +2632,7 @@ void HMI_AudioFeedback(const bool success=true) {
|
||||||
|
|
||||||
// Prepare
|
// Prepare
|
||||||
void HMI_Prepare() {
|
void HMI_Prepare() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -2847,7 +2846,7 @@ void Draw_Temperature_Menu() {
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
void HMI_Control() {
|
void HMI_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -2932,28 +2931,25 @@ void HMI_Control() {
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if HAS_ONESTEP_LEVELING
|
#if HAS_ONESTEP_LEVELING
|
||||||
|
|
||||||
// Leveling
|
// Leveling
|
||||||
void HMI_Leveling() {
|
void HMI_Leveling() {
|
||||||
Popup_Window_Leveling();
|
Popup_Window_Leveling();
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
queue.inject_P(PSTR("G28O\nG29"));
|
queue.inject_P(PSTR("G28O\nG29"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Axis Move
|
// Axis Move
|
||||||
void HMI_AxisMove() {
|
void HMI_AxisMove() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||||
// popup window resume
|
// popup window resume
|
||||||
if (HMI_flag.ETempTooLow_flag) {
|
if (HMI_flag.cold_flag) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
HMI_flag.ETempTooLow_flag = false;
|
HMI_flag.cold_flag = false;
|
||||||
HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
|
HMI_ValueStruct.Move_E_scaled = current_position.e * MINUNITMULT;
|
||||||
Draw_Move_Menu();
|
Draw_Move_Menu();
|
||||||
Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
|
Draw_Edit_Float3(1, HMI_ValueStruct.Move_X_scaled);
|
||||||
|
@ -3003,7 +2999,7 @@ void HMI_AxisMove() {
|
||||||
case 4: // Extruder
|
case 4: // Extruder
|
||||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||||
if (thermalManager.tooColdToExtrude(0)) {
|
if (thermalManager.tooColdToExtrude(0)) {
|
||||||
HMI_flag.ETempTooLow_flag = true;
|
HMI_flag.cold_flag = true;
|
||||||
Popup_Window_ETempTooLow();
|
Popup_Window_ETempTooLow();
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
return;
|
return;
|
||||||
|
@ -3022,7 +3018,7 @@ void HMI_AxisMove() {
|
||||||
|
|
||||||
// TemperatureID
|
// TemperatureID
|
||||||
void HMI_Temperature() {
|
void HMI_Temperature() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3449,7 +3445,7 @@ void Draw_Steps_Menu() {
|
||||||
|
|
||||||
// Motion
|
// Motion
|
||||||
void HMI_Motion() {
|
void HMI_Motion() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3497,7 +3493,7 @@ void HMI_Motion() {
|
||||||
|
|
||||||
// Advanced Settings
|
// Advanced Settings
|
||||||
void HMI_AdvSet() {
|
void HMI_AdvSet() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3594,7 +3590,7 @@ void HMI_AdvSet() {
|
||||||
|
|
||||||
// Home Offset
|
// Home Offset
|
||||||
void HMI_HomeOff() {
|
void HMI_HomeOff() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3633,7 +3629,7 @@ void HMI_AdvSet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_HomeOffN(const AxisEnum axis, float &posScaled, const_float_t lo, const_float_t hi) {
|
void HMI_HomeOffN(const AxisEnum axis, float &posScaled, const_float_t lo, const_float_t hi) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (Apply_Encoder(encoder_diffState, posScaled)) {
|
if (Apply_Encoder(encoder_diffState, posScaled)) {
|
||||||
|
@ -3654,9 +3650,10 @@ void HMI_AdvSet() {
|
||||||
#endif // HAS_HOME_OFFSET
|
#endif // HAS_HOME_OFFSET
|
||||||
|
|
||||||
#if HAS_ONESTEP_LEVELING
|
#if HAS_ONESTEP_LEVELING
|
||||||
|
|
||||||
// Probe Offset
|
// Probe Offset
|
||||||
void HMI_ProbeOff() {
|
void HMI_ProbeOff() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3689,7 +3686,7 @@ void HMI_AdvSet() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_ProbeOffN(float &posScaled, float &offset_ref) {
|
void HMI_ProbeOffN(float &posScaled, float &offset_ref) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (Apply_Encoder(encoder_diffState, posScaled)) {
|
if (Apply_Encoder(encoder_diffState, posScaled)) {
|
||||||
|
@ -3710,7 +3707,7 @@ void HMI_AdvSet() {
|
||||||
|
|
||||||
// Info
|
// Info
|
||||||
void HMI_Info() {
|
void HMI_Info() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
#if HAS_ONESTEP_LEVELING
|
#if HAS_ONESTEP_LEVELING
|
||||||
|
@ -3727,7 +3724,7 @@ void HMI_Info() {
|
||||||
|
|
||||||
// Tune
|
// Tune
|
||||||
void HMI_Tune() {
|
void HMI_Tune() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3813,7 +3810,7 @@ void HMI_Tune() {
|
||||||
|
|
||||||
// PLA Preheat
|
// PLA Preheat
|
||||||
void HMI_PLAPreheatSetting() {
|
void HMI_PLAPreheatSetting() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3869,7 +3866,7 @@ void HMI_Tune() {
|
||||||
|
|
||||||
// ABS Preheat
|
// ABS Preheat
|
||||||
void HMI_ABSPreheatSetting() {
|
void HMI_ABSPreheatSetting() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3927,7 +3924,7 @@ void HMI_Tune() {
|
||||||
|
|
||||||
// Max Speed
|
// Max Speed
|
||||||
void HMI_MaxSpeed() {
|
void HMI_MaxSpeed() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3956,7 +3953,7 @@ void HMI_MaxSpeed() {
|
||||||
|
|
||||||
// Max Acceleration
|
// Max Acceleration
|
||||||
void HMI_MaxAcceleration() {
|
void HMI_MaxAcceleration() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -3986,7 +3983,7 @@ void HMI_MaxAcceleration() {
|
||||||
#if HAS_CLASSIC_JERK
|
#if HAS_CLASSIC_JERK
|
||||||
// Max Jerk
|
// Max Jerk
|
||||||
void HMI_MaxJerk() {
|
void HMI_MaxJerk() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -4016,7 +4013,7 @@ void HMI_MaxAcceleration() {
|
||||||
|
|
||||||
// Step
|
// Step
|
||||||
void HMI_Step() {
|
void HMI_Step() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
|
@ -4172,7 +4169,7 @@ void EachMomentUpdate() {
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
|
|
||||||
while (recovery_flag) {
|
while (recovery_flag) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState != ENCODER_DIFF_NO) {
|
if (encoder_diffState != ENCODER_DIFF_NO) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
recovery_flag = false;
|
recovery_flag = false;
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
#include "rotary_encoder.h"
|
#include "../common/encoder.h"
|
||||||
#include "../../../libs/BL24CXX.h"
|
#include "../../../libs/BL24CXX.h"
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
@ -144,24 +144,21 @@ typedef struct {
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t language;
|
uint8_t language;
|
||||||
bool pause_flag:1;
|
bool pause_flag:1; // printing is paused
|
||||||
bool pause_action:1;
|
bool pause_action:1; // flag a pause action
|
||||||
bool print_finish:1;
|
bool print_finish:1; // print was finished
|
||||||
|
bool select_flag:1; // Popup button selected
|
||||||
|
bool home_flag:1; // homing in course
|
||||||
|
bool heat_flag:1; // 0: heating done 1: during heating
|
||||||
bool done_confirm_flag:1;
|
bool done_confirm_flag:1;
|
||||||
bool select_flag:1;
|
|
||||||
bool home_flag:1;
|
|
||||||
bool heat_flag:1; // 0: heating done 1: during heating
|
|
||||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||||
bool ETempTooLow_flag:1;
|
bool cold_flag:1;
|
||||||
#endif
|
|
||||||
#if HAS_LEVELING
|
|
||||||
bool leveling_offset_flag:1;
|
|
||||||
#endif
|
#endif
|
||||||
AxisEnum feedspeed_axis, acc_axis, jerk_axis, step_axis;
|
AxisEnum feedspeed_axis, acc_axis, jerk_axis, step_axis;
|
||||||
} HMI_Flag_t;
|
} HMI_flag_t;
|
||||||
|
|
||||||
extern HMI_value_t HMI_ValueStruct;
|
extern HMI_value_t HMI_ValueStruct;
|
||||||
extern HMI_Flag_t HMI_flag;
|
extern HMI_flag_t HMI_flag;
|
||||||
|
|
||||||
#if HAS_HOTEND || HAS_HEATED_BED
|
#if HAS_HOTEND || HAS_HEATED_BED
|
||||||
// Popup message window
|
// Popup message window
|
||||||
|
|
|
@ -35,94 +35,13 @@
|
||||||
#include "../../../inc/MarlinConfig.h"
|
#include "../../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
#include <string.h> // for memset
|
|
||||||
|
|
||||||
//#define DEBUG_OUT 1
|
//#define DEBUG_OUT 1
|
||||||
#include "../../../core/debug_out.h"
|
#include "../../../core/debug_out.h"
|
||||||
|
|
||||||
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
|
||||||
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
|
||||||
uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
|
|
||||||
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
|
||||||
uint8_t databuf[26] = { 0 };
|
|
||||||
uint8_t receivedType;
|
|
||||||
|
|
||||||
int recnum = 0;
|
|
||||||
|
|
||||||
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
|
||||||
DWIN_SendBuf[++i] = bval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
|
||||||
DWIN_SendBuf[++i] = wval >> 8;
|
|
||||||
DWIN_SendBuf[++i] = wval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = lval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, char * const string) {
|
|
||||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
|
|
||||||
if (!string) return;
|
|
||||||
const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
|
|
||||||
if (len == 0) return;
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the data in the buffer and the packet end
|
|
||||||
inline void DWIN_Send(size_t &i) {
|
|
||||||
++i;
|
|
||||||
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
|
||||||
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
void DWIN_Startup() {
|
||||||
bool DWIN_Handshake(void) {
|
|
||||||
#ifndef LCD_BAUDRATE
|
|
||||||
#define LCD_BAUDRATE 115200
|
|
||||||
#endif
|
|
||||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
|
||||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
|
||||||
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x00);
|
|
||||||
DWIN_Send(i);
|
|
||||||
|
|
||||||
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
|
||||||
databuf[recnum] = LCD_SERIAL.read();
|
|
||||||
// ignore the invalid data
|
|
||||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
|
||||||
if (recnum > 0) {
|
|
||||||
recnum = 0;
|
|
||||||
ZERO(databuf);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
delay(10);
|
|
||||||
recnum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( recnum >= 3
|
|
||||||
&& databuf[0] == FHONE
|
|
||||||
&& databuf[1] == '\0'
|
|
||||||
&& databuf[2] == 'O'
|
|
||||||
&& databuf[3] == 'K' );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DWIN_Startup(void) {
|
|
||||||
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
||||||
delay(750); // Delay here or init later in the boot process
|
delay(750); // Delay here or init later in the boot process
|
||||||
if (DWIN_Handshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
|
if (DWIN_Handshake()) DEBUG_ECHOLNPGM("ok."); else DEBUG_ECHOLNPGM("error.");
|
||||||
|
@ -133,255 +52,14 @@ void DWIN_Startup(void) {
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x30);
|
|
||||||
DWIN_Byte(i, _MAX(luminance, 0x1F));
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x34);
|
|
||||||
DWIN_Byte(i, 0x5A);
|
|
||||||
DWIN_Byte(i, 0xA5);
|
|
||||||
DWIN_Byte(i, dir);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x3D);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x01);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x02);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Byte(i, width);
|
|
||||||
DWIN_Byte(i, height);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x03);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x05);
|
|
||||||
DWIN_Byte(i, mode);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x09);
|
|
||||||
DWIN_Byte(i, (mode << 7) | dir);
|
|
||||||
DWIN_Word(i, dis);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// widthAdjust: true=self-adjust character width; false=no adjustment
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
|
|
||||||
uint8_t widthAdjust = 0;
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x11);
|
|
||||||
// Bit 7: widthAdjust
|
|
||||||
// Bit 6: bShow
|
|
||||||
// Bit 5-4: Unused (0)
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_String(i, string);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
// Bit 7: bshow
|
|
||||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
|
||||||
// Bit 5: zeroFill
|
|
||||||
// Bit 4: zeroMode
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, 0); // fNum
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
#if 0
|
|
||||||
for (char count = 0; count < 8; count++) {
|
|
||||||
DWIN_Byte(i, value);
|
|
||||||
value >>= 8;
|
|
||||||
if (!(value & 0xFF)) break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Write a big-endian 64 bit integer
|
|
||||||
const size_t p = i + 1;
|
|
||||||
for (char count = 8; count--;) { // 7..0
|
|
||||||
++i;
|
|
||||||
DWIN_SendBuf[p + count] = value;
|
|
||||||
value >>= 8;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
|
||||||
//uint8_t *fvalue = (uint8_t*)&value;
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, fNum);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Long(i, value);
|
|
||||||
/*
|
|
||||||
DWIN_Byte(i, fvalue[3]);
|
|
||||||
DWIN_Byte(i, fvalue[2]);
|
|
||||||
DWIN_Byte(i, fvalue[1]);
|
|
||||||
DWIN_Byte(i, fvalue[0]);
|
|
||||||
*/
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Word(i, 0x2200);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon
|
// Draw an Icon
|
||||||
// libID: Icon library ID
|
// libID: Icon library ID
|
||||||
// picID: Icon ID
|
// picID: Icon ID
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
DWIN_ICON_Show(true, false, false, libID, picID, x, y);
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x23);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Byte(i, 0x80 | libID);
|
|
||||||
//DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picID);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x25);
|
|
||||||
DWIN_Byte(i, n);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
// Copy area from virtual display area to current screen
|
||||||
|
@ -389,8 +67,7 @@ void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
DWIN_Byte(i, 0x27);
|
DWIN_Byte(i, 0x27);
|
||||||
DWIN_Byte(i, 0x80 | cacheID);
|
DWIN_Byte(i, 0x80 | cacheID);
|
||||||
|
@ -403,73 +80,4 @@ void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
||||||
DWIN_Send(i);
|
DWIN_Send(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID; 0x00-0x0F
|
|
||||||
// animate: true on; false off;
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
|
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x28);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
// Bit 7: animation on or off
|
|
||||||
// Bit 6: start from begin or end
|
|
||||||
// Bit 5-4: unused (0)
|
|
||||||
// Bit 3-0: animID
|
|
||||||
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
|
|
||||||
DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picIDs);
|
|
||||||
DWIN_Byte(i, picIDe);
|
|
||||||
DWIN_Byte(i, interval);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x29);
|
|
||||||
DWIN_Word(i, state);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Memory functions ----------------------------------------*/
|
|
||||||
// The LCD has an additional 32KB SRAM and 16KB Flash
|
|
||||||
|
|
||||||
// Data can be written to the sram and save to one of the jpeg page files
|
|
||||||
|
|
||||||
// Write Data Memory
|
|
||||||
// command 0x31
|
|
||||||
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Data: data
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
// Read Data Memory
|
|
||||||
// command 0x32
|
|
||||||
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Length: leangth of data to read; 0x01-0xF0
|
|
||||||
//
|
|
||||||
// Response:
|
|
||||||
// Type, Address, Length, Data
|
|
||||||
|
|
||||||
// Write Picture Memory
|
|
||||||
// Write the contents of the 32KB SRAM data memory into the designated image memory space
|
|
||||||
// Issued: 0x5A, 0xA5, PIC_ID
|
|
||||||
// Response: 0xA5 0x4F 0x4B
|
|
||||||
//
|
|
||||||
// command 0x33
|
|
||||||
// 0x5A, 0xA5
|
|
||||||
// PicId: Picture Memory location, 0x00-0x0F
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD
|
#endif // DWIN_CREALITY_LCD
|
||||||
|
|
|
@ -29,335 +29,22 @@
|
||||||
* @brief 迪文屏控制操作函数
|
* @brief 迪文屏控制操作函数
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#define RECEIVED_NO_DATA 0x00
|
|
||||||
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
|
||||||
|
|
||||||
#define FHONE 0xAA
|
|
||||||
|
|
||||||
#define DWIN_SCROLL_UP 2
|
|
||||||
#define DWIN_SCROLL_DOWN 3
|
|
||||||
|
|
||||||
#define DWIN_WIDTH 272
|
#define DWIN_WIDTH 272
|
||||||
#define DWIN_HEIGHT 480
|
#define DWIN_HEIGHT 480
|
||||||
|
|
||||||
// Picture ID
|
#include "../common/dwin_api.h"
|
||||||
#define Language_English 1
|
#include "../common/dwin_set.h"
|
||||||
#define Language_Chinese 2
|
#include "../common/dwin_font.h"
|
||||||
|
#include "../common/dwin_color.h"
|
||||||
// ICON ID
|
|
||||||
#define ICON 7 // Icon set file 7.ICO
|
|
||||||
|
|
||||||
#define ICON_LOGO 0
|
|
||||||
#define ICON_Print_0 1
|
|
||||||
#define ICON_Print_1 2
|
|
||||||
#define ICON_Prepare_0 3
|
|
||||||
#define ICON_Prepare_1 4
|
|
||||||
#define ICON_Control_0 5
|
|
||||||
#define ICON_Control_1 6
|
|
||||||
#define ICON_Leveling_0 7
|
|
||||||
#define ICON_Leveling_1 8
|
|
||||||
#define ICON_HotendTemp 9
|
|
||||||
#define ICON_BedTemp 10
|
|
||||||
#define ICON_Speed 11
|
|
||||||
#define ICON_Zoffset 12
|
|
||||||
#define ICON_Back 13
|
|
||||||
#define ICON_File 14
|
|
||||||
#define ICON_PrintTime 15
|
|
||||||
#define ICON_RemainTime 16
|
|
||||||
#define ICON_Setup_0 17
|
|
||||||
#define ICON_Setup_1 18
|
|
||||||
#define ICON_Pause_0 19
|
|
||||||
#define ICON_Pause_1 20
|
|
||||||
#define ICON_Continue_0 21
|
|
||||||
#define ICON_Continue_1 22
|
|
||||||
#define ICON_Stop_0 23
|
|
||||||
#define ICON_Stop_1 24
|
|
||||||
#define ICON_Bar 25
|
|
||||||
#define ICON_More 26
|
|
||||||
|
|
||||||
#define ICON_Axis 27
|
|
||||||
#define ICON_CloseMotor 28
|
|
||||||
#define ICON_Homing 29
|
|
||||||
#define ICON_SetHome 30
|
|
||||||
#define ICON_PLAPreheat 31
|
|
||||||
#define ICON_ABSPreheat 32
|
|
||||||
#define ICON_Cool 33
|
|
||||||
#define ICON_Language 34
|
|
||||||
|
|
||||||
#define ICON_MoveX 35
|
|
||||||
#define ICON_MoveY 36
|
|
||||||
#define ICON_MoveZ 37
|
|
||||||
#define ICON_Extruder 38
|
|
||||||
|
|
||||||
#define ICON_Temperature 40
|
|
||||||
#define ICON_Motion 41
|
|
||||||
#define ICON_WriteEEPROM 42
|
|
||||||
#define ICON_ReadEEPROM 43
|
|
||||||
#define ICON_ResumeEEPROM 44
|
|
||||||
#define ICON_Info 45
|
|
||||||
|
|
||||||
#define ICON_SetEndTemp 46
|
|
||||||
#define ICON_SetBedTemp 47
|
|
||||||
#define ICON_FanSpeed 48
|
|
||||||
#define ICON_SetPLAPreheat 49
|
|
||||||
#define ICON_SetABSPreheat 50
|
|
||||||
|
|
||||||
#define ICON_MaxSpeed 51
|
|
||||||
#define ICON_MaxAccelerated 52
|
|
||||||
#define ICON_MaxJerk 53
|
|
||||||
#define ICON_Step 54
|
|
||||||
#define ICON_PrintSize 55
|
|
||||||
#define ICON_Version 56
|
|
||||||
#define ICON_Contact 57
|
|
||||||
#define ICON_StockConfiguraton 58
|
|
||||||
#define ICON_MaxSpeedX 59
|
|
||||||
#define ICON_MaxSpeedY 60
|
|
||||||
#define ICON_MaxSpeedZ 61
|
|
||||||
#define ICON_MaxSpeedE 62
|
|
||||||
#define ICON_MaxAccX 63
|
|
||||||
#define ICON_MaxAccY 64
|
|
||||||
#define ICON_MaxAccZ 65
|
|
||||||
#define ICON_MaxAccE 66
|
|
||||||
#define ICON_MaxSpeedJerkX 67
|
|
||||||
#define ICON_MaxSpeedJerkY 68
|
|
||||||
#define ICON_MaxSpeedJerkZ 69
|
|
||||||
#define ICON_MaxSpeedJerkE 70
|
|
||||||
#define ICON_StepX 71
|
|
||||||
#define ICON_StepY 72
|
|
||||||
#define ICON_StepZ 73
|
|
||||||
#define ICON_StepE 74
|
|
||||||
#define ICON_Setspeed 75
|
|
||||||
#define ICON_SetZOffset 76
|
|
||||||
#define ICON_Rectangle 77
|
|
||||||
#define ICON_BLTouch 78
|
|
||||||
#define ICON_TempTooLow 79
|
|
||||||
#define ICON_AutoLeveling 80
|
|
||||||
#define ICON_TempTooHigh 81
|
|
||||||
#define ICON_NoTips_C 82
|
|
||||||
#define ICON_NoTips_E 83
|
|
||||||
#define ICON_Continue_C 84
|
|
||||||
#define ICON_Continue_E 85
|
|
||||||
#define ICON_Cancel_C 86
|
|
||||||
#define ICON_Cancel_E 87
|
|
||||||
#define ICON_Confirm_C 88
|
|
||||||
#define ICON_Confirm_E 89
|
|
||||||
#define ICON_Info_0 90
|
|
||||||
#define ICON_Info_1 91
|
|
||||||
|
|
||||||
#define ICON_AdvSet ICON_Language
|
|
||||||
#define ICON_HomeOff ICON_AdvSet
|
|
||||||
#define ICON_HomeOffX ICON_StepX
|
|
||||||
#define ICON_HomeOffY ICON_StepY
|
|
||||||
#define ICON_HomeOffZ ICON_StepZ
|
|
||||||
#define ICON_ProbeOff ICON_AdvSet
|
|
||||||
#define ICON_ProbeOffX ICON_StepX
|
|
||||||
#define ICON_ProbeOffY ICON_StepY
|
|
||||||
#define ICON_PIDNozzle ICON_SetEndTemp
|
|
||||||
#define ICON_PIDbed ICON_SetBedTemp
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
|
|
||||||
*/
|
|
||||||
#define font6x12 0x00
|
|
||||||
#define font8x16 0x01
|
|
||||||
#define font10x20 0x02
|
|
||||||
#define font12x24 0x03
|
|
||||||
#define font14x28 0x04
|
|
||||||
#define font16x32 0x05
|
|
||||||
#define font20x40 0x06
|
|
||||||
#define font24x48 0x07
|
|
||||||
#define font28x56 0x08
|
|
||||||
#define font32x64 0x09
|
|
||||||
|
|
||||||
#define DWIN_FONT_MENU font10x20
|
#define DWIN_FONT_MENU font10x20
|
||||||
#define DWIN_FONT_STAT font10x20
|
#define DWIN_FONT_STAT font10x20
|
||||||
#define DWIN_FONT_HEAD font10x20
|
#define DWIN_FONT_HEAD font10x20
|
||||||
#define DWIN_FONT_ALERT font14x28
|
#define DWIN_FONT_ALERT font14x28
|
||||||
|
|
||||||
// Color
|
|
||||||
#define Color_White 0xFFFF
|
|
||||||
#define Color_Yellow 0xFF0F
|
|
||||||
#define Color_Error_Red 0xB000 // Error!
|
|
||||||
#define Color_Bg_Red 0xF00F // Red background color
|
|
||||||
#define Color_Bg_Window 0x31E8 // Popup background color
|
|
||||||
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
|
||||||
#define Color_Bg_Black 0x0841 // Black background color
|
|
||||||
#define Color_IconBlue 0x45FA // Lighter blue that matches icons/accents
|
|
||||||
#define Popup_Text_Color 0xD6BA // Popup font background color
|
|
||||||
#define Line_Color 0x3A6A // Split line color
|
|
||||||
#define Rectangle_Color 0xEE2F // Blue square cursor color
|
|
||||||
#define Percent_Color 0xFE29 // Percentage color
|
|
||||||
#define BarFill_Color 0x10E4 // Fill color of progress bar
|
|
||||||
#define Select_Color 0x33BB // Selected color
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
|
||||||
bool DWIN_Handshake(void);
|
|
||||||
|
|
||||||
// Common DWIN startup
|
|
||||||
void DWIN_Startup(void);
|
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir);
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void);
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color);
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: point color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a Horizontal line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xLength: Line Length
|
|
||||||
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a Vertical line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// yLength: Line Length
|
|
||||||
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a box
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xSize/ySize: box size
|
|
||||||
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
|
|
||||||
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
|
|
||||||
|
|
||||||
class __FlashStringHelper;
|
|
||||||
|
|
||||||
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
|
|
||||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value);
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
|
||||||
|
|
||||||
// Draw an Icon
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picID: Icon ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to virtual display area #1
|
|
||||||
// id: Picture ID
|
|
||||||
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
// Copy area from virtual display area to current screen
|
||||||
// cacheID: virtual area number
|
// cacheID: virtual area number
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID up to 16
|
|
||||||
// animate: animation on or off
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
|
|
||||||
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state);
|
|
||||||
|
|
|
@ -1,263 +0,0 @@
|
||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2020 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* @file lcd/e3v2/creality/rotary_encoder.cpp
|
|
||||||
* @author LEO / Creality3D
|
|
||||||
* @date 2019/07/06
|
|
||||||
* @version 2.0.1
|
|
||||||
* @brief Rotary encoder functions
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD)
|
|
||||||
|
|
||||||
#include "rotary_encoder.h"
|
|
||||||
#include "../../buttons.h"
|
|
||||||
|
|
||||||
#include "../../../MarlinCore.h"
|
|
||||||
#include "../../../HAL/shared/Delay.h"
|
|
||||||
|
|
||||||
#if HAS_BUZZER
|
|
||||||
#include "../../../libs/buzzer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifndef ENCODER_PULSES_PER_STEP
|
|
||||||
#define ENCODER_PULSES_PER_STEP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ENCODER_Rate EncoderRate;
|
|
||||||
|
|
||||||
// Buzzer
|
|
||||||
void Encoder_tick() {
|
|
||||||
#if PIN_EXISTS(BEEPER)
|
|
||||||
WRITE(BEEPER_PIN, HIGH);
|
|
||||||
delay(10);
|
|
||||||
WRITE(BEEPER_PIN, LOW);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encoder initialization
|
|
||||||
void Encoder_Configuration() {
|
|
||||||
#if BUTTON_EXISTS(EN1)
|
|
||||||
SET_INPUT_PULLUP(BTN_EN1);
|
|
||||||
#endif
|
|
||||||
#if BUTTON_EXISTS(EN2)
|
|
||||||
SET_INPUT_PULLUP(BTN_EN2);
|
|
||||||
#endif
|
|
||||||
#if BUTTON_EXISTS(ENC)
|
|
||||||
SET_INPUT_PULLUP(BTN_ENC);
|
|
||||||
#endif
|
|
||||||
#if PIN_EXISTS(BEEPER)
|
|
||||||
SET_OUTPUT(BEEPER_PIN);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
|
||||||
const millis_t now = millis();
|
|
||||||
static uint8_t lastEncoderBits;
|
|
||||||
uint8_t newbutton = 0;
|
|
||||||
static signed char temp_diff = 0;
|
|
||||||
|
|
||||||
ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
|
|
||||||
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
|
||||||
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
|
||||||
if (BUTTON_PRESSED(ENC)) {
|
|
||||||
static millis_t next_click_update_ms;
|
|
||||||
if (ELAPSED(now, next_click_update_ms)) {
|
|
||||||
next_click_update_ms = millis() + 300;
|
|
||||||
Encoder_tick();
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
//LED_Action();
|
|
||||||
#endif
|
|
||||||
const bool was_waiting = wait_for_user;
|
|
||||||
wait_for_user = false;
|
|
||||||
return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
|
|
||||||
}
|
|
||||||
else return ENCODER_DIFF_NO;
|
|
||||||
}
|
|
||||||
if (newbutton != lastEncoderBits) {
|
|
||||||
switch (newbutton) {
|
|
||||||
case ENCODER_PHASE_0:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_1:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_2:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_3:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lastEncoderBits = newbutton;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
|
|
||||||
#if ENABLED(REVERSE_ENCODER_DIRECTION)
|
|
||||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CCW;
|
|
||||||
else temp_diffState = ENCODER_DIFF_CW;
|
|
||||||
#else
|
|
||||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
|
|
||||||
else temp_diffState = ENCODER_DIFF_CCW;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
||||||
|
|
||||||
millis_t ms = millis();
|
|
||||||
int32_t encoderMultiplier = 1;
|
|
||||||
|
|
||||||
// if must encoder rati multiplier
|
|
||||||
if (EncoderRate.enabled) {
|
|
||||||
const float abs_diff = ABS(temp_diff),
|
|
||||||
encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
|
|
||||||
if (EncoderRate.lastEncoderTime) {
|
|
||||||
// Note that the rate is always calculated between two passes through the
|
|
||||||
// loop and that the abs of the temp_diff value is tracked.
|
|
||||||
const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
|
|
||||||
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
|
||||||
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
|
||||||
#if ENCODER_5X_STEPS_PER_SEC
|
|
||||||
else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
EncoderRate.lastEncoderTime = ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
constexpr int32_t encoderMultiplier = 1;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
|
||||||
EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
|
||||||
if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
|
|
||||||
|
|
||||||
temp_diff = 0;
|
|
||||||
}
|
|
||||||
return temp_diffState;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
|
|
||||||
// Take the low 24 valid bits 24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
|
|
||||||
uint16_t LED_DataArray[LED_NUM];
|
|
||||||
|
|
||||||
// LED light operation
|
|
||||||
void LED_Action() {
|
|
||||||
LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
|
|
||||||
delay(30);
|
|
||||||
LED_Control(RGB_SCALE_WARM_WHITE,0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED initialization
|
|
||||||
void LED_Configuration() {
|
|
||||||
SET_OUTPUT(LCD_LED_PIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED write data
|
|
||||||
void LED_WriteData() {
|
|
||||||
uint8_t tempCounter_LED, tempCounter_Bit;
|
|
||||||
for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
|
|
||||||
for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
|
|
||||||
if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
|
|
||||||
LED_DATA_HIGH;
|
|
||||||
DELAY_NS(300);
|
|
||||||
LED_DATA_LOW;
|
|
||||||
DELAY_NS(200);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LED_DATA_HIGH;
|
|
||||||
LED_DATA_LOW;
|
|
||||||
DELAY_NS(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
LED_DataArray[i] = 0;
|
|
||||||
switch (RGB_Scale) {
|
|
||||||
case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
|
|
||||||
case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
|
|
||||||
case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LED_WriteData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED gradient control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
// change_Time: gradient time (ms)
|
|
||||||
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
|
|
||||||
struct { uint8_t g, r, b; } led_data[LED_NUM];
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
switch (RGB_Scale) {
|
|
||||||
case RGB_SCALE_R10_G7_B5:
|
|
||||||
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
|
|
||||||
break;
|
|
||||||
case RGB_SCALE_R10_G7_B4:
|
|
||||||
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
|
|
||||||
break;
|
|
||||||
case RGB_SCALE_R10_G8_B7:
|
|
||||||
led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct { bool g, r, b; } led_flag = { false, false, false };
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
while (1) {
|
|
||||||
const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
|
|
||||||
r = uint8_t(LED_DataArray[i] >> 8),
|
|
||||||
b = uint8_t(LED_DataArray[i]);
|
|
||||||
if (g == led_data[i].g) led_flag.g = true;
|
|
||||||
else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
|
|
||||||
if (r == led_data[i].r) led_flag.r = true;
|
|
||||||
else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
|
|
||||||
if (b == led_data[i].b) led_flag.b = true;
|
|
||||||
else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
|
|
||||||
LED_WriteData();
|
|
||||||
if (led_flag.r && led_flag.g && led_flag.b) break;
|
|
||||||
delay(change_Interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LCD_LED
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD
|
|
|
@ -1,94 +0,0 @@
|
||||||
/**
|
|
||||||
* Marlin 3D Printer Firmware
|
|
||||||
* Copyright (c) 2020 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/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* @file lcd/e3v2/creality/rotary_encoder.h
|
|
||||||
* @author LEO / Creality3D
|
|
||||||
* @date 2019/07/06
|
|
||||||
* @version 2.0.1
|
|
||||||
* @brief Rotary encoder functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
/*********************** Encoder Set ***********************/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool enabled = false;
|
|
||||||
int encoderMoveValue = 0;
|
|
||||||
millis_t lastEncoderTime = 0;
|
|
||||||
} ENCODER_Rate;
|
|
||||||
|
|
||||||
extern ENCODER_Rate EncoderRate;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ENCODER_DIFF_NO = 0, // no state
|
|
||||||
ENCODER_DIFF_CW = 1, // clockwise rotation
|
|
||||||
ENCODER_DIFF_CCW = 2, // counterclockwise rotation
|
|
||||||
ENCODER_DIFF_ENTER = 3 // click
|
|
||||||
} ENCODER_DiffState;
|
|
||||||
|
|
||||||
// Encoder initialization
|
|
||||||
void Encoder_Configuration();
|
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze();
|
|
||||||
|
|
||||||
/*********************** Encoder LED ***********************/
|
|
||||||
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
|
|
||||||
#define LED_NUM 4
|
|
||||||
#define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
|
|
||||||
#define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
|
|
||||||
|
|
||||||
#define RGB_SCALE_R10_G7_B5 1
|
|
||||||
#define RGB_SCALE_R10_G7_B4 2
|
|
||||||
#define RGB_SCALE_R10_G8_B7 3
|
|
||||||
#define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
|
|
||||||
#define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4
|
|
||||||
#define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7
|
|
||||||
|
|
||||||
extern unsigned int LED_DataArray[LED_NUM];
|
|
||||||
|
|
||||||
// LED light operation
|
|
||||||
void LED_Action();
|
|
||||||
|
|
||||||
// LED initialization
|
|
||||||
void LED_Configuration();
|
|
||||||
|
|
||||||
// LED write data
|
|
||||||
void LED_WriteData();
|
|
||||||
|
|
||||||
// LED control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
|
|
||||||
|
|
||||||
// LED gradient control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
// change_Time: gradient time (ms)
|
|
||||||
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
|
|
||||||
|
|
||||||
#endif // LCD_LED
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,11 +15,18 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/10
|
||||||
|
*/
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||||
|
@ -261,7 +269,7 @@ typedef struct { uint16_t x, y[2], w, h; } text_info_t;
|
||||||
|
|
||||||
void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) {
|
void ICON_Button(const bool here, const int iconid, const frame_rect_t &ico, const text_info_t (&txt)[2]) {
|
||||||
const bool cn = HMI_IsChinese();
|
const bool cn = HMI_IsChinese();
|
||||||
DWIN_ICON_Show(1, 0, 0, ICON, iconid + here, ico.x, ico.y);
|
DWIN_ICON_Show(true, false, false, ICON, iconid + here, ico.x, ico.y);
|
||||||
if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1);
|
if (here) DWIN_Draw_Rectangle(0, HMI_data.Highlight_Color, ico.x, ico.y, ico.x + ico.w - 1, ico.y + ico.h - 1);
|
||||||
DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2);
|
DWIN_Frame_AreaCopy(1, txt[cn].x, txt[cn].y[here], txt[cn].x + txt[cn].w - 1, txt[cn].y[here] + txt[cn].h - 1, ico.x + (ico.w - txt[cn].w) / 2, (ico.y + ico.h - 28) - txt[cn].h/2);
|
||||||
}
|
}
|
||||||
|
@ -438,17 +446,17 @@ void Draw_Back_First(const bool is_sel=true) {
|
||||||
if (is_sel) Draw_Menu_Cursor(0);
|
if (is_sel) Draw_Menu_Cursor(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ENCODER_DiffState get_encoder_state() {
|
inline EncoderState get_encoder_state() {
|
||||||
static millis_t Encoder_ms = 0;
|
static millis_t Encoder_ms = 0;
|
||||||
const millis_t ms = millis();
|
const millis_t ms = millis();
|
||||||
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
||||||
const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
|
const EncoderState state = Encoder_ReceiveAnalyze();
|
||||||
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) {
|
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
valref += EncoderRate.encoderMoveValue;
|
valref += EncoderRate.encoderMoveValue;
|
||||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
||||||
|
@ -762,15 +770,15 @@ void update_variable() {
|
||||||
// Tune page temperature update
|
// Tune page temperature update
|
||||||
#if HAS_HOTEND
|
#if HAS_HOTEND
|
||||||
if (_new_hotend_target)
|
if (_new_hotend_target)
|
||||||
HotendTargetItem->Draw(CurrentMenu->line(HotendTargetItem->pos));
|
HotendTargetItem->draw(CurrentMenu->line(HotendTargetItem->pos));
|
||||||
#endif
|
#endif
|
||||||
#if HAS_HEATED_BED
|
#if HAS_HEATED_BED
|
||||||
if (_new_bed_target)
|
if (_new_bed_target)
|
||||||
BedTargetItem->Draw(CurrentMenu->line(BedTargetItem->pos));
|
BedTargetItem->draw(CurrentMenu->line(BedTargetItem->pos));
|
||||||
#endif
|
#endif
|
||||||
#if HAS_FAN
|
#if HAS_FAN
|
||||||
if (_new_fanspeed)
|
if (_new_fanspeed)
|
||||||
FanSpeedItem->Draw(CurrentMenu->line(FanSpeedItem->pos));
|
FanSpeedItem->draw(CurrentMenu->line(FanSpeedItem->pos));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1098,7 +1106,7 @@ void Draw_Print_File_Menu() {
|
||||||
|
|
||||||
// Main Process
|
// Main Process
|
||||||
void HMI_MainMenu() {
|
void HMI_MainMenu() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
if (encoder_diffState == ENCODER_DIFF_CW) {
|
||||||
|
@ -1147,7 +1155,7 @@ void HMI_MainMenu() {
|
||||||
|
|
||||||
// Select (and Print) File
|
// Select (and Print) File
|
||||||
void HMI_SelectFile() {
|
void HMI_SelectFile() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
|
|
||||||
const uint16_t hasUpDir = !card.flag.workDirIsRoot;
|
const uint16_t hasUpDir = !card.flag.workDirIsRoot;
|
||||||
|
|
||||||
|
@ -1267,7 +1275,7 @@ void HMI_SelectFile() {
|
||||||
|
|
||||||
// Printing
|
// Printing
|
||||||
void HMI_Printing() {
|
void HMI_Printing() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
// Avoid flicker by updating only the previous menu
|
// Avoid flicker by updating only the previous menu
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
if (encoder_diffState == ENCODER_DIFF_CW) {
|
||||||
|
@ -1331,7 +1339,7 @@ void HMI_Printing() {
|
||||||
|
|
||||||
// Print done
|
// Print done
|
||||||
void HMI_PrintDone() {
|
void HMI_PrintDone() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
dwin_abort_flag = true; // Reset feedrate, return to Home
|
dwin_abort_flag = true; // Reset feedrate, return to Home
|
||||||
|
@ -1341,7 +1349,7 @@ void HMI_PrintDone() {
|
||||||
|
|
||||||
// Pause or Stop popup
|
// Pause or Stop popup
|
||||||
void HMI_PauseOrStop() {
|
void HMI_PauseOrStop() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
|
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
|
@ -1404,13 +1412,13 @@ void Draw_Main_Area() {
|
||||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||||
case FilamentPurge: Draw_Popup_FilamentPurge(); break;
|
case FilamentPurge: Draw_Popup_FilamentPurge(); break;
|
||||||
#endif
|
#endif
|
||||||
case Locked: LockScreen.Draw(); break;
|
case Locked: lockScreen.draw(); break;
|
||||||
case Menu:
|
case Menu:
|
||||||
case SetInt:
|
case SetInt:
|
||||||
case SetPInt:
|
case SetPInt:
|
||||||
case SetIntNoDraw:
|
case SetIntNoDraw:
|
||||||
case SetFloat:
|
case SetFloat:
|
||||||
case SetPFloat: CurrentMenu->Draw(); break;
|
case SetPFloat: CurrentMenu->draw(); break;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1423,7 +1431,7 @@ void HMI_ReturnScreen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_Popup() {
|
void HMI_Popup() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
wait_for_user = false;
|
wait_for_user = false;
|
||||||
|
@ -1560,7 +1568,7 @@ void EachMomentUpdate() {
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
|
|
||||||
while (recovery_flag) {
|
while (recovery_flag) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState != ENCODER_DIFF_NO) {
|
if (encoder_diffState != ENCODER_DIFF_NO) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
recovery_flag = false;
|
recovery_flag = false;
|
||||||
|
@ -1714,7 +1722,7 @@ void Draw_Title(TitleClass* title) {
|
||||||
if (title->frameid)
|
if (title->frameid)
|
||||||
DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1);
|
DWIN_Frame_AreaCopy(title->frameid, title->frame.left, title->frame.top, title->frame.right, title->frame.bottom, 14, (TITLE_HEIGHT - (title->frame.bottom - title->frame.top)) / 2 - 1);
|
||||||
else
|
else
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::Get_font_height(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
|
DWIN_Draw_String(false, DWIN_FONT_HEAD, HMI_data.TitleTxt_color, HMI_data.TitleBg_color, 14, (TITLE_HEIGHT - DWINUI::fontHeight(DWIN_FONT_HEAD)) / 2 - 1, title->caption);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Menu(MenuClass* menu) {
|
void Draw_Menu(MenuClass* menu) {
|
||||||
|
@ -1725,7 +1733,7 @@ void Draw_Menu(MenuClass* menu) {
|
||||||
|
|
||||||
// Startup routines
|
// Startup routines
|
||||||
void DWIN_Startup() {
|
void DWIN_Startup() {
|
||||||
DWINUI::Init();
|
DWINUI::init();
|
||||||
DWINUI::onCursorDraw = Draw_Menu_Cursor;
|
DWINUI::onCursorDraw = Draw_Menu_Cursor;
|
||||||
DWINUI::onCursorErase = Erase_Menu_Cursor;
|
DWINUI::onCursorErase = Erase_Menu_Cursor;
|
||||||
DWINUI::onTitleDraw = Draw_Title;
|
DWINUI::onTitleDraw = Draw_Title;
|
||||||
|
@ -1890,7 +1898,7 @@ void DWIN_Redraw_screen() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void HMI_FilamentPurge() {
|
void HMI_FilamentPurge() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
Draw_Select_Highlight(false);
|
Draw_Select_Highlight(false);
|
||||||
|
@ -1910,10 +1918,10 @@ void DWIN_Redraw_screen() {
|
||||||
#endif // ADVANCED_PAUSE_FEATURE
|
#endif // ADVANCED_PAUSE_FEATURE
|
||||||
|
|
||||||
void HMI_LockScreen() {
|
void HMI_LockScreen() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
LockScreen.onEncoderState(encoder_diffState);
|
lockScreen.onEncoder(encoder_diffState);
|
||||||
if (LockScreen.isUnlocked()) {
|
if (lockScreen.isUnlocked()) {
|
||||||
if (CurrentMenu == AdvancedSettings)
|
if (CurrentMenu == AdvancedSettings)
|
||||||
Draw_AdvancedSettings_Menu();
|
Draw_AdvancedSettings_Menu();
|
||||||
else
|
else
|
||||||
|
@ -1924,7 +1932,7 @@ void HMI_LockScreen() {
|
||||||
void DWIN_LockScreen(const bool flag) {
|
void DWIN_LockScreen(const bool flag) {
|
||||||
HMI_flag.lock_flag = flag;
|
HMI_flag.lock_flag = flag;
|
||||||
checkkey = Locked;
|
checkkey = Locked;
|
||||||
LockScreen.Init();
|
lockScreen.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -1974,7 +1982,7 @@ void SetValueOnClick(uint8_t process, const int32_t lo, const int32_t hi, const
|
||||||
void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
|
void SetValueOnClick(uint8_t process, const float lo, const float hi, uint8_t dp, const float val, void (*Apply)() = nullptr, void (*LiveUpdate)() = nullptr) {
|
||||||
const int32_t value = round(val * POW(10, dp));
|
const int32_t value = round(val * POW(10, dp));
|
||||||
SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
|
SetOnClick(process, lo * POW(10, dp), hi * POW(10, dp), dp, value, Apply, LiveUpdate);
|
||||||
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val);
|
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), val);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Generic onclick event for integer values
|
// Generic onclick event for integer values
|
||||||
|
@ -2379,7 +2387,7 @@ void LevBedC () { LevBed(4); }
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
#ifdef MANUAL_PROBE_START_Z
|
#ifdef MANUAL_PROBE_START_Z
|
||||||
const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos);
|
const uint8_t line = CurrentMenu->line(MMeshMoveZItem->pos);
|
||||||
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z);
|
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, 2, VALX - 2 * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), MANUAL_PROBE_START_Z);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2395,7 +2403,7 @@ void LevBedC () { LevBed(4); }
|
||||||
void ManualMeshContinue(){
|
void ManualMeshContinue(){
|
||||||
gcode.process_subcommands_now_P(PSTR("G29S2"));
|
gcode.process_subcommands_now_P(PSTR("G29S2"));
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
MMeshMoveZItem->Draw(CurrentMenu->line(MMeshMoveZItem->pos));
|
MMeshMoveZItem->draw(CurrentMenu->line(MMeshMoveZItem->pos));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ManualMeshSave(){
|
void ManualMeshSave(){
|
||||||
|
@ -2515,7 +2523,7 @@ void onDrawPInt32Menu(MenuItemClass* menuitem, int8_t line) {
|
||||||
|
|
||||||
void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
|
void onDrawFloatMenu(MenuItemClass* menuitem, int8_t line, uint8_t dp, const float value) {
|
||||||
onDrawMenuItem(menuitem, line);
|
onDrawMenuItem(menuitem, line);
|
||||||
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(line), value);
|
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(line), value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
|
void onDrawPFloatMenu(MenuItemClass* menuitem, int8_t line) {
|
||||||
|
@ -2928,7 +2936,7 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) {
|
||||||
|
|
||||||
// Generic menu control using the encoder
|
// Generic menu control using the encoder
|
||||||
void HMI_Menu() {
|
void HMI_Menu() {
|
||||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
EncoderState encoder_diffState = get_encoder_state();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
if (CurrentMenu != nullptr) CurrentMenu->onClick();
|
if (CurrentMenu != nullptr) CurrentMenu->onClick();
|
||||||
|
@ -2943,7 +2951,7 @@ void HMI_Menu() {
|
||||||
// 1 : live change
|
// 1 : live change
|
||||||
// 2 : apply change
|
// 2 : apply change
|
||||||
int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
|
int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState != ENCODER_DIFF_NO) {
|
if (encoder_diffState != ENCODER_DIFF_NO) {
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||||
EncoderRate.enabled = false;
|
EncoderRate.enabled = false;
|
||||||
|
@ -2964,7 +2972,7 @@ int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
|
||||||
// 1 : live change
|
// 1 : live change
|
||||||
// 2 : apply change
|
// 2 : apply change
|
||||||
int8_t HMI_GetInt(const int32_t lo, const int32_t hi) {
|
int8_t HMI_GetInt(const int32_t lo, const int32_t hi) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState != ENCODER_DIFF_NO) {
|
if (encoder_diffState != ENCODER_DIFF_NO) {
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||||
EncoderRate.enabled = false;
|
EncoderRate.enabled = false;
|
||||||
|
@ -3018,16 +3026,16 @@ void HMI_SetPInt() {
|
||||||
// 1 : live change
|
// 1 : live change
|
||||||
// 2 : apply change
|
// 2 : apply change
|
||||||
int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
|
int8_t HMI_GetFloat(uint8_t dp, int32_t lo, int32_t hi) {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState != ENCODER_DIFF_NO) {
|
if (encoder_diffState != ENCODER_DIFF_NO) {
|
||||||
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
if (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||||
EncoderRate.enabled = false;
|
EncoderRate.enabled = false;
|
||||||
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
|
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Background_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
|
||||||
checkkey = Menu;
|
checkkey = Menu;
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
LIMIT(HMI_value.Value, lo, hi);
|
LIMIT(HMI_value.Value, lo, hi);
|
||||||
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::Get_font_width(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
|
DWINUI::Draw_Signed_Float(HMI_data.Text_Color, HMI_data.Selected_Color, 3, dp, VALX - dp * DWINUI::fontWidth(DWIN_FONT_MENU), MBASE(CurrentMenu->line()), HMI_value.Value / POW(10, dp));
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -3098,7 +3106,7 @@ void Draw_Prepare_Menu() {
|
||||||
#endif
|
#endif
|
||||||
ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage);
|
ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_LevBedCorners_Menu() {
|
void Draw_LevBedCorners_Menu() {
|
||||||
|
@ -3116,7 +3124,7 @@ void Draw_LevBedCorners_Menu() {
|
||||||
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL);
|
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_BL), onDrawMenuItem, LevBedBL);
|
||||||
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_C ), onDrawMenuItem, LevBedC );
|
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_LEVBED_C ), onDrawMenuItem, LevBedC );
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Control_Menu() {
|
void Draw_Control_Menu() {
|
||||||
|
@ -3138,7 +3146,7 @@ void Draw_Control_Menu() {
|
||||||
ADDMENUITEM(ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu);
|
ADDMENUITEM(ICON_AdvSet, GET_TEXT(MSG_ADVANCED_SETTINGS), onDrawSubMenu, Draw_AdvancedSettings_Menu);
|
||||||
ADDMENUITEM(ICON_Info, GET_TEXT(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu);
|
ADDMENUITEM(ICON_Info, GET_TEXT(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_AdvancedSettings_Menu() {
|
void Draw_AdvancedSettings_Menu() {
|
||||||
|
@ -3176,7 +3184,7 @@ void Draw_AdvancedSettings_Menu() {
|
||||||
#endif
|
#endif
|
||||||
ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
|
ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Move_Menu() {
|
void Draw_Move_Menu() {
|
||||||
|
@ -3194,7 +3202,7 @@ void Draw_Move_Menu() {
|
||||||
ADDMENUITEM_P(ICON_Extruder, GET_TEXT(MSG_MOVE_E), onDrawMoveE, SetMoveE, ¤t_position.e);
|
ADDMENUITEM_P(ICON_Extruder, GET_TEXT(MSG_MOVE_E), onDrawMoveE, SetMoveE, ¤t_position.e);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow"));
|
if (!all_axes_trusted()) ui.set_status_P(PSTR("WARNING: position is unknow"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3211,7 +3219,7 @@ void Draw_Move_Menu() {
|
||||||
ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]);
|
ADDMENUITEM_P(ICON_HomeOffsetY, GET_TEXT(MSG_HOME_OFFSET_Y), onDrawPFloatMenu, SetHomeOffsetY, &home_offset[Y_AXIS]);
|
||||||
ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]);
|
ADDMENUITEM_P(ICON_HomeOffsetZ, GET_TEXT(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3229,7 +3237,7 @@ void Draw_Move_Menu() {
|
||||||
ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
|
ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
|
||||||
ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
|
ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3256,7 +3264,7 @@ void Draw_Move_Menu() {
|
||||||
ADDMENUITEM_P(ICON_FilUnload, GET_TEXT(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length);
|
ADDMENUITEM_P(ICON_FilUnload, GET_TEXT(MSG_FILAMENT_UNLOAD), onDrawPFloatMenu, SetFilUnload, &fc_settings[0].unload_length);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif // HAS_FILAMENT_SENSOR
|
#endif // HAS_FILAMENT_SENSOR
|
||||||
|
|
||||||
|
@ -3288,7 +3296,7 @@ void Draw_SelectColors_Menu() {
|
||||||
ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color);
|
ADDMENUITEM_P(0, "Indicator value", onDrawSelColorItem, SelColor, &HMI_data.Indicator_Color);
|
||||||
ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color);
|
ADDMENUITEM_P(0, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_GetColor_Menu() {
|
void Draw_GetColor_Menu() {
|
||||||
|
@ -3304,7 +3312,7 @@ void Draw_GetColor_Menu() {
|
||||||
ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor);
|
ADDMENUITEM(1, "Green", onDrawGetColorItem, SetRGBColor);
|
||||||
ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor);
|
ADDMENUITEM(2, "Blue", onDrawGetColorItem, SetRGBColor);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
|
DWIN_Draw_Rectangle(1, *HMI_value.P_Int, 20, 315, DWIN_WIDTH - 20, 335);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3338,7 +3346,7 @@ void Draw_Tune_Menu() {
|
||||||
ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness);
|
ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Motion_Menu() {
|
void Draw_Motion_Menu() {
|
||||||
|
@ -3357,7 +3365,7 @@ void Draw_Motion_Menu() {
|
||||||
ADDMENUITEM(ICON_Step, GET_TEXT(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu);
|
ADDMENUITEM(ICON_Step, GET_TEXT(MSG_STEPS_PER_MM), onDrawSteps, Draw_Steps_Menu);
|
||||||
ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
|
ADDMENUITEM_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||||
|
@ -3376,7 +3384,7 @@ void Draw_Motion_Menu() {
|
||||||
ADDMENUITEM(ICON_FilLoad, GET_TEXT(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament);
|
ADDMENUITEM(ICON_FilLoad, GET_TEXT(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3394,7 +3402,7 @@ void Draw_Motion_Menu() {
|
||||||
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue);
|
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue);
|
||||||
ADDMENUITEM(ICON_MeshSave, GET_TEXT(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave);
|
ADDMENUITEM(ICON_MeshSave, GET_TEXT(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3420,7 +3428,7 @@ void Draw_Motion_Menu() {
|
||||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom);
|
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_Preheat1_Menu() {
|
void Draw_Preheat1_Menu() {
|
||||||
|
@ -3471,7 +3479,7 @@ void Draw_Temperature_Menu() {
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_MaxSpeed_Menu() {
|
void Draw_MaxSpeed_Menu() {
|
||||||
|
@ -3489,7 +3497,7 @@ void Draw_MaxSpeed_Menu() {
|
||||||
ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
ADDMENUITEM_P(ICON_MaxSpeedE, GET_TEXT(MSG_MAXSPEED_E), onDrawMaxSpeedE, SetMaxSpeedE, &planner.settings.max_feedrate_mm_s[Z_AXIS]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Draw_MaxAccel_Menu() {
|
void Draw_MaxAccel_Menu() {
|
||||||
|
@ -3507,7 +3515,7 @@ void Draw_MaxAccel_Menu() {
|
||||||
ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
|
ADDMENUITEM_P(ICON_MaxAccE, GET_TEXT(MSG_AMAX_E), onDrawMaxAccelE, SetMaxAccelE, &planner.settings.max_acceleration_mm_per_s2[E_AXIS]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_CLASSIC_JERK
|
#if HAS_CLASSIC_JERK
|
||||||
|
@ -3526,7 +3534,7 @@ void Draw_MaxAccel_Menu() {
|
||||||
ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]);
|
ADDMENUITEM_P(ICON_MaxSpeedJerkE, GET_TEXT(MSG_VE_JERK), onDrawMaxJerkE, SetMaxJerkE, &planner.max_jerk[E_AXIS]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3545,7 +3553,7 @@ void Draw_Steps_Menu() {
|
||||||
ADDMENUITEM_P(ICON_StepE, GET_TEXT(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]);
|
ADDMENUITEM_P(ICON_StepE, GET_TEXT(MSG_E_STEPS), onDrawStepsE, SetStepsE, &planner.settings.axis_steps_per_mm[E_AXIS]);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAS_HOTEND
|
#if HAS_HOTEND
|
||||||
|
@ -3567,7 +3575,7 @@ void Draw_Steps_Menu() {
|
||||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3590,7 +3598,7 @@ void Draw_Steps_Menu() {
|
||||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -3607,7 +3615,7 @@ void Draw_Steps_Menu() {
|
||||||
ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0);
|
ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0);
|
||||||
ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
|
ADDMENUITEM_P(ICON_Zoffset, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetZOffset, &BABY_Z_VAR);
|
||||||
}
|
}
|
||||||
CurrentMenu->Draw();
|
CurrentMenu->draw();
|
||||||
if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
|
if (!axis_is_trusted(Z_AXIS)) ui.set_status_P(PSTR("WARNING: Z position is unknow, move Z to home"));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,15 +15,22 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
#include "dwinui.h"
|
#include "dwinui.h"
|
||||||
#include "rotary_encoder.h"
|
#include "../common/encoder.h"
|
||||||
#include "../../../libs/BL24CXX.h"
|
#include "../../../libs/BL24CXX.h"
|
||||||
|
|
||||||
#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
|
#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
|
||||||
|
@ -79,11 +87,6 @@ enum pidresult_t : uint8_t {
|
||||||
PID_DONE
|
PID_DONE
|
||||||
};
|
};
|
||||||
|
|
||||||
// Picture ID
|
|
||||||
#define Start_Process 0
|
|
||||||
#define Language_English 1
|
|
||||||
#define Language_Chinese 2
|
|
||||||
|
|
||||||
#define DWIN_CHINESE 123
|
#define DWIN_CHINESE 123
|
||||||
#define DWIN_ENGLISH 0
|
#define DWIN_ENGLISH 0
|
||||||
|
|
||||||
|
@ -120,12 +123,16 @@ typedef struct {
|
||||||
uint16_t Barfill_Color = Def_Barfill_Color;
|
uint16_t Barfill_Color = Def_Barfill_Color;
|
||||||
uint16_t Indicator_Color = Def_Indicator_Color;
|
uint16_t Indicator_Color = Def_Indicator_Color;
|
||||||
uint16_t Coordinate_Color = Def_Coordinate_Color;
|
uint16_t Coordinate_Color = Def_Coordinate_Color;
|
||||||
TERN_(HAS_HOTEND, int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND);
|
#if HAS_HOTEND
|
||||||
TERN_(HAS_HOTEND, int16_t PidCycles = 10);
|
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
|
||||||
|
int16_t PidCycles = 10;
|
||||||
|
#endif
|
||||||
#ifdef PREHEAT_1_TEMP_BED
|
#ifdef PREHEAT_1_TEMP_BED
|
||||||
int16_t BedPidT = PREHEAT_1_TEMP_BED;
|
int16_t BedPidT = PREHEAT_1_TEMP_BED;
|
||||||
#endif
|
#endif
|
||||||
TERN_(PREVENT_COLD_EXTRUSION, int16_t ExtMinT = EXTRUDE_MINTEMP);
|
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||||
|
int16_t ExtMinT = EXTRUDE_MINTEMP;
|
||||||
|
#endif
|
||||||
} HMI_data_t;
|
} HMI_data_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -150,7 +157,9 @@ void DWIN_Popup_Confirm(uint8_t icon, const char * const msg1, const char * cons
|
||||||
#if HAS_HOTEND || HAS_HEATED_BED
|
#if HAS_HOTEND || HAS_HEATED_BED
|
||||||
void DWIN_Popup_Temperature(const bool toohigh);
|
void DWIN_Popup_Temperature(const bool toohigh);
|
||||||
#endif
|
#endif
|
||||||
TERN_(HAS_HOTEND, void Popup_Window_ETempTooLow());
|
#if HAS_HOTEND
|
||||||
|
void Popup_Window_ETempTooLow();
|
||||||
|
#endif
|
||||||
void Popup_Window_Resume();
|
void Popup_Window_Resume();
|
||||||
|
|
||||||
// SD Card
|
// SD Card
|
||||||
|
@ -179,7 +188,6 @@ void HMI_AudioFeedback(const bool success=true);
|
||||||
void EachMomentUpdate();
|
void EachMomentUpdate();
|
||||||
void update_variable();
|
void update_variable();
|
||||||
void DWIN_HandleScreen();
|
void DWIN_HandleScreen();
|
||||||
void DWIN_Startup();
|
|
||||||
void DWIN_Update();
|
void DWIN_Update();
|
||||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
|
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
|
||||||
void DWIN_StatusChanged(const char * const text);
|
void DWIN_StatusChanged(const char * const text);
|
||||||
|
@ -229,27 +237,41 @@ void Draw_AdvancedSettings_Menu();
|
||||||
void Draw_Prepare_Menu();
|
void Draw_Prepare_Menu();
|
||||||
void Draw_Move_Menu();
|
void Draw_Move_Menu();
|
||||||
void Draw_LevBedCorners_Menu();
|
void Draw_LevBedCorners_Menu();
|
||||||
TERN_(HAS_HOME_OFFSET, void Draw_HomeOffset_Menu());
|
#if HAS_HOME_OFFSET
|
||||||
TERN_(HAS_BED_PROBE, void Draw_ProbeSet_Menu());
|
void Draw_HomeOffset_Menu();
|
||||||
TERN_(HAS_FILAMENT_SENSOR, void Draw_FilSet_Menu());
|
#endif
|
||||||
|
#if HAS_BED_PROBE
|
||||||
|
void Draw_ProbeSet_Menu();
|
||||||
|
#endif
|
||||||
|
#if HAS_FILAMENT_SENSOR
|
||||||
|
void Draw_FilSet_Menu();
|
||||||
|
#endif
|
||||||
void Draw_SelectColors_Menu();
|
void Draw_SelectColors_Menu();
|
||||||
void Draw_GetColor_Menu();
|
void Draw_GetColor_Menu();
|
||||||
void Draw_Tune_Menu();
|
void Draw_Tune_Menu();
|
||||||
void Draw_Motion_Menu();
|
void Draw_Motion_Menu();
|
||||||
TERN_(ADVANCED_PAUSE_FEATURE, void Draw_FilamentMan_Menu());
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||||
TERN_(MESH_BED_LEVELING, void Draw_ManualMesh_Menu());
|
void Draw_FilamentMan_Menu();
|
||||||
|
#endif
|
||||||
|
#if ENABLED(MESH_BED_LEVELING)
|
||||||
|
void Draw_ManualMesh_Menu();
|
||||||
|
#endif
|
||||||
#if HAS_HOTEND
|
#if HAS_HOTEND
|
||||||
void Draw_Preheat1_Menu();
|
void Draw_Preheat1_Menu();
|
||||||
void Draw_Preheat2_Menu();
|
void Draw_Preheat2_Menu();
|
||||||
void Draw_Preheat3_Menu();
|
void Draw_Preheat3_Menu();
|
||||||
|
void Draw_HotendPID_Menu();
|
||||||
#endif
|
#endif
|
||||||
void Draw_Temperature_Menu();
|
void Draw_Temperature_Menu();
|
||||||
void Draw_MaxSpeed_Menu();
|
void Draw_MaxSpeed_Menu();
|
||||||
void Draw_MaxAccel_Menu();
|
void Draw_MaxAccel_Menu();
|
||||||
TERN_(HAS_CLASSIC_JERK, void Draw_MaxJerk_Menu());
|
#if HAS_CLASSIC_JERK
|
||||||
|
void Draw_MaxJerk_Menu();
|
||||||
|
#endif
|
||||||
void Draw_Steps_Menu();
|
void Draw_Steps_Menu();
|
||||||
TERN_(HAS_HOTEND, void Draw_HotendPID_Menu());
|
#if HAS_HEATED_BED
|
||||||
TERN_(HAS_HEATED_BED, void Draw_BedPID_Menu());
|
void Draw_BedPID_Menu();
|
||||||
|
#endif
|
||||||
#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
|
#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
|
||||||
void Draw_ZOffsetWiz_Menu();
|
void Draw_ZOffsetWiz_Menu();
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,18 +15,17 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/********************************************************************************
|
/**
|
||||||
* @file lcd/e3v2/enhanced/dwin_lcd.cpp
|
* DWIN UI Enhanced implementation
|
||||||
* @author LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
|
* Author: Miguel A. Risco-Castillo
|
||||||
* @date 2021/09/08
|
* Version: 3.6.3
|
||||||
* @version 2.2.1
|
* Date: 2021/09/08
|
||||||
* @brief DWIN screen control functions
|
*/
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
@ -34,297 +34,6 @@
|
||||||
#include "../../../inc/MarlinConfig.h"
|
#include "../../../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
#include <string.h> // for memset
|
|
||||||
|
|
||||||
//#define DEBUG_OUT 1
|
|
||||||
#include "../../../core/debug_out.h"
|
|
||||||
|
|
||||||
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
|
||||||
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
|
||||||
uint8_t DWIN_SendBuf[11 + DWIN_DataLength] = { 0xAA };
|
|
||||||
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
|
||||||
uint8_t databuf[26] = { 0 };
|
|
||||||
uint8_t receivedType;
|
|
||||||
|
|
||||||
int recnum = 0;
|
|
||||||
|
|
||||||
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
|
||||||
DWIN_SendBuf[++i] = bval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
|
||||||
DWIN_SendBuf[++i] = wval >> 8;
|
|
||||||
DWIN_SendBuf[++i] = wval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = lval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const char * const string, uint16_t rlimit = 0xFFFF) {
|
|
||||||
if (!string) return;
|
|
||||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, _MIN(strlen(string), rlimit));
|
|
||||||
if (len == 0) return;
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const __FlashStringHelper * 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 it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
|
|
||||||
if (len == 0) return;
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the data in the buffer and the packet end
|
|
||||||
inline void DWIN_Send(size_t &i) {
|
|
||||||
++i;
|
|
||||||
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
|
||||||
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
|
||||||
bool DWIN_Handshake(void) {
|
|
||||||
#ifndef LCD_BAUDRATE
|
|
||||||
#define LCD_BAUDRATE 115200
|
|
||||||
#endif
|
|
||||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
|
||||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
|
||||||
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x00);
|
|
||||||
DWIN_Send(i);
|
|
||||||
|
|
||||||
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
|
||||||
databuf[recnum] = LCD_SERIAL.read();
|
|
||||||
// ignore the invalid data
|
|
||||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
|
||||||
if (recnum > 0) {
|
|
||||||
recnum = 0;
|
|
||||||
ZERO(databuf);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
delay(10);
|
|
||||||
recnum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( recnum >= 3
|
|
||||||
&& databuf[0] == FHONE
|
|
||||||
&& databuf[1] == '\0'
|
|
||||||
&& databuf[2] == 'O'
|
|
||||||
&& databuf[3] == 'K' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x34);
|
|
||||||
DWIN_Byte(i, 0x5A);
|
|
||||||
DWIN_Byte(i, 0xA5);
|
|
||||||
DWIN_Byte(i, dir);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x3D);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x01);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: point color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x02);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Byte(i, width);
|
|
||||||
DWIN_Byte(i, height);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x03);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x05);
|
|
||||||
DWIN_Byte(i, mode);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x09);
|
|
||||||
DWIN_Byte(i, (mode << 7) | dir);
|
|
||||||
DWIN_Word(i, dis);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// widthAdjust: true=self-adjust character width; false=no adjustment
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
// rlimit: For draw less chars than string length use rlimit
|
|
||||||
void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * const string, uint16_t rlimit) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x11);
|
|
||||||
// Bit 7: widthAdjust
|
|
||||||
// Bit 6: bShow
|
|
||||||
// Bit 5-4: Unused (0)
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_String(i, string, rlimit);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, long value) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
// Bit 7: bshow
|
|
||||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
|
||||||
// Bit 5: zeroFill
|
|
||||||
// Bit 4: zeroMode
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, 0); // fNum
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
#if 0
|
|
||||||
for (char count = 0; count < 8; count++) {
|
|
||||||
DWIN_Byte(i, value);
|
|
||||||
value >>= 8;
|
|
||||||
if (!(value & 0xFF)) break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Write a big-endian 64 bit integer
|
|
||||||
const size_t p = i + 1;
|
|
||||||
for (char count = 8; count--;) { // 7..0
|
|
||||||
++i;
|
|
||||||
DWIN_SendBuf[p + count] = value;
|
|
||||||
value >>= 8;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Scaled positive float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, fNum);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Long(i, value);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
// value: positive float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
|
||||||
const long val = round(value * POW(10, fNum));
|
|
||||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, val);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
|
@ -339,73 +48,23 @@ void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, char *string) {
|
||||||
DWIN_Word(i, x);
|
DWIN_Word(i, x);
|
||||||
DWIN_Word(i, y);
|
DWIN_Word(i, y);
|
||||||
DWIN_Byte(i, QR_Pixel);
|
DWIN_Byte(i, QR_Pixel);
|
||||||
DWIN_String(i, string);
|
DWIN_Text(i, string);
|
||||||
DWIN_Send(i);
|
DWIN_Send(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
// Draw an Icon with transparent background
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Word(i, 0x2200);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon
|
|
||||||
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
|
||||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
|
||||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
|
||||||
// libID: Icon library ID
|
// libID: Icon library ID
|
||||||
// picID: Icon ID
|
// picID: Icon ID
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
DWIN_ICON_Show(false, false, true, libID, picID, x, y);
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x23);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | libID);
|
|
||||||
DWIN_Byte(i, picID);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon from SRAM
|
|
||||||
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
|
||||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
|
||||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// addr: SRAM address
|
|
||||||
void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr) {
|
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x24);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | 0x00);
|
|
||||||
DWIN_Word(i, addr);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x25);
|
|
||||||
DWIN_Byte(i, n);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Copy area from current virtual display area to current screen
|
// Copy area from current virtual display area to current screen
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
DWIN_Byte(i, 0x26);
|
DWIN_Byte(i, 0x26);
|
||||||
DWIN_Word(i, xStart);
|
DWIN_Word(i, xStart);
|
||||||
|
@ -425,11 +84,10 @@ void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
DWIN_Byte(i, 0x27);
|
DWIN_Byte(i, 0x27);
|
||||||
DWIN_Byte(i, IBD%2<<7 | BIR%2<<6 | BFI%2<<5 | cacheID);
|
DWIN_Byte(i, (IBD & 1) << 7 | (BIR & 1) << 6 | (BFI & 1) << 5 | cacheID);
|
||||||
DWIN_Word(i, xStart);
|
DWIN_Word(i, xStart);
|
||||||
DWIN_Word(i, yStart);
|
DWIN_Word(i, yStart);
|
||||||
DWIN_Word(i, xEnd);
|
DWIN_Word(i, xEnd);
|
||||||
|
@ -439,48 +97,13 @@ void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID,
|
||||||
DWIN_Send(i);
|
DWIN_Send(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Animate a series of icons
|
// Copy area from virtual display area to current screen with transparent background
|
||||||
// animID: Animation ID; 0x00-0x0F
|
// cacheID: virtual area number
|
||||||
// animate: true on; false off;
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// libID: Icon library ID
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// picIDs: Icon starting ID
|
// x/y: Screen paste point
|
||||||
// picIDe: Icon ending ID
|
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||||
// x/y: Upper-left point
|
DWIN_Frame_AreaCopy(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
|
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x28);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
// Bit 7: animation on or off
|
|
||||||
// Bit 6: start from begin or end
|
|
||||||
// Bit 5-4: unused (0)
|
|
||||||
// Bit 3-0: animID
|
|
||||||
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
|
|
||||||
DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picIDs);
|
|
||||||
DWIN_Byte(i, picIDe);
|
|
||||||
DWIN_Byte(i, interval);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x29);
|
|
||||||
DWIN_Word(i, state);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set LCD Brightness 0x00-0xFF
|
|
||||||
void DWIN_LCD_Brightness(const uint8_t brightness) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x30);
|
|
||||||
DWIN_Byte(i, brightness);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Write buffer data to the SRAM or Flash
|
// Write buffer data to the SRAM or Flash
|
||||||
|
@ -524,47 +147,14 @@ void DWIN_SRAMToPic(uint8_t picID) {
|
||||||
|
|
||||||
//--------------------------Test area -------------------------
|
//--------------------------Test area -------------------------
|
||||||
|
|
||||||
// void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
||||||
// size_t i = 0;
|
// size_t i = 0;
|
||||||
// DWIN_Byte(i, 0x32);
|
// DWIN_Byte(i, 0x32);
|
||||||
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
||||||
// DWIN_Word(i, addr); // 0x0000 to 0x7FFF
|
// DWIN_Word(i, addr); // 0x0000 to 0x7FFF
|
||||||
// const size_t len = _MIN(0xF0, length);
|
// const size_t len = _MIN(0xF0, length);
|
||||||
// DWIN_Byte(i, len);
|
// DWIN_Byte(i, len);
|
||||||
// DWIN_Send(i);
|
// DWIN_Send(i);
|
||||||
// }
|
//}
|
||||||
|
|
||||||
/*---------------------------------------- Memory functions ----------------------------------------*/
|
|
||||||
// The LCD has an additional 32KB SRAM and 16KB Flash
|
|
||||||
|
|
||||||
// Data can be written to the sram and save to one of the jpeg page files
|
|
||||||
|
|
||||||
// Write Data Memory
|
|
||||||
// command 0x31
|
|
||||||
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Data: data
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
// Read Data Memory
|
|
||||||
// command 0x32
|
|
||||||
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Length: leangth of data to read; 0x01-0xF0
|
|
||||||
//
|
|
||||||
// Response:
|
|
||||||
// Type, Address, Length, Data
|
|
||||||
|
|
||||||
// Write Picture Memory
|
|
||||||
// Write the contents of the 32KB SRAM data memory into the designated image memory space
|
|
||||||
// Issued: 0x5A, 0xA5, PIC_ID
|
|
||||||
// Response: 0xA5 0x4F 0x4B
|
|
||||||
//
|
|
||||||
// command 0x33
|
|
||||||
// 0x5A, 0xA5
|
|
||||||
// PicId: Picture Memory location, 0x00-0x0F
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
#endif // DWIN_CREALITY_LCD_ENHANCED
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,169 +15,20 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/********************************************************************************
|
|
||||||
* @file lcd/e3v2/enhanced/dwin_lcd.h
|
|
||||||
* @author LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
|
|
||||||
* @date 2021/08/09
|
|
||||||
* @version 2.2.1
|
|
||||||
* @brief DWIN screen control functions
|
|
||||||
********************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
#define RECEIVED_NO_DATA 0x00
|
#include "../common/dwin_api.h"
|
||||||
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
|
||||||
|
|
||||||
#define FHONE 0xAA
|
|
||||||
|
|
||||||
#define DWIN_SCROLL_UP 2
|
|
||||||
#define DWIN_SCROLL_DOWN 3
|
|
||||||
|
|
||||||
#define DWIN_WIDTH 272
|
|
||||||
#define DWIN_HEIGHT 480
|
|
||||||
|
|
||||||
#define DWIN_DataLength (DWIN_WIDTH / 6 * 2)
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
|
||||||
bool DWIN_Handshake(void);
|
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir);
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void);
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color);
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: point color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a Horizontal line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xLength: Line Length
|
|
||||||
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a Vertical line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// yLength: Line Length
|
|
||||||
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a box
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xSize/ySize: box size
|
|
||||||
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
|
|
||||||
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// widthAdjust: true=self-adjust character width; false=no adjustment
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
// rlimit: For draw less chars than string length use rlimit
|
|
||||||
void DWIN_Draw_String(bool widthAdjust, 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, const char * const string, uint16_t rlimit = 0xFFFF) {
|
|
||||||
DWIN_Draw_String(0, bShow, size, color, bColor, x, y, string, rlimit);
|
|
||||||
}
|
|
||||||
|
|
||||||
class __FlashStringHelper;
|
|
||||||
|
|
||||||
inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
|
|
||||||
DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, (char *)title);
|
|
||||||
}
|
|
||||||
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
|
|
||||||
DWIN_Draw_String(0, bShow, size, color, bColor, x, y, (char *)title);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, long value);
|
|
||||||
|
|
||||||
// Draw a positive floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Scaled positive float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
|
|
||||||
// value: positive float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Display QR code
|
// Display QR code
|
||||||
// The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
|
// The size of the QR code is (46*QR_Pixel)*(46*QR_Pixel) dot matrix
|
||||||
|
@ -189,50 +41,25 @@ inline void DWIN_Draw_QR(uint8_t QR_Pixel, uint16_t x, uint16_t y, const __Flash
|
||||||
DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
|
DWIN_Draw_QR(QR_Pixel, x, y, (char *)title);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
// Copy area from virtual display area to current screen
|
||||||
// id: Picture ID
|
// cacheID: virtual area number
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
// xStart/yStart: Upper-left of virtual area
|
||||||
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
|
// x/y: Screen paste point
|
||||||
|
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
// Draw an Icon
|
// Copy area from virtual display area to current screen
|
||||||
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
// cacheID: virtual area number
|
||||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// libID: Icon library ID
|
// x/y: Screen paste point
|
||||||
// picID: Icon ID
|
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||||
// x/y: Upper-left point
|
|
||||||
void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Draw an Icon with transparent background
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picID: Icon ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
inline void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
|
||||||
DWIN_ICON_Show(0, 0, 1, libID, picID, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon from SRAM
|
|
||||||
// IBD: The icon background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
|
||||||
// BIR: Background image restoration: 0=Background image is not restored, 1=Automatically use virtual display area image for background restoration
|
|
||||||
// BFI: Background filtering strength: 0=normal, 1=enhanced, (only valid when the icon background display=0)
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// addr: SRAM address
|
|
||||||
void DWIN_ICON_Show(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint16_t x, uint16_t y, uint16_t addr);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to virtual display area #1
|
|
||||||
// id: Picture ID
|
|
||||||
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
|
||||||
|
|
||||||
// Copy area from current virtual display area to current screen
|
// Copy area from current virtual display area to current screen
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
// Copy area from virtual display area to current screen
|
||||||
// IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
// IBD: background display: 0=Background filtering is not displayed, 1=Background display \\When setting the background filtering not to display, the background must be pure black
|
||||||
|
@ -242,36 +69,7 @@ void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
||||||
// xStart/yStart: Upper-left of virtual area
|
// xStart/yStart: Upper-left of virtual area
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
// xEnd/yEnd: Lower-right of virtual area
|
||||||
// x/y: Screen paste point
|
// x/y: Screen paste point
|
||||||
void DWIN_Frame_AreaCopy(uint8_t IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
void DWIN_Frame_AreaCopy(bool IBD, bool BIR, bool BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen with transparent background
|
|
||||||
// cacheID: virtual area number
|
|
||||||
// xStart/yStart: Upper-left of virtual area
|
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
|
||||||
// x/y: Screen paste point
|
|
||||||
inline void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
DWIN_Frame_AreaCopy(0, 0, 1, cacheID, xStart, yStart, xEnd, yEnd, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID up to 16
|
|
||||||
// animate: animation on or off
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
|
|
||||||
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state);
|
|
||||||
|
|
||||||
// Set LCD Brightness 0x00-0x0F
|
|
||||||
void DWIN_LCD_Brightness(const uint8_t brightness);
|
|
||||||
|
|
||||||
// Write buffer data to the SRAM or Flash
|
// Write buffer data to the SRAM or Flash
|
||||||
// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
|
// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.3
|
*
|
||||||
* Date: 2021/08/09
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,11 +15,18 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||||
|
@ -48,7 +56,7 @@ void (*DWINUI::onCursorDraw)(uint8_t line)=nullptr;
|
||||||
void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
|
void (*DWINUI::onTitleDraw)(TitleClass* title)=nullptr;
|
||||||
void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
|
void (*DWINUI::onMenuDraw)(MenuClass* menu)=nullptr;
|
||||||
|
|
||||||
void DWINUI::Init(void) {
|
void DWINUI::init() {
|
||||||
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
||||||
delay(750); // Delay here or init later in the boot process
|
delay(750); // Delay here or init later in the boot process
|
||||||
const bool success = DWIN_Handshake();
|
const bool success = DWIN_Handshake();
|
||||||
|
@ -65,12 +73,12 @@ void DWINUI::Init(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set text/number font
|
// Set text/number font
|
||||||
void DWINUI::SetFont(uint8_t cfont) {
|
void DWINUI::setFont(uint8_t cfont) {
|
||||||
font = cfont;
|
font = cfont;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get font character width
|
// Get font character width
|
||||||
uint8_t DWINUI::Get_font_width(uint8_t cfont) {
|
uint8_t DWINUI::fontWidth(uint8_t cfont) {
|
||||||
switch (cfont) {
|
switch (cfont) {
|
||||||
case font6x12 : return 6;
|
case font6x12 : return 6;
|
||||||
case font8x16 : return 8;
|
case font8x16 : return 8;
|
||||||
|
@ -87,7 +95,7 @@ uint8_t DWINUI::Get_font_width(uint8_t cfont) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get font character heigh
|
// Get font character heigh
|
||||||
uint8_t DWINUI::Get_font_height(uint8_t cfont) {
|
uint8_t DWINUI::fontHeight(uint8_t cfont) {
|
||||||
switch (cfont) {
|
switch (cfont) {
|
||||||
case font6x12 : return 12;
|
case font6x12 : return 12;
|
||||||
case font8x16 : return 16;
|
case font8x16 : return 16;
|
||||||
|
@ -105,12 +113,12 @@ uint8_t DWINUI::Get_font_height(uint8_t cfont) {
|
||||||
|
|
||||||
// Get screen x coodinates from text column
|
// Get screen x coodinates from text column
|
||||||
uint16_t DWINUI::ColToX(uint8_t col) {
|
uint16_t DWINUI::ColToX(uint8_t col) {
|
||||||
return col * Get_font_width(font);
|
return col * fontWidth(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get screen y coodinates from text row
|
// Get screen y coodinates from text row
|
||||||
uint16_t DWINUI::RowToY(uint8_t row) {
|
uint16_t DWINUI::RowToY(uint8_t row) {
|
||||||
return row * Get_font_height(font);
|
return row * fontHeight(font);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set text/number color
|
// Set text/number color
|
||||||
|
@ -151,7 +159,7 @@ void DWINUI::MoveBy(xy_int_t point) {
|
||||||
|
|
||||||
// Draw a Centered string using DWIN_WIDTH
|
// Draw a Centered string using DWIN_WIDTH
|
||||||
void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
|
void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t y, const char * const string) {
|
||||||
const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * Get_font_width(size)) / 2 - 1;
|
const int8_t x = _MAX(0U, DWIN_WIDTH - strlen_P(string) * fontWidth(size)) / 2 - 1;
|
||||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
|
DWIN_Draw_String(bShow, size, color, bColor, x, y, string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +167,7 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1
|
||||||
void DWINUI::Draw_Char(const char c) {
|
void DWINUI::Draw_Char(const char c) {
|
||||||
const char string[2] = { c, 0};
|
const char string[2] = { c, 0};
|
||||||
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
|
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, 1);
|
||||||
MoveBy(Get_font_width(font), 0);
|
MoveBy(fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a string at cursor position
|
// Draw a string at cursor position
|
||||||
|
@ -168,11 +176,11 @@ void DWINUI::Draw_Char(const char c) {
|
||||||
// rlimit: For draw less chars than string length use rlimit
|
// rlimit: For draw less chars than string length use rlimit
|
||||||
void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
|
void DWINUI::Draw_String(const char * const string, uint16_t rlimit) {
|
||||||
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
|
DWIN_Draw_String(false, font, textcolor, backcolor, cursor.x, cursor.y, string, rlimit);
|
||||||
MoveBy(strlen(string) * Get_font_width(font), 0);
|
MoveBy(strlen(string) * fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
|
void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rlimit) {
|
||||||
DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
|
DWIN_Draw_String(false, font, color, backcolor, cursor.x, cursor.y, string, rlimit);
|
||||||
MoveBy(strlen(string) * Get_font_width(font), 0);
|
MoveBy(strlen(string) * fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a signed floating point number
|
// Draw a signed floating point number
|
||||||
|
@ -186,14 +194,8 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
// value: Float value
|
// value: Float value
|
||||||
void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
void DWINUI::Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||||
if (value < 0) {
|
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
|
||||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, -value);
|
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" "));
|
||||||
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F("-"));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, F(" "));
|
|
||||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw a circle
|
// Draw a circle
|
||||||
|
@ -239,7 +241,7 @@ void DWINUI::Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r) {
|
||||||
// Color Interpolator
|
// Color Interpolator
|
||||||
// val : Interpolator minv..maxv
|
// val : Interpolator minv..maxv
|
||||||
// minv : Minimum value
|
// minv : Minimum value
|
||||||
// maxv : Maximun value
|
// maxv : Maximum value
|
||||||
// color1 : Start color
|
// color1 : Start color
|
||||||
// color2 : End 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) {
|
||||||
|
@ -255,7 +257,7 @@ uint16_t DWINUI::ColorInt(int16_t val, int16_t minv, int16_t maxv, uint16_t colo
|
||||||
// Color Interpolator through Red->Yellow->Green->Blue
|
// Color Interpolator through Red->Yellow->Green->Blue
|
||||||
// val : Interpolator minv..maxv
|
// val : Interpolator minv..maxv
|
||||||
// minv : Minimum value
|
// minv : Minimum value
|
||||||
// maxv : Maximun value
|
// maxv : Maximum value
|
||||||
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
|
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
|
||||||
uint8_t B,G,R;
|
uint8_t B,G,R;
|
||||||
const uint8_t maxB = 28;
|
const uint8_t maxB = 28;
|
||||||
|
@ -292,7 +294,7 @@ uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
// mode : 0 : unchecked, 1 : checked
|
// mode : 0 : unchecked, 1 : checked
|
||||||
void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
|
void DWINUI::Draw_Checkbox(uint16_t color, uint16_t bcolor, uint16_t x, uint16_t y, bool checked=false) {
|
||||||
DWIN_Draw_String(false, true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
|
DWIN_Draw_String(true, font8x16, color, bcolor, x + 4, y, checked ? F("x") : F(" "));
|
||||||
DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
|
DWIN_Draw_Rectangle(0, color, x + 2, y + 2, x + 17, y + 17);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -332,7 +334,7 @@ MenuItemClass* DWINUI::MenuItemsAdd(MenuItemClass* menuitem) {
|
||||||
|
|
||||||
TitleClass Title;
|
TitleClass Title;
|
||||||
|
|
||||||
void TitleClass::Draw() {
|
void TitleClass::draw() {
|
||||||
if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
|
if (DWINUI::onTitleDraw != nullptr) (*DWINUI::onTitleDraw)(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -346,7 +348,7 @@ void TitleClass::SetCaption(const char * const title) {
|
||||||
|
|
||||||
void TitleClass::ShowCaption(const char * const title) {
|
void TitleClass::ShowCaption(const char * const title) {
|
||||||
SetCaption(title);
|
SetCaption(title);
|
||||||
Draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
void TitleClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
||||||
|
@ -361,7 +363,7 @@ void TitleClass::SetFrame(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||||
|
|
||||||
void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
void TitleClass::FrameCopy(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2) {
|
||||||
SetFrame(id, x1, y1, x2, y2);
|
SetFrame(id, x1, y1, x2, y2);
|
||||||
Draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||||
|
@ -375,11 +377,11 @@ MenuClass::MenuClass() {
|
||||||
topline = 0;
|
topline = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuClass::Draw() {
|
void MenuClass::draw() {
|
||||||
MenuTitle.Draw();
|
MenuTitle.draw();
|
||||||
if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
|
if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
|
||||||
for (uint8_t i = 0; i < MenuItemCount; i++)
|
for (uint8_t i = 0; i < MenuItemCount; i++)
|
||||||
MenuItems[i]->Draw(i - topline);
|
MenuItems[i]->draw(i - topline);
|
||||||
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
@ -393,12 +395,12 @@ void MenuClass::onScroll(bool dir) {
|
||||||
if ((sel - topline) == TROWS) {
|
if ((sel - topline) == TROWS) {
|
||||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||||
topline++;
|
topline++;
|
||||||
MenuItems[sel]->Draw(TROWS - 1);
|
MenuItems[sel]->draw(TROWS - 1);
|
||||||
}
|
}
|
||||||
if ((sel < topline)) {
|
if ((sel < topline)) {
|
||||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||||
topline--;
|
topline--;
|
||||||
MenuItems[sel]->Draw(0);
|
MenuItems[sel]->draw(0);
|
||||||
}
|
}
|
||||||
selected = sel;
|
selected = sel;
|
||||||
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
if (DWINUI::onCursorDraw != nullptr) DWINUI::onCursorDraw(line());
|
||||||
|
@ -440,7 +442,7 @@ void MenuItemClass::SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2,
|
||||||
frame = { x1, y1, x2, y2 };
|
frame = { x1, y1, x2, y2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
void MenuItemClass::Draw(int8_t line) {
|
void MenuItemClass::draw(int8_t line) {
|
||||||
if (line < 0 || line >= TROWS) return;
|
if (line < 0 || line >= TROWS) return;
|
||||||
if (onDraw != nullptr) (*onDraw)(this, line);
|
if (onDraw != nullptr) (*onDraw)(this, line);
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.3
|
*
|
||||||
* Date: 2021/08/09
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,117 +15,26 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
#include "../../../core/types.h"
|
#include "../../../core/types.h"
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
|
#include "../common/dwin_set.h"
|
||||||
// ICON ID
|
#include "../common/dwin_font.h"
|
||||||
#define ICON 7 // Icon set file 7.ICO
|
#include "../common/dwin_color.h"
|
||||||
|
|
||||||
#define ICON_LOGO 0
|
|
||||||
#define ICON_Print_0 1
|
|
||||||
#define ICON_Print_1 2
|
|
||||||
#define ICON_Prepare_0 3
|
|
||||||
#define ICON_Prepare_1 4
|
|
||||||
#define ICON_Control_0 5
|
|
||||||
#define ICON_Control_1 6
|
|
||||||
#define ICON_Leveling_0 7
|
|
||||||
#define ICON_Leveling_1 8
|
|
||||||
#define ICON_HotendTemp 9
|
|
||||||
#define ICON_BedTemp 10
|
|
||||||
#define ICON_Speed 11
|
|
||||||
#define ICON_Zoffset 12
|
|
||||||
#define ICON_Back 13
|
|
||||||
#define ICON_File 14
|
|
||||||
#define ICON_PrintTime 15
|
|
||||||
#define ICON_RemainTime 16
|
|
||||||
#define ICON_Setup_0 17
|
|
||||||
#define ICON_Setup_1 18
|
|
||||||
#define ICON_Pause_0 19
|
|
||||||
#define ICON_Pause_1 20
|
|
||||||
#define ICON_Continue_0 21
|
|
||||||
#define ICON_Continue_1 22
|
|
||||||
#define ICON_Stop_0 23
|
|
||||||
#define ICON_Stop_1 24
|
|
||||||
#define ICON_Bar 25
|
|
||||||
#define ICON_More 26
|
|
||||||
|
|
||||||
#define ICON_Axis 27
|
|
||||||
#define ICON_CloseMotor 28
|
|
||||||
#define ICON_Homing 29
|
|
||||||
#define ICON_SetHome 30
|
|
||||||
#define ICON_PLAPreheat 31
|
|
||||||
#define ICON_ABSPreheat 32
|
|
||||||
#define ICON_Cool 33
|
|
||||||
#define ICON_Language 34
|
|
||||||
|
|
||||||
#define ICON_MoveX 35
|
|
||||||
#define ICON_MoveY 36
|
|
||||||
#define ICON_MoveZ 37
|
|
||||||
#define ICON_Extruder 38
|
|
||||||
|
|
||||||
#define ICON_Temperature 40
|
|
||||||
#define ICON_Motion 41
|
|
||||||
#define ICON_WriteEEPROM 42
|
|
||||||
#define ICON_ReadEEPROM 43
|
|
||||||
#define ICON_ResumeEEPROM 44
|
|
||||||
#define ICON_Info 45
|
|
||||||
|
|
||||||
#define ICON_SetEndTemp 46
|
|
||||||
#define ICON_SetBedTemp 47
|
|
||||||
#define ICON_FanSpeed 48
|
|
||||||
#define ICON_SetPLAPreheat 49
|
|
||||||
#define ICON_SetABSPreheat 50
|
|
||||||
|
|
||||||
#define ICON_MaxSpeed 51
|
|
||||||
#define ICON_MaxAccelerated 52
|
|
||||||
#define ICON_MaxJerk 53
|
|
||||||
#define ICON_Step 54
|
|
||||||
#define ICON_PrintSize 55
|
|
||||||
#define ICON_Version 56
|
|
||||||
#define ICON_Contact 57
|
|
||||||
#define ICON_StockConfiguration 58
|
|
||||||
#define ICON_MaxSpeedX 59
|
|
||||||
#define ICON_MaxSpeedY 60
|
|
||||||
#define ICON_MaxSpeedZ 61
|
|
||||||
#define ICON_MaxSpeedE 62
|
|
||||||
#define ICON_MaxAccX 63
|
|
||||||
#define ICON_MaxAccY 64
|
|
||||||
#define ICON_MaxAccZ 65
|
|
||||||
#define ICON_MaxAccE 66
|
|
||||||
#define ICON_MaxSpeedJerkX 67
|
|
||||||
#define ICON_MaxSpeedJerkY 68
|
|
||||||
#define ICON_MaxSpeedJerkZ 69
|
|
||||||
#define ICON_MaxSpeedJerkE 70
|
|
||||||
#define ICON_StepX 71
|
|
||||||
#define ICON_StepY 72
|
|
||||||
#define ICON_StepZ 73
|
|
||||||
#define ICON_StepE 74
|
|
||||||
#define ICON_Setspeed 75
|
|
||||||
#define ICON_SetZOffset 76
|
|
||||||
#define ICON_Rectangle 77
|
|
||||||
#define ICON_BLTouch 78
|
|
||||||
#define ICON_TempTooLow 79
|
|
||||||
#define ICON_AutoLeveling 80
|
|
||||||
#define ICON_TempTooHigh 81
|
|
||||||
#define ICON_NoTips_C 82
|
|
||||||
#define ICON_NoTips_E 83
|
|
||||||
#define ICON_Continue_C 84
|
|
||||||
#define ICON_Continue_E 85
|
|
||||||
#define ICON_Cancel_C 86
|
|
||||||
#define ICON_Cancel_E 87
|
|
||||||
#define ICON_Confirm_C 88
|
|
||||||
#define ICON_Confirm_E 89
|
|
||||||
#define ICON_Info_0 90
|
|
||||||
#define ICON_Info_1 91
|
|
||||||
|
|
||||||
// Extra Icons
|
// Extra Icons
|
||||||
#define ICON_AdvSet ICON_Language
|
|
||||||
#define ICON_Brightness ICON_Motion
|
#define ICON_Brightness ICON_Motion
|
||||||
#define ICON_Cancel ICON_StockConfiguration
|
#define ICON_Cancel ICON_StockConfiguration
|
||||||
#define ICON_CustomPreheat ICON_SetEndTemp
|
#define ICON_CustomPreheat ICON_SetEndTemp
|
||||||
|
@ -135,10 +45,6 @@
|
||||||
#define ICON_FilSet ICON_ResumeEEPROM
|
#define ICON_FilSet ICON_ResumeEEPROM
|
||||||
#define ICON_FilUnload ICON_ReadEEPROM
|
#define ICON_FilUnload ICON_ReadEEPROM
|
||||||
#define ICON_Flow ICON_StepE
|
#define ICON_Flow ICON_StepE
|
||||||
#define ICON_HomeOffset ICON_AdvSet
|
|
||||||
#define ICON_HomeOffsetX ICON_StepX
|
|
||||||
#define ICON_HomeOffsetY ICON_StepY
|
|
||||||
#define ICON_HomeOffsetZ ICON_StepZ
|
|
||||||
#define ICON_LevBed ICON_SetEndTemp
|
#define ICON_LevBed ICON_SetEndTemp
|
||||||
#define ICON_Lock ICON_Cool
|
#define ICON_Lock ICON_Cool
|
||||||
#define ICON_ManualMesh ICON_HotendTemp
|
#define ICON_ManualMesh ICON_HotendTemp
|
||||||
|
@ -146,13 +52,8 @@
|
||||||
#define ICON_MeshSave ICON_WriteEEPROM
|
#define ICON_MeshSave ICON_WriteEEPROM
|
||||||
#define ICON_MoveZ0 ICON_HotendTemp
|
#define ICON_MoveZ0 ICON_HotendTemp
|
||||||
#define ICON_Park ICON_Motion
|
#define ICON_Park ICON_Motion
|
||||||
#define ICON_PIDbed ICON_SetBedTemp
|
|
||||||
#define ICON_PIDcycles ICON_ResumeEEPROM
|
#define ICON_PIDcycles ICON_ResumeEEPROM
|
||||||
#define ICON_PIDNozzle ICON_SetEndTemp
|
|
||||||
#define ICON_PIDValue ICON_Contact
|
#define ICON_PIDValue ICON_Contact
|
||||||
#define ICON_ProbeOffsetX ICON_StepX
|
|
||||||
#define ICON_ProbeOffsetY ICON_StepY
|
|
||||||
#define ICON_ProbeOffsetZ ICON_StepZ
|
|
||||||
#define ICON_ProbeSet ICON_SetEndTemp
|
#define ICON_ProbeSet ICON_SetEndTemp
|
||||||
#define ICON_ProbeTest ICON_SetEndTemp
|
#define ICON_ProbeTest ICON_SetEndTemp
|
||||||
#define ICON_Pwrlossr ICON_Motion
|
#define ICON_Pwrlossr ICON_Motion
|
||||||
|
@ -162,47 +63,6 @@
|
||||||
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
||||||
#define ICON_Sound ICON_Cool
|
#define ICON_Sound ICON_Cool
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
|
|
||||||
*/
|
|
||||||
#define font6x12 0x00
|
|
||||||
#define font8x16 0x01
|
|
||||||
#define font10x20 0x02
|
|
||||||
#define font12x24 0x03
|
|
||||||
#define font14x28 0x04
|
|
||||||
#define font16x32 0x05
|
|
||||||
#define font20x40 0x06
|
|
||||||
#define font24x48 0x07
|
|
||||||
#define font28x56 0x08
|
|
||||||
#define font32x64 0x09
|
|
||||||
|
|
||||||
// Extended and default UI Colors
|
|
||||||
#define RGB(R,G,B) (R << 11) | (G << 5) | (B) // R,B: 0..31; G: 0..63
|
|
||||||
#define GetRColor(color) ((color >> 11) & 0x1F)
|
|
||||||
#define GetGColor(color) ((color >> 5) & 0x3F)
|
|
||||||
#define GetBColor(color) ((color >> 0) & 0x1F)
|
|
||||||
|
|
||||||
#define Color_White 0xFFFF
|
|
||||||
#define Color_Bg_Window 0x31E8 // Popup background color
|
|
||||||
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
|
||||||
#define Color_Bg_Black 0x0841 // Black background color
|
|
||||||
#define Color_Bg_Red 0xF00F // Red background color
|
|
||||||
#define Popup_Text_Color 0xD6BA // Popup font background color
|
|
||||||
#define Line_Color 0x3A6A // Split line color
|
|
||||||
#define Rectangle_Color 0xEE2F // Blue square cursor color
|
|
||||||
#define Percent_Color 0xFE29 // Percentage color
|
|
||||||
#define BarFill_Color 0x10E4 // Fill color of progress bar
|
|
||||||
#define Select_Color 0x33BB // Selected color
|
|
||||||
|
|
||||||
#define Color_Black 0
|
|
||||||
#define Color_Red RGB(31,0,0)
|
|
||||||
#define Color_Yellow RGB(31,63,0)
|
|
||||||
#define Color_Green RGB(0,63,0)
|
|
||||||
#define Color_Aqua RGB(0,63,31)
|
|
||||||
#define Color_Blue RGB(0,0,31)
|
|
||||||
|
|
||||||
// Default UI Colors
|
// Default UI Colors
|
||||||
#define Def_Background_Color Color_Bg_Black
|
#define Def_Background_Color Color_Bg_Black
|
||||||
#define Def_Cursor_color Rectangle_Color
|
#define Def_Cursor_color Rectangle_Color
|
||||||
|
@ -223,7 +83,7 @@
|
||||||
#define Def_Indicator_Color Color_White
|
#define Def_Indicator_Color Color_White
|
||||||
#define Def_Coordinate_Color Color_White
|
#define Def_Coordinate_Color Color_White
|
||||||
|
|
||||||
//UI elements defines and constants
|
// UI element defines and constants
|
||||||
#define DWIN_FONT_MENU font8x16
|
#define DWIN_FONT_MENU font8x16
|
||||||
#define DWIN_FONT_STAT font10x20
|
#define DWIN_FONT_STAT font10x20
|
||||||
#define DWIN_FONT_HEAD font10x20
|
#define DWIN_FONT_HEAD font10x20
|
||||||
|
@ -262,7 +122,7 @@ public:
|
||||||
char caption[32] = "";
|
char caption[32] = "";
|
||||||
uint8_t frameid = 0;
|
uint8_t frameid = 0;
|
||||||
rect_t frame = {0};
|
rect_t frame = {0};
|
||||||
void Draw();
|
void draw();
|
||||||
void SetCaption(const char * const title);
|
void SetCaption(const char * const title);
|
||||||
inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
|
inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)title); }
|
||||||
void ShowCaption(const char * const title);
|
void ShowCaption(const char * const title);
|
||||||
|
@ -290,7 +150,7 @@ public:
|
||||||
MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
|
MenuItemClass(uint8_t cicon, uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, void (*ondraw)(MenuItemClass* menuitem, int8_t line)=nullptr, void (*onclick)()=nullptr);
|
||||||
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||||
virtual ~MenuItemClass(){};
|
virtual ~MenuItemClass(){};
|
||||||
virtual void Draw(int8_t line);
|
virtual void draw(int8_t line);
|
||||||
};
|
};
|
||||||
|
|
||||||
class MenuItemPtrClass: public MenuItemClass {
|
class MenuItemPtrClass: public MenuItemClass {
|
||||||
|
@ -310,7 +170,7 @@ public:
|
||||||
virtual ~MenuClass(){};
|
virtual ~MenuClass(){};
|
||||||
inline int8_t line() { return selected - topline; };
|
inline int8_t line() { return selected - topline; };
|
||||||
inline int8_t line(uint8_t pos) {return pos - topline; };
|
inline int8_t line(uint8_t pos) {return pos - topline; };
|
||||||
void Draw();
|
void draw();
|
||||||
void onScroll(bool dir);
|
void onScroll(bool dir);
|
||||||
void onClick();
|
void onClick();
|
||||||
MenuItemClass* SelectedItem();
|
MenuItemClass* SelectedItem();
|
||||||
|
@ -330,16 +190,16 @@ namespace DWINUI {
|
||||||
extern void (*onMenuDraw)(MenuClass* menu);
|
extern void (*onMenuDraw)(MenuClass* menu);
|
||||||
|
|
||||||
// DWIN LCD Initialization
|
// DWIN LCD Initialization
|
||||||
void Init(void);
|
void init();
|
||||||
|
|
||||||
// Set text/number font
|
// Set text/number font
|
||||||
void SetFont(uint8_t cfont);
|
void setFont(uint8_t cfont);
|
||||||
|
|
||||||
// Get font character width
|
// Get font character width
|
||||||
uint8_t Get_font_width(uint8_t cfont);
|
uint8_t fontWidth(uint8_t cfont);
|
||||||
|
|
||||||
// Get font character heigh
|
// Get font character heigh
|
||||||
uint8_t Get_font_height(uint8_t cfont);
|
uint8_t fontHeight(uint8_t cfont);
|
||||||
|
|
||||||
// Get screen x coodinates from text column
|
// Get screen x coodinates from text column
|
||||||
uint16_t ColToX(uint8_t col);
|
uint16_t ColToX(uint8_t col);
|
||||||
|
@ -398,7 +258,7 @@ namespace DWINUI {
|
||||||
}
|
}
|
||||||
inline void Draw_Int(uint8_t iNum, long value) {
|
inline void Draw_Int(uint8_t iNum, long value) {
|
||||||
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
|
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, cursor.x, cursor.y, value);
|
||||||
MoveBy(iNum * Get_font_width(font), 0);
|
MoveBy(iNum * fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
inline void Draw_Int(uint8_t iNum, uint16_t x, uint16_t y, long value) {
|
||||||
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
|
DWIN_Draw_IntValue(false, true, 0, font, textcolor, backcolor, iNum, x, y, value);
|
||||||
|
@ -429,7 +289,7 @@ namespace DWINUI {
|
||||||
}
|
}
|
||||||
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
|
inline void Draw_Float(uint8_t iNum, uint8_t fNum, float value) {
|
||||||
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
||||||
MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
|
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
inline void Draw_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||||
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
DWIN_Draw_FloatValue(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
||||||
|
@ -457,7 +317,7 @@ namespace DWINUI {
|
||||||
void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
|
void Draw_Signed_Float(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color, uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value);
|
||||||
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
|
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, float value) {
|
||||||
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, cursor.x, cursor.y, value);
|
||||||
MoveBy((iNum + fNum + 1) * Get_font_width(font), 0);
|
MoveBy((iNum + fNum + 1) * fontWidth(font), 0);
|
||||||
}
|
}
|
||||||
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
inline void Draw_Signed_Float(uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, float value) {
|
||||||
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
||||||
|
@ -548,7 +408,7 @@ namespace DWINUI {
|
||||||
|
|
||||||
// Draw a circle
|
// Draw a circle
|
||||||
// Color: circle color
|
// Color: circle color
|
||||||
// x: the abscissa of the center of the circle
|
// x: abscissa of the center of the circle
|
||||||
// y: ordinate of the center of the circle
|
// y: ordinate of the center of the circle
|
||||||
// r: circle radius
|
// r: circle radius
|
||||||
void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
|
void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
|
||||||
|
@ -569,7 +429,7 @@ namespace DWINUI {
|
||||||
// Color Interpolator
|
// Color Interpolator
|
||||||
// val : Interpolator minv..maxv
|
// val : Interpolator minv..maxv
|
||||||
// minv : Minimum value
|
// minv : Minimum value
|
||||||
// maxv : Maximun value
|
// maxv : Maximum value
|
||||||
// color1 : Start color
|
// color1 : Start color
|
||||||
// color2 : End 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);
|
||||||
|
@ -578,7 +438,7 @@ namespace DWINUI {
|
||||||
|
|
||||||
// Draw a circle filled with color
|
// Draw a circle filled with color
|
||||||
// bcolor: fill color
|
// bcolor: fill color
|
||||||
// x: the abscissa of the center of the circle
|
// x: abscissa of the center of the circle
|
||||||
// y: ordinate of the center of the circle
|
// y: ordinate of the center of the circle
|
||||||
// r: circle radius
|
// r: circle radius
|
||||||
void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
|
void Draw_FillCircle(uint16_t bcolor, uint16_t x,uint16_t y,uint8_t r);
|
||||||
|
@ -589,7 +449,7 @@ namespace DWINUI {
|
||||||
// Color Interpolator through Red->Yellow->Green->Blue
|
// Color Interpolator through Red->Yellow->Green->Blue
|
||||||
// val : Interpolator minv..maxv
|
// val : Interpolator minv..maxv
|
||||||
// minv : Minimum value
|
// minv : Minimum value
|
||||||
// maxv : Maximun 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
|
// Write buffer data to the SRAM
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,11 +15,18 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||||
|
@ -29,15 +37,18 @@
|
||||||
#include "dwin.h"
|
#include "dwin.h"
|
||||||
#include "lockscreen.h"
|
#include "lockscreen.h"
|
||||||
|
|
||||||
LockScreenClass LockScreen;
|
LockScreenClass lockScreen;
|
||||||
|
|
||||||
void LockScreenClass::Init() {
|
uint8_t LockScreenClass::lock_pos = 0;
|
||||||
Lock_Pos = 0;
|
bool LockScreenClass::unlocked = false;
|
||||||
|
|
||||||
|
void LockScreenClass::init() {
|
||||||
|
lock_pos = 0;
|
||||||
unlocked = false;
|
unlocked = false;
|
||||||
Draw();
|
draw();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LockScreenClass::Draw() {
|
void LockScreenClass::draw() {
|
||||||
Title.SetCaption(PSTR("Lock Screen"));
|
Title.SetCaption(PSTR("Lock Screen"));
|
||||||
DWINUI::ClearMenuArea();
|
DWINUI::ClearMenuArea();
|
||||||
DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
|
DWINUI::Draw_Icon(ICON_LOGO, 71, 120); // CREALITY logo
|
||||||
|
@ -45,25 +56,20 @@ void LockScreenClass::Draw() {
|
||||||
DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
|
DWINUI::Draw_CenteredString(Color_White, 200, F("Scroll to unlock."));
|
||||||
DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
|
DWINUI::Draw_CenteredString(Color_White, 240, F("-> | <-"));
|
||||||
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
||||||
DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
|
DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LockScreenClass::onEncoderState(ENCODER_DiffState encoder_diffState) {
|
void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
switch (encoder_diffState) {
|
||||||
Lock_Pos += 8;
|
case ENCODER_DIFF_CW: lock_pos += 8; break;
|
||||||
}
|
case ENCODER_DIFF_CCW: lock_pos -= 8; break;
|
||||||
else if (encoder_diffState == ENCODER_DIFF_CCW) {
|
case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
|
||||||
Lock_Pos -= 8;
|
default: break;
|
||||||
}
|
|
||||||
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
|
||||||
unlocked = (Lock_Pos == 128);
|
|
||||||
}
|
}
|
||||||
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
DWIN_Draw_Box(1, HMI_data.Barfill_Color, 0, 260, DWIN_WIDTH, 20);
|
||||||
DWIN_Draw_VLine(Color_Yellow, Lock_Pos * DWIN_WIDTH / 255, 260, 20);
|
DWIN_Draw_VLine(Color_Yellow, lock_pos * DWIN_WIDTH / 255, 260, 20);
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LockScreenClass::isUnlocked() { return unlocked; }
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
#endif // DWIN_CREALITY_LCD_ENHANCED
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
/**
|
/**
|
||||||
* DWIN UI Enhanced implementation
|
* Marlin 3D Printer Firmware
|
||||||
* Author: Miguel A. Risco-Castillo
|
* Copyright (c) 2021 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
|
||||||
* Version: 3.6.1
|
*
|
||||||
* Date: 2021/08/29
|
* 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
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Lesser General Public License as
|
* it under the terms of the GNU General Public License as published by
|
||||||
* published by the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
@ -14,22 +15,31 @@
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU Lesser General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../../../core/types.h"
|
/**
|
||||||
|
* DWIN UI Enhanced implementation
|
||||||
|
* Author: Miguel A. Risco-Castillo
|
||||||
|
* Version: 3.6.3
|
||||||
|
* Date: 2021/09/08
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "../common/encoder.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
class LockScreenClass {
|
class LockScreenClass {
|
||||||
private:
|
private:
|
||||||
uint8_t Lock_Pos = 0;
|
static bool unlocked;
|
||||||
bool unlocked = false;
|
static uint8_t lock_pos;
|
||||||
public:
|
public:
|
||||||
void Init();
|
static void init();
|
||||||
void onEncoderState(ENCODER_DiffState encoder_diffState);
|
static void onEncoder(EncoderState encoder_diffState);
|
||||||
void Draw();
|
static void draw();
|
||||||
bool isUnlocked();
|
static inline bool isUnlocked() { return unlocked; }
|
||||||
};
|
};
|
||||||
extern LockScreenClass LockScreen;
|
|
||||||
|
extern LockScreenClass lockScreen;
|
||||||
|
|
|
@ -1,263 +0,0 @@
|
||||||
/**
|
|
||||||
* DWIN UI Enhanced implementation
|
|
||||||
* Author: Miguel A. Risco-Castillo
|
|
||||||
* Version: 3.6.1
|
|
||||||
* Date: 2021/08/29
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser 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 Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* @file lcd/e3v2/enhanced/rotary_encoder.cpp
|
|
||||||
* @author LEO / Creality3D
|
|
||||||
* @date 2019/07/06
|
|
||||||
* @version 2.0.1
|
|
||||||
* @brief Rotary encoder functions
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
|
||||||
|
|
||||||
#include "rotary_encoder.h"
|
|
||||||
#include "../../buttons.h"
|
|
||||||
|
|
||||||
#include "../../../MarlinCore.h"
|
|
||||||
#include "../../../HAL/shared/Delay.h"
|
|
||||||
|
|
||||||
#if HAS_BUZZER
|
|
||||||
#include "../../../libs/buzzer.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#ifndef ENCODER_PULSES_PER_STEP
|
|
||||||
#define ENCODER_PULSES_PER_STEP 4
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if ENABLED(SOUND_MENU_ITEM)
|
|
||||||
#include "../../marlinui.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ENCODER_Rate EncoderRate;
|
|
||||||
|
|
||||||
// Buzzer
|
|
||||||
void Encoder_tick() {
|
|
||||||
#if PIN_EXISTS(BEEPER)
|
|
||||||
if (TERN1(SOUND_MENU_ITEM, ui.buzzer_enabled)) {
|
|
||||||
WRITE(BEEPER_PIN, HIGH);
|
|
||||||
delay(10);
|
|
||||||
WRITE(BEEPER_PIN, LOW);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Encoder initialization
|
|
||||||
void Encoder_Configuration() {
|
|
||||||
#if BUTTON_EXISTS(EN1)
|
|
||||||
SET_INPUT_PULLUP(BTN_EN1);
|
|
||||||
#endif
|
|
||||||
#if BUTTON_EXISTS(EN2)
|
|
||||||
SET_INPUT_PULLUP(BTN_EN2);
|
|
||||||
#endif
|
|
||||||
#if BUTTON_EXISTS(ENC)
|
|
||||||
SET_INPUT_PULLUP(BTN_ENC);
|
|
||||||
#endif
|
|
||||||
#if PIN_EXISTS(BEEPER)
|
|
||||||
SET_OUTPUT(BEEPER_PIN);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze() {
|
|
||||||
const millis_t now = millis();
|
|
||||||
static uint8_t lastEncoderBits;
|
|
||||||
uint8_t newbutton = 0;
|
|
||||||
static signed char temp_diff = 0;
|
|
||||||
|
|
||||||
ENCODER_DiffState temp_diffState = ENCODER_DIFF_NO;
|
|
||||||
if (BUTTON_PRESSED(EN1)) newbutton |= EN_A;
|
|
||||||
if (BUTTON_PRESSED(EN2)) newbutton |= EN_B;
|
|
||||||
if (BUTTON_PRESSED(ENC)) {
|
|
||||||
static millis_t next_click_update_ms;
|
|
||||||
if (ELAPSED(now, next_click_update_ms)) {
|
|
||||||
next_click_update_ms = millis() + 300;
|
|
||||||
Encoder_tick();
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
//LED_Action();
|
|
||||||
#endif
|
|
||||||
const bool was_waiting = wait_for_user;
|
|
||||||
wait_for_user = false;
|
|
||||||
return was_waiting ? ENCODER_DIFF_NO : ENCODER_DIFF_ENTER;
|
|
||||||
}
|
|
||||||
else return ENCODER_DIFF_NO;
|
|
||||||
}
|
|
||||||
if (newbutton != lastEncoderBits) {
|
|
||||||
switch (newbutton) {
|
|
||||||
case ENCODER_PHASE_0:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_3) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_1) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_1:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_0) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_2) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_2:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_1) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_3) temp_diff--;
|
|
||||||
break;
|
|
||||||
case ENCODER_PHASE_3:
|
|
||||||
if (lastEncoderBits == ENCODER_PHASE_2) temp_diff++;
|
|
||||||
else if (lastEncoderBits == ENCODER_PHASE_0) temp_diff--;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
lastEncoderBits = newbutton;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ABS(temp_diff) >= ENCODER_PULSES_PER_STEP) {
|
|
||||||
if (temp_diff > 0) temp_diffState = ENCODER_DIFF_CW;
|
|
||||||
else temp_diffState = ENCODER_DIFF_CCW;
|
|
||||||
|
|
||||||
#if ENABLED(ENCODER_RATE_MULTIPLIER)
|
|
||||||
|
|
||||||
millis_t ms = millis();
|
|
||||||
int32_t encoderMultiplier = 1;
|
|
||||||
|
|
||||||
// if must encoder rati multiplier
|
|
||||||
if (EncoderRate.enabled) {
|
|
||||||
const float abs_diff = ABS(temp_diff),
|
|
||||||
encoderMovementSteps = abs_diff / (ENCODER_PULSES_PER_STEP);
|
|
||||||
if (EncoderRate.lastEncoderTime) {
|
|
||||||
// Note that the rate is always calculated between two passes through the
|
|
||||||
// loop and that the abs of the temp_diff value is tracked.
|
|
||||||
const float encoderStepRate = encoderMovementSteps / float(ms - EncoderRate.lastEncoderTime) * 1000;
|
|
||||||
if (encoderStepRate >= ENCODER_100X_STEPS_PER_SEC) encoderMultiplier = 100;
|
|
||||||
else if (encoderStepRate >= ENCODER_10X_STEPS_PER_SEC) encoderMultiplier = 10;
|
|
||||||
#if ENCODER_5X_STEPS_PER_SEC
|
|
||||||
else if (encoderStepRate >= ENCODER_5X_STEPS_PER_SEC) encoderMultiplier = 5;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
EncoderRate.lastEncoderTime = ms;
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
constexpr int32_t encoderMultiplier = 1;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// EncoderRate.encoderMoveValue += (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
|
||||||
EncoderRate.encoderMoveValue = (temp_diff * encoderMultiplier) / (ENCODER_PULSES_PER_STEP);
|
|
||||||
if (EncoderRate.encoderMoveValue < 0) EncoderRate.encoderMoveValue = -EncoderRate.encoderMoveValue;
|
|
||||||
|
|
||||||
temp_diff = 0;
|
|
||||||
}
|
|
||||||
return temp_diffState;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
|
|
||||||
// Take the low 24 valid bits 24Bit: G7 G6 G5 G4 G3 G2 G1 G0 R7 R6 R5 R4 R3 R2 R1 R0 B7 B6 B5 B4 B3 B2 B1 B0
|
|
||||||
uint16_t LED_DataArray[LED_NUM];
|
|
||||||
|
|
||||||
// LED light operation
|
|
||||||
void LED_Action() {
|
|
||||||
LED_Control(RGB_SCALE_WARM_WHITE,0x0F);
|
|
||||||
delay(30);
|
|
||||||
LED_Control(RGB_SCALE_WARM_WHITE,0x00);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED initialization
|
|
||||||
void LED_Configuration() {
|
|
||||||
SET_OUTPUT(LCD_LED_PIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED write data
|
|
||||||
void LED_WriteData() {
|
|
||||||
uint8_t tempCounter_LED, tempCounter_Bit;
|
|
||||||
for (tempCounter_LED = 0; tempCounter_LED < LED_NUM; tempCounter_LED++) {
|
|
||||||
for (tempCounter_Bit = 0; tempCounter_Bit < 24; tempCounter_Bit++) {
|
|
||||||
if (LED_DataArray[tempCounter_LED] & (0x800000 >> tempCounter_Bit)) {
|
|
||||||
LED_DATA_HIGH;
|
|
||||||
DELAY_NS(300);
|
|
||||||
LED_DATA_LOW;
|
|
||||||
DELAY_NS(200);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
LED_DATA_HIGH;
|
|
||||||
LED_DATA_LOW;
|
|
||||||
DELAY_NS(200);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance) {
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
LED_DataArray[i] = 0;
|
|
||||||
switch (RGB_Scale) {
|
|
||||||
case RGB_SCALE_R10_G7_B5: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 5/10; break;
|
|
||||||
case RGB_SCALE_R10_G7_B4: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 7/10) << 16 | luminance * 4/10; break;
|
|
||||||
case RGB_SCALE_R10_G8_B7: LED_DataArray[i] = (luminance * 10/10) << 8 | (luminance * 8/10) << 16 | luminance * 7/10; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
LED_WriteData();
|
|
||||||
}
|
|
||||||
|
|
||||||
// LED gradient control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
// change_Time: gradient time (ms)
|
|
||||||
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval) {
|
|
||||||
struct { uint8_t g, r, b; } led_data[LED_NUM];
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
switch (RGB_Scale) {
|
|
||||||
case RGB_SCALE_R10_G7_B5:
|
|
||||||
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 5/10 };
|
|
||||||
break;
|
|
||||||
case RGB_SCALE_R10_G7_B4:
|
|
||||||
led_data[i] = { luminance * 7/10, luminance * 10/10, luminance * 4/10 };
|
|
||||||
break;
|
|
||||||
case RGB_SCALE_R10_G8_B7:
|
|
||||||
led_data[i] = { luminance * 8/10, luminance * 10/10, luminance * 7/10 };
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
struct { bool g, r, b; } led_flag = { false, false, false };
|
|
||||||
for (uint8_t i = 0; i < LED_NUM; i++) {
|
|
||||||
while (1) {
|
|
||||||
const uint8_t g = uint8_t(LED_DataArray[i] >> 16),
|
|
||||||
r = uint8_t(LED_DataArray[i] >> 8),
|
|
||||||
b = uint8_t(LED_DataArray[i]);
|
|
||||||
if (g == led_data[i].g) led_flag.g = true;
|
|
||||||
else LED_DataArray[i] += (g > led_data[i].g) ? -0x010000 : 0x010000;
|
|
||||||
if (r == led_data[i].r) led_flag.r = true;
|
|
||||||
else LED_DataArray[i] += (r > led_data[i].r) ? -0x000100 : 0x000100;
|
|
||||||
if (b == led_data[i].b) led_flag.b = true;
|
|
||||||
else LED_DataArray[i] += (b > led_data[i].b) ? -0x000001 : 0x000001;
|
|
||||||
LED_WriteData();
|
|
||||||
if (led_flag.r && led_flag.g && led_flag.b) break;
|
|
||||||
delay(change_Interval);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // LCD_LED
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
|
|
@ -1,93 +0,0 @@
|
||||||
/**
|
|
||||||
* DWIN UI Enhanced implementation
|
|
||||||
* Author: Miguel A. Risco-Castillo
|
|
||||||
* Version: 3.6.1
|
|
||||||
* Date: 2021/08/29
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Lesser 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 Lesser General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
* @file lcd/e3v2/enhanced/rotary_encoder.h
|
|
||||||
* @author LEO / Creality3D
|
|
||||||
* @date 2019/07/06
|
|
||||||
* @version 2.0.1
|
|
||||||
* @brief Rotary encoder functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
/*********************** Encoder Set ***********************/
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
bool enabled = false;
|
|
||||||
int encoderMoveValue = 0;
|
|
||||||
millis_t lastEncoderTime = 0;
|
|
||||||
} ENCODER_Rate;
|
|
||||||
|
|
||||||
extern ENCODER_Rate EncoderRate;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
ENCODER_DIFF_NO = 0, // no state
|
|
||||||
ENCODER_DIFF_CW = 1, // clockwise rotation
|
|
||||||
ENCODER_DIFF_CCW = 2, // counterclockwise rotation
|
|
||||||
ENCODER_DIFF_ENTER = 3 // click
|
|
||||||
} ENCODER_DiffState;
|
|
||||||
|
|
||||||
// Encoder initialization
|
|
||||||
void Encoder_Configuration();
|
|
||||||
|
|
||||||
// Analyze encoder value and return state
|
|
||||||
ENCODER_DiffState Encoder_ReceiveAnalyze();
|
|
||||||
|
|
||||||
/*********************** Encoder LED ***********************/
|
|
||||||
|
|
||||||
#if PIN_EXISTS(LCD_LED)
|
|
||||||
|
|
||||||
#define LED_NUM 4
|
|
||||||
#define LED_DATA_HIGH WRITE(LCD_LED_PIN, 1)
|
|
||||||
#define LED_DATA_LOW WRITE(LCD_LED_PIN, 0)
|
|
||||||
|
|
||||||
#define RGB_SCALE_R10_G7_B5 1
|
|
||||||
#define RGB_SCALE_R10_G7_B4 2
|
|
||||||
#define RGB_SCALE_R10_G8_B7 3
|
|
||||||
#define RGB_SCALE_NEUTRAL_WHITE RGB_SCALE_R10_G7_B5
|
|
||||||
#define RGB_SCALE_WARM_WHITE RGB_SCALE_R10_G7_B4
|
|
||||||
#define RGB_SCALE_COOL_WHITE RGB_SCALE_R10_G8_B7
|
|
||||||
|
|
||||||
extern unsigned int LED_DataArray[LED_NUM];
|
|
||||||
|
|
||||||
// LED light operation
|
|
||||||
void LED_Action();
|
|
||||||
|
|
||||||
// LED initialization
|
|
||||||
void LED_Configuration();
|
|
||||||
|
|
||||||
// LED write data
|
|
||||||
void LED_WriteData();
|
|
||||||
|
|
||||||
// LED control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
void LED_Control(const uint8_t RGB_Scale, const uint8_t luminance);
|
|
||||||
|
|
||||||
// LED gradient control
|
|
||||||
// RGB_Scale: RGB color ratio
|
|
||||||
// luminance: brightness (0~0xFF)
|
|
||||||
// change_Time: gradient time (ms)
|
|
||||||
void LED_GraduallyControl(const uint8_t RGB_Scale, const uint8_t luminance, const uint16_t change_Interval);
|
|
||||||
|
|
||||||
#endif // LCD_LED
|
|
|
@ -40,6 +40,9 @@
|
||||||
#include "../../../libs/buzzer.h"
|
#include "../../../libs/buzzer.h"
|
||||||
#include "../../../inc/Conditionals_post.h"
|
#include "../../../inc/Conditionals_post.h"
|
||||||
|
|
||||||
|
//#define DEBUG_OUT 1
|
||||||
|
#include "../../../core/debug_out.h"
|
||||||
|
|
||||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||||
#include "../../../feature/pause.h"
|
#include "../../../feature/pause.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -200,7 +203,6 @@ CrealityDWINClass CrealityDWIN;
|
||||||
uint8_t mesh_y = 0;
|
uint8_t mesh_y = 0;
|
||||||
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
bed_mesh_t &mesh_z_values = ubl.z_values;
|
|
||||||
uint8_t tilt_grid = 1;
|
uint8_t tilt_grid = 1;
|
||||||
|
|
||||||
void manual_value_update(bool undefined=false) {
|
void manual_value_update(bool undefined=false) {
|
||||||
|
@ -213,11 +215,11 @@ CrealityDWINClass CrealityDWIN;
|
||||||
struct linear_fit_data lsf_results;
|
struct linear_fit_data lsf_results;
|
||||||
incremental_LSF_reset(&lsf_results);
|
incremental_LSF_reset(&lsf_results);
|
||||||
GRID_LOOP(x, y) {
|
GRID_LOOP(x, y) {
|
||||||
if (!isnan(mesh_z_values[x][y])) {
|
if (!isnan(Z_VALUES_ARR[x][y])) {
|
||||||
xy_pos_t rpos;
|
xy_pos_t rpos;
|
||||||
rpos.x = ubl.mesh_index_to_xpos(x);
|
rpos.x = ubl.mesh_index_to_xpos(x);
|
||||||
rpos.y = ubl.mesh_index_to_ypos(y);
|
rpos.y = ubl.mesh_index_to_ypos(y);
|
||||||
incremental_LSF(&lsf_results, rpos, mesh_z_values[x][y]);
|
incremental_LSF(&lsf_results, rpos, Z_VALUES_ARR[x][y]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -232,7 +234,7 @@ CrealityDWINClass CrealityDWIN;
|
||||||
GRID_LOOP(i, j) {
|
GRID_LOOP(i, j) {
|
||||||
float mx = ubl.mesh_index_to_xpos(i),
|
float mx = ubl.mesh_index_to_xpos(i),
|
||||||
my = ubl.mesh_index_to_ypos(j),
|
my = ubl.mesh_index_to_ypos(j),
|
||||||
mz = mesh_z_values[i][j];
|
mz = Z_VALUES_ARR[i][j];
|
||||||
|
|
||||||
if (DEBUGGING(LEVELING)) {
|
if (DEBUGGING(LEVELING)) {
|
||||||
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
DEBUG_ECHOPAIR_F("before rotation = [", mx, 7);
|
||||||
|
@ -256,13 +258,12 @@ CrealityDWINClass CrealityDWIN;
|
||||||
DEBUG_DELAY(20);
|
DEBUG_DELAY(20);
|
||||||
}
|
}
|
||||||
|
|
||||||
mesh_z_values[i][j] = mz - lsf_results.D;
|
Z_VALUES_ARR[i][j] = mz - lsf_results.D;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
bed_mesh_t &mesh_z_values = z_values;
|
|
||||||
|
|
||||||
void manual_value_update() {
|
void manual_value_update() {
|
||||||
sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
|
sprintf_P(cmd, PSTR("G29 I%i J%i Z%s"), mesh_x, mesh_y, dtostrf(current_position.z, 1, 3, str_1));
|
||||||
|
@ -275,7 +276,7 @@ CrealityDWINClass CrealityDWIN;
|
||||||
void manual_move(bool zmove=false) {
|
void manual_move(bool zmove=false) {
|
||||||
if (zmove) {
|
if (zmove) {
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
}
|
}
|
||||||
|
@ -286,7 +287,7 @@ CrealityDWINClass CrealityDWIN;
|
||||||
sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
|
sprintf_P(cmd, PSTR("G42 F4000 I%i J%i"), mesh_x, mesh_y);
|
||||||
gcode.process_subcommands_now_P(cmd);
|
gcode.process_subcommands_now_P(cmd);
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z = goto_mesh_value ? mesh_z_values[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
current_position.z = goto_mesh_value ? Z_VALUES_ARR[mesh_x][mesh_y] : Z_CLEARANCE_BETWEEN_PROBES;
|
||||||
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
planner.buffer_line(current_position, homing_feedrate(Z_AXIS), active_extruder);
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
CrealityDWIN.Redraw_Menu();
|
CrealityDWIN.Redraw_Menu();
|
||||||
|
@ -296,8 +297,8 @@ CrealityDWINClass CrealityDWIN;
|
||||||
float get_max_value() {
|
float get_max_value() {
|
||||||
float max = __FLT_MIN__;
|
float max = __FLT_MIN__;
|
||||||
GRID_LOOP(x, y) {
|
GRID_LOOP(x, y) {
|
||||||
if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] > max)
|
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] > max)
|
||||||
max = mesh_z_values[x][y];
|
max = Z_VALUES_ARR[x][y];
|
||||||
}
|
}
|
||||||
return max;
|
return max;
|
||||||
}
|
}
|
||||||
|
@ -305,8 +306,8 @@ CrealityDWINClass CrealityDWIN;
|
||||||
float get_min_value() {
|
float get_min_value() {
|
||||||
float min = __FLT_MAX__;
|
float min = __FLT_MAX__;
|
||||||
GRID_LOOP(x, y) {
|
GRID_LOOP(x, y) {
|
||||||
if (!isnan(mesh_z_values[x][y]) && mesh_z_values[x][y] < min)
|
if (!isnan(Z_VALUES_ARR[x][y]) && Z_VALUES_ARR[x][y] < min)
|
||||||
min = mesh_z_values[x][y];
|
min = Z_VALUES_ARR[x][y];
|
||||||
}
|
}
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
@ -335,12 +336,12 @@ CrealityDWINClass CrealityDWIN;
|
||||||
const auto end_x_px = start_x_px + cell_width_px - 1 - gridline_width;
|
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 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;
|
const auto end_y_px = start_y_px + cell_height_px - 1 - gridline_width;
|
||||||
DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
|
DWIN_Draw_Rectangle(1, // RGB565 colors: http://www.barth-dev.de/online/rgb565-color-picker/
|
||||||
isnan(mesh_z_values[x][y]) ? Color_Grey : ( // gray if undefined
|
isnan(Z_VALUES_ARR[x][y]) ? Color_Grey : ( // gray if undefined
|
||||||
(mesh_z_values[x][y] < 0 ?
|
(Z_VALUES_ARR[x][y] < 0 ?
|
||||||
(uint16_t)round(0x1F * -mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
(uint16_t)round(0x1F * -Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_min)) << 11 : // red if mesh point value is negative
|
||||||
(uint16_t)round(0x3F * mesh_z_values[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
(uint16_t)round(0x3F * Z_VALUES_ARR[x][y] / (!viewer_asymmetric_range ? range : v_max)) << 5) | // green if mesh point value is positive
|
||||||
_MIN(0x1F, (((uint8_t)abs(mesh_z_values[x][y]) / 10) * 4))), // + blue stepping for every mm
|
_MIN(0x1F, (((uint8_t)abs(Z_VALUES_ARR[x][y]) / 10) * 4))), // + blue stepping for every mm
|
||||||
start_x_px, start_y_px, end_x_px, end_y_px
|
start_x_px, start_y_px, end_x_px, end_y_px
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -350,18 +351,18 @@ CrealityDWINClass CrealityDWIN;
|
||||||
// Draw value text on
|
// Draw value text on
|
||||||
if (viewer_print_value) {
|
if (viewer_print_value) {
|
||||||
int8_t offset_x, offset_y = cell_height_px / 2 - 6;
|
int8_t offset_x, offset_y = cell_height_px / 2 - 6;
|
||||||
if (isnan(mesh_z_values[x][y])) { // undefined
|
if (isnan(Z_VALUES_ARR[x][y])) { // undefined
|
||||||
DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
|
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + cell_width_px / 2 - 5, start_y_px + offset_y, F("X"));
|
||||||
}
|
}
|
||||||
else { // has value
|
else { // has value
|
||||||
if (GRID_MAX_POINTS_X < 10)
|
if (GRID_MAX_POINTS_X < 10)
|
||||||
sprintf_P(buf, PSTR("%s"), dtostrf(abs(mesh_z_values[x][y]), 1, 2, str_1));
|
sprintf_P(buf, PSTR("%s"), dtostrf(abs(Z_VALUES_ARR[x][y]), 1, 2, str_1));
|
||||||
else
|
else
|
||||||
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(mesh_z_values[x][y] - (int16_t)mesh_z_values[x][y]) * 100));
|
sprintf_P(buf, PSTR("%02i"), (uint16_t)(abs(Z_VALUES_ARR[x][y] - (int16_t)Z_VALUES_ARR[x][y]) * 100));
|
||||||
offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
|
offset_x = cell_width_px / 2 - 3 * (strlen(buf)) - 2;
|
||||||
if (!(GRID_MAX_POINTS_X < 10))
|
if (!(GRID_MAX_POINTS_X < 10))
|
||||||
DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
|
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px - 2 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, F("."));
|
||||||
DWIN_Draw_String(false, false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
|
DWIN_Draw_String(false, font6x12, Color_White, Color_Bg_Blue, start_x_px + 1 + offset_x, start_y_px + offset_y /*+ square / 2 - 6*/, buf);
|
||||||
}
|
}
|
||||||
safe_delay(10);
|
safe_delay(10);
|
||||||
LCD_SERIAL.flushTX();
|
LCD_SERIAL.flushTX();
|
||||||
|
@ -415,16 +416,11 @@ void CrealityDWINClass::Draw_Float(float value, uint8_t row, bool selected/*=fal
|
||||||
const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
|
const uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
|
||||||
const uint16_t xpos = 240 - (digits * 8);
|
const uint16_t xpos = 240 - (digits * 8);
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 194, MBASE(row), 234 - (digits * 8), MBASE(row) + 16);
|
||||||
if (isnan(value)) {
|
if (isnan(value))
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN"));
|
DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" NaN"));
|
||||||
}
|
|
||||||
else if (value < 0) {
|
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), -value * minunit);
|
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F("-"));
|
|
||||||
}
|
|
||||||
else {
|
else {
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), value * minunit);
|
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, Color_White, bColor, digits - log10(minunit) + 1, log10(minunit), xpos, MBASE(row), (value < 0 ? -value : value) * minunit);
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), F(" "));
|
DWIN_Draw_String(true, DWIN_FONT_MENU, Color_White, bColor, xpos - 8, MBASE(row), value < 0 ? F("-") : F(" "));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -432,7 +428,7 @@ void CrealityDWINClass::Draw_Option(uint8_t value, const char * const * options,
|
||||||
uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
|
uint16_t bColor = (selected) ? Select_Color : Color_Bg_Black;
|
||||||
uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
|
uint16_t tColor = (color) ? GetColor(value, Color_White, false) : Color_White;
|
||||||
DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
|
DWIN_Draw_Rectangle(1, bColor, 202, MBASE(row) + 14, 258, MBASE(row) - 2);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, tColor, bColor, 202, MBASE(row) - 1, options[value]);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
|
uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool light/*=false*/) {
|
||||||
|
@ -475,15 +471,15 @@ uint16_t CrealityDWINClass::GetColor(uint8_t color, uint16_t original, bool ligh
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Draw_Title(const char * title) {
|
void CrealityDWINClass::Draw_Title(const char * title) {
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(title) * STAT_CHR_W) / 2, 5, title);
|
DWIN_Draw_String(false, DWIN_FONT_HEAD, GetColor(eeprom_settings.menu_top_txt, Color_White, false), Color_Bg_Blue, (DWIN_WIDTH - strlen(title) * STAT_CHR_W) / 2, 5, title);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
|
void CrealityDWINClass::Draw_Menu_Item(uint8_t row, uint8_t icon/*=0*/, const char * label1, const char * label2, bool more/*=false*/, bool centered/*=false*/) {
|
||||||
const uint8_t label_offset_y = !(label1 && label2) ? 0 : MENU_CHR_H * 3 / 5;
|
const uint8_t label_offset_y = !(label1 && label2) ? 0 : MENU_CHR_H * 3 / 5;
|
||||||
const uint8_t label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2);
|
const uint8_t label1_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label1 ? strlen(label1) : 0) * MENU_CHR_W) / 2);
|
||||||
const uint8_t label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
|
const uint8_t label2_offset_x = !centered ? LBLX : LBLX * 4/5 + _MAX(LBLX * 1U/5, (DWIN_WIDTH - LBLX - (label2 ? strlen(label2) : 0) * MENU_CHR_W) / 2);
|
||||||
if (label1) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label
|
if (label1) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label1_offset_x, MBASE(row) - 1 - label_offset_y, label1); // Draw Label
|
||||||
if (label2) DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label
|
if (label2) DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, label2_offset_x, MBASE(row) - 1 + label_offset_y, label2); // Draw Label
|
||||||
if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon
|
if (icon) DWIN_ICON_Show(ICON, icon, 26, MBASE(row) - 3); //Draw Menu Icon
|
||||||
if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow
|
if (more) DWIN_ICON_Show(ICON, ICON_More, 226, MBASE(row) - 3); // Draw More Arrow
|
||||||
DWIN_Draw_Line(GetColor(eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
|
DWIN_Draw_Line(GetColor(eeprom_settings.menu_split_line, Line_Color, true), 16, MBASE(row) + 33, 256, MBASE(row) + 33); // Draw Menu Line
|
||||||
|
@ -547,50 +543,49 @@ void CrealityDWINClass::Main_Menu_Icons() {
|
||||||
if (selection == 0) {
|
if (selection == 0) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
|
DWIN_ICON_Show(ICON, ICON_Print_1, 17, 130);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 130, 126, 229);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
|
DWIN_ICON_Show(ICON, ICON_Print_0, 17, 130);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 52, 200, F("Print"));
|
||||||
}
|
}
|
||||||
if (selection == 1) {
|
if (selection == 1) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
|
DWIN_ICON_Show(ICON, ICON_Prepare_1, 145, 130);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 130, 254, 229);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
|
DWIN_ICON_Show(ICON, ICON_Prepare_0, 145, 130);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 170, 200, F("Prepare"));
|
||||||
}
|
}
|
||||||
if (selection == 2) {
|
if (selection == 2) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
|
DWIN_ICON_Show(ICON, ICON_Control_1, 17, 246);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 17, 246, 126, 345);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
|
DWIN_ICON_Show(ICON, ICON_Control_0, 17, 246);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 43, 317, F("Control"));
|
||||||
}
|
}
|
||||||
#if HAS_ABL_OR_UBL
|
#if HAS_ABL_OR_UBL
|
||||||
if (selection == 3) {
|
if (selection == 3) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
|
DWIN_ICON_Show(ICON, ICON_Leveling_1, 145, 246);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
|
DWIN_ICON_Show(ICON, ICON_Leveling_0, 145, 246);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 179, 317, F("Level"));
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (selection == 3) {
|
if (selection == 3) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
|
DWIN_ICON_Show(ICON, ICON_Info_1, 145, 246);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 145, 246, 254, 345);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
|
DWIN_ICON_Show(ICON, ICON_Info_0, 145, 246);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 181, 317, F("Info"));
|
||||||
//DWIN_Frame_AreaCopy(1, 132, 423, 159, 435, 186, 318);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -610,41 +605,41 @@ void CrealityDWINClass::Print_Screen_Icons() {
|
||||||
if (selection == 0) {
|
if (selection == 0) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
|
DWIN_ICON_Show(ICON, ICON_Setup_1, 8, 252);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 8, 252, 87, 351);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
|
DWIN_ICON_Show(ICON, ICON_Setup_0, 8, 252);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 30, 322, F("Tune"));
|
||||||
}
|
}
|
||||||
if (selection == 2) {
|
if (selection == 2) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
|
DWIN_ICON_Show(ICON, ICON_Stop_1, 184, 252);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 184, 252, 263, 351);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
|
DWIN_ICON_Show(ICON, ICON_Stop_0, 184, 252);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 205, 322, F("Stop"));
|
||||||
}
|
}
|
||||||
if (paused) {
|
if (paused) {
|
||||||
if (selection == 1) {
|
if (selection == 1) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
|
DWIN_ICON_Show(ICON, ICON_Continue_1, 96, 252);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
|
DWIN_ICON_Show(ICON, ICON_Continue_0, 96, 252);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Print"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (selection == 1) {
|
if (selection == 1) {
|
||||||
DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
|
DWIN_ICON_Show(ICON, ICON_Pause_1, 96, 252);
|
||||||
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
|
DWIN_Draw_Rectangle(0, GetColor(eeprom_settings.highlight_box, Color_White), 96, 252, 175, 351);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
|
DWIN_ICON_Show(ICON, ICON_Pause_0, 96, 252);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Blue, 114, 322, F("Pause"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -658,8 +653,8 @@ void CrealityDWINClass::Draw_Print_Screen() {
|
||||||
Print_Screen_Icons();
|
Print_Screen_Icons();
|
||||||
DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171);
|
DWIN_ICON_Show(ICON, ICON_PrintTime, 14, 171);
|
||||||
DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169);
|
DWIN_ICON_Show(ICON, ICON_RemainTime, 147, 169);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, "Elapsed");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 41, 163, F("Elapsed"));
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, "Remaining");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, 176, 163, F("Remaining"));
|
||||||
Update_Status_Bar(true);
|
Update_Status_Bar(true);
|
||||||
Draw_Print_ProgressBar();
|
Draw_Print_ProgressBar();
|
||||||
Draw_Print_ProgressElapsed();
|
Draw_Print_ProgressElapsed();
|
||||||
|
@ -687,14 +682,14 @@ void CrealityDWINClass::Draw_Print_Filename(const bool reset/*=false*/) {
|
||||||
dispname[len] = '\0';
|
dispname[len] = '\0';
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
|
||||||
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, dispname);
|
||||||
if (-pos >= 30) namescrl = 0;
|
if (-pos >= 30) namescrl = 0;
|
||||||
namescrl++;
|
namescrl++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 50, DWIN_WIDTH - 8, 80);
|
||||||
const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - strlen(filename) * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, Color_White, Color_Bg_Black, npos, 60, filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -704,7 +699,7 @@ void CrealityDWINClass::Draw_Print_ProgressBar() {
|
||||||
DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
|
DWIN_ICON_Show(ICON, ICON_Bar, 15, 93);
|
||||||
DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113);
|
DWIN_Draw_Rectangle(1, BarFill_Color, 16 + printpercent * 240 / 100, 93, 256, 113);
|
||||||
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent);
|
DWIN_Draw_IntValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 3, 109, 133, printpercent);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, "%");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_percent, Percent_Color), Color_Bg_Black, 133, 133, F("%"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ENABLED(USE_M73_REMAINING_TIME)
|
#if ENABLED(USE_M73_REMAINING_TIME)
|
||||||
|
@ -714,11 +709,11 @@ void CrealityDWINClass::Draw_Print_ProgressBar() {
|
||||||
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600);
|
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 176, 187, remainingtime / 3600);
|
||||||
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60);
|
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 200, 187, (remainingtime % 3600) / 60);
|
||||||
if (eeprom_settings.time_format_textual) {
|
if (eeprom_settings.time_format_textual) {
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, "h");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F("h"));
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, "m");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 216, 187, F("m"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, ":");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 192, 187, F(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -728,11 +723,11 @@ void CrealityDWINClass::Draw_Print_ProgressElapsed() {
|
||||||
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600);
|
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 42, 187, elapsed.value / 3600);
|
||||||
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60);
|
DWIN_Draw_IntValue(true, true, 1, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 2, 66, 187, (elapsed.value % 3600) / 60);
|
||||||
if (eeprom_settings.time_format_textual) {
|
if (eeprom_settings.time_format_textual) {
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, "h");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F("h"));
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, "m");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 82, 187, F("m"));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, ":");
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.progress_time, Color_White), Color_Bg_Black, 58, 187, F(":"));
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Draw_Print_confirm() {
|
void CrealityDWINClass::Draw_Print_confirm() {
|
||||||
|
@ -779,7 +774,7 @@ void CrealityDWINClass::Draw_SD_List(bool removed/*=false*/) {
|
||||||
else {
|
else {
|
||||||
Draw_Menu_Item(0, ICON_Back, "Back");
|
Draw_Menu_Item(0, ICON_Back, "Back");
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
|
DWIN_Draw_Rectangle(1, Color_Bg_Red, 10, MBASE(3) - 10, DWIN_WIDTH - 10, MBASE(4));
|
||||||
DWIN_Draw_String(false, false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), "No Media");
|
DWIN_Draw_String(false, font16x32, Color_Yellow, Color_Bg_Red, ((DWIN_WIDTH) - 8 * 16) / 2, MBASE(3), F("No Media"));
|
||||||
}
|
}
|
||||||
DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
|
DWIN_Draw_Rectangle(1, GetColor(eeprom_settings.cursor_color, Rectangle_Color), 0, MBASE(0) - 18, 14, MBASE(0) + 33);
|
||||||
}
|
}
|
||||||
|
@ -795,7 +790,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
hotend = -1;
|
hotend = -1;
|
||||||
hotendtarget = -1;
|
hotendtarget = -1;
|
||||||
DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
|
DWIN_ICON_Show(ICON, ICON_HotendTemp, 10, 383);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
|
DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 384, F("/"));
|
||||||
}
|
}
|
||||||
if (thermalManager.temp_hotend[0].celsius != hotend) {
|
if (thermalManager.temp_hotend[0].celsius != hotend) {
|
||||||
hotend = thermalManager.temp_hotend[0].celsius;
|
hotend = thermalManager.temp_hotend[0].celsius;
|
||||||
|
@ -810,7 +805,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
if (icons) {
|
if (icons) {
|
||||||
flow = -1;
|
flow = -1;
|
||||||
DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
|
DWIN_ICON_Show(ICON, ICON_StepE, 112, 417);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
|
DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 417, F("%"));
|
||||||
}
|
}
|
||||||
if (planner.flow_percentage[0] != flow) {
|
if (planner.flow_percentage[0] != flow) {
|
||||||
flow = planner.flow_percentage[0];
|
flow = planner.flow_percentage[0];
|
||||||
|
@ -825,7 +820,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
bed = -1;
|
bed = -1;
|
||||||
bedtarget = -1;
|
bedtarget = -1;
|
||||||
DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
|
DWIN_ICON_Show(ICON, ICON_BedTemp, 10, 416);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
|
DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 25 + 3 * STAT_CHR_W + 5, 417, F("/"));
|
||||||
}
|
}
|
||||||
if (thermalManager.temp_bed.celsius != bed) {
|
if (thermalManager.temp_bed.celsius != bed) {
|
||||||
bed = thermalManager.temp_bed.celsius;
|
bed = thermalManager.temp_bed.celsius;
|
||||||
|
@ -860,14 +855,8 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
}
|
}
|
||||||
if (zoffsetvalue != offset) {
|
if (zoffsetvalue != offset) {
|
||||||
offset = zoffsetvalue;
|
offset = zoffsetvalue;
|
||||||
if (zoffsetvalue < 0) {
|
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, (zoffsetvalue < 0 ? -zoffsetvalue : zoffsetvalue) * 100);
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, -zoffsetvalue * 100);
|
DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, zoffsetvalue < 0 ? F("-") : F(" "));
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, "-");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 2, 2, 207, 417, zoffsetvalue* 100);
|
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 205, 419, " ");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -875,7 +864,7 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
if (icons) {
|
if (icons) {
|
||||||
feedrate = -1;
|
feedrate = -1;
|
||||||
DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
|
DWIN_ICON_Show(ICON, ICON_Speed, 113, 383);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
|
DWIN_Draw_String(false, DWIN_FONT_STAT, GetColor(eeprom_settings.status_area_text, Color_White), Color_Bg_Black, 116 + 5 * STAT_CHR_W + 2, 384, F("%"));
|
||||||
}
|
}
|
||||||
if (feedrate_percentage != feedrate) {
|
if (feedrate_percentage != feedrate) {
|
||||||
feedrate = feedrate_percentage;
|
feedrate = feedrate_percentage;
|
||||||
|
@ -897,21 +886,21 @@ void CrealityDWINClass::Draw_Status_Area(bool icons/*=false*/) {
|
||||||
if (update_x) {
|
if (update_x) {
|
||||||
x = current_position.x;
|
x = current_position.x;
|
||||||
if ((update_x = axis_should_home(X_AXIS) && ui.get_blink()))
|
if ((update_x = axis_should_home(X_AXIS) && ui.get_blink()))
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, " -?- ");
|
DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 35, 459, F(" -?- "));
|
||||||
else
|
else
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10);
|
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 35, 459, current_position.x * 10);
|
||||||
}
|
}
|
||||||
if (update_y) {
|
if (update_y) {
|
||||||
y = current_position.y;
|
y = current_position.y;
|
||||||
if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink()))
|
if ((update_y = axis_should_home(Y_AXIS) && ui.get_blink()))
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, " -?- ");
|
DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 120, 459, F(" -?- "));
|
||||||
else
|
else
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10);
|
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 1, 120, 459, current_position.y * 10);
|
||||||
}
|
}
|
||||||
if (update_z) {
|
if (update_z) {
|
||||||
z = current_position.z;
|
z = current_position.z;
|
||||||
if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
|
if ((update_z = axis_should_home(Z_AXIS) && ui.get_blink()))
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, " -?- ");
|
DWIN_Draw_String(true, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 205, 459, F(" -?- "));
|
||||||
else
|
else
|
||||||
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z * 100 : 0);
|
DWIN_Draw_FloatValue(true, true, 0, DWIN_FONT_MENU, GetColor(eeprom_settings.coordinates_text, Color_White), Color_Bg_Black, 3, 2, 205, 459, (current_position.z>=0) ? current_position.z * 100 : 0);
|
||||||
}
|
}
|
||||||
|
@ -927,20 +916,20 @@ void CrealityDWINClass::Draw_Popup(PGM_P const line1, PGM_P const line2, PGM_P c
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350);
|
DWIN_Draw_Rectangle(1, Color_Bg_Window, 14, 60, 258, 350);
|
||||||
const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230;
|
const uint8_t ypos = (mode == Popup || mode == Confirm) ? 150 : 230;
|
||||||
if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105);
|
if (icon > 0) DWIN_ICON_Show(ICON, icon, 101, 105);
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line1)) / 2, ypos, line1);
|
DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line1)) / 2, ypos, line1);
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line2)) / 2, ypos + 30, line2);
|
DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line2)) / 2, ypos + 30, line2);
|
||||||
DWIN_Draw_String(false, true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line3)) / 2, ypos + 60, line3);
|
DWIN_Draw_String(true, DWIN_FONT_MENU, Popup_Text_Color, Color_Bg_Window, (272 - 8 * strlen_P(line3)) / 2, ypos + 60, line3);
|
||||||
if (mode == Popup) {
|
if (mode == Popup) {
|
||||||
selection = 0;
|
selection = 0;
|
||||||
DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317);
|
DWIN_Draw_Rectangle(1, Confirm_Color, 26, 280, 125, 317);
|
||||||
DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317);
|
DWIN_Draw_Rectangle(1, Cancel_Color, 146, 280, 245, 317);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, "Confirm");
|
DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 39, 290, F("Confirm"));
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, "Cancel");
|
DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 165, 290, F("Cancel"));
|
||||||
Popup_Select();
|
Popup_Select();
|
||||||
}
|
}
|
||||||
else if (mode == Confirm) {
|
else if (mode == Confirm) {
|
||||||
DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317);
|
DWIN_Draw_Rectangle(1, Confirm_Color, 87, 280, 186, 317);
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, "Continue");
|
DWIN_Draw_String(false, DWIN_FONT_STAT, Color_White, Color_Bg_Window, 96, 290, F("Continue"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -985,12 +974,12 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
|
||||||
if (process == Print) {
|
if (process == Print) {
|
||||||
DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
|
DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
|
||||||
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, dispmsg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
|
||||||
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - 30 * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, dispmsg);
|
||||||
}
|
}
|
||||||
if (-pos >= 30) msgscrl = 0;
|
if (-pos >= 30) msgscrl = 0;
|
||||||
msgscrl++;
|
msgscrl++;
|
||||||
|
@ -1001,12 +990,12 @@ void CrealityDWINClass::Update_Status_Bar(bool refresh/*=false*/) {
|
||||||
if (process == Print) {
|
if (process == Print) {
|
||||||
DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
|
DWIN_Draw_Rectangle(1, Color_Grey, 8, 214, DWIN_WIDTH - 8, 238);
|
||||||
const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 219, statusmsg);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 8, 352, DWIN_WIDTH - 8, 376);
|
||||||
const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
|
const int8_t npos = (DWIN_WIDTH - strlen(statusmsg) * MENU_CHR_W) / 2;
|
||||||
DWIN_Draw_String(false, false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg);
|
DWIN_Draw_String(false, DWIN_FONT_MENU, GetColor(eeprom_settings.status_bar_text, Color_White), Color_Bg_Black, npos, 357, statusmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1280,7 +1269,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
case MOVE_P:
|
case MOVE_P:
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_StockConfiguraton, "Probe");
|
Draw_Menu_Item(row, ICON_StockConfiguration, "Probe");
|
||||||
Draw_Checkbox(row, probe_deployed);
|
Draw_Checkbox(row, probe_deployed);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -2866,7 +2855,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
case Advanced:
|
case Advanced:
|
||||||
|
|
||||||
#define ADVANCED_BACK 0
|
#define ADVANCED_BACK 0
|
||||||
#define ADVANCED_BEEPER (ADVANCED_BACK + 1)
|
#define ADVANCED_BEEPER (ADVANCED_BACK + ENABLED(SOUND_MENU_ITEM))
|
||||||
#define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
|
#define ADVANCED_PROBE (ADVANCED_BEEPER + ENABLED(HAS_BED_PROBE))
|
||||||
#define ADVANCED_CORNER (ADVANCED_PROBE + 1)
|
#define ADVANCED_CORNER (ADVANCED_PROBE + 1)
|
||||||
#define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
|
#define ADVANCED_LA (ADVANCED_CORNER + ENABLED(LIN_ADVANCE))
|
||||||
|
@ -2886,16 +2875,18 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
Draw_Menu(Control, CONTROL_ADVANCED);
|
Draw_Menu(Control, CONTROL_ADVANCED);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ADVANCED_BEEPER:
|
#if ENABLED(SOUND_MENU_ITEM)
|
||||||
if (draw) {
|
case ADVANCED_BEEPER:
|
||||||
Draw_Menu_Item(row, ICON_Version, "LCD Beeper");
|
if (draw) {
|
||||||
Draw_Checkbox(row, eeprom_settings.beeperenable);
|
Draw_Menu_Item(row, ICON_Version, "LCD Beeper");
|
||||||
}
|
Draw_Checkbox(row, ui.buzzer_enabled);
|
||||||
else {
|
}
|
||||||
eeprom_settings.beeperenable = !eeprom_settings.beeperenable;
|
else {
|
||||||
Draw_Checkbox(row, eeprom_settings.beeperenable);
|
ui.buzzer_enabled = !ui.buzzer_enabled;
|
||||||
}
|
Draw_Checkbox(row, ui.buzzer_enabled);
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
#if HAS_BED_PROBE
|
#if HAS_BED_PROBE
|
||||||
case ADVANCED_PROBE:
|
case ADVANCED_PROBE:
|
||||||
|
@ -3122,7 +3113,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
break;
|
break;
|
||||||
case LEVELING_ACTIVE:
|
case LEVELING_ACTIVE:
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_StockConfiguraton, "Leveling Active");
|
Draw_Menu_Item(row, ICON_StockConfiguration, "Leveling Active");
|
||||||
Draw_Checkbox(row, planner.leveling_active);
|
Draw_Checkbox(row, planner.leveling_active);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3407,7 +3398,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
if (draw)
|
if (draw)
|
||||||
Draw_Menu_Item(row, ICON_Mesh, "Zero Current Mesh");
|
Draw_Menu_Item(row, ICON_Mesh, "Zero Current Mesh");
|
||||||
else
|
else
|
||||||
ZERO(mesh_conf.mesh_z_values);
|
ZERO(Z_VALUES_ARR);
|
||||||
break;
|
break;
|
||||||
case LEVELING_SETTINGS_UNDEF:
|
case LEVELING_SETTINGS_UNDEF:
|
||||||
if (draw)
|
if (draw)
|
||||||
|
@ -3493,41 +3484,41 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
case LEVELING_M_OFFSET:
|
case LEVELING_M_OFFSET:
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
|
Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||||
Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEVELING_M_UP:
|
case LEVELING_M_UP:
|
||||||
if (draw)
|
if (draw)
|
||||||
Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
|
Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
|
||||||
else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||||
gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
|
gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z += 0.01f;
|
current_position.z += 0.01f;
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEVELING_M_DOWN:
|
case LEVELING_M_DOWN:
|
||||||
if (draw)
|
if (draw)
|
||||||
Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
|
Draw_Menu_Item(row, ICON_AxisD, "Microstep Down");
|
||||||
else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||||
gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
|
gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z -= 0.01f;
|
current_position.z -= 0.01f;
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case LEVELING_M_GOTO_VALUE:
|
case LEVELING_M_GOTO_VALUE:
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_StockConfiguraton, "Go to Mesh Z Value");
|
Draw_Menu_Item(row, ICON_StockConfiguration, "Go to Mesh Z Value");
|
||||||
Draw_Checkbox(row, mesh_conf.goto_mesh_value);
|
Draw_Checkbox(row, mesh_conf.goto_mesh_value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3614,36 +3605,36 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
case UBL_M_OFFSET:
|
case UBL_M_OFFSET:
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
|
Draw_Menu_Item(row, ICON_SetZOffset, "Point Z Offset");
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row, false, 100);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (isnan(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
if (isnan(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y]))
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] = 0;
|
||||||
Modify_Value(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
Modify_Value(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], MIN_Z_OFFSET, MAX_Z_OFFSET, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UBL_M_UP:
|
case UBL_M_UP:
|
||||||
if (draw)
|
if (draw)
|
||||||
Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
|
Draw_Menu_Item(row, ICON_Axis, "Microstep Up");
|
||||||
else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] < MAX_Z_OFFSET) {
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] += 0.01;
|
||||||
gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
|
gcode.process_subcommands_now_P(PSTR("M290 Z0.01"));
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z += 0.01f;
|
current_position.z += 0.01f;
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 1, false, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case UBL_M_DOWN:
|
case UBL_M_DOWN:
|
||||||
if (draw)
|
if (draw)
|
||||||
Draw_Menu_Item(row, ICON_Axis, "Microstep Down");
|
Draw_Menu_Item(row, ICON_Axis, "Microstep Down");
|
||||||
else if (mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
else if (Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] > MIN_Z_OFFSET) {
|
||||||
mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y] -= 0.01;
|
||||||
gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
|
gcode.process_subcommands_now_P(PSTR("M290 Z-0.01"));
|
||||||
planner.synchronize();
|
planner.synchronize();
|
||||||
current_position.z -= 0.01f;
|
current_position.z -= 0.01f;
|
||||||
sync_plan_position();
|
sync_plan_position();
|
||||||
Draw_Float(mesh_conf.mesh_z_values[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
Draw_Float(Z_VALUES_ARR[mesh_conf.mesh_x][mesh_conf.mesh_y], row - 2, false, 100);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -3733,7 +3724,7 @@ void CrealityDWINClass::Menu_Item_Handler(uint8_t menu, uint8_t item, bool draw/
|
||||||
if (mesh_y % 2 == 1)
|
if (mesh_y % 2 == 1)
|
||||||
mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
|
mesh_x = GRID_MAX_POINTS_X - mesh_x - 1;
|
||||||
|
|
||||||
const float currval = mesh_conf.mesh_z_values[mesh_x][mesh_y];
|
const float currval = Z_VALUES_ARR[mesh_x][mesh_y];
|
||||||
|
|
||||||
if (draw) {
|
if (draw) {
|
||||||
Draw_Menu_Item(row, ICON_Zoffset, "Goto Mesh Value");
|
Draw_Menu_Item(row, ICON_Zoffset, "Goto Mesh Value");
|
||||||
|
@ -4215,7 +4206,7 @@ void CrealityDWINClass::Confirm_Handler(PopupID popupid) {
|
||||||
/* Navigation and Control */
|
/* Navigation and Control */
|
||||||
|
|
||||||
void CrealityDWINClass::Main_Menu_Control() {
|
void CrealityDWINClass::Main_Menu_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW && selection < PAGE_COUNT - 1) {
|
if (encoder_diffState == ENCODER_DIFF_CW && selection < PAGE_COUNT - 1) {
|
||||||
selection++; // Select Down
|
selection++; // Select Down
|
||||||
|
@ -4236,7 +4227,7 @@ void CrealityDWINClass::Main_Menu_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Menu_Control() {
|
void CrealityDWINClass::Menu_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) {
|
if (encoder_diffState == ENCODER_DIFF_CW && selection < Get_Menu_Size(active_menu)) {
|
||||||
DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
|
DWIN_Draw_Rectangle(1, Color_Bg_Black, 0, MBASE(selection - scrollpos) - 18, 14, MBASE(selection - scrollpos) + 33);
|
||||||
|
@ -4264,7 +4255,7 @@ void CrealityDWINClass::Menu_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Value_Control() {
|
void CrealityDWINClass::Value_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
tempvalue += EncoderRate.encoderMoveValue;
|
tempvalue += EncoderRate.encoderMoveValue;
|
||||||
|
@ -4329,7 +4320,7 @@ void CrealityDWINClass::Value_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Option_Control() {
|
void CrealityDWINClass::Option_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||||
tempvalue += EncoderRate.encoderMoveValue;
|
tempvalue += EncoderRate.encoderMoveValue;
|
||||||
|
@ -4368,7 +4359,7 @@ void CrealityDWINClass::Option_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::File_Control() {
|
void CrealityDWINClass::File_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
static uint8_t filescrl = 0;
|
static uint8_t filescrl = 0;
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) {
|
if (encoder_diffState == ENCODER_DIFF_NO) {
|
||||||
if (selection > 0) {
|
if (selection > 0) {
|
||||||
|
@ -4456,7 +4447,7 @@ void CrealityDWINClass::File_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Print_Screen_Control() {
|
void CrealityDWINClass::Print_Screen_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW && selection < PRINT_COUNT - 1) {
|
if (encoder_diffState == ENCODER_DIFF_CW && selection < PRINT_COUNT - 1) {
|
||||||
selection++; // Select Down
|
selection++; // Select Down
|
||||||
|
@ -4509,7 +4500,7 @@ void CrealityDWINClass::Print_Screen_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Popup_Control() {
|
void CrealityDWINClass::Popup_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) {
|
if (encoder_diffState == ENCODER_DIFF_CW && selection < 1) {
|
||||||
selection++;
|
selection++;
|
||||||
|
@ -4659,7 +4650,7 @@ void CrealityDWINClass::Popup_Control() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CrealityDWINClass::Confirm_Control() {
|
void CrealityDWINClass::Confirm_Control() {
|
||||||
ENCODER_DiffState encoder_diffState = Encoder_ReceiveAnalyze();
|
EncoderState encoder_diffState = Encoder_ReceiveAnalyze();
|
||||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||||
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||||
switch (popup) {
|
switch (popup) {
|
||||||
|
@ -4967,14 +4958,14 @@ void CrealityDWINClass::Screen_Update() {
|
||||||
|
|
||||||
void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
|
void CrealityDWINClass::AudioFeedback(const bool success/*=true*/) {
|
||||||
if (success) {
|
if (success) {
|
||||||
if (eeprom_settings.beeperenable) {
|
if (ui.buzzer_enabled) {
|
||||||
BUZZ(100, 659);
|
BUZZ(100, 659);
|
||||||
BUZZ( 10, 0);
|
BUZZ( 10, 0);
|
||||||
BUZZ(100, 698);
|
BUZZ(100, 698);
|
||||||
}
|
}
|
||||||
else Update_Status("Success");
|
else Update_Status("Success");
|
||||||
}
|
}
|
||||||
else if (eeprom_settings.beeperenable)
|
else if (ui.buzzer_enabled)
|
||||||
BUZZ(40, 440);
|
BUZZ(40, 440);
|
||||||
else
|
else
|
||||||
Update_Status("Failed");
|
Update_Status("Failed");
|
||||||
|
@ -5003,7 +4994,6 @@ void CrealityDWINClass::Load_Settings(const char *buff) {
|
||||||
|
|
||||||
void CrealityDWINClass::Reset_Settings() {
|
void CrealityDWINClass::Reset_Settings() {
|
||||||
eeprom_settings.time_format_textual = false;
|
eeprom_settings.time_format_textual = false;
|
||||||
eeprom_settings.beeperenable = true;
|
|
||||||
TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0);
|
TERN_(AUTO_BED_LEVELING_UBL, eeprom_settings.tilt_grid_size = 0);
|
||||||
eeprom_settings.corner_pos = 325;
|
eeprom_settings.corner_pos = 325;
|
||||||
eeprom_settings.cursor_color = 0;
|
eeprom_settings.cursor_color = 0;
|
||||||
|
@ -5019,6 +5009,7 @@ void CrealityDWINClass::Reset_Settings() {
|
||||||
eeprom_settings.coordinates_split_line = 0;
|
eeprom_settings.coordinates_split_line = 0;
|
||||||
TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
|
TERN_(AUTO_BED_LEVELING_UBL, mesh_conf.tilt_grid = eeprom_settings.tilt_grid_size + 1);
|
||||||
corner_pos = eeprom_settings.corner_pos / 10.0f;
|
corner_pos = eeprom_settings.corner_pos / 10.0f;
|
||||||
|
TERN_(SOUND_MENU_ITEM, ui.buzzer_enabled = true);
|
||||||
Redraw_Screen();
|
Redraw_Screen();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,10 +26,16 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
#include "rotary_encoder.h"
|
#include "../common/dwin_set.h"
|
||||||
|
#include "../common/dwin_font.h"
|
||||||
|
#include "../common/dwin_color.h"
|
||||||
|
#include "../common/encoder.h"
|
||||||
#include "../../../libs/BL24CXX.h"
|
#include "../../../libs/BL24CXX.h"
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfigPre.h"
|
#include "../../../inc/MarlinConfigPre.h"
|
||||||
|
|
||||||
|
//#define DWIN_CREALITY_LCD_CUSTOM_ICONS
|
||||||
|
|
||||||
enum processID : uint8_t {
|
enum processID : uint8_t {
|
||||||
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
|
Main, Print, Menu, Value, Option, File, Popup, Confirm, Wait
|
||||||
};
|
};
|
||||||
|
@ -82,109 +88,6 @@ enum menuID : uint8_t {
|
||||||
PreheatHotend
|
PreheatHotend
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Start_Process 0
|
|
||||||
#define Language_English 1
|
|
||||||
#define Language_Chinese 2
|
|
||||||
|
|
||||||
#define ICON 7 // Icon set file 7.ICO
|
|
||||||
|
|
||||||
#define ICON_LOGO 0
|
|
||||||
#define ICON_Print_0 1
|
|
||||||
#define ICON_Print_1 2
|
|
||||||
#define ICON_Prepare_0 3
|
|
||||||
#define ICON_Prepare_1 4
|
|
||||||
#define ICON_Control_0 5
|
|
||||||
#define ICON_Control_1 6
|
|
||||||
#define ICON_Leveling_0 7
|
|
||||||
#define ICON_Leveling_1 8
|
|
||||||
#define ICON_HotendTemp 9
|
|
||||||
#define ICON_BedTemp 10
|
|
||||||
#define ICON_Speed 11
|
|
||||||
#define ICON_Zoffset 12
|
|
||||||
#define ICON_Back 13
|
|
||||||
#define ICON_File 14
|
|
||||||
#define ICON_PrintTime 15
|
|
||||||
#define ICON_RemainTime 16
|
|
||||||
#define ICON_Setup_0 17
|
|
||||||
#define ICON_Setup_1 18
|
|
||||||
#define ICON_Pause_0 19
|
|
||||||
#define ICON_Pause_1 20
|
|
||||||
#define ICON_Continue_0 21
|
|
||||||
#define ICON_Continue_1 22
|
|
||||||
#define ICON_Stop_0 23
|
|
||||||
#define ICON_Stop_1 24
|
|
||||||
#define ICON_Bar 25
|
|
||||||
#define ICON_More 26
|
|
||||||
|
|
||||||
#define ICON_Axis 27
|
|
||||||
#define ICON_CloseMotor 28
|
|
||||||
#define ICON_Homing 29
|
|
||||||
#define ICON_SetHome 30
|
|
||||||
#define ICON_PLAPreheat 31
|
|
||||||
#define ICON_ABSPreheat 32
|
|
||||||
#define ICON_Cool 33
|
|
||||||
#define ICON_Language 34
|
|
||||||
|
|
||||||
#define ICON_MoveX 35
|
|
||||||
#define ICON_MoveY 36
|
|
||||||
#define ICON_MoveZ 37
|
|
||||||
#define ICON_Extruder 38
|
|
||||||
|
|
||||||
#define ICON_Temperature 40
|
|
||||||
#define ICON_Motion 41
|
|
||||||
#define ICON_WriteEEPROM 42
|
|
||||||
#define ICON_ReadEEPROM 43
|
|
||||||
#define ICON_ResumeEEPROM 44
|
|
||||||
#define ICON_Info 45
|
|
||||||
|
|
||||||
#define ICON_SetEndTemp 46
|
|
||||||
#define ICON_SetBedTemp 47
|
|
||||||
#define ICON_FanSpeed 48
|
|
||||||
#define ICON_SetPLAPreheat 49
|
|
||||||
#define ICON_SetABSPreheat 50
|
|
||||||
|
|
||||||
#define ICON_MaxSpeed 51
|
|
||||||
#define ICON_MaxAccelerated 52
|
|
||||||
#define ICON_MaxJerk 53
|
|
||||||
#define ICON_Step 54
|
|
||||||
#define ICON_PrintSize 55
|
|
||||||
#define ICON_Version 56
|
|
||||||
#define ICON_Contact 57
|
|
||||||
#define ICON_StockConfiguraton 58
|
|
||||||
#define ICON_MaxSpeedX 59
|
|
||||||
#define ICON_MaxSpeedY 60
|
|
||||||
#define ICON_MaxSpeedZ 61
|
|
||||||
#define ICON_MaxSpeedE 62
|
|
||||||
#define ICON_MaxAccX 63
|
|
||||||
#define ICON_MaxAccY 64
|
|
||||||
#define ICON_MaxAccZ 65
|
|
||||||
#define ICON_MaxAccE 66
|
|
||||||
#define ICON_MaxSpeedJerkX 67
|
|
||||||
#define ICON_MaxSpeedJerkY 68
|
|
||||||
#define ICON_MaxSpeedJerkZ 69
|
|
||||||
#define ICON_MaxSpeedJerkE 70
|
|
||||||
#define ICON_StepX 71
|
|
||||||
#define ICON_StepY 72
|
|
||||||
#define ICON_StepZ 73
|
|
||||||
#define ICON_StepE 74
|
|
||||||
#define ICON_Setspeed 75
|
|
||||||
#define ICON_SetZOffset 76
|
|
||||||
#define ICON_Rectangle 77
|
|
||||||
#define ICON_BLTouch 78
|
|
||||||
#define ICON_TempTooLow 79
|
|
||||||
#define ICON_AutoLeveling 80
|
|
||||||
#define ICON_TempTooHigh 81
|
|
||||||
#define ICON_NoTips_C 82
|
|
||||||
#define ICON_NoTips_E 83
|
|
||||||
#define ICON_Continue_C 84
|
|
||||||
#define ICON_Continue_E 85
|
|
||||||
#define ICON_Cancel_C 86
|
|
||||||
#define ICON_Cancel_E 87
|
|
||||||
#define ICON_Confirm_C 88
|
|
||||||
#define ICON_Confirm_E 89
|
|
||||||
#define ICON_Info_0 90
|
|
||||||
#define ICON_Info_1 91
|
|
||||||
|
|
||||||
// Custom icons
|
// Custom icons
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
|
#if ENABLED(DWIN_CREALITY_LCD_CUSTOM_ICONS)
|
||||||
// index of every custom icon should be >= CUSTOM_ICON_START
|
// index of every custom icon should be >= CUSTOM_ICON_START
|
||||||
|
@ -214,25 +117,14 @@ enum menuID : uint8_t {
|
||||||
#define ICON_AxisC ICON_Axis
|
#define ICON_AxisC ICON_Axis
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define font6x12 0x00
|
|
||||||
#define font8x16 0x01
|
|
||||||
#define font10x20 0x02
|
|
||||||
#define font12x24 0x03
|
|
||||||
#define font14x28 0x04
|
|
||||||
#define font16x32 0x05
|
|
||||||
#define font20x40 0x06
|
|
||||||
#define font24x48 0x07
|
|
||||||
#define font28x56 0x08
|
|
||||||
#define font32x64 0x09
|
|
||||||
|
|
||||||
enum colorID : uint8_t {
|
enum colorID : uint8_t {
|
||||||
Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
|
Default, White, Green, Cyan, Blue, Magenta, Red, Orange, Yellow, Brown, Black
|
||||||
};
|
};
|
||||||
|
|
||||||
#define Custom_Colors 10
|
#define Custom_Colors 10
|
||||||
#define Color_White 0xFFFF
|
#define Color_Aqua RGB(0x00,0x3F,0x1F)
|
||||||
#define Color_Light_White 0xBDD7
|
#define Color_Light_White 0xBDD7
|
||||||
#define Color_Green 0x07E0
|
#define Color_Green RGB(0x00,0x3F,0x00)
|
||||||
#define Color_Light_Green 0x3460
|
#define Color_Light_Green 0x3460
|
||||||
#define Color_Cyan 0x07FF
|
#define Color_Cyan 0x07FF
|
||||||
#define Color_Light_Cyan 0x04F3
|
#define Color_Light_Cyan 0x04F3
|
||||||
|
@ -240,28 +132,16 @@ enum colorID : uint8_t {
|
||||||
#define Color_Light_Blue 0x3A6A
|
#define Color_Light_Blue 0x3A6A
|
||||||
#define Color_Magenta 0xF81F
|
#define Color_Magenta 0xF81F
|
||||||
#define Color_Light_Magenta 0x9813
|
#define Color_Light_Magenta 0x9813
|
||||||
#define Color_Red 0xF800
|
|
||||||
#define Color_Light_Red 0x8800
|
#define Color_Light_Red 0x8800
|
||||||
#define Color_Orange 0xFA20
|
#define Color_Orange 0xFA20
|
||||||
#define Color_Light_Orange 0xFBC0
|
#define Color_Light_Orange 0xFBC0
|
||||||
#define Color_Yellow 0xFF0F
|
|
||||||
#define Color_Light_Yellow 0x8BE0
|
#define Color_Light_Yellow 0x8BE0
|
||||||
#define Color_Brown 0xCC27
|
#define Color_Brown 0xCC27
|
||||||
#define Color_Light_Brown 0x6204
|
#define Color_Light_Brown 0x6204
|
||||||
#define Color_Black 0x0000
|
#define Color_Black 0x0000
|
||||||
#define Color_Grey 0x18E3
|
#define Color_Grey 0x18E3
|
||||||
#define Color_Bg_Window 0x31E8 // Popup background color
|
|
||||||
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
|
||||||
#define Color_Bg_Black 0x0841 // Black background color
|
|
||||||
#define Color_Bg_Red 0xF00F // Red background color
|
|
||||||
#define Popup_Text_Color 0xD6BA // Popup font background color
|
|
||||||
#define Line_Color 0x3A6A // Split line color
|
|
||||||
#define Rectangle_Color 0xEE2F // Blue square cursor color
|
|
||||||
#define Percent_Color 0xFE29 // Percentage color
|
|
||||||
#define BarFill_Color 0x10E4 // Fill color of progress bar
|
|
||||||
#define Select_Color 0x33BB // Selected color
|
|
||||||
#define Check_Color 0x4E5C // Check-box check color
|
#define Check_Color 0x4E5C // Check-box check color
|
||||||
#define Confirm_Color 0x34B9
|
#define Confirm_Color 0x34B9
|
||||||
#define Cancel_Color 0x3186
|
#define Cancel_Color 0x3186
|
||||||
|
|
||||||
class CrealityDWINClass {
|
class CrealityDWINClass {
|
||||||
|
@ -269,7 +149,6 @@ public:
|
||||||
static constexpr size_t eeprom_data_size = 48;
|
static constexpr size_t eeprom_data_size = 48;
|
||||||
static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
|
static struct EEPROM_Settings { // use bit fields to save space, max 48 bytes
|
||||||
bool time_format_textual : 1;
|
bool time_format_textual : 1;
|
||||||
bool beeperenable : 1;
|
|
||||||
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
#if ENABLED(AUTO_BED_LEVELING_UBL)
|
||||||
uint8_t tilt_grid_size : 3;
|
uint8_t tilt_grid_size : 3;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -29,185 +29,17 @@
|
||||||
|
|
||||||
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
#if ENABLED(DWIN_CREALITY_LCD_JYERSUI)
|
||||||
|
|
||||||
#include "../../../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#include "dwin_lcd.h"
|
#include "dwin_lcd.h"
|
||||||
#include <string.h> // for memset
|
|
||||||
|
|
||||||
//#define DEBUG_OUT 1
|
|
||||||
#include "../../../core/debug_out.h"
|
|
||||||
|
|
||||||
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
|
||||||
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
|
||||||
uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
|
|
||||||
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
|
||||||
uint8_t databuf[26] = { 0 };
|
|
||||||
uint8_t receivedType;
|
|
||||||
|
|
||||||
int recnum = 0;
|
|
||||||
|
|
||||||
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
|
||||||
DWIN_SendBuf[++i] = bval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
|
||||||
DWIN_SendBuf[++i] = wval >> 8;
|
|
||||||
DWIN_SendBuf[++i] = wval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = lval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const char * const string) {
|
|
||||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
|
|
||||||
memcpy(&DWIN_SendBuf[i + 1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
|
|
||||||
if (!string) return;
|
|
||||||
const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
|
|
||||||
if (len == 0) return;
|
|
||||||
memcpy(&DWIN_SendBuf[i + 1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the data in the buffer and the packet end
|
|
||||||
inline void DWIN_Send(size_t &i) {
|
|
||||||
++i;
|
|
||||||
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
|
||||||
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
void DWIN_Startup() {}
|
||||||
bool DWIN_Handshake(void) {
|
|
||||||
#ifndef LCD_BAUDRATE
|
|
||||||
#define LCD_BAUDRATE 115200
|
|
||||||
#endif
|
|
||||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
|
||||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
|
||||||
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x00);
|
|
||||||
DWIN_Send(i);
|
|
||||||
|
|
||||||
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
|
||||||
databuf[recnum] = LCD_SERIAL.read();
|
|
||||||
// ignore the invalid data
|
|
||||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
|
||||||
if (recnum > 0) {
|
|
||||||
recnum = 0;
|
|
||||||
ZERO(databuf);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
delay(10);
|
|
||||||
recnum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( recnum >= 3
|
|
||||||
&& databuf[0] == FHONE
|
|
||||||
&& databuf[1] == '\0'
|
|
||||||
&& databuf[2] == 'O'
|
|
||||||
&& databuf[3] == 'K' );
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x30);
|
|
||||||
DWIN_Byte(i, luminance);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x34);
|
|
||||||
DWIN_Byte(i, 0x5A);
|
|
||||||
DWIN_Byte(i, 0xA5);
|
|
||||||
DWIN_Byte(i, dir);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x3D);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
||||||
|
|
||||||
// Clear screen
|
// Draw the degree (°) symbol
|
||||||
// color: Clear screen color
|
// Color: color
|
||||||
void DWIN_Frame_Clear(const uint16_t color) {
|
// x/y: Upper-left coordinate of the first pixel
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x01);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: Pixel segment color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x02);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Byte(i, width);
|
|
||||||
DWIN_Byte(i, height);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x03);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x05);
|
|
||||||
DWIN_Byte(i, mode);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Color: color
|
|
||||||
//x/y: Upper-left coordinate of the first pixel
|
|
||||||
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
|
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 + 1, y);
|
||||||
DWIN_Draw_Point(Color, 1, 1, x + 2, y);
|
DWIN_Draw_Point(Color, 1, 1, x + 2, y);
|
||||||
|
@ -219,256 +51,14 @@ void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y) {
|
||||||
DWIN_Draw_Point(Color, 1, 1, x + 2, 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
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x09);
|
|
||||||
DWIN_Byte(i, (mode << 7) | dir);
|
|
||||||
DWIN_Word(i, dis);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// widthAdjust: true=self-adjust character width; false=no adjustment
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
|
|
||||||
uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * string) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x11);
|
|
||||||
// Bit 7: widthAdjust
|
|
||||||
// Bit 6: bShow
|
|
||||||
// Bit 5-4: Unused (0)
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_String(i, string);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
// Bit 7: bshow
|
|
||||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
|
||||||
// Bit 5: zeroFill
|
|
||||||
// Bit 4: zeroMode
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, 0); // fNum
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
#if 0
|
|
||||||
for (char count = 0; count < 8; count++) {
|
|
||||||
DWIN_Byte(i, value);
|
|
||||||
value >>= 8;
|
|
||||||
if (!(value & 0xFF)) break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Write a big-endian 64 bit integer
|
|
||||||
const size_t p = i + 1;
|
|
||||||
for (char count = 8; count--;) { // 7..0
|
|
||||||
++i;
|
|
||||||
DWIN_SendBuf[p + count] = value;
|
|
||||||
value >>= 8;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
|
||||||
//uint8_t *fvalue = (uint8_t*)&value;
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, fNum);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Long(i, value);
|
|
||||||
/*
|
|
||||||
DWIN_Byte(i, fvalue[3]);
|
|
||||||
DWIN_Byte(i, fvalue[2]);
|
|
||||||
DWIN_Byte(i, fvalue[1]);
|
|
||||||
DWIN_Byte(i, fvalue[0]);
|
|
||||||
*/
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Word(i, 0x2200);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon
|
// Draw an Icon
|
||||||
// libID: Icon library ID
|
// libID: Icon library ID
|
||||||
// picID: Icon ID
|
// picID: Icon ID
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
DWIN_ICON_Show(true, false, false, libID, picID, x, y);
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x23);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Byte(i, 0x80 | libID);
|
|
||||||
DWIN_Byte(i, picID);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x25);
|
|
||||||
DWIN_Byte(i, n);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
|
||||||
// cacheID: virtual area number
|
|
||||||
// xStart/yStart: Upper-left of virtual area
|
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
|
||||||
// x/y: Screen paste point
|
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x27);
|
|
||||||
DWIN_Byte(i, 0x80 | cacheID);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID; 0x00-0x0F
|
|
||||||
// animate: true on; false off;
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
|
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x28);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
// Bit 7: animation on or off
|
|
||||||
// Bit 6: start from begin or end
|
|
||||||
// Bit 5-4: unused (0)
|
|
||||||
// Bit 3-0: animID
|
|
||||||
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
|
|
||||||
DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picIDs);
|
|
||||||
DWIN_Byte(i, picIDe);
|
|
||||||
DWIN_Byte(i, interval);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x28);
|
|
||||||
DWIN_Word(i, state);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Memory functions ----------------------------------------*/
|
|
||||||
// The LCD has an additional 32KB SRAM and 16KB Flash
|
|
||||||
|
|
||||||
// Data can be written to the sram and save to one of the jpeg page files
|
|
||||||
|
|
||||||
// Write Data Memory
|
|
||||||
// command 0x31
|
|
||||||
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Data: data
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
// Read Data Memory
|
|
||||||
// command 0x32
|
|
||||||
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Length: leangth of data to read; 0x01-0xF0
|
|
||||||
//
|
|
||||||
// Response:
|
|
||||||
// Type, Address, Length, Data
|
|
||||||
|
|
||||||
// Write Picture Memory
|
|
||||||
// Write the contents of the 32KB SRAM data memory into the designated image memory space
|
|
||||||
// Issued: 0x5A, 0xA5, PIC_ID
|
|
||||||
// Response: 0xA5 0x4F 0x4B
|
|
||||||
//
|
|
||||||
// command 0x33
|
|
||||||
// 0x5A, 0xA5
|
|
||||||
// PicId: Picture Memory location, 0x00-0x0F
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
#endif // DWIN_CREALITY_LCD_JYERSUI
|
#endif // DWIN_CREALITY_LCD_JYERSUI
|
||||||
|
|
|
@ -26,190 +26,9 @@
|
||||||
* @brief DWIN screen control functions
|
* @brief DWIN screen control functions
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <stdint.h>
|
#include "../common/dwin_api.h"
|
||||||
|
|
||||||
#define RECEIVED_NO_DATA 0x00
|
// Draw the degree (°) symbol
|
||||||
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
// Color: color
|
||||||
|
// x/y: Upper-left coordinate of the first pixel
|
||||||
#define FHONE 0xAA
|
|
||||||
|
|
||||||
#define DWIN_SCROLL_UP 2
|
|
||||||
#define DWIN_SCROLL_DOWN 3
|
|
||||||
|
|
||||||
#define DWIN_WIDTH 272
|
|
||||||
#define DWIN_HEIGHT 480
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
|
||||||
bool DWIN_Handshake(void);
|
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir);
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void);
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color);
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: Line segment color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a Horizontal line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xLength: Line Length
|
|
||||||
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a Vertical line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// yLength: Line Length
|
|
||||||
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a box
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xSize/ySize: box size
|
|
||||||
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
|
|
||||||
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
//Color: color
|
|
||||||
//x: upper left point
|
|
||||||
//y: bottom right point
|
|
||||||
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
|
void DWIN_Draw_DegreeSymbol(uint16_t Color, uint16_t x, uint16_t y);
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// widthAdjust: true=self-adjust character width; false=no adjustment
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size,
|
|
||||||
uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const char * string);
|
|
||||||
|
|
||||||
class __FlashStringHelper;
|
|
||||||
|
|
||||||
inline void DWIN_Draw_String(bool widthAdjust, bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
|
|
||||||
// Note that this won't work on AVR. This is for 32-bit systems only!
|
|
||||||
// Are __FlashStringHelper versions worth keeping?
|
|
||||||
DWIN_Draw_String(widthAdjust, bShow, size, color, bColor, x, y, reinterpret_cast<const char*>(title));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value);
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
|
||||||
|
|
||||||
// Draw an Icon
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picID: Icon ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to virtual display area #1
|
|
||||||
// id: Picture ID
|
|
||||||
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
|
||||||
// cacheID: virtual area number
|
|
||||||
// xStart/yStart: Upper-left of virtual area
|
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
|
||||||
// x/y: Screen paste point
|
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID up to 16
|
|
||||||
// animate: animation on or off
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
|
|
||||||
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state);
|
|
||||||
|
|
|
@ -37,89 +37,9 @@
|
||||||
//#define DEBUG_OUT 1
|
//#define DEBUG_OUT 1
|
||||||
#include "../../../core/debug_out.h"
|
#include "../../../core/debug_out.h"
|
||||||
|
|
||||||
// Make sure DWIN_SendBuf is large enough to hold the largest string plus draw command and tail.
|
|
||||||
// Assume the narrowest (6 pixel) font and 2-byte gb2312-encoded characters.
|
|
||||||
uint8_t DWIN_SendBuf[11 + DWIN_WIDTH / 6 * 2] = { 0xAA };
|
|
||||||
uint8_t DWIN_BufTail[4] = { 0xCC, 0x33, 0xC3, 0x3C };
|
|
||||||
uint8_t databuf[26] = { 0 };
|
|
||||||
uint8_t receivedType;
|
|
||||||
|
|
||||||
int recnum = 0;
|
|
||||||
|
|
||||||
inline void DWIN_Byte(size_t &i, const uint16_t bval) {
|
|
||||||
DWIN_SendBuf[++i] = bval;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Word(size_t &i, const uint16_t wval) {
|
|
||||||
DWIN_SendBuf[++i] = wval >> 8;
|
|
||||||
DWIN_SendBuf[++i] = wval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_Long(size_t &i, const uint32_t lval) {
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 24) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 16) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = (lval >> 8) & 0xFF;
|
|
||||||
DWIN_SendBuf[++i] = lval & 0xFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, char * const string) {
|
|
||||||
const size_t len = _MIN(sizeof(DWIN_SendBuf) - i, strlen(string));
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void DWIN_String(size_t &i, const __FlashStringHelper * string) {
|
|
||||||
if (!string) return;
|
|
||||||
const size_t len = strlen_P((PGM_P)string); // cast it to PGM_P, which is basically const char *, and measure it using the _P version of strlen.
|
|
||||||
if (len == 0) return;
|
|
||||||
memcpy(&DWIN_SendBuf[i+1], string, len);
|
|
||||||
i += len;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the data in the buffer and the packet end
|
|
||||||
inline void DWIN_Send(size_t &i) {
|
|
||||||
++i;
|
|
||||||
LOOP_L_N(n, i) { LCD_SERIAL.write(DWIN_SendBuf[n]); delayMicroseconds(1); }
|
|
||||||
LOOP_L_N(n, 4) { LCD_SERIAL.write(DWIN_BufTail[n]); delayMicroseconds(1); }
|
|
||||||
}
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
/*-------------------------------------- System variable function --------------------------------------*/
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
void DWIN_Startup() {
|
||||||
bool DWIN_Handshake(void) {
|
|
||||||
#ifndef LCD_BAUDRATE
|
|
||||||
#define LCD_BAUDRATE 115200
|
|
||||||
#endif
|
|
||||||
LCD_SERIAL.begin(LCD_BAUDRATE);
|
|
||||||
const millis_t serial_connect_timeout = millis() + 1000UL;
|
|
||||||
while (!LCD_SERIAL.connected() && PENDING(millis(), serial_connect_timeout)) { /*nada*/ }
|
|
||||||
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x00);
|
|
||||||
DWIN_Send(i);
|
|
||||||
|
|
||||||
while (LCD_SERIAL.available() > 0 && recnum < (signed)sizeof(databuf)) {
|
|
||||||
databuf[recnum] = LCD_SERIAL.read();
|
|
||||||
// ignore the invalid data
|
|
||||||
if (databuf[0] != FHONE) { // prevent the program from running.
|
|
||||||
if (recnum > 0) {
|
|
||||||
recnum = 0;
|
|
||||||
ZERO(databuf);
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
delay(10);
|
|
||||||
recnum++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( recnum >= 3
|
|
||||||
&& databuf[0] == FHONE
|
|
||||||
&& databuf[1] == '\0'
|
|
||||||
&& databuf[2] == 'O'
|
|
||||||
&& databuf[3] == 'K' );
|
|
||||||
}
|
|
||||||
|
|
||||||
void DWIN_Startup(void) {
|
|
||||||
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
||||||
delay(750); // Delay here or init later in the boot process
|
delay(750); // Delay here or init later in the boot process
|
||||||
const bool success = DWIN_Handshake();
|
const bool success = DWIN_Handshake();
|
||||||
|
@ -129,342 +49,14 @@ void DWIN_Startup(void) {
|
||||||
DWIN_UpdateLCD();
|
DWIN_UpdateLCD();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the backlight luminance
|
|
||||||
// luminance: (0x00-0xFF)
|
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x30);
|
|
||||||
DWIN_Byte(i, _MAX(luminance, 0x1F));
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x34);
|
|
||||||
DWIN_Byte(i, 0x5A);
|
|
||||||
DWIN_Byte(i, 0xA5);
|
|
||||||
DWIN_Byte(i, dir);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x3D);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x01);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x02);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Byte(i, width);
|
|
||||||
DWIN_Byte(i, height);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x03);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x05);
|
|
||||||
DWIN_Byte(i, mode);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x09);
|
|
||||||
DWIN_Byte(i, (mode << 7) | dir);
|
|
||||||
DWIN_Word(i, dis);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string) {
|
|
||||||
uint8_t widthAdjust = 0;
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x11);
|
|
||||||
// Bit 7: widthAdjust
|
|
||||||
// Bit 6: bShow
|
|
||||||
// Bit 5-4: Unused (0)
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (widthAdjust * 0x80) | (bShow * 0x40) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_String(i, string);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
// Bit 7: bshow
|
|
||||||
// Bit 6: 1 = signed; 0 = unsigned number;
|
|
||||||
// Bit 5: zeroFill
|
|
||||||
// Bit 4: zeroMode
|
|
||||||
// Bit 3-0: size
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, 0); // fNum
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
#if 0
|
|
||||||
for (char count = 0; count < 8; count++) {
|
|
||||||
DWIN_Byte(i, value);
|
|
||||||
value >>= 8;
|
|
||||||
if (!(value & 0xFF)) break;
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Write a big-endian 64 bit integer
|
|
||||||
const size_t p = i + 1;
|
|
||||||
for (char count = 8; count--;) { // 7..0
|
|
||||||
++i;
|
|
||||||
DWIN_SendBuf[p + count] = value;
|
|
||||||
value >>= 8;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value) {
|
|
||||||
//uint8_t *fvalue = (uint8_t*)&value;
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x14);
|
|
||||||
DWIN_Byte(i, (bShow * 0x80) | (zeroFill * 0x20) | (zeroMode * 0x10) | size);
|
|
||||||
DWIN_Word(i, color);
|
|
||||||
DWIN_Word(i, bColor);
|
|
||||||
DWIN_Byte(i, iNum);
|
|
||||||
DWIN_Byte(i, fNum);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Long(i, value);
|
|
||||||
/*
|
|
||||||
DWIN_Byte(i, fvalue[3]);
|
|
||||||
DWIN_Byte(i, fvalue[2]);
|
|
||||||
DWIN_Byte(i, fvalue[1]);
|
|
||||||
DWIN_Byte(i, fvalue[0]);
|
|
||||||
*/
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Word(i, 0x2200);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i); // AA 23 00 00 00 00 08 00 01 02 03 CC 33 C3 3C
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw an Icon
|
// Draw an Icon
|
||||||
// libID: Icon library ID
|
// libID: Icon library ID
|
||||||
// picID: Icon ID
|
// picID: Icon ID
|
||||||
// x/y: Upper-left point
|
// x/y: Upper-left point
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
DWIN_ICON_Show(true, false, false, libID, picID, x, y);
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x23);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Byte(i, 0x80 | libID);
|
|
||||||
//DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picID);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x25);
|
|
||||||
DWIN_Byte(i, n);
|
|
||||||
DWIN_Byte(i, id);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
|
||||||
// cacheID: virtual area number
|
|
||||||
// xStart/yStart: Upper-left of virtual area
|
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
|
||||||
// x/y: Screen paste point
|
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x27);
|
|
||||||
DWIN_Byte(i, 0x80 | cacheID);
|
|
||||||
DWIN_Word(i, xStart);
|
|
||||||
DWIN_Word(i, yStart);
|
|
||||||
DWIN_Word(i, xEnd);
|
|
||||||
DWIN_Word(i, yEnd);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID; 0x00-0x0F
|
|
||||||
// animate: true on; false off;
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs, uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval) {
|
|
||||||
NOMORE(x, DWIN_WIDTH - 1);
|
|
||||||
NOMORE(y, DWIN_HEIGHT - 1); // -- ozy -- srl
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x28);
|
|
||||||
DWIN_Word(i, x);
|
|
||||||
DWIN_Word(i, y);
|
|
||||||
// Bit 7: animation on or off
|
|
||||||
// Bit 6: start from begin or end
|
|
||||||
// Bit 5-4: unused (0)
|
|
||||||
// Bit 3-0: animID
|
|
||||||
DWIN_Byte(i, (animate * 0x80) | 0x40 | animID);
|
|
||||||
DWIN_Byte(i, libID);
|
|
||||||
DWIN_Byte(i, picIDs);
|
|
||||||
DWIN_Byte(i, picIDe);
|
|
||||||
DWIN_Byte(i, interval);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state) {
|
|
||||||
size_t i = 0;
|
|
||||||
DWIN_Byte(i, 0x29);
|
|
||||||
DWIN_Word(i, state);
|
|
||||||
DWIN_Send(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*---------------------------------------- Memory functions ----------------------------------------*/
|
|
||||||
// The LCD has an additional 32KB SRAM and 16KB Flash
|
|
||||||
|
|
||||||
// Data can be written to the sram and save to one of the jpeg page files
|
|
||||||
|
|
||||||
// Write Data Memory
|
|
||||||
// command 0x31
|
|
||||||
// Type: Write memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Write data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Data: data
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
// Read Data Memory
|
|
||||||
// command 0x32
|
|
||||||
// Type: Read memory selection; 0x5A=SRAM; 0xA5=Flash
|
|
||||||
// Address: Read data memory address; 0x000-0x7FFF for SRAM; 0x000-0x3FFF for Flash
|
|
||||||
// Length: leangth of data to read; 0x01-0xF0
|
|
||||||
//
|
|
||||||
// Response:
|
|
||||||
// Type, Address, Length, Data
|
|
||||||
|
|
||||||
// Write Picture Memory
|
|
||||||
// Write the contents of the 32KB SRAM data memory into the designated image memory space
|
|
||||||
// Issued: 0x5A, 0xA5, PIC_ID
|
|
||||||
// Response: 0xA5 0x4F 0x4B
|
|
||||||
//
|
|
||||||
// command 0x33
|
|
||||||
// 0x5A, 0xA5
|
|
||||||
// PicId: Picture Memory location, 0x00-0x0F
|
|
||||||
//
|
|
||||||
// Flash writing returns 0xA5 0x4F 0x4B
|
|
||||||
|
|
||||||
#endif // IS_DWIN_MARLINUI
|
#endif // IS_DWIN_MARLINUI
|
||||||
|
|
|
@ -26,82 +26,30 @@
|
||||||
* @brief DWIN screen control functions
|
* @brief DWIN screen control functions
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
#include <stdint.h>
|
#if ENABLED(DWIN_MARLINUI_LANDSCAPE)
|
||||||
|
|
||||||
#define RECEIVED_NO_DATA 0x00
|
|
||||||
#define RECEIVED_SHAKE_HAND_ACK 0x01
|
|
||||||
|
|
||||||
#define FHONE 0xAA
|
|
||||||
|
|
||||||
#define DWIN_SCROLL_UP 2
|
|
||||||
#define DWIN_SCROLL_DOWN 3
|
|
||||||
|
|
||||||
#if DISABLED(DWIN_MARLINUI_LANDSCAPE)
|
|
||||||
#define DWIN_WIDTH 272
|
|
||||||
#define DWIN_HEIGHT 480
|
|
||||||
#else
|
|
||||||
#define DWIN_WIDTH 480
|
#define DWIN_WIDTH 480
|
||||||
#define DWIN_HEIGHT 272
|
#define DWIN_HEIGHT 272
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include "../common/dwin_api.h"
|
||||||
|
|
||||||
// Picture ID
|
// Picture ID
|
||||||
#define DWIN_Boot_Horiz 0
|
#define DWIN_Boot_Horiz 0
|
||||||
#define DWIN_Boot_Vert 1
|
#define DWIN_Boot_Vert 1
|
||||||
#define DWIN_MarlinUI_Assets 2
|
#define DWIN_MarlinUI_Assets 2
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
|
||||||
* 0x05=16*32 0x06=20*40 0x07=24*48 0x08=28*56 0x09=32*64
|
|
||||||
*/
|
|
||||||
#define font6x12 0x00
|
|
||||||
#define font8x16 0x01
|
|
||||||
#define font10x20 0x02
|
|
||||||
#define font12x24 0x03
|
|
||||||
#define font14x28 0x04
|
|
||||||
#define font16x32 0x05
|
|
||||||
#define font20x40 0x06
|
|
||||||
#define font24x48 0x07
|
|
||||||
#define font28x56 0x08
|
|
||||||
#define font32x64 0x09
|
|
||||||
|
|
||||||
#define DWIN_FONT_MENU font10x20
|
|
||||||
#define DWIN_FONT_STAT font14x28
|
|
||||||
#define DWIN_FONT_ALERT font14x28
|
|
||||||
|
|
||||||
// Color
|
|
||||||
#define Color_White 0xFFFF
|
|
||||||
#define Color_Yellow 0xFF0F
|
|
||||||
#define Color_Error_Red 0xB000 // Error!
|
|
||||||
#define Color_Bg_Red 0xF00F // Red background color
|
|
||||||
#define Color_Bg_Window 0x31E8 // Popup background color
|
|
||||||
#define Color_Bg_Heading 0x3344 // Static Heading
|
|
||||||
#define Color_Bg_Blue 0x1125 // Dark blue background color
|
|
||||||
#define Color_Bg_Black 0x0841 // Black background color
|
|
||||||
#define Color_IconBlue 0x45FA // Lighter blue that matches icons/accents
|
|
||||||
#define Popup_Text_Color 0xD6BA // Popup font background color
|
|
||||||
#define Line_Color 0x3A6A // Split line color
|
|
||||||
#define Rectangle_Color 0xEE2F // Blue square cursor color
|
|
||||||
#define Percent_Color 0xFE29 // Percentage color
|
|
||||||
#define BarFill_Color 0x10E4 // Fill color of progress bar
|
|
||||||
#define Select_Color 0x33BB // Selected color
|
|
||||||
|
|
||||||
// Character matrix width x height
|
|
||||||
//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
|
|
||||||
//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)
|
|
||||||
|
|
||||||
// ICON ID
|
// ICON ID
|
||||||
#define BOOT_ICON 3 // Icon set file 3.ICO
|
#define BOOT_ICON 3 // Icon set file 3.ICO
|
||||||
#define ICON 4 // Icon set file 4.ICO
|
#define ICON 4 // Icon set file 4.ICO
|
||||||
|
|
||||||
// MarlinUI Boot Icons
|
// MarlinUI Boot Icons from Set 3
|
||||||
#define ICON_MarlinBoot 0
|
#define ICON_MarlinBoot 0
|
||||||
#define ICON_OpenSource 1
|
#define ICON_OpenSource 1
|
||||||
#define ICON_GitHubURL 2
|
#define ICON_GitHubURL 2
|
||||||
#define ICON_MarlinURL 3
|
#define ICON_MarlinURL 3
|
||||||
#define ICON_Copyright 4
|
#define ICON_Copyright 4
|
||||||
|
|
||||||
// MarlinUI Icons
|
// MarlinUI Icons from Set 4
|
||||||
#define ICON_LOGO_Marlin 0
|
#define ICON_LOGO_Marlin 0
|
||||||
#define ICON_HotendOff 1
|
#define ICON_HotendOff 1
|
||||||
#define ICON_HotendOn 2
|
#define ICON_HotendOn 2
|
||||||
|
@ -120,182 +68,16 @@
|
||||||
#define ICON_DownArrow 15
|
#define ICON_DownArrow 15
|
||||||
#define ICON_BedLine 16
|
#define ICON_BedLine 16
|
||||||
|
|
||||||
#define ICON_AdvSet ICON_Language
|
#include "../common/dwin_font.h"
|
||||||
#define ICON_HomeOff ICON_AdvSet
|
|
||||||
#define ICON_HomeOffX ICON_StepX
|
|
||||||
#define ICON_HomeOffY ICON_StepY
|
|
||||||
#define ICON_HomeOffZ ICON_StepZ
|
|
||||||
#define ICON_ProbeOff ICON_AdvSet
|
|
||||||
#define ICON_ProbeOffX ICON_StepX
|
|
||||||
#define ICON_ProbeOffY ICON_StepY
|
|
||||||
#define ICON_PIDNozzle ICON_SetEndTemp
|
|
||||||
#define ICON_PIDbed ICON_SetBedTemp
|
|
||||||
|
|
||||||
/*-------------------------------------- System variable function --------------------------------------*/
|
#define DWIN_FONT_MENU font10x20
|
||||||
|
#define DWIN_FONT_STAT font14x28
|
||||||
|
#define DWIN_FONT_ALERT font14x28
|
||||||
|
|
||||||
// Handshake (1: Success, 0: Fail)
|
#include "../common/dwin_color.h"
|
||||||
bool DWIN_Handshake(void);
|
|
||||||
|
|
||||||
// Common DWIN startup
|
#define Color_Bg_Heading 0x3344 // Static Heading
|
||||||
void DWIN_Startup(void);
|
|
||||||
|
|
||||||
// Set the backlight luminance
|
// Character matrix width x height
|
||||||
// luminance: (0x00-0xFF)
|
//#define LCD_WIDTH ((DWIN_WIDTH) / 8)
|
||||||
void DWIN_Backlight_SetLuminance(const uint8_t luminance);
|
//#define LCD_HEIGHT ((DWIN_HEIGHT) / 12)
|
||||||
|
|
||||||
// Set screen display direction
|
|
||||||
// dir: 0=0°, 1=90°, 2=180°, 3=270°
|
|
||||||
void DWIN_Frame_SetDir(uint8_t dir);
|
|
||||||
|
|
||||||
// Update display
|
|
||||||
void DWIN_UpdateLCD(void);
|
|
||||||
|
|
||||||
/*---------------------------------------- Drawing functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Clear screen
|
|
||||||
// color: Clear screen color
|
|
||||||
void DWIN_Frame_Clear(const uint16_t color);
|
|
||||||
|
|
||||||
// Draw a point
|
|
||||||
// color: point color
|
|
||||||
// width: point width 0x01-0x0F
|
|
||||||
// height: point height 0x01-0x0F
|
|
||||||
// x,y: upper left point
|
|
||||||
void DWIN_Draw_Point(uint16_t color, uint8_t width, uint8_t height, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Draw a line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xEnd/yEnd: End point
|
|
||||||
void DWIN_Draw_Line(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a Horizontal line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// xLength: Line Length
|
|
||||||
inline void DWIN_Draw_HLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart + xLength - 1, yStart);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a Vertical line
|
|
||||||
// color: Line segment color
|
|
||||||
// xStart/yStart: Start point
|
|
||||||
// yLength: Line Length
|
|
||||||
inline void DWIN_Draw_VLine(uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t yLength) {
|
|
||||||
DWIN_Draw_Line(color, xStart, yStart, xStart, yStart + yLength - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a rectangle
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: lower right point
|
|
||||||
void DWIN_Draw_Rectangle(uint8_t mode, uint16_t color,
|
|
||||||
uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
// Draw a box
|
|
||||||
// mode: 0=frame, 1=fill, 2=XOR fill
|
|
||||||
// color: Rectangle color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xSize/ySize: box size
|
|
||||||
inline void DWIN_Draw_Box(uint8_t mode, uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xSize, uint16_t ySize) {
|
|
||||||
DWIN_Draw_Rectangle(mode, color, xStart, yStart, xStart + xSize - 1, yStart + ySize - 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Move a screen area
|
|
||||||
// mode: 0, circle shift; 1, translation
|
|
||||||
// dir: 0=left, 1=right, 2=up, 3=down
|
|
||||||
// dis: Distance
|
|
||||||
// color: Fill color
|
|
||||||
// xStart/yStart: upper left point
|
|
||||||
// xEnd/yEnd: bottom right point
|
|
||||||
void DWIN_Frame_AreaMove(uint8_t mode, uint8_t dir, uint16_t dis,
|
|
||||||
uint16_t color, uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd);
|
|
||||||
|
|
||||||
/*---------------------------------------- Text related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw a string
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// x/y: Upper-left coordinate of the string
|
|
||||||
// *string: The string
|
|
||||||
void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, char *string);
|
|
||||||
|
|
||||||
class __FlashStringHelper;
|
|
||||||
|
|
||||||
inline void DWIN_Draw_String(bool bShow, uint8_t size, uint16_t color, uint16_t bColor, uint16_t x, uint16_t y, const __FlashStringHelper *title) {
|
|
||||||
DWIN_Draw_String(bShow, size, color, bColor, x, y, (char *)title);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Draw a positive integer
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of digits
|
|
||||||
// x/y: Upper-left coordinate
|
|
||||||
// value: Integer value
|
|
||||||
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, uint16_t value);
|
|
||||||
|
|
||||||
// Draw a floating point number
|
|
||||||
// bShow: true=display background color; false=don't display background color
|
|
||||||
// zeroFill: true=zero fill; false=no zero fill
|
|
||||||
// zeroMode: 1=leading 0 displayed as 0; 0=leading 0 displayed as a space
|
|
||||||
// size: Font size
|
|
||||||
// color: Character color
|
|
||||||
// bColor: Background color
|
|
||||||
// iNum: Number of whole digits
|
|
||||||
// fNum: Number of decimal digits
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// value: Float value
|
|
||||||
void DWIN_Draw_FloatValue(uint8_t bShow, bool zeroFill, uint8_t zeroMode, uint8_t size, uint16_t color,
|
|
||||||
uint16_t bColor, uint8_t iNum, uint8_t fNum, uint16_t x, uint16_t y, long value);
|
|
||||||
|
|
||||||
/*---------------------------------------- Picture related functions ----------------------------------------*/
|
|
||||||
|
|
||||||
// Draw JPG and cached in #0 virtual display area
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_ShowAndCache(const uint8_t id);
|
|
||||||
|
|
||||||
// Draw an Icon
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picID: Icon ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to a virtual display area
|
|
||||||
// n: Cache index
|
|
||||||
// id: Picture ID
|
|
||||||
void DWIN_JPG_CacheToN(uint8_t n, uint8_t id);
|
|
||||||
|
|
||||||
// Unzip the JPG picture to virtual display area #1
|
|
||||||
// id: Picture ID
|
|
||||||
inline void DWIN_JPG_CacheTo1(uint8_t id) { DWIN_JPG_CacheToN(1, id); }
|
|
||||||
|
|
||||||
// Copy area from virtual display area to current screen
|
|
||||||
// cacheID: virtual area number
|
|
||||||
// xStart/yStart: Upper-left of virtual area
|
|
||||||
// xEnd/yEnd: Lower-right of virtual area
|
|
||||||
// x/y: Screen paste point
|
|
||||||
void DWIN_Frame_AreaCopy(uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
|
||||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
|
||||||
|
|
||||||
// Animate a series of icons
|
|
||||||
// animID: Animation ID up to 16
|
|
||||||
// animate: animation on or off
|
|
||||||
// libID: Icon library ID
|
|
||||||
// picIDs: Icon starting ID
|
|
||||||
// picIDe: Icon ending ID
|
|
||||||
// x/y: Upper-left point
|
|
||||||
// interval: Display time interval, unit 10mS
|
|
||||||
void DWIN_ICON_Animation(uint8_t animID, bool animate, uint8_t libID, uint8_t picIDs,
|
|
||||||
uint8_t picIDe, uint16_t x, uint16_t y, uint16_t interval);
|
|
||||||
|
|
||||||
// Animation Control
|
|
||||||
// state: 16 bits, each bit is the state of an animation id
|
|
||||||
void DWIN_ICON_AnimationControl(uint16_t state);
|
|
||||||
|
|
|
@ -21,12 +21,11 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
|
|
||||||
#include "../../fontutils.h"
|
#include "../../fontutils.h"
|
||||||
#include "../../marlinui.h"
|
#include "../../marlinui.h"
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
typedef struct _dwin_charmap_t {
|
typedef struct _dwin_charmap_t {
|
||||||
wchar_t uchar; // the unicode char
|
wchar_t uchar; // the unicode char
|
||||||
uint8_t idx; // the glyph of the char in the ROM
|
uint8_t idx; // the glyph of the char in the ROM
|
||||||
|
|
|
@ -83,7 +83,7 @@ void MarlinUI::init_lcd() {
|
||||||
DWIN_Startup();
|
DWIN_Startup();
|
||||||
|
|
||||||
// Load the assets JPG (currently just the status screen 'icon')
|
// Load the assets JPG (currently just the status screen 'icon')
|
||||||
DWIN_JPG_CacheToN(1, DWIN_MarlinUI_Assets);
|
DWIN_JPG_CacheTo1(DWIN_MarlinUI_Assets);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This LCD should clear where it will draw anew
|
// This LCD should clear where it will draw anew
|
||||||
|
@ -545,8 +545,8 @@ void MarlinUI::draw_status_message(const bool blink) {
|
||||||
|
|
||||||
// Show the location value
|
// Show the location value
|
||||||
dwin_string.set(Z_LBL);
|
dwin_string.set(Z_LBL);
|
||||||
if (!isnan(ubl.z_values[x_plot][y_plot]))
|
if (!isnan(Z_VALUES_ARR[x_plot][y_plot]))
|
||||||
dwin_string.add(ftostr43sign(ubl.z_values[x_plot][y_plot]));
|
dwin_string.add(ftostr43sign(Z_VALUES_ARR[x_plot][y_plot]));
|
||||||
else
|
else
|
||||||
dwin_string.add(PSTR(" -----"));
|
dwin_string.add(PSTR(" -----"));
|
||||||
lcd_moveto(
|
lcd_moveto(
|
||||||
|
|
|
@ -104,7 +104,7 @@ constexpr uint8_t epps = ENCODER_PULSES_PER_STEP;
|
||||||
if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
|
if (backlight) brightness = constrain(value, MIN_LCD_BRIGHTNESS, MAX_LCD_BRIGHTNESS);
|
||||||
// Set brightness on enabled LCD here
|
// Set brightness on enabled LCD here
|
||||||
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
|
TERN_(DWIN_CREALITY_LCD_ENHANCED, DWIN_LCD_Brightness(brightness));
|
||||||
TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_Backlight_SetLuminance(backlight ? brightness : 0));
|
TERN_(DWIN_CREALITY_LCD_JYERSUI, DWIN_LCD_Brightness(backlight ? brightness : 0));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -21,12 +21,11 @@
|
||||||
*/
|
*/
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "../inc/MarlinConfig.h"
|
|
||||||
|
|
||||||
#include "../module/motion.h"
|
#include "../module/motion.h"
|
||||||
|
|
||||||
#include "buttons.h"
|
#include "buttons.h"
|
||||||
|
|
||||||
|
#include "../inc/MarlinConfig.h"
|
||||||
|
|
||||||
#if HAS_BUZZER
|
#if HAS_BUZZER
|
||||||
#include "../libs/buzzer.h"
|
#include "../libs/buzzer.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
#include "SdBaseFile.h"
|
#include "SdBaseFile.h"
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \class SdFile
|
* \class SdFile
|
||||||
|
|
|
@ -10,21 +10,21 @@ set -e
|
||||||
# Build with configs included in the PR
|
# Build with configs included in the PR
|
||||||
#
|
#
|
||||||
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
||||||
opt_enable MARLIN_DEV_MODE BUFFER_MONITORING
|
opt_enable MARLIN_DEV_MODE BUFFER_MONITORING BLTOUCH AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
|
||||||
exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
|
exec_test $1 $2 "Ender 3 v2 with CrealityUI" "$3"
|
||||||
|
|
||||||
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
||||||
opt_disable DWIN_CREALITY_LCD
|
opt_disable DWIN_CREALITY_LCD
|
||||||
opt_enable DWIN_CREALITY_LCD_ENHANCED
|
opt_enable DWIN_CREALITY_LCD_ENHANCED BLTOUCH AUTO_BED_LEVELING_UBL Z_SAFE_HOMING
|
||||||
exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3"
|
exec_test $1 $2 "Ender 3 v2 with Enhanced UI" "$3"
|
||||||
|
|
||||||
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
use_example_configs "Creality/Ender-3 V2/CrealityUI"
|
||||||
opt_disable DWIN_CREALITY_LCD
|
opt_disable DWIN_CREALITY_LCD
|
||||||
opt_enable DWIN_CREALITY_LCD_JYERSUI
|
opt_enable DWIN_CREALITY_LCD_JYERSUI AUTO_BED_LEVELING_BILINEAR PROBE_MANUALLY
|
||||||
exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
|
exec_test $1 $2 "Ender 3 v2 with JyersUI" "$3"
|
||||||
|
|
||||||
use_example_configs "Creality/Ender-3 V2/MarlinUI"
|
use_example_configs "Creality/Ender-3 V2/MarlinUI"
|
||||||
opt_add SDCARD_EEPROM_EMULATION
|
opt_add SDCARD_EEPROM_EMULATION NOZZLE_AS_PROBE AUTO_BED_LEVELING_BILINEAR Z_SAFE_HOMING
|
||||||
exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
|
exec_test $1 $2 "Ender 3 v2 with MarlinUI" "$3"
|
||||||
|
|
||||||
restore_configs
|
restore_configs
|
||||||
|
|
|
@ -44,10 +44,11 @@ HAS_SPI_TFT = src_filter=+<src/HAL/STM32/tft/tft_spi.
|
||||||
I2C_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_i2c.cpp>
|
I2C_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_i2c.cpp>
|
||||||
SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
|
SOFT_I2C_EEPROM = SlowSoftI2CMaster, SlowSoftWire=https://github.com/felias-fogg/SlowSoftWire/archive/master.zip
|
||||||
SPI_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
|
SPI_EEPROM = src_filter=+<src/HAL/shared/eeprom_if_spi.cpp>
|
||||||
|
HAS_DWIN_E3V2|IS_DWIN_MARLINUI = src_filter=+<src/lcd/e3v2/common>
|
||||||
DWIN_CREALITY_LCD = src_filter=+<src/lcd/e3v2/creality>
|
DWIN_CREALITY_LCD = src_filter=+<src/lcd/e3v2/creality>
|
||||||
DWIN_CREALITY_LCD_ENHANCED = src_filter=+<src/lcd/e3v2/enhanced>
|
DWIN_CREALITY_LCD_ENHANCED = src_filter=+<src/lcd/e3v2/enhanced>
|
||||||
DWIN_CREALITY_LCD_JYERSUI = src_filter=+<src/lcd/e3v2/jyersui>
|
DWIN_CREALITY_LCD_JYERSUI = src_filter=+<src/lcd/e3v2/jyersui>
|
||||||
DWIN_MARLINUI_.+ = src_filter=+<src/lcd/e3v2/marlinui>
|
IS_DWIN_MARLINUI = src_filter=+<src/lcd/e3v2/marlinui>
|
||||||
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
|
HAS_GRAPHICAL_TFT = src_filter=+<src/lcd/tft>
|
||||||
IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD>
|
IS_TFTGLCD_PANEL = src_filter=+<src/lcd/TFTGLCD>
|
||||||
HAS_TOUCH_BUTTONS = src_filter=+<src/lcd/touch/touch_buttons.cpp>
|
HAS_TOUCH_BUTTONS = src_filter=+<src/lcd/touch/touch_buttons.cpp>
|
||||||
|
|
|
@ -50,7 +50,7 @@ lib_deps =
|
||||||
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
default_src_filter = +<src/*> -<src/config> -<src/HAL> +<src/HAL/shared>
|
||||||
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
|
-<src/lcd/HD44780> -<src/lcd/TFTGLCD> -<src/lcd/dogm> -<src/lcd/tft> -<src/lcd/tft_io>
|
||||||
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
|
-<src/HAL/STM32/tft> -<src/HAL/STM32F1/tft>
|
||||||
-<src/lcd/e3v2/creality> -<src/lcd/e3v2/enhanced> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
|
-<src/lcd/e3v2/common> -<src/lcd/e3v2/creality> -<src/lcd/e3v2/enhanced> -<src/lcd/e3v2/jyersui> -<src/lcd/e3v2/marlinui>
|
||||||
-<src/lcd/menu>
|
-<src/lcd/menu>
|
||||||
-<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
|
-<src/lcd/menu/game/game.cpp> -<src/lcd/menu/game/brickout.cpp> -<src/lcd/menu/game/invaders.cpp>
|
||||||
-<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>
|
-<src/lcd/menu/game/maze.cpp> -<src/lcd/menu/game/snake.cpp>
|
||||||
|
|
Loading…
Reference in a new issue