🎨 Consolidate Ender-3 V2 DWIN common code (#22778)
This commit is contained in:
committed by
Scott Lahteine
parent
5b593da04d
commit
e705a7724e
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,11 +15,18 @@
|
||||
* 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
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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"
|
||||
|
||||
#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]) {
|
||||
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);
|
||||
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);
|
||||
}
|
||||
|
||||
inline ENCODER_DiffState get_encoder_state() {
|
||||
inline EncoderState get_encoder_state() {
|
||||
static millis_t Encoder_ms = 0;
|
||||
const millis_t ms = millis();
|
||||
if (PENDING(ms, Encoder_ms)) return ENCODER_DIFF_NO;
|
||||
const ENCODER_DiffState state = Encoder_ReceiveAnalyze();
|
||||
const EncoderState state = Encoder_ReceiveAnalyze();
|
||||
if (state != ENCODER_DIFF_NO) Encoder_ms = ms + ENCODER_WAIT_MS;
|
||||
return state;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
inline bool Apply_Encoder(const ENCODER_DiffState &encoder_diffState, T &valref) {
|
||||
inline bool Apply_Encoder(const EncoderState &encoder_diffState, T &valref) {
|
||||
if (encoder_diffState == ENCODER_DIFF_CW)
|
||||
valref += EncoderRate.encoderMoveValue;
|
||||
else if (encoder_diffState == ENCODER_DIFF_CCW)
|
||||
@ -762,15 +770,15 @@ void update_variable() {
|
||||
// Tune page temperature update
|
||||
#if HAS_HOTEND
|
||||
if (_new_hotend_target)
|
||||
HotendTargetItem->Draw(CurrentMenu->line(HotendTargetItem->pos));
|
||||
HotendTargetItem->draw(CurrentMenu->line(HotendTargetItem->pos));
|
||||
#endif
|
||||
#if HAS_HEATED_BED
|
||||
if (_new_bed_target)
|
||||
BedTargetItem->Draw(CurrentMenu->line(BedTargetItem->pos));
|
||||
BedTargetItem->draw(CurrentMenu->line(BedTargetItem->pos));
|
||||
#endif
|
||||
#if HAS_FAN
|
||||
if (_new_fanspeed)
|
||||
FanSpeedItem->Draw(CurrentMenu->line(FanSpeedItem->pos));
|
||||
FanSpeedItem->draw(CurrentMenu->line(FanSpeedItem->pos));
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -1098,7 +1106,7 @@ void Draw_Print_File_Menu() {
|
||||
|
||||
// Main Process
|
||||
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_CW) {
|
||||
@ -1147,7 +1155,7 @@ void HMI_MainMenu() {
|
||||
|
||||
// Select (and Print) File
|
||||
void HMI_SelectFile() {
|
||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
||||
EncoderState encoder_diffState = get_encoder_state();
|
||||
|
||||
const uint16_t hasUpDir = !card.flag.workDirIsRoot;
|
||||
|
||||
@ -1267,7 +1275,7 @@ void HMI_SelectFile() {
|
||||
|
||||
// Printing
|
||||
void HMI_Printing() {
|
||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
||||
EncoderState encoder_diffState = get_encoder_state();
|
||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||
// Avoid flicker by updating only the previous menu
|
||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
||||
@ -1331,7 +1339,7 @@ void HMI_Printing() {
|
||||
|
||||
// Print done
|
||||
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_ENTER) {
|
||||
dwin_abort_flag = true; // Reset feedrate, return to Home
|
||||
@ -1341,7 +1349,7 @@ void HMI_PrintDone() {
|
||||
|
||||
// Pause or Stop popup
|
||||
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_CW)
|
||||
@ -1404,13 +1412,13 @@ void Draw_Main_Area() {
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
case FilamentPurge: Draw_Popup_FilamentPurge(); break;
|
||||
#endif
|
||||
case Locked: LockScreen.Draw(); break;
|
||||
case Locked: lockScreen.draw(); break;
|
||||
case Menu:
|
||||
case SetInt:
|
||||
case SetPInt:
|
||||
case SetIntNoDraw:
|
||||
case SetFloat:
|
||||
case SetPFloat: CurrentMenu->Draw(); break;
|
||||
case SetPFloat: CurrentMenu->draw(); break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
@ -1423,7 +1431,7 @@ void HMI_ReturnScreen() {
|
||||
}
|
||||
|
||||
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_ENTER) {
|
||||
wait_for_user = false;
|
||||
@ -1560,7 +1568,7 @@ void EachMomentUpdate() {
|
||||
DWIN_UpdateLCD();
|
||||
|
||||
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_ENTER) {
|
||||
recovery_flag = false;
|
||||
@ -1714,7 +1722,7 @@ void Draw_Title(TitleClass* title) {
|
||||
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);
|
||||
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) {
|
||||
@ -1725,7 +1733,7 @@ void Draw_Menu(MenuClass* menu) {
|
||||
|
||||
// Startup routines
|
||||
void DWIN_Startup() {
|
||||
DWINUI::Init();
|
||||
DWINUI::init();
|
||||
DWINUI::onCursorDraw = Draw_Menu_Cursor;
|
||||
DWINUI::onCursorErase = Erase_Menu_Cursor;
|
||||
DWINUI::onTitleDraw = Draw_Title;
|
||||
@ -1890,7 +1898,7 @@ void DWIN_Redraw_screen() {
|
||||
}
|
||||
|
||||
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_CW)
|
||||
Draw_Select_Highlight(false);
|
||||
@ -1910,10 +1918,10 @@ void DWIN_Redraw_screen() {
|
||||
#endif // ADVANCED_PAUSE_FEATURE
|
||||
|
||||
void HMI_LockScreen() {
|
||||
ENCODER_DiffState encoder_diffState = get_encoder_state();
|
||||
EncoderState encoder_diffState = get_encoder_state();
|
||||
if (encoder_diffState == ENCODER_DIFF_NO) return;
|
||||
LockScreen.onEncoderState(encoder_diffState);
|
||||
if (LockScreen.isUnlocked()) {
|
||||
lockScreen.onEncoder(encoder_diffState);
|
||||
if (lockScreen.isUnlocked()) {
|
||||
if (CurrentMenu == AdvancedSettings)
|
||||
Draw_AdvancedSettings_Menu();
|
||||
else
|
||||
@ -1924,7 +1932,7 @@ void HMI_LockScreen() {
|
||||
void DWIN_LockScreen(const bool flag) {
|
||||
HMI_flag.lock_flag = flag;
|
||||
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) {
|
||||
const int32_t value = round(val * POW(10, dp));
|
||||
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
|
||||
@ -2379,7 +2387,7 @@ void LevBedC () { LevBed(4); }
|
||||
planner.synchronize();
|
||||
#ifdef MANUAL_PROBE_START_Z
|
||||
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
|
||||
}
|
||||
|
||||
@ -2395,7 +2403,7 @@ void LevBedC () { LevBed(4); }
|
||||
void ManualMeshContinue(){
|
||||
gcode.process_subcommands_now_P(PSTR("G29S2"));
|
||||
planner.synchronize();
|
||||
MMeshMoveZItem->Draw(CurrentMenu->line(MMeshMoveZItem->pos));
|
||||
MMeshMoveZItem->draw(CurrentMenu->line(MMeshMoveZItem->pos));
|
||||
}
|
||||
|
||||
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) {
|
||||
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) {
|
||||
@ -2928,7 +2936,7 @@ void onDrawStepsZ(MenuItemClass* menuitem, int8_t line) {
|
||||
|
||||
// Generic menu control using the encoder
|
||||
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_ENTER) {
|
||||
if (CurrentMenu != nullptr) CurrentMenu->onClick();
|
||||
@ -2943,7 +2951,7 @@ void HMI_Menu() {
|
||||
// 1 : live change
|
||||
// 2 : apply change
|
||||
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 (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||
EncoderRate.enabled = false;
|
||||
@ -2964,7 +2972,7 @@ int8_t HMI_GetIntNoDraw(const int32_t lo, const int32_t hi) {
|
||||
// 1 : live change
|
||||
// 2 : apply change
|
||||
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 (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||
EncoderRate.enabled = false;
|
||||
@ -3018,16 +3026,16 @@ void HMI_SetPInt() {
|
||||
// 1 : live change
|
||||
// 2 : apply change
|
||||
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 (Apply_Encoder(encoder_diffState, HMI_value.Value)) {
|
||||
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;
|
||||
return 2;
|
||||
}
|
||||
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 0;
|
||||
@ -3098,7 +3106,7 @@ void Draw_Prepare_Menu() {
|
||||
#endif
|
||||
ADDMENUITEM(ICON_Language, PSTR("UI Language"), onDrawLanguage, SetLanguage);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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_C ), onDrawMenuItem, LevBedC );
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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_Info, GET_TEXT(MSG_INFO_SCREEN), onDrawInfoSubMenu, Goto_InfoMenu);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
void Draw_AdvancedSettings_Menu() {
|
||||
@ -3176,7 +3184,7 @@ void Draw_AdvancedSettings_Menu() {
|
||||
#endif
|
||||
ADDMENUITEM(ICON_Lock, F("Lock Screen"), onDrawMenuItem, Goto_LockScreen);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
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_HomeOffsetZ, GET_TEXT(MSG_HOME_OFFSET_Z), onDrawPFloatMenu, SetHomeOffsetZ, &home_offset[Z_AXIS]);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3229,7 +3237,7 @@ void Draw_Move_Menu() {
|
||||
ADDMENUITEM_P(ICON_ProbeOffsetZ, GET_TEXT(MSG_ZPROBE_ZOFFSET), onDrawPFloat2Menu, SetProbeOffsetZ, &probe.offset.z);
|
||||
ADDMENUITEM(ICON_ProbeTest, GET_TEXT(MSG_M48_TEST), onDrawMenuItem, ProbeTest);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#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);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#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, "Coordinate value", onDrawSelColorItem, SelColor, &HMI_data.Coordinate_Color);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
void Draw_GetColor_Menu() {
|
||||
@ -3304,7 +3312,7 @@ void Draw_GetColor_Menu() {
|
||||
ADDMENUITEM(1, "Green", 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);
|
||||
}
|
||||
|
||||
@ -3338,7 +3346,7 @@ void Draw_Tune_Menu() {
|
||||
ADDMENUITEM_P(ICON_Brightness, F("LCD Brightness"), onDrawPInt8Menu, SetBrightness, &ui.brightness);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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_P(ICON_Flow, GET_TEXT(MSG_FLOW), onDrawPIntMenu, SetFlow, &planner.flow_percentage[0]);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
@ -3376,7 +3384,7 @@ void Draw_Motion_Menu() {
|
||||
ADDMENUITEM(ICON_FilLoad, GET_TEXT(MSG_FILAMENTLOAD), onDrawMenuItem, LoadFilament);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3394,7 +3402,7 @@ void Draw_Motion_Menu() {
|
||||
ADDMENUITEM(ICON_Axis, GET_TEXT(MSG_UBL_CONTINUE_MESH), onDrawMenuItem, ManualMeshContinue);
|
||||
ADDMENUITEM(ICON_MeshSave, GET_TEXT(MSG_UBL_SAVE_MESH), onDrawMenuItem, ManualMeshSave);
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3420,7 +3428,7 @@ void Draw_Motion_Menu() {
|
||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawWriteEeprom, WriteEeprom);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
void Draw_Preheat1_Menu() {
|
||||
@ -3471,7 +3479,7 @@ void Draw_Temperature_Menu() {
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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]);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
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]);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
#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]);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#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]);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
|
||||
#if HAS_HOTEND
|
||||
@ -3567,7 +3575,7 @@ void Draw_Steps_Menu() {
|
||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3590,7 +3598,7 @@ void Draw_Steps_Menu() {
|
||||
ADDMENUITEM(ICON_WriteEEPROM, GET_TEXT(MSG_STORE_EEPROM), onDrawMenuItem, WriteEeprom);
|
||||
#endif
|
||||
}
|
||||
CurrentMenu->Draw();
|
||||
CurrentMenu->draw();
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -3607,7 +3615,7 @@ void Draw_Steps_Menu() {
|
||||
ADDMENUITEM(ICON_MoveZ0, F("Move Z to Home"), onDrawMenuItem, SetMoveZto0);
|
||||
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"));
|
||||
}
|
||||
#endif
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,15 +15,22 @@
|
||||
* 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
|
||||
* 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
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/09/08
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
#include "dwinui.h"
|
||||
#include "rotary_encoder.h"
|
||||
#include "../common/encoder.h"
|
||||
#include "../../../libs/BL24CXX.h"
|
||||
|
||||
#if ANY(HAS_HOTEND, HAS_HEATED_BED, HAS_FAN) && PREHEAT_COUNT
|
||||
@ -79,11 +87,6 @@ enum pidresult_t : uint8_t {
|
||||
PID_DONE
|
||||
};
|
||||
|
||||
// Picture ID
|
||||
#define Start_Process 0
|
||||
#define Language_English 1
|
||||
#define Language_Chinese 2
|
||||
|
||||
#define DWIN_CHINESE 123
|
||||
#define DWIN_ENGLISH 0
|
||||
|
||||
@ -120,12 +123,16 @@ typedef struct {
|
||||
uint16_t Barfill_Color = Def_Barfill_Color;
|
||||
uint16_t Indicator_Color = Def_Indicator_Color;
|
||||
uint16_t Coordinate_Color = Def_Coordinate_Color;
|
||||
TERN_(HAS_HOTEND, int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND);
|
||||
TERN_(HAS_HOTEND, int16_t PidCycles = 10);
|
||||
#if HAS_HOTEND
|
||||
int16_t HotendPidT = PREHEAT_1_TEMP_HOTEND;
|
||||
int16_t PidCycles = 10;
|
||||
#endif
|
||||
#ifdef PREHEAT_1_TEMP_BED
|
||||
int16_t BedPidT = PREHEAT_1_TEMP_BED;
|
||||
#endif
|
||||
TERN_(PREVENT_COLD_EXTRUSION, int16_t ExtMinT = EXTRUDE_MINTEMP);
|
||||
#if ENABLED(PREVENT_COLD_EXTRUSION)
|
||||
int16_t ExtMinT = EXTRUDE_MINTEMP;
|
||||
#endif
|
||||
} HMI_data_t;
|
||||
|
||||
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
|
||||
void DWIN_Popup_Temperature(const bool toohigh);
|
||||
#endif
|
||||
TERN_(HAS_HOTEND, void Popup_Window_ETempTooLow());
|
||||
#if HAS_HOTEND
|
||||
void Popup_Window_ETempTooLow();
|
||||
#endif
|
||||
void Popup_Window_Resume();
|
||||
|
||||
// SD Card
|
||||
@ -179,7 +188,6 @@ void HMI_AudioFeedback(const bool success=true);
|
||||
void EachMomentUpdate();
|
||||
void update_variable();
|
||||
void DWIN_HandleScreen();
|
||||
void DWIN_Startup();
|
||||
void DWIN_Update();
|
||||
void DWIN_DrawStatusLine(const uint16_t color, const uint16_t bgcolor, const char *text);
|
||||
void DWIN_StatusChanged(const char * const text);
|
||||
@ -229,27 +237,41 @@ void Draw_AdvancedSettings_Menu();
|
||||
void Draw_Prepare_Menu();
|
||||
void Draw_Move_Menu();
|
||||
void Draw_LevBedCorners_Menu();
|
||||
TERN_(HAS_HOME_OFFSET, void Draw_HomeOffset_Menu());
|
||||
TERN_(HAS_BED_PROBE, void Draw_ProbeSet_Menu());
|
||||
TERN_(HAS_FILAMENT_SENSOR, void Draw_FilSet_Menu());
|
||||
#if HAS_HOME_OFFSET
|
||||
void Draw_HomeOffset_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_GetColor_Menu();
|
||||
void Draw_Tune_Menu();
|
||||
void Draw_Motion_Menu();
|
||||
TERN_(ADVANCED_PAUSE_FEATURE, void Draw_FilamentMan_Menu());
|
||||
TERN_(MESH_BED_LEVELING, void Draw_ManualMesh_Menu());
|
||||
#if ENABLED(ADVANCED_PAUSE_FEATURE)
|
||||
void Draw_FilamentMan_Menu();
|
||||
#endif
|
||||
#if ENABLED(MESH_BED_LEVELING)
|
||||
void Draw_ManualMesh_Menu();
|
||||
#endif
|
||||
#if HAS_HOTEND
|
||||
void Draw_Preheat1_Menu();
|
||||
void Draw_Preheat2_Menu();
|
||||
void Draw_Preheat3_Menu();
|
||||
void Draw_HotendPID_Menu();
|
||||
#endif
|
||||
void Draw_Temperature_Menu();
|
||||
void Draw_MaxSpeed_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();
|
||||
TERN_(HAS_HOTEND, void Draw_HotendPID_Menu());
|
||||
TERN_(HAS_HEATED_BED, void Draw_BedPID_Menu());
|
||||
#if HAS_HEATED_BED
|
||||
void Draw_BedPID_Menu();
|
||||
#endif
|
||||
#if EITHER(HAS_BED_PROBE, BABYSTEPPING)
|
||||
void Draw_ZOffsetWiz_Menu();
|
||||
#endif
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,18 +15,17 @@
|
||||
* 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
|
||||
* 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/enhanced/dwin_lcd.cpp
|
||||
* @author LEO / Creality3D - Enhanced by Miguel A. Risco-Castillo
|
||||
* @date 2021/09/08
|
||||
* @version 2.2.1
|
||||
* @brief DWIN screen control functions
|
||||
********************************************************************************/
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/09/08
|
||||
*/
|
||||
|
||||
#include "../../../inc/MarlinConfigPre.h"
|
||||
|
||||
@ -34,297 +34,6 @@
|
||||
#include "../../../inc/MarlinConfig.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 ----------------------------------------*/
|
||||
|
||||
@ -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, y);
|
||||
DWIN_Byte(i, QR_Pixel);
|
||||
DWIN_String(i, string);
|
||||
DWIN_Text(i, string);
|
||||
DWIN_Send(i);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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)
|
||||
// Draw an Icon with transparent background
|
||||
// libID: Icon library ID
|
||||
// picID: Icon ID
|
||||
// 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) {
|
||||
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%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);
|
||||
void DWIN_ICON_Show(uint8_t libID, uint8_t picID, uint16_t x, uint16_t y) {
|
||||
DWIN_ICON_Show(false, false, true, libID, picID, x, y);
|
||||
}
|
||||
|
||||
// Copy area from current virtual display area to current screen
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||
void DWIN_Frame_AreaCopy(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, 0x26);
|
||||
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
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// 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,
|
||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y) {
|
||||
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) {
|
||||
size_t i = 0;
|
||||
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, yStart);
|
||||
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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
// 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);
|
||||
// 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
|
||||
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(false, false, true, cacheID, xStart, yStart, xEnd, yEnd, x, y);
|
||||
}
|
||||
|
||||
// Write buffer data to the SRAM or Flash
|
||||
@ -524,47 +147,14 @@ void DWIN_SRAMToPic(uint8_t picID) {
|
||||
|
||||
//--------------------------Test area -------------------------
|
||||
|
||||
// void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
||||
// size_t i = 0;
|
||||
// DWIN_Byte(i, 0x32);
|
||||
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
||||
// DWIN_Word(i, addr); // 0x0000 to 0x7FFF
|
||||
// const size_t len = _MIN(0xF0, length);
|
||||
// DWIN_Byte(i, len);
|
||||
// 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
|
||||
//void DWIN_ReadSRAM(uint16_t addr, uint8_t length, const char * const data) {
|
||||
// size_t i = 0;
|
||||
// DWIN_Byte(i, 0x32);
|
||||
// DWIN_Byte(i, 0x5A); // 0x5A Read from SRAM - 0xA5 Read from Flash
|
||||
// DWIN_Word(i, addr); // 0x0000 to 0x7FFF
|
||||
// const size_t len = _MIN(0xF0, length);
|
||||
// DWIN_Byte(i, len);
|
||||
// DWIN_Send(i);
|
||||
//}
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,169 +15,20 @@
|
||||
* 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
|
||||
* 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/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
|
||||
|
||||
#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
|
||||
#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 ----------------------------------------*/
|
||||
#include "../common/dwin_api.h"
|
||||
|
||||
// Display QR code
|
||||
// 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);
|
||||
}
|
||||
|
||||
// Draw JPG and cached in #0 virtual display area
|
||||
// id: Picture ID
|
||||
void DWIN_JPG_ShowAndCache(const uint8_t 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);
|
||||
|
||||
// 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(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 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);
|
||||
|
||||
// Copy area from current virtual display area to current screen
|
||||
// xStart/yStart: Upper-left of virtual area
|
||||
// xEnd/yEnd: Lower-right of virtual area
|
||||
// x/y: Screen paste point
|
||||
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
||||
uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||
void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart, uint16_t xEnd, uint16_t yEnd, uint16_t x, uint16_t y);
|
||||
|
||||
// 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
|
||||
@ -242,36 +69,7 @@ void DWIN_Frame_AreaCopy(uint16_t xStart, uint16_t yStart,
|
||||
// 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 IBD, uint8_t BIR, uint8_t BFI, uint8_t cacheID, uint16_t xStart, uint16_t yStart,
|
||||
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);
|
||||
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);
|
||||
|
||||
// Write buffer data to the SRAM or Flash
|
||||
// mem: 0x5A=32KB SRAM, 0xA5=16KB Flash
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/08/09
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,11 +15,18 @@
|
||||
* 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
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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"
|
||||
|
||||
#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::onMenuDraw)(MenuClass* menu)=nullptr;
|
||||
|
||||
void DWINUI::Init(void) {
|
||||
void DWINUI::init() {
|
||||
DEBUG_ECHOPGM("\r\nDWIN handshake ");
|
||||
delay(750); // Delay here or init later in the boot process
|
||||
const bool success = DWIN_Handshake();
|
||||
@ -65,12 +73,12 @@ void DWINUI::Init(void) {
|
||||
}
|
||||
|
||||
// Set text/number font
|
||||
void DWINUI::SetFont(uint8_t cfont) {
|
||||
void DWINUI::setFont(uint8_t cfont) {
|
||||
font = cfont;
|
||||
}
|
||||
|
||||
// Get font character width
|
||||
uint8_t DWINUI::Get_font_width(uint8_t cfont) {
|
||||
uint8_t DWINUI::fontWidth(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 6;
|
||||
case font8x16 : return 8;
|
||||
@ -87,7 +95,7 @@ uint8_t DWINUI::Get_font_width(uint8_t cfont) {
|
||||
}
|
||||
|
||||
// Get font character heigh
|
||||
uint8_t DWINUI::Get_font_height(uint8_t cfont) {
|
||||
uint8_t DWINUI::fontHeight(uint8_t cfont) {
|
||||
switch (cfont) {
|
||||
case font6x12 : return 12;
|
||||
case font8x16 : return 16;
|
||||
@ -105,12 +113,12 @@ uint8_t DWINUI::Get_font_height(uint8_t cfont) {
|
||||
|
||||
// Get screen x coodinates from text column
|
||||
uint16_t DWINUI::ColToX(uint8_t col) {
|
||||
return col * Get_font_width(font);
|
||||
return col * fontWidth(font);
|
||||
}
|
||||
|
||||
// Get screen y coodinates from text row
|
||||
uint16_t DWINUI::RowToY(uint8_t row) {
|
||||
return row * Get_font_height(font);
|
||||
return row * fontHeight(font);
|
||||
}
|
||||
|
||||
// Set text/number color
|
||||
@ -151,7 +159,7 @@ void DWINUI::MoveBy(xy_int_t point) {
|
||||
|
||||
// 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) {
|
||||
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);
|
||||
}
|
||||
|
||||
@ -159,7 +167,7 @@ void DWINUI::Draw_CenteredString(bool bShow, uint8_t size, uint16_t color, uint1
|
||||
void DWINUI::Draw_Char(const char c) {
|
||||
const char string[2] = { c, 0};
|
||||
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
|
||||
@ -168,11 +176,11 @@ void DWINUI::Draw_Char(const char c) {
|
||||
// rlimit: For draw less chars than string length use 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);
|
||||
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) {
|
||||
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
|
||||
@ -186,14 +194,8 @@ void DWINUI::Draw_String(uint16_t color, const char * const string, uint16_t rli
|
||||
// x/y: Upper-left point
|
||||
// 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) {
|
||||
if (value < 0) {
|
||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, -value);
|
||||
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);
|
||||
}
|
||||
DWIN_Draw_FloatValue(bShow, zeroFill, zeroMode, size, color, bColor, iNum, fNum, x, y, value < 0 ? -value : value);
|
||||
DWIN_Draw_String(bShow, size, color, bColor, x - 6, y, value < 0 ? F("-") : F(" "));
|
||||
}
|
||||
|
||||
// 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
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
// color1 : Start color
|
||||
// color2 : End color
|
||||
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
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
uint16_t DWINUI::RainbowInt(int16_t val, int16_t minv, int16_t maxv) {
|
||||
uint8_t B,G,R;
|
||||
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
|
||||
// mode : 0 : unchecked, 1 : checked
|
||||
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);
|
||||
}
|
||||
|
||||
@ -332,7 +334,7 @@ MenuItemClass* DWINUI::MenuItemsAdd(MenuItemClass* menuitem) {
|
||||
|
||||
TitleClass Title;
|
||||
|
||||
void TitleClass::Draw() {
|
||||
void TitleClass::draw() {
|
||||
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) {
|
||||
SetCaption(title);
|
||||
Draw();
|
||||
draw();
|
||||
}
|
||||
|
||||
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) {
|
||||
SetFrame(id, x1, y1, x2, y2);
|
||||
Draw();
|
||||
draw();
|
||||
}
|
||||
|
||||
void TitleClass::FrameCopy(uint16_t x, uint16_t y, uint16_t w, uint16_t h) {
|
||||
@ -375,11 +377,11 @@ MenuClass::MenuClass() {
|
||||
topline = 0;
|
||||
}
|
||||
|
||||
void MenuClass::Draw() {
|
||||
MenuTitle.Draw();
|
||||
void MenuClass::draw() {
|
||||
MenuTitle.draw();
|
||||
if (DWINUI::onMenuDraw != nullptr) (*DWINUI::onMenuDraw)(this);
|
||||
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());
|
||||
DWIN_UpdateLCD();
|
||||
}
|
||||
@ -393,12 +395,12 @@ void MenuClass::onScroll(bool dir) {
|
||||
if ((sel - topline) == TROWS) {
|
||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_UP, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||
topline++;
|
||||
MenuItems[sel]->Draw(TROWS - 1);
|
||||
MenuItems[sel]->draw(TROWS - 1);
|
||||
}
|
||||
if ((sel < topline)) {
|
||||
DWIN_Frame_AreaMove(1, DWIN_SCROLL_DOWN, MLINE, DWINUI::backcolor, 0, TITLE_HEIGHT + 1, DWIN_WIDTH, STATUS_Y - 1);
|
||||
topline--;
|
||||
MenuItems[sel]->Draw(0);
|
||||
MenuItems[sel]->draw(0);
|
||||
}
|
||||
selected = sel;
|
||||
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 };
|
||||
}
|
||||
|
||||
void MenuItemClass::Draw(int8_t line) {
|
||||
void MenuItemClass::draw(int8_t line) {
|
||||
if (line < 0 || line >= TROWS) return;
|
||||
if (onDraw != nullptr) (*onDraw)(this, line);
|
||||
};
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/08/09
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,117 +15,26 @@
|
||||
* 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
|
||||
* 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
|
||||
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.3
|
||||
* Date: 2021/09/08
|
||||
*/
|
||||
|
||||
#include "../../../core/types.h"
|
||||
#include "dwin_lcd.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_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
|
||||
#include "../common/dwin_set.h"
|
||||
#include "../common/dwin_font.h"
|
||||
#include "../common/dwin_color.h"
|
||||
|
||||
// Extra Icons
|
||||
#define ICON_AdvSet ICON_Language
|
||||
#define ICON_Brightness ICON_Motion
|
||||
#define ICON_Cancel ICON_StockConfiguration
|
||||
#define ICON_CustomPreheat ICON_SetEndTemp
|
||||
@ -135,10 +45,6 @@
|
||||
#define ICON_FilSet ICON_ResumeEEPROM
|
||||
#define ICON_FilUnload ICON_ReadEEPROM
|
||||
#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_Lock ICON_Cool
|
||||
#define ICON_ManualMesh ICON_HotendTemp
|
||||
@ -146,13 +52,8 @@
|
||||
#define ICON_MeshSave ICON_WriteEEPROM
|
||||
#define ICON_MoveZ0 ICON_HotendTemp
|
||||
#define ICON_Park ICON_Motion
|
||||
#define ICON_PIDbed ICON_SetBedTemp
|
||||
#define ICON_PIDcycles ICON_ResumeEEPROM
|
||||
#define ICON_PIDNozzle ICON_SetEndTemp
|
||||
#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_ProbeTest ICON_SetEndTemp
|
||||
#define ICON_Pwrlossr ICON_Motion
|
||||
@ -162,47 +63,6 @@
|
||||
#define ICON_SetCustomPreheat ICON_SetEndTemp
|
||||
#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
|
||||
#define Def_Background_Color Color_Bg_Black
|
||||
#define Def_Cursor_color Rectangle_Color
|
||||
@ -223,7 +83,7 @@
|
||||
#define Def_Indicator_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_STAT font10x20
|
||||
#define DWIN_FONT_HEAD font10x20
|
||||
@ -262,7 +122,7 @@ public:
|
||||
char caption[32] = "";
|
||||
uint8_t frameid = 0;
|
||||
rect_t frame = {0};
|
||||
void Draw();
|
||||
void draw();
|
||||
void SetCaption(const char * const title);
|
||||
inline void SetCaption(const __FlashStringHelper * title) { SetCaption((char *)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);
|
||||
void SetFrame(uint8_t id, uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2);
|
||||
virtual ~MenuItemClass(){};
|
||||
virtual void Draw(int8_t line);
|
||||
virtual void draw(int8_t line);
|
||||
};
|
||||
|
||||
class MenuItemPtrClass: public MenuItemClass {
|
||||
@ -310,7 +170,7 @@ public:
|
||||
virtual ~MenuClass(){};
|
||||
inline int8_t line() { return selected - topline; };
|
||||
inline int8_t line(uint8_t pos) {return pos - topline; };
|
||||
void Draw();
|
||||
void draw();
|
||||
void onScroll(bool dir);
|
||||
void onClick();
|
||||
MenuItemClass* SelectedItem();
|
||||
@ -330,16 +190,16 @@ namespace DWINUI {
|
||||
extern void (*onMenuDraw)(MenuClass* menu);
|
||||
|
||||
// DWIN LCD Initialization
|
||||
void Init(void);
|
||||
void init();
|
||||
|
||||
// Set text/number font
|
||||
void SetFont(uint8_t cfont);
|
||||
void setFont(uint8_t cfont);
|
||||
|
||||
// Get font character width
|
||||
uint8_t Get_font_width(uint8_t cfont);
|
||||
uint8_t fontWidth(uint8_t cfont);
|
||||
|
||||
// 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
|
||||
uint16_t ColToX(uint8_t col);
|
||||
@ -398,7 +258,7 @@ namespace DWINUI {
|
||||
}
|
||||
inline void Draw_Int(uint8_t iNum, long 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) {
|
||||
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) {
|
||||
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) {
|
||||
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);
|
||||
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);
|
||||
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) {
|
||||
Draw_Signed_Float(false, true, 0, font, textcolor, backcolor, iNum, fNum, x, y, value);
|
||||
@ -548,7 +408,7 @@ namespace DWINUI {
|
||||
|
||||
// Draw a circle
|
||||
// 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
|
||||
// r: circle radius
|
||||
void Draw_Circle(uint16_t color, uint16_t x,uint16_t y,uint8_t r);
|
||||
@ -569,7 +429,7 @@ namespace DWINUI {
|
||||
// Color Interpolator
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
// color1 : Start color
|
||||
// color2 : End color
|
||||
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
|
||||
// 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
|
||||
// r: circle radius
|
||||
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
|
||||
// val : Interpolator minv..maxv
|
||||
// minv : Minimum value
|
||||
// maxv : Maximun value
|
||||
// maxv : Maximum value
|
||||
uint16_t RainbowInt(int16_t val, int16_t minv, int16_t maxv);
|
||||
|
||||
// Write buffer data to the SRAM
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,11 +15,18 @@
|
||||
* 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
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* 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"
|
||||
|
||||
#if ENABLED(DWIN_CREALITY_LCD_ENHANCED)
|
||||
@ -29,15 +37,18 @@
|
||||
#include "dwin.h"
|
||||
#include "lockscreen.h"
|
||||
|
||||
LockScreenClass LockScreen;
|
||||
LockScreenClass lockScreen;
|
||||
|
||||
void LockScreenClass::Init() {
|
||||
Lock_Pos = 0;
|
||||
uint8_t LockScreenClass::lock_pos = 0;
|
||||
bool LockScreenClass::unlocked = false;
|
||||
|
||||
void LockScreenClass::init() {
|
||||
lock_pos = 0;
|
||||
unlocked = false;
|
||||
Draw();
|
||||
draw();
|
||||
}
|
||||
|
||||
void LockScreenClass::Draw() {
|
||||
void LockScreenClass::draw() {
|
||||
Title.SetCaption(PSTR("Lock Screen"));
|
||||
DWINUI::ClearMenuArea();
|
||||
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, 240, F("-> | <-"));
|
||||
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();
|
||||
}
|
||||
|
||||
void LockScreenClass::onEncoderState(ENCODER_DiffState encoder_diffState) {
|
||||
if (encoder_diffState == ENCODER_DIFF_CW) {
|
||||
Lock_Pos += 8;
|
||||
}
|
||||
else if (encoder_diffState == ENCODER_DIFF_CCW) {
|
||||
Lock_Pos -= 8;
|
||||
}
|
||||
else if (encoder_diffState == ENCODER_DIFF_ENTER) {
|
||||
unlocked = (Lock_Pos == 128);
|
||||
void LockScreenClass::onEncoder(EncoderState encoder_diffState) {
|
||||
switch (encoder_diffState) {
|
||||
case ENCODER_DIFF_CW: lock_pos += 8; break;
|
||||
case ENCODER_DIFF_CCW: lock_pos -= 8; break;
|
||||
case ENCODER_DIFF_ENTER: unlocked = (lock_pos == 128); break;
|
||||
default: break;
|
||||
}
|
||||
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();
|
||||
}
|
||||
|
||||
bool LockScreenClass::isUnlocked() { return unlocked; }
|
||||
|
||||
#endif // DWIN_CREALITY_LCD_ENHANCED
|
||||
|
@ -1,12 +1,13 @@
|
||||
/**
|
||||
* DWIN UI Enhanced implementation
|
||||
* Author: Miguel A. Risco-Castillo
|
||||
* Version: 3.6.1
|
||||
* Date: 2021/08/29
|
||||
* 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 Lesser General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the License, or
|
||||
* 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,
|
||||
@ -14,22 +15,31 @@
|
||||
* 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
|
||||
* 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 "../../../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 {
|
||||
private:
|
||||
uint8_t Lock_Pos = 0;
|
||||
bool unlocked = false;
|
||||
static bool unlocked;
|
||||
static uint8_t lock_pos;
|
||||
public:
|
||||
void Init();
|
||||
void onEncoderState(ENCODER_DiffState encoder_diffState);
|
||||
void Draw();
|
||||
bool isUnlocked();
|
||||
static void init();
|
||||
static void onEncoder(EncoderState encoder_diffState);
|
||||
static void draw();
|
||||
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
|
Reference in New Issue
Block a user