Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Add copy buttons to all
 blocks
(function() {
function addCopyButtons() {
document.querySelectorAll('pre code').forEach(function(codeBlock) {
if (codeBlock.parentElement.hasAttribute('data-copy-added')) return;
codeBlock.parentElement.setAttribute('data-copy-added', 'true');
var btn = document.createElement('button');
btn.textContent = 'Copy';
btn.style.cssText = 'position:absolute;top:4px;right:4px;padding:2px 8px;font-size:11px;background:#4ecdc4;border:none;border-radius:4px;color:#1a1a2e;cursor:pointer;opacity:0.7;transition:opacity 0.2s;';
btn.onmouseover = function() { this.style.opacity = '1'; };
btn.onmouseout = function() { this.style.opacity = '0.7'; };
btn.onclick = function() {
navigator.clipboard.writeText(codeBlock.textContent).then(function() {
btn.textContent = 'Copied!';
setTimeout(function() { btn.textContent = 'Copy'; }, 1500);
});
};
codeBlock.parentElement.style.position = 'relative';
codeBlock.parentElement.appendChild(btn);
});
}
addCopyButtons();
// Re-run on dynamic content
var observer = new MutationObserver(addCopyButtons);
observer.observe(document.body, { childList: true, subtree: true });
})();
}
} catch(__e) { console.warn('[Userscript:Add Copy Buttons to Code Blocks]', __e); }
})();
(function(){
try {
var __m = "github.com";
var __re = new RegExp('^' + "github\\.com" + '
GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Force GitHub README to respect dark mode (function() { var style = document.createElement('style'); style.textContent = ' .markdown-body { color-scheme: dark light; } .markdown-body pre { background: #161b22 !important; } .markdown-body code { background: rgba(110, 118, 129, 0.4) !important; } .markdown-body table th, .markdown-body table td { border-color: #30363d !important; } .markdown-body img { background: #0d1117; } .markdown-body blockquote { border-left-color: #8b949e; } .markdown-body hr { border-color: #30363d; } '; document.head.appendChild(style); })(); } } catch(__e) { console.warn('[Userscript:GitHub Dark Mode README Fix]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Highlight search terms from Google/DuckDuckGo/Bing referrer (function() { var ref = document.referrer; var terms = []; if (ref.includes('google.com') || ref.includes('duckduckgo.com') || ref.includes('bing.com')) { var url = new URL(ref); var q = url.searchParams.get('q') || url.searchParams.get('p'); if (q) { terms = q.split(/\s+/).filter(function(t) { return t.length > 2; }); } } if (terms.length === 0) return; var style = document.createElement('style'); style.textContent = '.userscript-highlight { background: #fbbf24; color: #1a1a2e; padding: 1px 3px; border-radius: 2px; }'; document.head.appendChild(style); function highlight(node) { if (node.nodeType === 3) { // text node var text = node.textContent; var found = false; terms.forEach(function(term) { var regex = new RegExp('(' + term.replace(/[.*+?^${}()|[\]\\]/g, '\\') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ' GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ' GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages

, 'i'); if (__m === '*' || __re.test(location.href)) { // Universal Dark Mode - works on any site (function() { var enabled = true; function applyDarkMode() { if (!enabled) return; // Create style element if it doesn't exist var style = document.getElementById('universal-dark-mode-style'); if (!style) { style = document.createElement('style'); style.id = 'universal-dark-mode-style'; document.head.appendChild(style); } // Dark mode CSS - inverts colors but preserves images/video style.textContent = ' /* Invert everything except media */ html { filter: invert(1) hue-rotate(180deg) !important; background: #1a1a2e !important; } /* Restore images, videos, iframes, canvas */ img, video, iframe, canvas, svg, picture, [style*="background-image"] { filter: invert(1) hue-rotate(180deg) !important; } /* Preserve specific elements that should not be inverted */ .no-dark-mode, .no-dark-mode *, [data-theme="light"], [data-theme="light"], .ace_editor, .ace_editor *, .CodeMirror, .CodeMirror *, .monaco-editor, .monaco-editor *, .markdown-body pre, .markdown-body pre *, .highlight, .highlight *, pre code, pre code * { filter: none !important; } /* Fix common UI elements */ .modal, .popup, .dropdown-menu, .tooltip, .popover { filter: invert(1) hue-rotate(180deg) !important; background: #2d2d44 !important; border-color: #444 !important; } /* Scrollbars */ ::-webkit-scrollbar { background: #1a1a2e !important; } ::-webkit-scrollbar-thumb { background: #444 !important; } ::-webkit-scrollbar-thumb:hover { background: #555 !important; } /* Selection */ ::selection { background: #4ecdc4 !important; color: #1a1a2e !important; } ::-moz-selection { background: #4ecdc4 !important; color: #1a1a2e !important; } '; } function removeDarkMode() { var style = document.getElementById('universal-dark-mode-style'); if (style) style.remove(); } // Toggle with Alt+Shift+D document.addEventListener('keydown', function(e) { if (e.altKey && e.shiftKey && e.key === 'D') { e.preventDefault(); enabled = !enabled; if (enabled) { applyDarkMode(); console.log('[Universal Dark Mode] Enabled'); } else { removeDarkMode(); console.log('[Universal Dark Mode] Disabled'); } } }); // Apply on load applyDarkMode(); // Re-apply on dynamic content var observer = new MutationObserver(function(mutations) { if (enabled && !document.getElementById('universal-dark-mode-style')) { applyDarkMode(); } }); observer.observe(document.head, { childList: true }); console.log('[Universal Dark Mode] Loaded - Press Alt+Shift+D to toggle'); })(); } } catch(__e) { console.warn('[Userscript:Universal Dark Mode]', __e); } })(); })(); GitHub - pervu/DWIN2_Display: Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays · GitHub
Skip to content

Latest commit

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

DWIN2_Display

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays.
It is unofficial library for the DWIN DGUS Displays with extended features for ESP32.
Does not block execution of other code. Sends and receives data as fast as possible.
In the DWIN_Display_Interface folder you will find DGUS project example for the DWIN Display.

DWIN2 Ver. 1.0.2 changes

Added methods:

voidsetVarIcon(constint &icoNum); // to set Variables Icon.voidsetPos(constint &x, constint &y); // to set UI-element position.uint8_tgetVarIconIndex(); // to get current Variables Icon index.

Use

#defineHW_SERIAL_NUM (hw number)

at .h file to change default HardwareSerial number connected to the DWIN display.

DWIN2 Class Methods

// Common methods// Set page numbervoidsetPage(constuint8_t &pageNum);
// Get page numberuint8_tgetPage();
// Set diaplay brightnessvoidsetBrightness(constuint8_t &brightness);
// Get diaplay brightnessuint8_tgetBrightness();
// Restart displayvoidrestartHMI();
// Methods for ui elements// Set the id of the object to be createdvoidsetId(constuint8_t &id);
// Setting a new address for the UI elementvoidsetAddress(constuint16_t &spHexAddr, constuint16_t &vpHexAddr);
// Select the UI type of the display elementvoidsetUiType(constuitype_t &uitype);
// Set the min. and max. values, // delta to increase/decrease the valuevoidsetLimits(constuint32_t &minVal, constuint32_t &maxVal, constbool &loopRotation = false);
// For text data, limits can be calculated automaticallyvoidsetLimits(constbool& loopRotation = true);
// Setting the initial valuevoidsetStartVal(constdouble &currentVal);
// Set a text list of values for UI elementsvoidsetStrListVal(const std::vector<String> listStrVal);
// Set blink rate in millisecondsvoidsetBlinkPeriod(constuint64_t &blinkPeriodMs);
// Setting the called colbeck functionvoidsetUartCbHandler(CallbackFunction f);
// Enable/disable echo modevoidsetEcho(constbool &echo);
// Set color// Overloaded functionvoidsetColor(uint16_t colorHex);
voidsetColor(uicolor_t color);
// Dwin answer
String getDwinEcho();
// Blink ui element.voidblink(constbool &isBlink);
// Hide/unhide UI elementvoidshowUi();
voidhideUi();
// Sending numeric/text values to the display// Overloaded functionvoidsendData(constint &data);
voidsendData(constdouble &data);
voidsendData(const String &data);
// Send the command to the display in Hex formatvoidsendRawCommand(constuint8_t *cmd, constsize_t &cmdLength);
// Increment/decrement the value by a specified delta depending on the direction when calling the methodvoidupdate(constdouble &delta = 1.0, constbool &rightDir = true);
// Clearing the text fieldvoidclearText(uint8_t length = 10);
// Get blink statusboolgetBlinkStatus();
// Get the current value (as a number for int and dbl values and as an index for text values)doublegetCurrentVal();
// Get object IDuint8_tgetId();
// Read data from UI element
String getUiData(constuint8_t &textSize = 10);

DWIN Display QuickStart

#include<Arduino.h>
#include<Dwin2.h>// Rx Tx ESP gpio connected to DWin Display
#defineRX_PIN16
#defineTX_PIN17// Class of controlling UI elements of the displayDWIN2 dwc;
// Callback function to receive a response from the displayvoiddwinEchoCallback(DWIN2 &d);
voidsetup() {
Serial.begin(115200);
while (Serial.available()) {}
Serial.printf("-------- Start DWIN communication demo --------\n");
Serial.printf("-----------------------------------------------\n");
constint d = 1000;
delay(d);
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin Display Common commands start -----\n");
//************ DWIN Display Common commands **************// Init timers, tasks, serial communication and other
dwc.begin();
// Set callback for answer
dwc.setUartCbHandler(dwinEchoCallback);
// Show commands and answers
dwc.setEcho(true);
//---------------------------------------------------------------------------------------- // General commands that refer to the display and not its UI elements// Set/get display pages// Set page
dwc.setPage(2);
delay(d);
dwc.setPage(1);
delay(d);
dwc.setPage(0);
delay(d);
// Get pageuint8_t pageNum = dwc.getPage();
Serial.printf("Current page: %d\n", pageNum);
delay(d);
// Set/get brightness// Set display brightness (Should be from 0 to 127)
dwc.setBrightness(15);
delay(d);
uint8_t brtn = 0;
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Set display brightness
dwc.setBrightness(127);
delay(d);
// Get display current brightness
brtn = dwc.getBrightness();
Serial.printf("Current brightness: %d\n", brtn);
delay(d);
// Send raw command// Set display brightness to 0%constuint8_t rawCmd1[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x00};
// Set display brightness to 100% constuint8_t rawCmd2[] = {0x5A, 0xA5, 0x04, 0x82, 0x00, 0x82, 0x7F}; dwc.sendRawCommand(rawCmd1, sizeof(rawCmd1));
delay(d);
dwc.sendRawCommand(rawCmd2, sizeof(rawCmd2));
delay(d);
//----------------------------------------------------------------------------------------// Restart HMI//dwc.restartHMI();delay(1000);
Serial.printf("----- Dwin Display common commands end -----\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n----- Dwin UI commands start -----\n");
// Set ui adress
dwc.setAddress(0x9000, 0x1000);
// Set ui type of the display elemet communicating with
dwc.setUiType(INT);
// Set text color
dwc.setColor(SKY_BLUE);
delay(d);
// Or set color in DWIN HEX fromat
dwc.setColor(0xFFFF);
// Send data
dwc.sendData(55);
// Set start val. Same as sendData. It is used with update() method. 
dwc.setStartVal(20);
// Set limits for the ui-elements. It will not less then min value, and greater than max value// You also can turn on cycle rotation when value reaches min or max value
dwc.setLimits(10, 50, true);
for (int i = 0; i < 10; i++)
{
// Increment/decrement the value by a given delta depending on the direction
dwc.update(2.0, true);
delay(200);
}
// Get value of the ui-element always return String
String val = dwc.getUiData();
Serial.printf("UI value: %s\n", val);
// Hide ui element
dwc.hideUi();
delay(d);
// Show ui element
dwc.showUi();
delay(d);
// Change ui address
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(UTF); // Set type of the UI element of the dwin display// Send UTF text to display
dwc.sendData("UTF Текст");
//----------------------------------------------------------------------------------------// Change ui address, return it to INT ui
dwc.setAddress(0x9030, 0x1030);
// Set new UI type
dwc.setUiType(INT); // Set type of the UI element of the dwin display// Lets blink it!// Blinking EXAMPLES:// Set blink period
Serial.printf("Blink 200\n");
dwc.setBlinkPeriod(200);
// Start blink
dwc.blink(true);
delay(2000);
// Set other blink period
dwc.setBlinkPeriod(600);
Serial.printf("Blink 800\n");
delay(3000);
// Stop blinking
dwc.blink(false);
delay(d);
//----------------------------------------------------------------------------------------// update() method is good to use with some interrupts,// such as button pushes, encoder rotating, etc.// update() EXAMPLES:// Set ui adress for the ASCII element
dwc.setAddress(0x9020, 0x1020);
// Set ui type of the display elemet communicating with
dwc.setUiType(ASCII);
std::vector<String> asciiList = {"One", "Two", "Three", "Four", "Five"};
dwc.setStrListVal(asciiList);
dwc.setLimits();
// Then set start value as index of the list
dwc.setStartVal(2);
// Simulate encoder rotationfor (int i = 0; i < 10; i++)
{
dwc.update(true);
delay(100);
}
// Set ui adress for the double element
dwc.setAddress(0x9010, 0x1010);
// Set ui type of the display elemet communicating with
dwc.setUiType(DOUBLE);
// Send some int data
dwc.setStartVal(25.8);
dwc.setLimits(10, 50, true);
for (int i = 0; i < 20; i++)
{
dwc.update(0.1, true);
delay(100);
}
delay(d);
Serial.printf("------ Dwin UI commands examples end ------\n");
//----------------------------------------------------------------------------------------
Serial.printf("\n--------------------------------------------------\n");
Serial.printf("-------- DWIN communication demo finished --------\n");
}
voidloop() {
delay(portMAX_DELAY);
}
voiddwinEchoCallback(DWIN2 &d)
{
Serial.print("Echo ");
Serial.println(d.getDwinEcho());
}

About

Advanced ESP32 Libabry for DWIN DGUS T5L HMI Displays

Topics

Resources

Stars

11 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages