Nextion - HMI - 1. zadatak
Dependencies: mbed
Revision 0:66e658666f89, committed 2022-01-15
- Comitter:
- dfraj
- Date:
- Sat Jan 15 08:49:39 2022 +0000
- Child:
- 1:53649f3053fc
- Commit message:
- Nextion - HMI - 1. zadatak
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Sat Jan 15 08:49:39 2022 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+Serial nextion(p28, p27);
+DigitalOut myled1(LED2);
+DigitalOut myled2(LED4);
+
+char buffer[20];
+int znak = 0;
+
+void Rx_interrupt(void){
+ char c;
+ if(nextion.readable()) {
+ c = nextion.getc();
+ buffer[znak] = c;
+ znak++;
+ if ((znak >= 3) && (buffer[znak-1] == 0xff) && (buffer[znak-2] == 0xff) && (buffer[znak-3] == 0xff)) {
+ nextion.printf("\n\r");
+ if (buffer[2] == 0x04){
+ myled1 = buffer[3];
+ }else if (buffer[0] == 0x5A){
+ myled2 = buffer[1] - 48;
+ }
+ memset(buffer,0,strlen(buffer));
+ znak = 0;
+ }
+ }
+}
+
+int main(){
+ nextion.attach(&Rx_interrupt, Serial::RxIrq);
+ while (1) {
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Jan 15 08:49:39 2022 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file