Forráskód Böngészése

Merge branch 'master' of https://git.sweproj.com/sweproj.com/DC_Load

Per Mårtensson 1 hónapja
szülő
commit
1909cd6120

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 108 - 583
Electronic_DC_Load.kicad_pcb


+ 1 - 1
Electronic_DC_Load.kicad_prl

@@ -1,6 +1,6 @@
 {
   "board": {
-    "active_layer": 0,
+    "active_layer": 31,
     "active_layer_preset": "",
     "auto_track_width": true,
     "hidden_netclasses": [],

+ 15 - 11
Electronic_DC_Load.kicad_pro

@@ -7,13 +7,13 @@
         "apply_defaults_to_fp_shapes": false,
         "apply_defaults_to_fp_text": false,
         "board_outline_line_width": 0.15,
-        "copper_line_width": 0.19999999999999998,
+        "copper_line_width": 0.2,
         "copper_text_italic": false,
         "copper_text_size_h": 1.5,
         "copper_text_size_v": 1.5,
         "copper_text_thickness": 0.3,
         "copper_text_upright": false,
-        "courtyard_line_width": 0.049999999999999996,
+        "courtyard_line_width": 0.05,
         "dimension_precision": 4,
         "dimension_units": 3,
         "dimensions": {
@@ -24,13 +24,13 @@
           "text_position": 0,
           "units_format": 1
         },
-        "fab_line_width": 0.09999999999999999,
+        "fab_line_width": 0.1,
         "fab_text_italic": false,
         "fab_text_size_h": 1.0,
         "fab_text_size_v": 1.0,
         "fab_text_thickness": 0.15,
         "fab_text_upright": false,
-        "other_line_width": 0.09999999999999999,
+        "other_line_width": 0.1,
         "other_text_italic": false,
         "other_text_size_h": 1.0,
         "other_text_size_v": 1.0,
@@ -52,7 +52,11 @@
         }
       },
       "diff_pair_dimensions": [],
-      "drc_exclusions": [],
+      "drc_exclusions": [
+        "courtyards_overlap|131249999|77747999|00000000-0000-0000-0000-0000594d371d|00000000-0000-0000-0000-0000594d3777",
+        "courtyards_overlap|160453999|103625999|00000000-0000-0000-0000-0000594d3783|00000000-0000-0000-0000-00005a45827e",
+        "courtyards_overlap|160453999|121405999|00000000-0000-0000-0000-0000594d3789|00000000-0000-0000-0000-00005a458284"
+      ],
       "meta": {
         "filename": "board_design_settings.json",
         "version": 2
@@ -115,16 +119,16 @@
         "min_copper_edge_clearance": 0.075,
         "min_hole_clearance": 0.25,
         "min_hole_to_hole": 0.25,
-        "min_microvia_diameter": 0.19999999999999998,
-        "min_microvia_drill": 0.09999999999999999,
+        "min_microvia_diameter": 0.2,
+        "min_microvia_drill": 0.1,
         "min_resolved_spokes": 2,
         "min_silk_clearance": 0.0,
-        "min_text_height": 0.7999999999999999,
+        "min_text_height": 0.8,
         "min_text_thickness": 0.08,
         "min_through_hole_diameter": 0.3,
-        "min_track_width": 0.19999999999999998,
-        "min_via_annular_width": 0.09999999999999999,
-        "min_via_diameter": 0.39999999999999997,
+        "min_track_width": 0.2,
+        "min_via_annular_width": 0.1,
+        "min_via_diameter": 0.4,
         "solder_mask_to_copper_clearance": 0.0,
         "use_height_for_length_calcs": true
       },

+ 0 - 716
Electronic_DC_Load.kicad_sch

@@ -5217,493 +5217,6 @@
 				)
 			)
 		)
-		(symbol "Electronic_DC_Load-rescue:LCD_I2C_20x4"
-			(pin_names
-				(offset 1.016)
-			)
-			(exclude_from_sim no)
-			(in_bom yes)
-			(on_board yes)
-			(property "Reference" "LCD"
-				(at 0 15.24 0)
-				(effects
-					(font
-						(size 1.524 1.524)
-					)
-				)
-			)
-			(property "Value" "LCD_I2C_20x4"
-				(at 19.05 -10.16 0)
-				(effects
-					(font
-						(size 1.524 1.524)
-					)
-				)
-			)
-			(property "Footprint" ""
-				(at 0 0 0)
-				(effects
-					(font
-						(size 1.524 1.524)
-					)
-					(hide yes)
-				)
-			)
-			(property "Datasheet" ""
-				(at 0 0 0)
-				(effects
-					(font
-						(size 1.524 1.524)
-					)
-					(hide yes)
-				)
-			)
-			(property "Description" ""
-				(at 0 0 0)
-				(effects
-					(font
-						(size 1.27 1.27)
-					)
-					(hide yes)
-				)
-			)
-			(symbol "LCD_I2C_20x4_0_0"
-				(rectangle
-					(start -40.64 12.7)
-					(end 26.67 -7.62)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -39.37 11.43)
-					(end 1.27 -3.81)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -30.48 -1.27)
-					(end -29.21 -2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -30.48 1.27)
-					(end -29.21 0)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -30.48 7.62)
-					(end -25.4 2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -27.94 -1.27)
-					(end -26.67 -2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -27.94 1.27)
-					(end -26.67 0)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(circle
-					(center -27.94 5.08)
-					(radius 1.27)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -25.4 -1.27)
-					(end -24.13 -2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -25.4 1.27)
-					(end -24.13 0)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -19.05 7.62)
-					(end -12.7 -2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(rectangle
-					(start -1.27 6.35)
-					(end 3.81 2.54)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(polyline
-					(pts
-						(xy -29.21 5.08) (xy -27.94 5.08)
-					)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(polyline
-					(pts
-						(xy -27.94 5.08) (xy -26.67 5.08)
-					)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(polyline
-					(pts
-						(xy -1.27 3.81) (xy 2.54 3.81)
-					)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(polyline
-					(pts
-						(xy -1.27 5.08) (xy 2.54 5.08)
-					)
-					(stroke
-						(width 0)
-						(type solid)
-					)
-					(fill
-						(type none)
-					)
-				)
-				(text "20 x 4 LCD"
-					(at 18.5166 0.6604 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-							(bold yes)
-						)
-					)
-				)
-				(text "A0"
-					(at -24.7396 -0.5842 0)
-					(effects
-						(font
-							(size 0.6096 0.6096)
-							(bold yes)
-						)
-					)
-				)
-				(text "A1"
-					(at -27.1526 -0.6096 0)
-					(effects
-						(font
-							(size 0.6096 0.6096)
-							(bold yes)
-						)
-					)
-				)
-				(text "A2"
-					(at -29.7942 -0.7112 0)
-					(effects
-						(font
-							(size 0.6096 0.6096)
-							(bold yes)
-						)
-					)
-				)
-				(text "LED"
-					(at -0.0508 1.6002 0)
-					(effects
-						(font
-							(size 0.7874 0.7874)
-						)
-					)
-				)
-				(text "PCF8574"
-					(at -15.9512 2.8956 0)
-					(effects
-						(font
-							(size 0.7874 0.7874)
-						)
-					)
-				)
-				(text "●"
-					(at -38.1 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -35.56 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -33.02 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -30.48 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -27.94 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -25.4 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -22.86 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -20.32 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -17.78 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -15.24 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -12.7 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -10.16 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -7.62 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -5.08 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at -2.54 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-				(text "●"
-					(at 0 10.16 0)
-					(effects
-						(font
-							(size 1.524 1.524)
-						)
-					)
-				)
-			)
-			(symbol "LCD_I2C_20x4_1_1"
-				(pin power_in line
-					(at -45.72 7.62 0)
-					(length 7.62)
-					(name "GND"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-					(number "1"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-				)
-				(pin power_in line
-					(at -45.72 5.08 0)
-					(length 7.62)
-					(name "VCC"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-					(number "2"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-				)
-				(pin input line
-					(at -45.72 2.54 0)
-					(length 7.62)
-					(name "SDA"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-					(number "3"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-				)
-				(pin input line
-					(at -45.72 0 0)
-					(length 7.62)
-					(name "SCL"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-					(number "4"
-						(effects
-							(font
-								(size 1.27 1.27)
-							)
-						)
-					)
-				)
-			)
-		)
 		(symbol "Electronic_DC_Load-rescue:LM35DT"
 			(pin_names
 				(offset 1.016)
@@ -9154,12 +8667,6 @@
 		(color 0 0 0 0)
 		(uuid "2aac4000-eb64-4234-bbc1-a8bbf9e75903")
 	)
-	(junction
-		(at 107.95 165.1)
-		(diameter 0)
-		(color 0 0 0 0)
-		(uuid "2ae17159-1c24-4f88-8d64-c77c873261b7")
-	)
 	(junction
 		(at 140.97 50.8)
 		(diameter 0)
@@ -9184,12 +8691,6 @@
 		(color 0 0 0 0)
 		(uuid "30c09667-0302-4fa1-81fb-f3c27641db29")
 	)
-	(junction
-		(at 96.52 157.48)
-		(diameter 0)
-		(color 0 0 0 0)
-		(uuid "320672db-338e-48f4-bff3-8e249c3de089")
-	)
 	(junction
 		(at 134.62 57.15)
 		(diameter 0)
@@ -9580,12 +9081,6 @@
 		(color 0 0 0 0)
 		(uuid "aac1ca05-89e7-4da0-858e-61c91b7a858a")
 	)
-	(junction
-		(at 113.03 171.45)
-		(diameter 0)
-		(color 0 0 0 0)
-		(uuid "abf6be8b-a944-444e-a1ef-9e253d16e579")
-	)
 	(junction
 		(at 76.2 142.24)
 		(diameter 0)
@@ -10014,16 +9509,6 @@
 		)
 		(uuid "0320b82a-a152-4294-9f5f-d4e1f255b1e8")
 	)
-	(wire
-		(pts
-			(xy 107.95 165.1) (xy 107.95 185.42)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "0321f1c0-7c13-43c0-8f44-b09f711b10fe")
-	)
 	(wire
 		(pts
 			(xy 64.77 40.64) (xy 71.12 40.64)
@@ -10584,16 +10069,6 @@
 		)
 		(uuid "1b435e82-6bac-4663-b09e-f6e233a8cd45")
 	)
-	(wire
-		(pts
-			(xy 107.95 185.42) (xy 96.52 185.42)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "1c029097-051e-4526-b112-3f00c22507f1")
-	)
 	(wire
 		(pts
 			(xy 160.02 81.28) (xy 163.83 81.28)
@@ -11934,16 +11409,6 @@
 		)
 		(uuid "5e0389a7-04c7-49bd-ab39-8daff29e5fcc")
 	)
-	(wire
-		(pts
-			(xy 113.03 171.45) (xy 113.03 187.96)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "5e0befb0-09fa-4734-960e-a85ca1620862")
-	)
 	(wire
 		(pts
 			(xy 58.42 26.67) (xy 58.42 40.64)
@@ -13164,16 +12629,6 @@
 		)
 		(uuid "9e41e1b4-c7a1-4e6a-9e24-06a1eaecf846")
 	)
-	(wire
-		(pts
-			(xy 96.52 157.48) (xy 96.52 182.88)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "9ecbd81c-3792-4f73-a080-d95e871269ec")
-	)
 	(wire
 		(pts
 			(xy 46.99 17.78) (xy 46.99 21.59)
@@ -13344,16 +12799,6 @@
 		)
 		(uuid "a8c41fe3-65cf-4f8a-a9f6-29a309c9dae0")
 	)
-	(wire
-		(pts
-			(xy 113.03 187.96) (xy 96.52 187.96)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "aba109a8-22b7-42da-9243-c1381ef138f6")
-	)
 	(wire
 		(pts
 			(xy 102.87 81.28) (xy 96.52 81.28)
@@ -13884,16 +13329,6 @@
 		)
 		(uuid "c1b1c332-099f-4fe6-bf17-75877811619a")
 	)
-	(wire
-		(pts
-			(xy 96.52 180.34) (xy 104.14 180.34)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "c23ae327-8eed-4d61-b50d-1a1c065d686c")
-	)
 	(wire
 		(pts
 			(xy 134.62 100.33) (xy 140.97 100.33)
@@ -15204,16 +14639,6 @@
 		)
 		(uuid "fe3e5912-d11d-46b1-83fb-0c59cbb27d5b")
 	)
-	(wire
-		(pts
-			(xy 104.14 180.34) (xy 104.14 193.04)
-		)
-		(stroke
-			(width 0)
-			(type default)
-		)
-		(uuid "fe67641f-b918-4a1f-86a2-105e75b6aaec")
-	)
 	(wire
 		(pts
 			(xy 17.78 88.9) (xy 60.96 88.9)
@@ -21335,72 +20760,6 @@
 			)
 		)
 	)
-	(symbol
-		(lib_id "Electronic_DC_Load-rescue:GNDPWR")
-		(at 104.14 193.04 0)
-		(unit 1)
-		(exclude_from_sim no)
-		(in_bom yes)
-		(on_board yes)
-		(dnp no)
-		(uuid "00000000-0000-0000-0000-0000594d80d4")
-		(property "Reference" "#PWR012"
-			(at 104.14 198.12 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(property "Value" "GNDPWR"
-			(at 104.14 196.342 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(property "Footprint" ""
-			(at 104.14 194.31 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(property "Datasheet" ""
-			(at 104.14 194.31 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(property "Description" ""
-			(at 104.14 193.04 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(pin "1"
-			(uuid "ad91bce6-6120-4883-a93f-0d4d5add1dcb")
-		)
-		(instances
-			(project "Electronic_DC_Load"
-				(path "/c0dab339-7200-490f-9e31-c88351ec25c5"
-					(reference "#PWR012")
-					(unit 1)
-				)
-			)
-		)
-	)
 	(symbol
 		(lib_id "Electronic_DC_Load-rescue:GNDPWR")
 		(at 78.74 170.18 0)
@@ -22572,81 +21931,6 @@
 			)
 		)
 	)
-	(symbol
-		(lib_id "Electronic_DC_Load-rescue:LCD_I2C_20x4")
-		(at 50.8 187.96 0)
-		(mirror y)
-		(unit 1)
-		(exclude_from_sim no)
-		(in_bom yes)
-		(on_board yes)
-		(dnp no)
-		(uuid "00000000-0000-0000-0000-0000594f952b")
-		(property "Reference" "LCD1"
-			(at 50.8 172.72 0)
-			(effects
-				(font
-					(size 1.778 1.778)
-					(bold yes)
-				)
-			)
-		)
-		(property "Value" "LCD_I2C_20x4"
-			(at 24.13 173.99 0)
-			(effects
-				(font
-					(size 1.524 1.524)
-				)
-			)
-		)
-		(property "Footprint" "Connectors_JST:JST_XH_B04B-XH-A_04x2.50mm_Straight"
-			(at 50.8 187.96 0)
-			(effects
-				(font
-					(size 1.524 1.524)
-				)
-				(hide yes)
-			)
-		)
-		(property "Datasheet" ""
-			(at 50.8 187.96 0)
-			(effects
-				(font
-					(size 1.524 1.524)
-				)
-				(hide yes)
-			)
-		)
-		(property "Description" ""
-			(at 50.8 187.96 0)
-			(effects
-				(font
-					(size 1.27 1.27)
-				)
-				(hide yes)
-			)
-		)
-		(pin "1"
-			(uuid "dffbe504-b9e3-4db1-8cca-641d1f1e035f")
-		)
-		(pin "2"
-			(uuid "f7415584-2c1b-41f9-b1ef-b74efbc19df3")
-		)
-		(pin "3"
-			(uuid "776b456e-3f99-4f44-8db2-1e10320451c8")
-		)
-		(pin "4"
-			(uuid "95f8d091-aac5-4380-b650-c2e3c46f0fb4")
-		)
-		(instances
-			(project "Electronic_DC_Load"
-				(path "/c0dab339-7200-490f-9e31-c88351ec25c5"
-					(reference "LCD1")
-					(unit 1)
-				)
-			)
-		)
-	)
 	(symbol
 		(lib_id "Electronic_DC_Load-rescue:R")
 		(at 194.31 134.62 270)

+ 14 - 14
sw/DC_LOAD/include/config.h

@@ -9,10 +9,10 @@
 #define I2C_MCP342x_ADDRESS     0x68            //0x68 is the default address for the MCP3426 device
 #define rxPin 8
 #define txPin 7
-#define col_red                 63488
-#define col_green               1024
-#define col_gray                50712
-#define col_blue                1055
+#define COL_RED                 63488
+#define COL_GREEN               1024
+#define COL_GRAY                50712
+#define COL_BLUE                1055
 #define line_len                21
 #define MODE_CC                 1
 #define MODE_CP                 2
@@ -22,18 +22,18 @@
 #define MODE_TT                 6
 #define MODE_TL                 7
 #define MODE_BC                 8
-
+#define CURRENTCUTOFF_ADDRESS   0x00
+#define POWERCUTOFF_ADDRESS     0x20
+#define TEMPCUTOFF_ADDRESS      0x40
 
 #define pinA                    2                   //digital pin (also interrupt pin) for the A pin of the Rotary Encoder (changed to digital pin 2)
 #define pinB                    4                   //digital pin for the B pin of the Rotary Encoder
 
-#define CursorPos               17                  //analog pin A3 used as a digital pin to set cursor position (rotary encoder push button)
-#define LoadOnOff               15                  //analog pin A1 used as a digital pin to set Load ON/OFF
-
-#define TriggerPulse            16                  //analog pin A2 used as a digital pin for trigger pulse input in transient mode
-
-#define fan                     3                   //digital pin 3 for fan control output (changed to Digital pin 3)
-#define temperature             A6                  //analog pin used for temperature output from LM35 (was A0 previously but changed)
+#define CURSORPOS_PIN           17                  //analog pin A3 used as a digital pin to set cursor position (rotary encoder push button)
+#define LOADONOFF_PIN           15                  //analog pin A1 used as a digital pin to set Load ON/OFF
+#define TRIGGERPULSE_PIN        16                  //analog pin A2 used as a digital pin for trigger pulse input in transient mode
+#define FAN_PIN                 3                   //digital pin 3 for fan control output (changed to Digital pin 3)
+#define TEMP_PIN                A6                  //analog pin used for temperature output from LM35 (was A0 previously but changed)
 #define setCurrentCalibrationFactor     0.980       //calibration adjustment - set as required if needed (was 1.000)
 #define displayCurrentCal               0.000       //calibration correction for LCD current display (was 0.040)
 #define ResistorCutOff                  999         //maximum Resistor we want to deal with in software
@@ -42,8 +42,8 @@
 #define MCP4725_CMD_WRITEDAC (0x40)                 //< Writes data to the DAC
 #define MCP4725_CMD_WRITEDACEEPROM    (0x60)        //< Writes data to the DAC and the EEPROM (persisting the assigned
 
-#define pic_usb_grey            2
-#define pic_usb_black           3
+#define PIC_USB_GRAY            2
+#define PIC_USB_BLACK           3
 
 #define LiPoCutOffVoltage        3.0                //set cutoff voltage for LiPo battery
 #define LiFeCutOffVoltage        2.8                //set cutoff voltage for LiFe battery

+ 1 - 0
sw/DC_LOAD/include/input.h

@@ -26,4 +26,5 @@
 #define NO_KEY               0
 
 void serialEvent(void);
+void wait_for_key(bool);
 #endif //DCLOAD_INPUT_H

+ 1 - 1
sw/DC_LOAD/include/screen.h

@@ -4,7 +4,7 @@
 void setmode();
 void print_char(int x1,int z, char text);
 void print_chars(int x1,int z, char * text,int len);
-void print_chars2(int x1,int len);
+void print_line(int x1,int len);
 void screen_clear(char empty);
 void writeStr(char *  command, char * txt);
 void writeNum2(char * command, uint16_t value);

+ 39 - 0
sw/DC_LOAD/src/1wire.cpp

@@ -0,0 +1,39 @@
+#include <Arduino.h>
+#include <config.h>
+#include <input.h>
+#include <SoftwareSerial.h>
+/*
+byte error, address;
+int nDevices;
+nDevices = 0;
+  for(address = 1; address < 127; address++ )
+  {
+    // The i2c_scanner uses the return value of
+    // the Write.endTransmisstion to see if
+    // a device did acknowledge to the address.
+    Wire.beginTransmission(address);
+    error = Wire.endTransmission();
+ 
+    if (error == 0)
+    {
+      Serial.print("I2C device found at address 0x");
+      if (address<16)
+        Serial.print("0");
+      Serial.print(address,HEX);
+      Serial.println("  !");
+ 
+      nDevices++;
+    }
+    else if (error==4)
+    {
+      Serial.print("Unknown error at address 0x");
+      if (address<16)
+        Serial.print("0");
+      Serial.println(address,HEX);
+    }    
+  }
+  if (nDevices == 0)
+    Serial.println("No I2C devices found\n");
+  else
+    Serial.println("done\n");
+*/

+ 16 - 4
sw/DC_LOAD/src/input.cpp

@@ -1,10 +1,9 @@
 #include <Arduino.h>
 #include <config.h>
 #include <input.h>
-#include <SoftwareSerial.h>
+
 
 extern uint8_t customKey;
-extern SoftwareSerial nexSerial;
 extern bool trig_key;
 extern void toggle_usb(void);
 uint16_t i1;
@@ -12,9 +11,9 @@ uint8_t c1;
 static uint8_t __buffer[10];
 
 void serialEvent() {
-    while (nexSerial.available() > 0 ){   
+    while (Serial1.available() > 0 ){   
         
-        c1 = nexSerial.read();
+        c1 = Serial1.read();
         if (0x65 == c1 ||__buffer[0] == 0x65)
         {
             if (0x65 == c1){
@@ -48,3 +47,16 @@ void serialEvent() {
     }
     }
 }
+void wait_for_key(bool wait){
+
+  bool waiting = true;
+
+  while (customKey==0x00 && (waiting)){  
+    waiting = wait;
+    delay(10);
+    while (customKey==0x00 ){   
+        serialEvent();
+        
+    }
+  }
+}

+ 100 - 170
sw/DC_LOAD/src/main.cpp

@@ -14,11 +14,6 @@
 #include <config.h>
 #include <input.h>
 #include <screen.h>
-#include <SoftwareSerial.h>
-
-SoftwareSerial nexSerial (rxPin,txPin);
-
-
 
 void setupLimits (void);
 void transientSwitch(float current_setting, boolean toggle_status);
@@ -55,35 +50,23 @@ void wait_for_key(bool wait =true );
 
 
 
-uint8_t customKey;
-
-bool decimalPoint=false;                            //used to test for more than one press of * key (decimal point)
 
                     
-
 MCP342x adc = MCP342x(I2C_MCP342x_ADDRESS);
-
 MCP79410_Timer timer = MCP79410_Timer(I2C_MCP79410_ADDRESS);
 
-//Set the pins on the I2C chip used for LCD connections
-//ADDR,EN,R/W,RS,D4,D5,D6,D7
-
-
 int temp;                                     //
-
+uint8_t customKey;
+bool decimalPoint=false;                            //used to test for more than one press of * key (decimal point)
 float BatteryLife = 0;                        //
 float BatteryLifePrevious = 0;                //
 float Seconds = 0;                            //time variable used in Battery Capacity Mode (BC)
 float SecondsLog = 0;                         //variable used for data logging of the time in seconds
 float BatteryCutoffVolts;                     //used to set battery discharge cut-off voltage
 float MaxBatteryCurrent = 1.0;                //maximum battery current allowed for Battery Capacity Testing
-
 int stopSeconds;                              //store for seconds when timer stopped
-
 int CP = 8;                                   //cursor start position
-
 boolean toggle = false;                       //used for toggle of Load On/Off button
-
 unsigned long controlVoltage = 0;             //used for DAC to control MOSFET
 
 long current = 0;                             //variable used by ADC for measuring the current
@@ -95,9 +78,7 @@ float setCurrent = 0;                         //variable used for the set curren
 float setPower = 0;                           //variable used for the set power of the load
 float setResistance = 0;                      //variable used for the set resistance of the load
 
-
-
-int Load = 0;                                 //Load On/Off flag
+bool Load = 0;                                 //Load On/Off flag
 
 float setControlCurrent = 0;                  //variable used to set the temporary store for control current required
 
@@ -220,9 +201,9 @@ void isr()
 
 void toggle_usb(void){
   if (usb_enable){
-    writeNum2("pusb.pic",(int) pic_usb_grey); 
+    writeNum2("pusb.pic",(int) PIC_USB_GRAY); 
   }else{
-    writeNum2("pusb.pic",(int) pic_usb_black); 
+    writeNum2("pusb.pic",(int) PIC_USB_BLACK); 
   }
   usb_enable=!usb_enable;
 }
@@ -231,72 +212,37 @@ void toggle_usb(void){
 
 //---------------------------------Initial Set up---------------------------------------
 void setup() {
-                                   //used for testing only
-  Wire.begin();                                            //join i2c bus (address optional for master)
-  Wire.setClock(400000L);                                  //sets bit rate to 400KHz
+  Serial.begin(38400);
+  Serial1.begin(38400);
   pinMode(rxPin, INPUT);
   pinMode(txPin, OUTPUT);
-  nexSerial.begin(38400);
-  Serial.begin(38400);
-  analogReference(INTERNAL2V5);
+  Serial1.begin(38400);
+  Wire.begin();                                            //join i2c bus (address optional for master)
+  Wire.setClock(400000L);                                  //sets bit rate to 400KHz
+
   /* Register the pop event callback function of the current button component. */
   delay(100);
   unsigned long _tmr1;
   _tmr1 = millis();
-  while(nexSerial.available() > 0){     // Read the Serial until it is empty. This is used to clear Serial buffer
+  while(Serial1.available() > 0){     // Read the Serial until it is empty. This is used to clear Serial buffer
     if((millis() - _tmr1) > 400UL){    // Reading... Waiting... But not forever...... 
       break;                            
     } 
-      nexSerial.read();                // Read and delete bytes
+      Serial1.read();                // Read and delete bytes
   }
   memset(line_input,' ',10);
-  CurrentCutOff = EEPROM.read(0x00);
-  PowerCutOff = EEPROM.read(0x20);
-  tempCutOff = EEPROM.read(0x40);
+  CurrentCutOff = EEPROM.read(CURRENTCUTOFF_ADDRESS);
+  PowerCutOff = EEPROM.read(POWERCUTOFF_ADDRESS);
+  tempCutOff = EEPROM.read(TEMPCUTOFF_ADDRESS);
   MCP342x::generalCallReset();                             //Reset devices
   pinMode (pinA, INPUT);
   pinMode (pinB, INPUT);
-  pinMode (CursorPos, INPUT_PULLUP);
-  pinMode (LoadOnOff, INPUT_PULLUP);
- 
-  pinMode (TriggerPulse, INPUT_PULLUP);
-    byte error, address;
-  int nDevices;
-nDevices = 0;
-  for(address = 1; address < 127; address++ )
-  {
-    // The i2c_scanner uses the return value of
-    // the Write.endTransmisstion to see if
-    // a device did acknowledge to the address.
-    Wire.beginTransmission(address);
-    error = Wire.endTransmission();
- 
-    if (error == 0)
-    {
-      Serial.print("I2C device found at address 0x");
-      if (address<16)
-        Serial.print("0");
-      Serial.print(address,HEX);
-      Serial.println("  !");
- 
-      nDevices++;
-    }
-    else if (error==4)
-    {
-      Serial.print("Unknown error at address 0x");
-      if (address<16)
-        Serial.print("0");
-      Serial.println(address,HEX);
-    }    
-  }
-  if (nDevices == 0)
-    Serial.println("No I2C devices found\n");
-  else
-    Serial.println("done\n");
-
-  pinMode (fan, OUTPUT);
+  pinMode (CURSORPOS_PIN, INPUT_PULLUP);
+  pinMode (LOADONOFF_PIN, INPUT_PULLUP);
+  pinMode (TRIGGERPULSE_PIN, INPUT_PULLUP);
+  pinMode (FAN_PIN, OUTPUT);
   //TCCR2B = (TCCR2B & 0b11111000) | 1;                      //change PWM to above hearing (Kenneth Larvsen recommendation)
-  pinMode (temperature, INPUT);
+  pinMode (TEMP_PIN, INPUT);
   setVoltage(0,false);                                 //reset DAC to zero for no output current set at Switch On
   analogReference(INTERNAL);                               //use Arduino internal reference for tempurature monitoring
   attachInterrupt(digitalPinToInterrupt(pinA), isr, LOW);
@@ -308,18 +254,18 @@ nDevices = 0;
   writeNum2("t2.xcen",(int) 1); 
   writeNum2("t3.xcen",(int) 1); 
   memcpy(line0,(char*)"SCULLCOM",9);
-  print_chars2(0,9);
+  print_line(0,9);
   
   memcpy(line1,(char*)"Hobby Electronics",18); 
-  print_chars2(1,18);
+  print_line(1,18);
 
   memcpy(line2,(char*)"DC Electronic Load",19);
-  print_chars2(2,19);
+  print_line(2,19);
 
   memcpy(line3,(char*)"Ver. ",5);
   memcpy(line3+5,(char*)DC_LOAD_VER,2);
   memcpy(line3+7,(char*)" (Nextion)",11);
-  print_chars2(3,21);
+  print_line(3,21);
   memcpy(line_current," ",1);
   memcpy(line_volt," ",1);
   memcpy(line_power," ",1);
@@ -332,7 +278,7 @@ nDevices = 0;
   writeNum2("t3.xcen",(int) 0);                                           //3000 mSec delay for intro display
   screen_clear(' ');  
   setupLimits();
-  delay(3000);
+  delay(2000);
   screen_clear(' ');  
 
   last_time = 0;                                           //set the last_time to 0 at the start (Transicent Mode)
@@ -358,7 +304,7 @@ void loop() {
   }else{
   
     readKeypadInput();                                     //read Keypad entry
-    OnOffcurrentState = digitalRead(LoadOnOff);
+    OnOffcurrentState = digitalRead(LOADONOFF_PIN);
     if (OnOffcurrentState != OnOfflastFlickerableState) {
       OnOfflastDebounceTime = millis();
       OnOfflastFlickerableState = OnOffcurrentState;
@@ -415,7 +361,6 @@ void readKeypadInput (void) {
   }
 
   if(customKey == DIGIT_SETUP){                                   //check if Set-Up Mode Selected 
-    delay(200);
     toggle = true;  
     customKey=NO_KEY;                                       //switch Load OFF
     LoadSwitch();
@@ -442,7 +387,7 @@ void readKeypadInput (void) {
   if(customKey == DIGIT_CURRENT){                                   //check if Constant Current button pressed
     toggle = false;                                         //switch Load OFF
     color_load(0);
-    print_chars2(0,20);
+    print_line(0,20);
     Current();                                              //if selected go to Constant Current Selected routine
     encoderPosition = 0;                                    //reset encoder reading to zero
     index = 0;
@@ -454,7 +399,7 @@ void readKeypadInput (void) {
   if(customKey == DIGIT_POWER){                                   //check if Constant Power button pressed
     toggle = false;                                         //switch Load OFF
     color_load(0);
-    print_chars2(0,20);
+    print_line(0,20);
     Power();                                                //if selected go to Constant Power Selected routine
     encoderPosition = 0;                                    //reset encoder reading to zero
     index = 0;
@@ -466,7 +411,7 @@ void readKeypadInput (void) {
   if(customKey == DIGIT_RESISTANS){                                   //check if Constant Resistance button pressed  
     toggle = false;                                         //switch Load OFF
     color_load(0);
-    print_chars2(0,20);
+    print_line(0,20);
     Resistance();                                           //if selected go to Constant Resistance Selected routine
     encoderPosition = 0;                                    //reset encoder reading to zero
     index = 0;
@@ -484,7 +429,7 @@ void readKeypadInput (void) {
     decimalPoint = false;                                //clear decimal point test character reset
     if (exitMode == 1){                                   //if NO battery type selected revert to CC Mode
       color_load(0);
-      print_chars2(0,20);
+      print_line(0,20);
       Current();                                            //if selected go to Constant Current Selected routine
       encoderPosition = 0;                                  //reset encoder reading to zero
       customKey = DIGIT_CURRENT;
@@ -492,9 +437,9 @@ void readKeypadInput (void) {
     else
     {
       memcpy(line2+16,(char*)BatteryType.c_str(),4);
-      print_chars2(2,20);
+      print_line(2,20);
       color_load(0);
-      print_chars2(0,20);
+      print_line(0,20);
       timer.reset();                                        //reset timer
       BatteryLifePrevious = 0;
       CP = 9;                                               //set cursor position
@@ -591,7 +536,7 @@ void powerLevelCutOff (void) {
 
     print_chars(3,0,(char*)"Exceeded Power      ",20);
     color_load(0);
-    print_chars2(0,20);
+    print_line(0,20);
     toggle = false;                                         //switch Load Off
   }
 }
@@ -606,8 +551,6 @@ void batteryCurrentLimitValue (void) {
 
 //----------------------Display Rotary Encoder Input Reading on LCD---------------------------
 void displayEncoderReading (void) {
-
-    //lcd.setCursor(8,2);                                      //start position of setting entry
     char buff[6];
     uint8_t cursor_pos=8;
     /*
@@ -628,8 +571,6 @@ void displayEncoderReading (void) {
         dtostrf(reading, 5, 3, buff);
         print_chars(1,cursor_pos++,(char*)buff,5);
     }
-    //lcd.setCursor (CP, 2);                                   //sets cursor position
-    //lcd.cursor();                                            //show cursor on LCD
 }
 
 //--------------------------Cursor Position-------------------------------------------------------
@@ -644,9 +585,9 @@ void CursorPosition(void) {
         unitPosition = 10;        
     }
 
-    if (digitalRead(CursorPos) == LOW) {
+    if (digitalRead(CURSORPOS_PIN) == LOW) {
     
-        delay(200);                                          //simple key bounce delay  
+        delay(DEBOUNCE_DELAY);                                          //simple key bounce delay  
         CP = CP + 1;
         if (CP == unitPosition + 1 ) {
             CP = CP + 1;
@@ -794,7 +735,7 @@ void batteryCapacityloop (void) {
       }
 
     memcpy(line3+13,"mAh",3);
-    print_chars2(3,20);
+    print_line(3,20);
     BatteryLifePrevious = BatteryLife;                      //update displayed battery capacity on LCD
     } 
   }
@@ -821,13 +762,13 @@ void batteryCapacityloop (void) {
 
 //--------------------------------------------------Fan Control----------------------------------------------------------
 void fanControl (void) {
-  temp = analogRead(temperature);
+  temp = analogRead(TEMP_PIN);
   temp = temp * 0.107421875/2;                                // convert to Celsius
   
   if (temp >= 40){                                        //if temperature 40 degree C or above turn fan on.
-    digitalWrite(fan, HIGH); 
+    digitalWrite(FAN_PIN, HIGH); 
   }  else {
-    digitalWrite(fan, LOW);                               //otherwise turn fan turned off
+    digitalWrite(FAN_PIN, LOW);                               //otherwise turn fan turned off
   }
   
   memcpy(temperature_val,(char*)String(temp).c_str(),2);
@@ -842,7 +783,7 @@ void fanControl (void) {
 //-----------------------Toggle Current Load ON or OFF------------------------------
 void LoadSwitch(void) {
   
-  delay(200);                                              //simple key bounce delay 
+
  
     if(toggle)
     {
@@ -850,7 +791,7 @@ void LoadSwitch(void) {
 
       current_instruction = 0;                            //reset current instruction for Transient List Mode to zero
       last_time = 0;                                      //reset last time to zero
-      transientPeriod = 0;                                //reset transient period time to zero
+      //transientPeriod = 0;                                //reset transient period time to zero
       setCurrent = 0;                                     //reset setCurrent to zero
       toggle = !toggle;
       Load = 0;        
@@ -862,19 +803,20 @@ void LoadSwitch(void) {
       toggle = !toggle;
       Load = 1;
     }
+    delay(DEBOUNCE_DELAY);                                              //simple key bounce delay 
 }
 
 //-----------------------Select Constant Current LCD set up--------------------------------
 void Current(void) {
   Mode = MODE_CC;
   memcpy(line0,(char*)"DC LOAD     ",12);
-  print_chars2(0,20);
+  print_line(0,20);
   writeNum2("t0.xcen",(uint16_t) 0);
   print_chars(1,0,(char*)"Set I =            A",20);
   memset(line2,' ',20);
-  print_chars2(2,20);
+  print_line(2,20);
   memset(line3,' ',20);
-  print_chars2(3,20);
+  print_line(3,20);
   CP = 9;                                            //sets cursor starting position to units.
   setmode() ; 
 }
@@ -884,12 +826,12 @@ void Power(void) {
   Mode = MODE_CP;
   writeNum2("t0.xcen",(int) 0);
   memcpy(line0,(char*)"DC LOAD     ",12);
-  print_chars2(0,20);
+  print_line(0,20);
   print_chars(1,0,(char*)"Set W =            W",20);
   memset(line2,' ',20);
-  print_chars2(2,20);
+  print_line(2,20);
   memset(line3,' ',20);
-  print_chars2(3,20);
+  print_line(3,20);
   CP = 10;                                             //sets cursor starting position to units.
   setmode() ;    
 }
@@ -899,12 +841,12 @@ void Resistance(void) {
   Mode = MODE_CR;
   writeNum2("t0.xcen",(int) 0);
   memcpy(line0,(char*)"DC LOAD     ",12);
-  print_chars2(0,20);
+  print_line(0,20);
   print_chars(1,0,(char*)"Set R =            R",20);
   memset(line2,' ',20);
-  print_chars2(2,20);
+  print_line(2,20);
   memset(line3,' ',20);
-  print_chars2(3,20);
+  print_line(3,20);
   CP = 10;                                             //sets cursor starting position to units.
   setmode() ;
                                           //sets cursor starting position to units.
@@ -917,12 +859,12 @@ void BatteryCapacity(void) {
   writeNum2("t0.xcen",0);
   memcpy(line0,"BATTERY             ",20);
   memcpy(line0+8,(char *)BatteryType.c_str(),4);
-  print_chars2(0,20);
+  print_line(0,20);
   print_chars(1,0,(char*)"Set I =            A",20);
   memset(line2,' ',20);
-  print_chars2(2,20);
+  print_line(2,20);
   memset(line3,' ',20);
-  print_chars2(3,20);
+  print_line(3,20);
   CP = 9;                                             //sets cursor starting position to units.
   setmode() ;  
 }
@@ -1012,10 +954,10 @@ void batteryTypeSelected (void) {
     dtostrf(BatteryCutoffVolts, 4, 2, buff);
     memcpy(line3+6,buff,4);
     memcpy(line3+11," volts",6);
-    print_chars2(0,21);
-    print_chars2(1,21);
-    print_chars2(2,21);
-    print_chars2(3,21);                                
+    print_line(0,21);
+    print_line(1,21);
+    print_line(2,21);
+    print_line(3,21);                                
     delay(2000);
   }
 }
@@ -1032,19 +974,7 @@ void setBatteryCutOff (void) {
   BatteryCutoffVolts = x;
   screen_clear(' ');
 }
-void wait_for_key(bool wait){
-
-  bool waiting = true;
 
-  while (customKey==0x00 && (waiting)){  
-    waiting = wait;
-    delay(10);
-    while (customKey==0x00 ){   
-        serialEvent();
-        
-    }
-  }
-}
 //------------------------Key input used for Battery Cut-Off and Transient Mode------------------------
 void inputValue (int r=0){
  
@@ -1105,7 +1035,7 @@ void transientMode (void) {
     print_chars(0,4,(char*)"Transient Mode",15); 
     memcpy(line1,(char *)"Set Low  I=",11);
     memcpy(line1+19,(char *)"A " ,2);
-    print_chars2(1,0); 
+    print_line(1,0); 
     inputValue(1);
     
     if(x >= CurrentCutOff){
@@ -1123,7 +1053,7 @@ void transientMode (void) {
     z = 11;
     memcpy(line2,(char *)"Set High I=",11);
     memcpy(line2+19,(char *)"A " ,2);
-    print_chars2(2,0); 
+    print_line(2,0); 
     inputValue(2);
     if(x >= CurrentCutOff){
       HighCurrent = CurrentCutOff;
@@ -1140,7 +1070,7 @@ void transientMode (void) {
       z = 11;
       memcpy(line3,(char *)"Set Time  =",11);
       memcpy(line3+16,(char *)"mSec " ,5);
-      print_chars2(3,0); 
+      print_line(3,0); 
       inputValue(3);
       transientPeriod = x;
       r++;
@@ -1150,7 +1080,7 @@ void transientMode (void) {
     }else{
 
       memset(line3,' ',20);
-      print_chars2(3,0);
+      print_line(3,0);
     }
 
     screen_clear(' ');
@@ -1173,15 +1103,15 @@ void transientType (void) {
   screen_clear(' ');
   writeNum2("t0.xcen",(int) 0);                                 //print SCULLCOM to display with 5 leading spaces (you can change to your own)
   memcpy(line0,(char*)"Transient Mode",15);
-  print_chars2(0,0);
+  print_line(0,0);
   memcpy(line1,(char*)"1 = Continuous",15);
-  print_chars2(1,0);
+  print_line(1,0);
   memcpy(line2,(char*)"2 = Toggle",10);
   memcpy(line2+11,(char*)"3 = Pulse",9);
-  print_chars2(2,0);
+  print_line(2,0);
   memcpy(line3,(char*)"4 = List",8);
   memcpy(line3+11,(char*)"5 = Exit",9);
-  print_chars2(3,0);
+  print_line(3,0);
   while ( customKey == 0x00 || 
           customKey == DIGIT_6 || 
           customKey == DIGIT_7 || 
@@ -1228,7 +1158,7 @@ void transient (void) {
   char buff[6]={0x00};
   if(Mode ==  MODE_TC || Mode ==  MODE_TP || Mode ==  MODE_TT || Mode ==  MODE_TL){
     memcpy(line0,(char*)"DC LOAD ",8);
-    print_chars2(0,20);
+    print_line(0,20);
     if(Mode != MODE_TL){
       memcpy(line2,"Lo=     A  Hi=     A",20);
       dtostrf(LowCurrent, 4, 3, buff);
@@ -1251,8 +1181,8 @@ void transient (void) {
       memcpy(line3,"  ",2);
      
     }
-    print_chars2(2,20);
-    print_chars2(3,20);
+    print_line(2,20);
+    print_line(3,20);
   }
 delay(1);
 }
@@ -1263,11 +1193,11 @@ void transientListSetup(){
   screen_clear(' ');
   writeNum2("t0.xcen",(int) 0);                                 //print SCULLCOM to display with 5 leading spaces (you can change to your own)
   memcpy(line0,(char*)"Setup Transient List",21);
-  print_chars2(0,0);
+  print_line(0,0);
   memcpy(line1,(char*)"Enter Number in List",21);
-  print_chars2(1,0);
+  print_line(1,0);
   memcpy(line2,(char*)"(between 2 to 10 max",21);
-  print_chars2(2,0);
+  print_line(2,0);
   y = 0;
   z = 0;
   inputValue(3);
@@ -1282,8 +1212,8 @@ void transientListSetup(){
       itoa(i+1 ,buff,10);
       memcpy(line0+12,buff,length);
       memcpy(line1,"               A",16);
-      print_chars2(0,0);
-      print_chars2(1,0);
+      print_line(0,0);
+      print_line(1,0);
 
       y = 0;
       z = 0;
@@ -1296,8 +1226,8 @@ void transientListSetup(){
       
       memcpy(line2+12,buff,length);
       memcpy(line3,"               mSec",19);
-      print_chars2(2,0);
-      print_chars2(3,0);
+      print_line(2,0);
+      print_line(3,0);
       y = 0;
       z = 0;
       inputValue(3);            //get the users input value
@@ -1311,7 +1241,7 @@ void transientListSetup(){
 //-------------------------------------Transcient Load Toggel-------------------------------------------
 void transientLoadToggle(){
   char buff[5] = {0x00};
-  if(Mode == MODE_TC){
+  if(Mode == MODE_TC && Load == 1){
   current_time = micros();                              //get the current time in micro seconds()
   if (last_time == 0){
     last_time = current_time;
@@ -1324,7 +1254,7 @@ void transientLoadToggle(){
             transientSwitch(LowCurrent, true); 
             dtostrf(LowCurrent, 4, 3, buff);
             memcpy(line1+8,buff ,5);
-            print_chars2(1,20); 
+            print_line(1,20); 
           }
         break;
       case (true):
@@ -1333,7 +1263,7 @@ void transientLoadToggle(){
             transientSwitch(HighCurrent, true);      
             dtostrf(HighCurrent, 4, 3, buff);
             memcpy(line1+8,buff ,5);  
-            print_chars2(1,20);    
+            print_line(1,20);    
           }
         break; 
       } 
@@ -1342,7 +1272,7 @@ void transientLoadToggle(){
 }
 
 
-  if(Mode == MODE_TP){
+  if(Mode == MODE_TP && Load == 1){
     current_time = micros();                            //get the current time in micro seconds()
     memcpy(line1,"Set I =            A",20);
     if (last_time == 0){
@@ -1351,29 +1281,29 @@ void transientLoadToggle(){
         dtostrf(LowCurrent, 4, 3, buff);
         memcpy(line1+8,buff ,5);    
     }
-    if (digitalRead(TriggerPulse) == LOW || trig_key){
+    if (digitalRead(TRIGGERPULSE_PIN) == LOW || trig_key){
       // a trigger pluse is received
       // set to the high current
       trig_key=false;
       transientSwitch(HighCurrent, true); 
       dtostrf(HighCurrent, 4, 3, buff);
       memcpy(line1+8,buff ,5);  
-      print_chars2(1,20);    
+      print_line(1,20);    
     } else {
         if ((current_time - last_time) >= (transientPeriod * 1000.0)){
             transientSwitch(LowCurrent, true);    
             dtostrf(LowCurrent, 4, 3, buff);
             memcpy(line1+8,buff ,5);      
-            print_chars2(1,20);  
+            print_line(1,20);  
         }
     } 
      
   }
 
 
- if(Mode == MODE_TT){          // this function will toggle between high and low current when the trigger pin is taken low
+ if(Mode == MODE_TT && Load == 1){          // this function will toggle between high and low current when the trigger pin is taken low
 
-  if (digitalRead(TriggerPulse) == LOW  || trig_key){
+  if (digitalRead(TRIGGERPULSE_PIN) == LOW  || trig_key){
     memcpy(line1,"Set I =            A",20);
     trig_key=false;
     switch (transient_mode_status){
@@ -1381,16 +1311,16 @@ void transientLoadToggle(){
         transientSwitch(LowCurrent, true);
         dtostrf(LowCurrent, 4, 3, buff);
         memcpy(line1+8,buff ,5);   
-        delay(200);         //added to prevent key bounce when transient button used (date of addition 31-03-2018)
+        delay(DEBOUNCE_DELAY);         //added to prevent key bounce when transient button used (date of addition 31-03-2018)
         break;
       case (true):
         transientSwitch(HighCurrent, true);
         dtostrf(HighCurrent, 4, 3, buff);
         memcpy(line1+8,buff ,5);  
-        delay(200);         //added to prevent key bounce when transient button used (date of addition 31-03-2018)   
+        delay(DEBOUNCE_DELAY);         //added to prevent key bounce when transient button used (date of addition 31-03-2018)   
         break;
       }
-      print_chars2(1,20); 
+      print_line(1,20); 
     }
   }
 
@@ -1438,13 +1368,13 @@ void userSetUp (void) {
   writeNum2("t3.xcen",(int) 0);   
 
   memcpy(line0,"User Set-Up         ",21);
-  print_chars2(0,20);
+  print_line(0,20);
   memset(line2,' ',20);
-  print_chars2(2,20);
+  print_line(2,20);
   memset(line3,' ',20);
-  print_chars2(3,20);
+  print_line(3,20);
   memcpy(line1,"Current Limit=     A",21);
-  print_chars2(1,20);
+  print_line(1,20);
 
   inputValue(1);
   CurrentCutOff = x;
@@ -1453,7 +1383,7 @@ void userSetUp (void) {
   customKey=NO_KEY;
   z = 15;
   memcpy(line2,"Power Limit =      W",21);
-  print_chars2(2,20);
+  print_line(2,20);
   inputValue(2);
   PowerCutOff = x;
   EEPROM.write(0x20, PowerCutOff);        
@@ -1462,7 +1392,7 @@ void userSetUp (void) {
   z = 15;
   line3[18]=0xB0;
   memcpy(line3,"Temp. Limit =      C",21);
-  print_chars2(3,20);
+  print_line(3,20);
   inputValue(3);
   z = 1;
   tempCutOff = x;
@@ -1483,7 +1413,7 @@ void temperatureCutOff (void){
   reading = 0;
   encoderPosition = 0; 
   memcpy(line3,"Over Temperature    ",20);
-  print_chars2(3,20);
+  print_line(3,20);
   color_load(0);
   toggle = false;                                         //switch Load Off
   }
@@ -1527,7 +1457,7 @@ void setupLimits (void){
   writeNum2("t2.xcen",(int) 0); 
   writeNum2("t3.xcen",(int) 0); 
   memcpy(line0," Maximum Limits Set ",20);
-  print_chars2(0,20);
+  print_line(0,20);
   char snum[5];
   memcpy(line1,"Current Limit=    A ",20);
   CurrentCutOff = EEPROM.read(0x00);
@@ -1535,21 +1465,21 @@ void setupLimits (void){
 
   itoa(CurrentCutOff, snum, 10);
   memcpy(line1+15,snum,length);
-  print_chars2(1,20);
+  print_line(1,20);
 
   memcpy(line2,"Power Limit  =    W ",20);
   PowerCutOff = EEPROM.read(0x20);
   length = snprintf( NULL, 0, "%d", PowerCutOff );
   itoa(PowerCutOff, snum, 10);
   memcpy(line2+15,snum,length);
-  print_chars2(2,20);
+  print_line(2,20);
 
   memcpy(line3,"Temp. Limit  =    C ",20);
   tempCutOff = EEPROM.read(0x40);
   length = snprintf( NULL, 0, "%d", tempCutOff );
   itoa(tempCutOff, snum, 10);
   memcpy(line3+15,snum,length);
-  print_chars2(3,20);
+  print_line(3,20);
 
 
   }

+ 39 - 41
sw/DC_LOAD/src/screen.cpp

@@ -1,7 +1,5 @@
 #include <Arduino.h>
 #include <config.h>
-#include <SoftwareSerial.h>
-extern SoftwareSerial nexSerial;
 extern uint8_t Mode; 
 extern uint8_t old_Mode;
 extern char line0[line_len];
@@ -24,23 +22,23 @@ extern char line_power_old[7];
 extern char line_input[10];
 
 void writeNum2(char * command, uint16_t value){ 
-  nexSerial.print(command);  
+  Serial1.print(command);  
   if(command !="cmd"){
-    nexSerial.print("=");
-    nexSerial.print(value);
+    Serial1.print("=");
+    Serial1.print(value);
   }
-  nexSerial.print("\xFF\xFF\xFF");
+  Serial1.print("\xFF\xFF\xFF");
 }
 void writeStr(char *  command, char * txt){ 
 
-  nexSerial.print(command);
+  Serial1.print(command);
     
   if(command != "cmd"){
-    nexSerial.print(F(".txt=\""));
-    nexSerial.print(txt);
-    nexSerial.print("\"");
+    Serial1.print(F(".txt=\""));
+    Serial1.print(txt);
+    Serial1.print("\"");
   }
-  nexSerial.print("\xFF\xFF\xFF");
+  Serial1.print("\xFF\xFF\xFF");
 }
 
 void screen_clear(char empty){
@@ -96,7 +94,7 @@ void print_reading(void){
     }
     
 }
-void print_chars2(int x1,int len){
+void print_line(int x1,int len){
       uint8_t compare=0;
       switch(x1){
         case 0: 
@@ -153,7 +151,7 @@ void print_chars(int x1,int z, char * text,int len){
           break;          
 
       }
-      print_chars2(x1,20);
+      print_line(x1,20);
 }
 void print_char(int x1,int z, char text){
       switch(x1){
@@ -171,44 +169,44 @@ void print_char(int x1,int z, char text){
           break;          
 
       }
-      print_chars2(x1,20);
+      print_line(x1,20);
 }
 void setmode(){
   if (Mode!=old_Mode){
     if (Mode == MODE_TC || Mode == MODE_TP || Mode == MODE_TT || Mode == MODE_TL ) {
-          writeNum2("bi.bco",(int) col_gray);
-          writeNum2("bw.bco",(int) col_gray);
-          writeNum2("br.bco",(int) col_gray);  
-          writeNum2("bbat.bco",(int) col_gray); 
-          writeNum2("btrans.bco",(int) col_blue);
+          writeNum2("bi.bco",(int) COL_GRAY);
+          writeNum2("bw.bco",(int) COL_GRAY);
+          writeNum2("br.bco",(int) COL_GRAY);  
+          writeNum2("bbat.bco",(int) COL_GRAY); 
+          writeNum2("btrans.bco",(int) COL_BLUE);
     }
     if (Mode == MODE_CC ) {
-          writeNum2("bi.bco",(int) col_blue);
-          writeNum2("bw.bco",(int) col_gray);
-          writeNum2("br.bco",(int) col_gray);  
-          writeNum2("bbat.bco",(int) col_gray); 
-          writeNum2("btrans.bco",(int) col_gray);
+          writeNum2("bi.bco",(int) COL_BLUE);
+          writeNum2("bw.bco",(int) COL_GRAY);
+          writeNum2("br.bco",(int) COL_GRAY);  
+          writeNum2("bbat.bco",(int) COL_GRAY); 
+          writeNum2("btrans.bco",(int) COL_GRAY);
     }
     if (Mode == MODE_CP ) {
-          writeNum2("bi.bco",(int) col_gray);
-          writeNum2("bw.bco",(int) col_blue);
-          writeNum2("br.bco",(int) col_gray);  
-          writeNum2("bbat.bco",(int) col_gray); 
-          writeNum2("btrans.bco",(int) col_gray);
+          writeNum2("bi.bco",(int) COL_GRAY);
+          writeNum2("bw.bco",(int) COL_BLUE);
+          writeNum2("br.bco",(int) COL_GRAY);  
+          writeNum2("bbat.bco",(int) COL_GRAY); 
+          writeNum2("btrans.bco",(int) COL_GRAY);
     }
     if (Mode == MODE_CR ) {
-          writeNum2("bi.bco",(int) col_gray);
-          writeNum2("bw.bco",(int) col_gray);
-          writeNum2("br.bco",(int) col_blue);  
-          writeNum2("bbat.bco",(int) col_gray); 
-          writeNum2("btrans.bco",(int) col_gray);
+          writeNum2("bi.bco",(int) COL_GRAY);
+          writeNum2("bw.bco",(int) COL_GRAY);
+          writeNum2("br.bco",(int) COL_BLUE);  
+          writeNum2("bbat.bco",(int) COL_GRAY); 
+          writeNum2("btrans.bco",(int) COL_GRAY);
     }
     if (Mode == MODE_BC ) {
-          writeNum2("bi.bco",(int) col_gray);
-          writeNum2("bw.bco",(int) col_gray);
-          writeNum2("br.bco",(int) col_gray);  
-          writeNum2("bbat.bco",(int) col_blue); 
-          writeNum2("btrans.bco",(int) col_gray);
+          writeNum2("bi.bco",(int) COL_GRAY);
+          writeNum2("bw.bco",(int) COL_GRAY);
+          writeNum2("br.bco",(int) COL_GRAY);  
+          writeNum2("bbat.bco",(int) COL_BLUE); 
+          writeNum2("btrans.bco",(int) COL_GRAY);
     }
     old_Mode=Mode;
   }
@@ -217,9 +215,9 @@ void color_load (bool load){
 
   if (old_load != load){
     if (load){
-      writeNum2("bload.bco",(int) col_green); 
+      writeNum2("bload.bco",(int) COL_GREEN); 
     }else{
-      writeNum2("bload.bco",(int) col_red); 
+      writeNum2("bload.bco",(int) COL_RED); 
     }
   }
   old_load=load;

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott