
My basic operation system for STM32 MCU
Revision 3:5047e6339308, committed 2019-02-24
- Comitter:
- Hagrid
- Date:
- Sun Feb 24 17:41:44 2019 +0000
- Parent:
- 2:7e5786eb45db
- Commit message:
- Add nextion page and progress bar fce
Changed in this revision
--- a/Nextion/Nextion.cpp Sun Feb 24 07:36:22 2019 +0000 +++ b/Nextion/Nextion.cpp Sun Feb 24 17:41:44 2019 +0000 @@ -5,9 +5,9 @@ void Nextion::setText(char _id[3], char _txt[50]) { - char data[60]; - sprintf(data, "%s.txt=\"%s\"%c%c%c", _id, _txt, 0xff, 0xff, 0xff); - lcd.printf(data); + char _data[60]; + sprintf(_data, "%s.txt=\"%s\"%c%c%c", _id, _txt, 0xff, 0xff, 0xff); + lcd.printf(_data); } void Nextion::init() @@ -16,3 +16,17 @@ lcd.printf("rest%c%c%c", 0xff, 0xff, 0xff); wait(0.2); } + +void Nextion::page(int _page) +{ + char _data[60]; + sprintf(_data, "page %d%c%c%c",_page, 0xff, 0xff, 0xff); + lcd.printf(_data); +} + +void Nextion::setProgress(char _id[3], int _value) +{ + char _data[60]; + sprintf(_data, "%s.val=%d%c%c%c",_id, _value, 0xff, 0xff, 0xff); + lcd.printf(_data); +} \ No newline at end of file
--- a/Nextion/Nextion.h Sun Feb 24 07:36:22 2019 +0000 +++ b/Nextion/Nextion.h Sun Feb 24 17:41:44 2019 +0000 @@ -9,6 +9,8 @@ Nextion(PinName Tx, PinName Rx); void init(); void setText(char _id[3], char _txt[50]); + void page(int _page); + void setProgress(char _id[3], int _value); private: Serial lcd;
--- a/PonyxisOS-lib/PonyxisOS.cpp Sun Feb 24 07:36:22 2019 +0000 +++ b/PonyxisOS-lib/PonyxisOS.cpp Sun Feb 24 17:41:44 2019 +0000 @@ -8,6 +8,10 @@ { _actline = 0; nextion.init(); + nextion.page(0); + nextion.setProgress("j0", 100); + wait(0.5); + nextion.page(1); } void PonyxisOS::print(char *_data)