Skip to content

Commit

Permalink
Merge pull request #2 from dwinhmi/dev
Browse files Browse the repository at this point in the history
Added Buzzer Beep Functionality. Fixed Restart CMD
  • Loading branch information
dwinhmi authored May 8, 2023
2 parents 246cfcd + d13caa2 commit 14e36c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Supporting Features till date.
- setBrightness()
- getBrightness()
- setVP()
- setText()
- beepHMI()
- listenEvents()

## Usage
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=DWIN_DGUS_HMI
version=1.1.1
version=1.1.2
author=Tejeet Magar
maintainer=Tejeet Magar <[email protected]>
sentence=DWIN DGUS HMI Display
Expand Down
24 changes: 16 additions & 8 deletions src/DWIN.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@




void DWIN::init(Stream* port, bool isSoft){
this->_dwinSerial = port;
this->_isSoft = isSoft;
Expand All @@ -66,7 +65,7 @@ double DWIN::getHWVersion(){ // HEX(5A A5 04 83 00 0F 01)

// Restart DWIN HMI
void DWIN::restartHMI(){ // HEX(5A A5 07 82 00 04 55 aa 5a a5 )
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x07, CMD_WRITE, 0x04, 0x55, 0xaa, CMD_HEAD1, CMD_HEAD2};
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x07, CMD_WRITE, 0x00, 0x04, 0x55, 0xaa, CMD_HEAD1, CMD_HEAD2};
_dwinSerial->write(sendBuffer, sizeof(sendBuffer));
delay(10);
readDWIN();
Expand Down Expand Up @@ -94,6 +93,13 @@ void DWIN::setPage(byte page){
readDWIN();
}

// Get Current Page ID
byte DWIN::getPage(){
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x04, CMD_READ, 0x00 , 0x14, 0x01};
_dwinSerial->write(sendBuffer, sizeof(sendBuffer));
return readCMDLastByte();
}

// Set Text on VP Address
void DWIN::setText(long address, String textData){

Expand All @@ -110,21 +116,23 @@ void DWIN::setText(long address, String textData){
readDWIN();
}

// Set Text on VP Address
// Set Data on VP Address
void DWIN::setVP(long address, byte data){
// 0x5A, 0xA5, 0x05, 0x82, 0x40, 0x20, 0x00, state
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x05 , CMD_WRITE, (address >> 8) & 0xFF, (address) & 0xFF, 0x00, data};
_dwinSerial->write(sendBuffer, sizeof(sendBuffer));
readDWIN();
}

// Get Current Page ID
byte DWIN::getPage(){
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x04, CMD_READ, 0x00 , 0x14, 0x01};
_dwinSerial->write(sendBuffer, sizeof(sendBuffer));
return readCMDLastByte();
// beep Buzzer for 1 Sec
void DWIN::beepHMI(){
// 0x5A, 0xA5, 0x05, 0x82, 0x00, 0xA0, 0x00, 0x7D
byte sendBuffer[] = {CMD_HEAD1, CMD_HEAD2, 0x05 , CMD_WRITE, 0x00, 0xA0, 0x00, 0x7D};
_dwinSerial->write(sendBuffer, sizeof(sendBuffer));
readDWIN();
}


// SET CallBack Event
void DWIN::hmiCallBack(hmiListner callBack){
listnerCallback = callBack;
Expand Down
10 changes: 6 additions & 4 deletions src/DWIN.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,18 @@ class DWIN{
void restartHMI();
// set Perticulat Page
void setPage(byte pageID);
// set Text on VP Address
void setText(long address, String textData);
// set Byte on VP Address
void setVP(long address, byte data);
// get Current Page ID
byte getPage();
// set LCD Brightness
void setBrightness(byte pConstrast);
// set LCD Brightness
byte getBrightness();
// set Data on VP Address
void setText(long address, String textData);
// set Byte on VP Address
void setVP(long address, byte data);
// beep Buzzer for 1 sec
void beepHMI();
// Callback Function
typedef void (*hmiListner) (String address, int lastByte, String messege, String response);

Expand Down

0 comments on commit 14e36c3

Please sign in to comment.