Browse Source

Adding SW

Per Mårtensson 1 year ago
parent
commit
6611bda4fc
3 changed files with 703 additions and 298 deletions
  1. 9 4
      sw/DC_LOAD/platformio.ini
  2. 531 294
      sw/DC_LOAD/src/main.cpp
  3. 163 0
      sw/DC_LOAD/src/screen.cpp

+ 9 - 4
sw/DC_LOAD/platformio.ini

@@ -10,10 +10,15 @@
 
 [env:nanoatmega328]
 platform = atmelavr
-board = nanoatmega328
-
+board = nanoatmega328new
+board_build.f_cpu = 16000000L
 framework = arduino
-lib_deps =  https://github.com/cyberang3l/NewLiquidCrystal
+lib_deps =  https://git.sweproj.com/IHOLL/EasyNextionLibrary.git#master
             https://github.com/adafruit/Adafruit_MCP4725
             https://github.com/stevemarple/MCP342x
-            https://github.com/Chris--A/Keypad
+        
+
+
+upload_port = /dev/ttyUSB0
+monitor_port = /dev/ttyUSB0
+monitor_speed = 38400

File diff suppressed because it is too large
+ 531 - 294
sw/DC_LOAD/src/main.cpp


+ 163 - 0
sw/DC_LOAD/src/screen.cpp

@@ -0,0 +1,163 @@
+#include <Arduino.h>
+#include "EasyNextionLibrary.h"
+#include <screen.h>
+#include <SoftwareSerial.h>
+extern char line1[21];
+extern char line2[21];
+extern char line3[21];
+extern char line4[21];
+extern char line1_buf[21];
+extern char line2_buf[21];
+extern char line3_buf[21];
+extern char line4_buf[21];
+extern EasyNex myNex;
+
+extern SoftwareSerial nexSerial;
+void writeStr(char *  command, char * txt){ 
+	String _component = String(command);
+	String _strVal = String(txt);
+  if(_component == "cmd"){
+    nexSerial.print(_component);
+    nexSerial.print("\xFF\xFF\xFF");
+    
+  }else if(_component != "cmd"){
+    nexSerial.print(command);
+    nexSerial.print("=\"");
+    nexSerial.print(txt);
+
+    nexSerial.print("\"");
+    nexSerial.print("\xFF\xFF\xFF");
+  }
+}
+void writeNum2(char *  command, uint16_t txt){ 
+	String _component = String(command);
+	String _strVal = String(txt);
+  if(_component == "cmd"){
+    nexSerial.print(_component);
+    nexSerial.print("\xFF\xFF\xFF");
+    
+  }else if(_component != "cmd"){
+    nexSerial.print(command);
+    nexSerial.print("=");
+    nexSerial.print(txt);
+
+    nexSerial.print("\xFF\xFF\xFF");
+  }
+}
+void screen_clear(char empty){
+  memset(line1, empty, 20);
+  memset(line2, empty, 20);
+  memset(line3, empty, 20);
+  memset(line4, empty, 20);
+  writeStr("t0.txt",line1);
+  writeStr("t1.txt",line2);
+  writeStr("t2.txt",line3);
+  writeStr("t3.txt",line4);
+}
+
+void print_chars(int x1,int z, char * text,int len){
+      switch(x1){
+        case 0:
+          memcpy(line1+z,text,len);
+          if (memcmp(line1_buf,line1,20)!=0){
+            writeStr("t0.txt",(char *)line1);
+          }
+          memcpy(line1_buf,line1,20);
+          break;
+        case 1:
+
+          memcpy(line2+z,text,len);
+          if (memcmp(line2_buf,line2,20)){
+            writeStr("t1.txt",line2);
+          }
+          memcpy(line2_buf,line2,20);
+          break;
+        case 2:
+          
+          memcpy(line3+z,text,len);
+          if (memcmp(line3_buf,line3,20)!=0)
+            writeStr("t2.txt",line3);
+          memcpy(line3_buf,line3,20);
+          break;
+        case 3:
+          
+          memcpy(line4+z,text,len);
+          if (memcmp(line4_buf,line4,20)!=0)
+            writeStr("t3.txt",line4);
+          memcpy(line4_buf,line4,20); 
+          break;          
+
+      }
+}
+void print_chars2(int x1,int len){
+      switch(x1){
+        case 0:
+          line1[21]='\0';
+          if (memcmp(line1_buf,line1,20)!=0){
+            writeStr("t0.txt",(line1));
+          }
+          line1[21]='\0';
+          memcpy(line1_buf,line1,21);
+          
+          break;
+        case 1:
+          line2[20]='\0';
+          if (memcmp(line2_buf,line2,20)){
+            writeStr("t1.txt",(line2));
+          }
+          line2[20]='\0';
+          memcpy(line2_buf,line2,21);    
+          break;
+        case 2:
+          line3[20]='\0';
+          if (memcmp(line3_buf,line3,20)!=0)
+            writeStr("t2.txt",(line3));
+          line3[20]='\0';
+          memcpy(line3_buf,line3,21);
+          break;
+        case 3:
+          line4[20]='\0';
+          if (memcmp(line4_buf,line4,20)!=0)
+            writeStr("t3.txt",(line4));
+          line4[20]='\0';
+          memcpy(line4_buf,line4,21); 
+          break;          
+
+      }
+      Serial.flush();
+      Serial.flush();
+      delay(1);
+}
+void print_char(int x1,int z, char text){
+      switch(x1){
+        case 0:
+          
+          line1[z]=text;
+          if (memcmp(line1_buf,line1,20)!=0)
+            writeStr("t0.txt",(char *)line1);
+          memcpy(line1_buf,line1,20);   
+          break;
+        case 1:
+          
+          line2[z]=text;
+          if (memcmp(line2_buf,line2,20)!=0)
+            writeStr("t1.txt",line2);
+          memcpy(line2_buf,line2,20);  
+          break;
+        case 2:
+          
+          line3[z]=text;
+          if (memcmp(line3_buf,line3,20)!=0)  
+            writeStr("t2.txt",line3);
+          memcpy(line3_buf,line3,20);  
+          break;
+        case 3:
+          
+          line4[z]=text;
+          if (memcmp(line4_buf,line4,20)!=0)
+            writeStr("t3.txt",line4);
+          memcpy(line4_buf,line4,20);  
+          break;          
+
+      }
+}

Some files were not shown because too many files changed in this diff