Compare commits
No commits in common. "develop" and "feature/partition_table_stuff" have entirely different histories.
develop
...
feature/pa
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"board": {
|
"board": {
|
||||||
"active_layer": 5,
|
"active_layer": 0,
|
||||||
"active_layer_preset": "All Layers",
|
"active_layer_preset": "All Layers",
|
||||||
"auto_track_width": false,
|
"auto_track_width": false,
|
||||||
"hidden_netclasses": [],
|
"hidden_netclasses": [],
|
||||||
|
@ -1102,15 +1102,6 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
|
||||||
(at 0 0 0)
|
|
||||||
(effects
|
|
||||||
(font
|
|
||||||
(size 1.27 1.27)
|
|
||||||
)
|
|
||||||
(hide yes)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(property "ki_keywords" "LED diode"
|
(property "ki_keywords" "LED diode"
|
||||||
(at 0 0 0)
|
(at 0 0 0)
|
||||||
(effects
|
(effects
|
||||||
@ -4751,26 +4742,6 @@
|
|||||||
)
|
)
|
||||||
(uuid f1cb09e6-74b4-43c4-8247-c9f441069dc5)
|
(uuid f1cb09e6-74b4-43c4-8247-c9f441069dc5)
|
||||||
)
|
)
|
||||||
(text "free"
|
|
||||||
(exclude_from_sim no)
|
|
||||||
(at 180.848 72.39 0)
|
|
||||||
(effects
|
|
||||||
(font
|
|
||||||
(size 1.27 1.27)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(uuid "1556efd1-3aac-45ee-8113-03336077a83d")
|
|
||||||
)
|
|
||||||
(text "GPIO21 pulses high during flashing!\nGPIO19 is used for communication during flashing"
|
|
||||||
(exclude_from_sim no)
|
|
||||||
(at 202.692 102.362 0)
|
|
||||||
(effects
|
|
||||||
(font
|
|
||||||
(size 1.27 1.27)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
(uuid "2195adc7-ab0b-4ee3-aa2e-b2786571de43")
|
|
||||||
)
|
|
||||||
(text "To Allow Wakeup via interrupt"
|
(text "To Allow Wakeup via interrupt"
|
||||||
(exclude_from_sim no)
|
(exclude_from_sim no)
|
||||||
(at 157.734 70.104 0)
|
(at 157.734 70.104 0)
|
||||||
@ -5050,10 +5021,6 @@
|
|||||||
(at 31.75 200.66)
|
(at 31.75 200.66)
|
||||||
(uuid "133b7027-41a1-4e09-a1e6-24d8bb033b2a")
|
(uuid "133b7027-41a1-4e09-a1e6-24d8bb033b2a")
|
||||||
)
|
)
|
||||||
(no_connect
|
|
||||||
(at 184.15 72.39)
|
|
||||||
(uuid "5a1ba32e-b2ae-4014-aefc-1b75b4dc3c15")
|
|
||||||
)
|
|
||||||
(no_connect
|
(no_connect
|
||||||
(at 184.15 67.31)
|
(at 184.15 67.31)
|
||||||
(uuid "6d645bf1-339f-4b38-a26a-bdd168ca591e")
|
(uuid "6d645bf1-339f-4b38-a26a-bdd168ca591e")
|
||||||
@ -6184,7 +6151,7 @@
|
|||||||
)
|
)
|
||||||
(global_label "WORKING"
|
(global_label "WORKING"
|
||||||
(shape input)
|
(shape input)
|
||||||
(at 224.79 87.63 0)
|
(at 224.79 72.39 0)
|
||||||
(fields_autoplaced yes)
|
(fields_autoplaced yes)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -6194,7 +6161,7 @@
|
|||||||
)
|
)
|
||||||
(uuid "0af53f6a-ea11-4d73-a8d1-f63ebcdc2e54")
|
(uuid "0af53f6a-ea11-4d73-a8d1-f63ebcdc2e54")
|
||||||
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
(at 235.6482 87.63 0)
|
(at 235.6482 72.39 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
@ -6468,6 +6435,28 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
(global_label "PUMP_ENABLE"
|
||||||
|
(shape input)
|
||||||
|
(at 184.15 72.39 180)
|
||||||
|
(fields_autoplaced yes)
|
||||||
|
(effects
|
||||||
|
(font
|
||||||
|
(size 1.27 1.27)
|
||||||
|
)
|
||||||
|
(justify right)
|
||||||
|
)
|
||||||
|
(uuid "2e795b18-a106-4105-bbb4-8c45273e4987")
|
||||||
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
|
(at 168.5143 72.39 0)
|
||||||
|
(effects
|
||||||
|
(font
|
||||||
|
(size 1.27 1.27)
|
||||||
|
)
|
||||||
|
(justify right)
|
||||||
|
(hide yes)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
(global_label "SDA"
|
(global_label "SDA"
|
||||||
(shape input)
|
(shape input)
|
||||||
(at 224.79 85.09 0)
|
(at 224.79 85.09 0)
|
||||||
@ -6712,22 +6701,44 @@
|
|||||||
)
|
)
|
||||||
(global_label "EXTRA_1"
|
(global_label "EXTRA_1"
|
||||||
(shape input)
|
(shape input)
|
||||||
(at 184.15 82.55 180)
|
(at 224.79 92.71 0)
|
||||||
(fields_autoplaced yes)
|
(fields_autoplaced yes)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
)
|
)
|
||||||
(justify right)
|
(justify left)
|
||||||
)
|
)
|
||||||
(uuid "4635eda0-e395-42c7-9764-c7b7fc3019ec")
|
(uuid "4635eda0-e395-42c7-9764-c7b7fc3019ec")
|
||||||
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
(at 173.9572 82.55 0)
|
(at 234.9828 92.71 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
)
|
)
|
||||||
(justify right)
|
(justify left)
|
||||||
|
(hide yes)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
(global_label "GND"
|
||||||
|
(shape input)
|
||||||
|
(at 59.69 135.89 0)
|
||||||
|
(fields_autoplaced yes)
|
||||||
|
(effects
|
||||||
|
(font
|
||||||
|
(size 1.27 1.27)
|
||||||
|
)
|
||||||
|
(justify left)
|
||||||
|
)
|
||||||
|
(uuid "472614c1-a2b1-4366-9d8e-904ae5de7b8a")
|
||||||
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
|
(at 65.8915 135.89 0)
|
||||||
|
(effects
|
||||||
|
(font
|
||||||
|
(size 1.27 1.27)
|
||||||
|
)
|
||||||
|
(justify left)
|
||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -7064,22 +7075,22 @@
|
|||||||
)
|
)
|
||||||
(global_label "WARN_LED"
|
(global_label "WARN_LED"
|
||||||
(shape input)
|
(shape input)
|
||||||
(at 224.79 92.71 0)
|
(at 184.15 82.55 180)
|
||||||
(fields_autoplaced yes)
|
(fields_autoplaced yes)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
)
|
)
|
||||||
(justify left)
|
(justify right)
|
||||||
)
|
)
|
||||||
(uuid "63850aa5-2eca-4827-9a2f-c5aed597072f")
|
(uuid "63850aa5-2eca-4827-9a2f-c5aed597072f")
|
||||||
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
(at 236.6762 92.71 0)
|
(at 172.2638 82.55 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
)
|
)
|
||||||
(justify left)
|
(justify right)
|
||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -7328,7 +7339,7 @@
|
|||||||
)
|
)
|
||||||
(global_label "EXTRA_2"
|
(global_label "EXTRA_2"
|
||||||
(shape input)
|
(shape input)
|
||||||
(at 224.79 72.39 0)
|
(at 224.79 87.63 0)
|
||||||
(fields_autoplaced yes)
|
(fields_autoplaced yes)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -7338,7 +7349,7 @@
|
|||||||
)
|
)
|
||||||
(uuid "79c7218b-c7f0-4a6c-8b1d-8ae92200b937")
|
(uuid "79c7218b-c7f0-4a6c-8b1d-8ae92200b937")
|
||||||
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
(property "Intersheetrefs" "${INTERSHEET_REFS}"
|
||||||
(at 234.9828 72.39 0)
|
(at 234.9828 87.63 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
(size 1.27 1.27)
|
(size 1.27 1.27)
|
||||||
@ -12065,7 +12076,7 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Description" "Light emitting diode"
|
(property "Description" ""
|
||||||
(at 142.24 115.57 0)
|
(at 142.24 115.57 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -12099,7 +12110,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
(property "Sim.Pins" ""
|
||||||
(at 142.24 115.57 0)
|
(at 142.24 115.57 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -12287,7 +12298,7 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Description" "Light emitting diode"
|
(property "Description" ""
|
||||||
(at 74.93 337.82 0)
|
(at 74.93 337.82 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -12321,7 +12332,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
(property "Sim.Pins" ""
|
||||||
(at 74.93 337.82 0)
|
(at 74.93 337.82 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -13620,7 +13631,7 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Description" "Light emitting diode"
|
(property "Description" ""
|
||||||
(at 113.03 107.95 0)
|
(at 113.03 107.95 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -13654,7 +13665,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
(property "Sim.Pins" ""
|
||||||
(at 113.03 107.95 0)
|
(at 113.03 107.95 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -14377,7 +14388,7 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Description" "Light emitting diode"
|
(property "Description" ""
|
||||||
(at 35.56 337.82 0)
|
(at 35.56 337.82 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -14411,7 +14422,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
(property "Sim.Pins" ""
|
||||||
(at 35.56 337.82 0)
|
(at 35.56 337.82 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -14928,7 +14939,7 @@
|
|||||||
(hide yes)
|
(hide yes)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Description" "Light emitting diode"
|
(property "Description" ""
|
||||||
(at 281.94 101.6 0)
|
(at 281.94 101.6 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
@ -14962,7 +14973,7 @@
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
(property "Sim.Pins" "1=K 2=A"
|
(property "Sim.Pins" ""
|
||||||
(at 281.94 101.6 0)
|
(at 281.94 101.6 0)
|
||||||
(effects
|
(effects
|
||||||
(font
|
(font
|
||||||
|
@ -166,40 +166,40 @@
|
|||||||
)
|
)
|
||||||
(pad "7" thru_hole rect
|
(pad "7" thru_hole rect
|
||||||
(at -0.5 -12)
|
(at -0.5 -12)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(uuid "536f0038-06c5-45e5-b1c8-898a364f6ec4")
|
(uuid "536f0038-06c5-45e5-b1c8-898a364f6ec4")
|
||||||
)
|
)
|
||||||
(pad "8" thru_hole rect
|
(pad "8" thru_hole rect
|
||||||
(at 39.5 -16)
|
(at 39.5 -16)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(uuid "3e0cdbaa-8219-48c4-bb0a-fd4f0e78a390")
|
(uuid "3e0cdbaa-8219-48c4-bb0a-fd4f0e78a390")
|
||||||
)
|
)
|
||||||
(pad "9" thru_hole rect
|
(pad "9" thru_hole rect
|
||||||
(at 39.5 22.5)
|
(at 39.5 22.5)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(uuid "f01565c2-eadd-4451-9dea-2ebe28d872f0")
|
(uuid "f01565c2-eadd-4451-9dea-2ebe28d872f0")
|
||||||
)
|
)
|
||||||
(pad "10" thru_hole rect
|
(pad "10" thru_hole rect
|
||||||
(at -0.5 15)
|
(at -0.5 15)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(uuid "56ec7c50-069f-4f46-9b83-ac18e4928930")
|
(uuid "56ec7c50-069f-4f46-9b83-ac18e4928930")
|
||||||
)
|
)
|
||||||
(pad "11" thru_hole rect
|
(pad "11" thru_hole rect
|
||||||
(at -43 22.5)
|
(at -43 22.5)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(uuid "f423be21-13b8-46de-8e19-e48325411a29")
|
(uuid "f423be21-13b8-46de-8e19-e48325411a29")
|
||||||
|
@ -738,7 +738,7 @@
|
|||||||
(type default)
|
(type default)
|
||||||
)
|
)
|
||||||
(layer "F.SilkS")
|
(layer "F.SilkS")
|
||||||
(uuid "23d58535-2840-4798-8fe6-a41e5dd82cfc")
|
(uuid "87f61a83-c9a2-45b6-a235-fe6e83f3dbe3")
|
||||||
)
|
)
|
||||||
(fp_line
|
(fp_line
|
||||||
(start -45 24)
|
(start -45 24)
|
||||||
@ -748,7 +748,7 @@
|
|||||||
(type default)
|
(type default)
|
||||||
)
|
)
|
||||||
(layer "F.SilkS")
|
(layer "F.SilkS")
|
||||||
(uuid "ed3c0755-343c-4d19-9481-c2c33348ef82")
|
(uuid "f24175c8-21e2-4899-af70-89e48457e9ba")
|
||||||
)
|
)
|
||||||
(fp_line
|
(fp_line
|
||||||
(start -44 24)
|
(start -44 24)
|
||||||
@ -758,7 +758,7 @@
|
|||||||
(type default)
|
(type default)
|
||||||
)
|
)
|
||||||
(layer "F.SilkS")
|
(layer "F.SilkS")
|
||||||
(uuid "cd2e639b-4e20-40a4-8976-6223f2753aeb")
|
(uuid "a884c661-0353-48a0-9bc6-995e02652e36")
|
||||||
)
|
)
|
||||||
(fp_line
|
(fp_line
|
||||||
(start 41 -18)
|
(start 41 -18)
|
||||||
@ -768,7 +768,7 @@
|
|||||||
(type default)
|
(type default)
|
||||||
)
|
)
|
||||||
(layer "F.SilkS")
|
(layer "F.SilkS")
|
||||||
(uuid "f34b006e-828a-45d3-b0f5-daad16782ed8")
|
(uuid "675d135e-52c1-4dd1-b434-983f40a2b544")
|
||||||
)
|
)
|
||||||
(fp_line
|
(fp_line
|
||||||
(start 41 24)
|
(start 41 24)
|
||||||
@ -778,7 +778,7 @@
|
|||||||
(type default)
|
(type default)
|
||||||
)
|
)
|
||||||
(layer "F.SilkS")
|
(layer "F.SilkS")
|
||||||
(uuid "03fcb85f-a42f-4eab-bf16-6ff7087e0441")
|
(uuid "fbfb2621-73ae-4c15-8403-abdec5cc45cd")
|
||||||
)
|
)
|
||||||
(fp_text user "${REFERENCE}"
|
(fp_text user "${REFERENCE}"
|
||||||
(at 0 2.5 0)
|
(at 0 2.5 0)
|
||||||
@ -860,8 +860,8 @@
|
|||||||
)
|
)
|
||||||
(pad "7" thru_hole rect
|
(pad "7" thru_hole rect
|
||||||
(at -0.5 -12)
|
(at -0.5 -12)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(net 1 "GND")
|
(net 1 "GND")
|
||||||
@ -871,8 +871,8 @@
|
|||||||
)
|
)
|
||||||
(pad "8" thru_hole rect
|
(pad "8" thru_hole rect
|
||||||
(at 39.5 -16)
|
(at 39.5 -16)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(net 1 "GND")
|
(net 1 "GND")
|
||||||
@ -882,8 +882,8 @@
|
|||||||
)
|
)
|
||||||
(pad "9" thru_hole rect
|
(pad "9" thru_hole rect
|
||||||
(at 39.5 22.5)
|
(at 39.5 22.5)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(net 1 "GND")
|
(net 1 "GND")
|
||||||
@ -893,8 +893,8 @@
|
|||||||
)
|
)
|
||||||
(pad "10" thru_hole rect
|
(pad "10" thru_hole rect
|
||||||
(at -0.5 15)
|
(at -0.5 15)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(net 1 "GND")
|
(net 1 "GND")
|
||||||
@ -904,8 +904,8 @@
|
|||||||
)
|
)
|
||||||
(pad "11" thru_hole rect
|
(pad "11" thru_hole rect
|
||||||
(at -43 22.5)
|
(at -43 22.5)
|
||||||
(size 1.7 1.7)
|
(size 0.85 0.85)
|
||||||
(drill 1)
|
(drill 0.5)
|
||||||
(layers "*.Cu" "*.Mask")
|
(layers "*.Cu" "*.Mask")
|
||||||
(remove_unused_layers no)
|
(remove_unused_layers no)
|
||||||
(net 1 "GND")
|
(net 1 "GND")
|
||||||
|
Binary file not shown.
@ -7,123 +7,54 @@ P arrayDim N
|
|||||||
317VBAT VIA MD0157PA00X+043130Y-035039X0315Y0000R000S3
|
317VBAT VIA MD0157PA00X+043130Y-035039X0315Y0000R000S3
|
||||||
317GND VIA MD1181PA00X+077500Y-007000X1575Y0000R000S3
|
317GND VIA MD1181PA00X+077500Y-007000X1575Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+062402Y-010433X0315Y0000R000S3
|
317GND VIA MD0157PA00X+062402Y-010433X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+054449Y-012323X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054134Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+044606Y-010551X0315Y0000R000S3
|
317GND VIA MD0157PA00X+062205Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+054921Y-011417X0315Y0000R000S3
|
317GND VIA MD0157PA00X+058169Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+050787Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+051772Y-009646X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+042126Y-008976X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+062205Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+059291Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+058150Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+054843Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+043228Y-012480X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047244Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+060374Y-011594X0315Y0000R000S3
|
|
||||||
317GND VIA MD1181PA00X+041500Y-042900X1575Y0000R000S3
|
317GND VIA MD1181PA00X+041500Y-042900X1575Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+047165Y-011260X0315Y0000R000S3
|
317GND VIA MD0157PA00X+059685Y-012402X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+042717Y-013031X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054429Y-011909X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+057008Y-012323X0315Y0000R000S3
|
317GND VIA MD0157PA00X+053346Y-010925X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+062205Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+062205Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+058917Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+040945Y-035630X0315Y0000R000S3
|
317GND VIA MD0157PA00X+040945Y-035630X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+059606Y-011575X0315Y0000R000S3
|
|
||||||
317GND VIA MD1181PA00X+077500Y-042900X1575Y0000R000S3
|
317GND VIA MD1181PA00X+077500Y-042900X1575Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+046890Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+059055Y-012402X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+054016Y-010591X0315Y0000R000S3
|
317GND VIA MD0157PA00X+056594Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+046457Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045039Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045748Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+051850Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+051260Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+054646Y-011142X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+043819Y-011929X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+046102Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+059646Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+050079Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+056594Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045118Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+061122Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+061122Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+043346Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054626Y-010827X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+056693Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+056693Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+044055Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+052559Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+050197Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+048228Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045669Y-007087X0315Y0000R000S3
|
317GND VIA MD0157PA00X+045669Y-007087X0315Y0000R000S3
|
||||||
|
317GND VIA MD0157PA00X+054724Y-012205X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+063386Y-011220X0315Y0000R000S3
|
317GND VIA MD0157PA00X+063386Y-011220X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+060472Y-012323X0315Y0000R000S3
|
317GND VIA MD0157PA00X+059685Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+045699Y-017156X0315Y0000R000S3
|
317GND VIA MD0157PA00X+045699Y-017156X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+048661Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+049724Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+048091Y-016535X0315Y0000R000S3
|
317GND VIA MD0157PA00X+048091Y-016535X0315Y0000R000S3
|
||||||
|
317GND VIA MD0157PA00X+053740Y-011220X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+048917Y-031102X0315Y0000R000S3
|
317GND VIA MD0157PA00X+048917Y-031102X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+056299Y-005591X0315Y0000R000S3
|
317GND VIA MD0157PA00X+056299Y-005591X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+053858Y-011693X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+049843Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+059232Y-011575X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+055709Y-011220X0315Y0000R000S3
|
317GND VIA MD0157PA00X+055709Y-011220X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+058169Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+058169Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+044094Y-011654X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+061654Y-008071X0315Y0000R000S3
|
317GND VIA MD0157PA00X+061654Y-008071X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+050551Y-011260X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054035Y-010138X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+049370Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054331Y-010531X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+042402Y-009213X0315Y0000R000S3
|
317GND VIA MD0157PA00X+055217Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+059980Y-011594X0315Y0000R000S3
|
317GND VIA MD0157PA00X+056102Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+056181Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+055315Y-011516X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+044409Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+055709Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+055276Y-012323X0315Y0000R000S3
|
317GND VIA MD0157PA00X+054921Y-011220X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+056181Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045394Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+060748Y-011614X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+044685Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+055276Y-011614X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+051142Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+055748Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+045827Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+052835Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+053189Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047953Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+052205Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+053780Y-010315X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+046181Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047283Y-023622X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+051496Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+059843Y-005591X0315Y0000R000S3
|
317GND VIA MD0157PA00X+059843Y-005591X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+053583Y-011378X0315Y0000R000S3
|
317GND VIA MD0157PA00X+050787Y-009646X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+049016Y-034154X0315Y0000R000S3
|
317GND VIA MD0157PA00X+049016Y-034154X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+045472Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+051772Y-008858X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+058543Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+054331Y-010866X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+046811Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+046555Y-030512X0315Y0000R000S3
|
317GND VIA MD0157PA00X+046555Y-030512X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+052913Y-009646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+061122Y-012303X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+043701Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+048307Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+061181Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+049488Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047520Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+060059Y-012323X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+042283Y-013386X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+044764Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047205Y-025709X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+055709Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+055709Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+060827Y-012323X0315Y0000R000S3
|
317GND VIA MD0157PA00X+059055Y-011614X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+054134Y-011969X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+046535Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+043504Y-012205X0315Y0000R000S3
|
|
||||||
317GND VIA MD1181PA00X+041575Y-007087X1575Y0000R000S3
|
317GND VIA MD1181PA00X+041575Y-007087X1575Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+050906Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+042992Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+040945Y-034646X0315Y0000R000S3
|
317GND VIA MD0157PA00X+040945Y-034646X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+063386Y-012598X0315Y0000R000S3
|
317GND VIA MD0157PA00X+063386Y-012598X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+047598Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+047874Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+042756Y-009291X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+050433Y-009646X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+048583Y-011260X0315Y0000R000S3
|
|
||||||
317GND VIA MD0157PA00X+048031Y-014567X0315Y0000R000S3
|
317GND VIA MD0157PA00X+048031Y-014567X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+057185Y-011614X0315Y0000R000S3
|
317GND VIA MD0157PA00X+057185Y-011516X0315Y0000R000S3
|
||||||
317GND VIA MD0157PA00X+042953Y-012756X0315Y0000R000S3
|
|
||||||
3173_3V VIA MD0157PA00X+064646Y-014567X0315Y0000R000S3
|
3173_3V VIA MD0157PA00X+064646Y-014567X0315Y0000R000S3
|
||||||
3173_3V VIA MD0157PA00X+075906Y-014331X0315Y0000R000S3
|
3173_3V VIA MD0157PA00X+075906Y-014331X0315Y0000R000S3
|
||||||
3173_3V VIA MD0157PA00X+074094Y-014331X0315Y0000R000S3
|
3173_3V VIA MD0157PA00X+074094Y-014331X0315Y0000R000S3
|
||||||
@ -145,19 +76,79 @@ P arrayDim N
|
|||||||
317ISDAY VIA MD0157PA00X+066929Y-011024X0315Y0000R000S3
|
317ISDAY VIA MD0157PA00X+066929Y-011024X0315Y0000R000S3
|
||||||
317LED_ENABLE VIA MD0157PA00X+064764Y-010728X0315Y0000R000S3
|
317LED_ENABLE VIA MD0157PA00X+064764Y-010728X0315Y0000R000S3
|
||||||
317WORKING VIA MD0157PA00X+058661Y-011417X0315Y0000R000S3
|
317WORKING VIA MD0157PA00X+058661Y-011417X0315Y0000R000S3
|
||||||
317WORKING VIA MD0157PA00X+069843Y-008858X0315Y0000R000S3
|
317WORKING VIA MD0157PA00X+071949Y-008169X0315Y0000R000S3
|
||||||
317ENABLE_TANK VIA MD0157PA00X+062894Y-011516X0315Y0000R000S3
|
317ENABLE_TANK VIA MD0157PA00X+062894Y-011516X0315Y0000R000S3
|
||||||
317ENABLE_TANK VIA MD0157PA00X+050525Y-015584X0315Y0000R000S3
|
317ENABLE_TANK VIA MD0157PA00X+050525Y-015584X0315Y0000R000S3
|
||||||
317USB_D- VIA MD0157PA00X+045276Y-010305X0315Y0000R000S3
|
|
||||||
317USB_D- VIA MD0157PA00X+063377Y-011752X0315Y0000R000S3
|
317USB_D- VIA MD0157PA00X+063377Y-011752X0315Y0000R000S3
|
||||||
|
317USB_D- VIA MD0157PA00X+052902Y-009500X0315Y0000R000S3
|
||||||
317FLOW VIA MD0157PA00X+048543Y-023228X0315Y0000R000S3
|
317FLOW VIA MD0157PA00X+048543Y-023228X0315Y0000R000S3
|
||||||
317FLOW VIA MD0157PA00X+063484Y-007382X0315Y0000R000S3
|
317FLOW VIA MD0157PA00X+063484Y-007382X0315Y0000R000S3
|
||||||
317USB_D+ VIA MD0157PA00X+045276Y-010719X0315Y0000R000S3
|
|
||||||
317USB_D+ VIA MD0157PA00X+063377Y-012165X0315Y0000R000S3
|
317USB_D+ VIA MD0157PA00X+063377Y-012165X0315Y0000R000S3
|
||||||
|
317USB_D+ VIA MD0157PA00X+052610Y-009792X0315Y0000R000S3
|
||||||
317BOOT_SEL VIA MD0157PA00X+064764Y-009744X0315Y0000R000S3
|
317BOOT_SEL VIA MD0157PA00X+064764Y-009744X0315Y0000R000S3
|
||||||
317BOOT_SEL VIA MD0157PA00X+070374Y-012205X0315Y0000R000S3
|
317BOOT_SEL VIA MD0157PA00X+070374Y-012205X0315Y0000R000S3
|
||||||
317WARN_LED VIA MD0157PA00X+069803Y-008465X0315Y0000R000S3
|
|
||||||
317WARN_LED VIA MD0157PA00X+044390Y-005807X0315Y0000R000S3
|
317WARN_LED VIA MD0157PA00X+044390Y-005807X0315Y0000R000S3
|
||||||
|
317WARN_LED VIA MD0157PA00X+063386Y-008268X0315Y0000R000S3
|
||||||
|
327GND U2 -1 A01X+064094Y-005709X0591Y0354R000S2
|
||||||
|
3273_3V U2 -2 A01X+064094Y-006209X0591Y0354R000S2
|
||||||
|
327EN U2 -3 A01X+064094Y-006709X0591Y0354R000S2
|
||||||
|
327FLOW U2 -4 A01X+064094Y-007209X0591Y0354R000S2
|
||||||
|
327TANK_SENSOR U2 -5 A01X+064094Y-007709X0591Y0354R000S2
|
||||||
|
327WARN_LED U2 -6 A01X+064094Y-008209X0591Y0354R000S2
|
||||||
|
327ISDAY U2 -7 A01X+064094Y-008709X0591Y0354R000S2
|
||||||
|
327-(U2-IO0-PAD8) U2 -8 A01X+064094Y-009209X0591Y0354R000S2
|
||||||
|
327BOOT_SEL U2 -9 A01X+064094Y-009709X0591Y0354R000S2
|
||||||
|
327(U2-IO8-PAD10) U2 -10 A01X+064094Y-010209X0591Y0354R000S2
|
||||||
|
327LED_ENABLE U2 -11 A01X+064094Y-010709X0591Y0354R000S2
|
||||||
|
327ENABLE_TANK U2 -12 A01X+064094Y-011209X0591Y0354R000S2
|
||||||
|
327USB_D- U2 -13 A01X+064094Y-011709X0591Y0354R000S2
|
||||||
|
327USB_D+ U2 -14 A01X+064094Y-012209X0591Y0354R000S2
|
||||||
|
327BOOT_SEL U2 -15 A01X+070984Y-012209X0591Y0354R000S2
|
||||||
|
327TEMP U2 -16 A01X+070984Y-011709X0591Y0354R000S2
|
||||||
|
327SCL U2 -17 A01X+070984Y-011209X0591Y0354R000S2
|
||||||
|
327SDA U2 -18 A01X+070984Y-010709X0591Y0354R000S2
|
||||||
|
327EXTRA_2 U2 -19 A01X+070984Y-010209X0591Y0354R000S2
|
||||||
|
327CD_PROBE U2 -20 A01X+070984Y-009709X0591Y0354R000S2
|
||||||
|
327EXTRA_1 U2 -21 A01X+070984Y-009209X0591Y0354R000S2
|
||||||
|
327-(U2-NC-PAD22) U2 -22 A01X+070984Y-008709X0591Y0354R000S2
|
||||||
|
327WORKING U2 -23 A01X+070984Y-008209X0591Y0354R000S2
|
||||||
|
327ESP_RX U2 -24 A01X+070984Y-007709X0591Y0354R000S2
|
||||||
|
327ESP_TX U2 -25 A01X+070984Y-007209X0591Y0354R000S2
|
||||||
|
327CHARGE U2 -26 A01X+070984Y-006709X0591Y0354R000S2
|
||||||
|
327PUMP_ENABLE U2 -27 A01X+070984Y-006209X0591Y0354R000S2
|
||||||
|
327GND U2 -28 A01X+070984Y-005709X0591Y0354R000S2
|
||||||
|
327GND U2 -29_5 A01X+066947Y-007961X0315Y0315R000S2
|
||||||
|
327GND U2 -29_1 A01X+066455Y-007469X0315Y0315R000S2
|
||||||
|
327GND U2 -29_2 A01X+066947Y-007469X0315Y0315R000S2
|
||||||
|
327GND U2 -29_3 A01X+067439Y-007469X0315Y0315R000S2
|
||||||
|
327GND U2 -29_4 A01X+066455Y-007961X0315Y0315R000S2
|
||||||
|
327GND U2 -29_6 A01X+067439Y-007961X0315Y0315R000S2
|
||||||
|
327GND U2 -29_7 A01X+066455Y-008453X0315Y0315R000S2
|
||||||
|
327GND U2 -29_8 A01X+066947Y-008453X0315Y0315R000S2
|
||||||
|
327GND U2 -29_9 A01X+067439Y-008453X0315Y0315R000S2
|
||||||
|
317GND U2 -30_1 D0098PA00X+066701Y-007469X0138Y0000R000S3
|
||||||
|
317GND U2 -30_2 D0098PA00X+067193Y-007469X0138Y0000R000S3
|
||||||
|
317GND U2 -30_3 D0098PA00X+066455Y-007715X0138Y0000R000S3
|
||||||
|
317GND U2 -30_4 D0098PA00X+066947Y-007715X0138Y0000R000S3
|
||||||
|
317GND U2 -30_5 D0098PA00X+067439Y-007715X0138Y0000R000S3
|
||||||
|
317GND U2 -30_6 D0098PA00X+066701Y-007961X0138Y0000R000S3
|
||||||
|
317GND U2 -30_7 D0098PA00X+067193Y-007961X0138Y0000R000S3
|
||||||
|
317GND U2 -30_8 D0098PA00X+066455Y-008207X0138Y0000R000S3
|
||||||
|
317GND U2 -30_9 D0098PA00X+066947Y-008207X0138Y0000R000S3
|
||||||
|
317GND U2 -30_1 D0098PA00X+067439Y-008207X0138Y0000R000S3
|
||||||
|
317GND U2 -30_1 D0098PA00X+066701Y-008453X0138Y0000R000S3
|
||||||
|
317GND U2 -30_1 D0098PA00X+067193Y-008453X0138Y0000R000S3
|
||||||
|
3173_3V U5 -1 D0394PA00X+046339Y-019764X0669Y0669R000S0
|
||||||
|
317(U5-VBAT-PAD2) U5 -2 D0394PA00X+046339Y-020764X0669Y0000R000S0
|
||||||
|
317SDA U5 -3 D0394PA00X+046339Y-021764X0669Y0000R000S0
|
||||||
|
317SCL U5 -4 D0394PA00X+046339Y-022764X0669Y0000R000S0
|
||||||
|
317CD_PROBE U5 -5 D0394PA00X+046339Y-023764X0669Y0000R000S0
|
||||||
|
317GND U5 -6 D0394PA00X+046339Y-024764X0669Y0000R000S0
|
||||||
|
317GND U5 -7 D0197PA00X+062835Y-021063X0335Y0335R000S0
|
||||||
|
317GND U5 -8 D0197PA00X+078583Y-019488X0335Y0335R000S0
|
||||||
|
317GND U5 -9 D0197PA00X+078583Y-034646X0335Y0335R000S0
|
||||||
|
317GND U5 -10 D0197PA00X+062835Y-031693X0335Y0335R000S0
|
||||||
|
317GND U5 -11 D0197PA00X+046102Y-034646X0335Y0335R000S0
|
||||||
327GND D11 -1 A01X+046506Y-030000X0581Y0236R180S2
|
327GND D11 -1 A01X+046506Y-030000X0581Y0236R180S2
|
||||||
327VBAT D11 -2 A01X+046506Y-029252X0581Y0236R180S2
|
327VBAT D11 -2 A01X+046506Y-029252X0581Y0236R180S2
|
||||||
327NET-(D10-K) D11 -3 A01X+045768Y-029626X0581Y0236R180S2
|
327NET-(D10-K) D11 -3 A01X+045768Y-029626X0581Y0236R180S2
|
||||||
@ -206,9 +197,9 @@ P arrayDim N
|
|||||||
327GND R16 -2 A01X+048091Y-016043X0315Y0374R180S2
|
327GND R16 -2 A01X+048091Y-016043X0315Y0374R180S2
|
||||||
327NET-(Q2-G) R22 -1 A01X+047805Y-034843X0315Y0374R000S2
|
327NET-(Q2-G) R22 -1 A01X+047805Y-034843X0315Y0374R000S2
|
||||||
327GND R22 -2 A01X+048455Y-034843X0315Y0374R000S2
|
327GND R22 -2 A01X+048455Y-034843X0315Y0374R000S2
|
||||||
327GND D5 -1 A01X+048027Y-023602X0581Y0236R180S2
|
|
||||||
3273_3V D5 -2 A01X+048027Y-022854X0581Y0236R180S2
|
|
||||||
327FLOW D5 -3 A01X+047288Y-023228X0581Y0236R180S2
|
327FLOW D5 -3 A01X+047288Y-023228X0581Y0236R180S2
|
||||||
|
3273_3V D5 -2 A01X+048027Y-022854X0581Y0236R180S2
|
||||||
|
327GND D5 -1 A01X+048027Y-023602X0581Y0236R180S2
|
||||||
327NET-(D2-K) D2 -1 A01X+043701Y-006570X0384Y0551R270S2
|
327NET-(D2-K) D2 -1 A01X+043701Y-006570X0384Y0551R270S2
|
||||||
327WARN_LED D2 -2 A01X+043701Y-005832X0384Y0551R270S2
|
327WARN_LED D2 -2 A01X+043701Y-005832X0384Y0551R270S2
|
||||||
327GND D6 -1 A01X+046043Y-016811X0581Y0236R180S2
|
327GND D6 -1 A01X+046043Y-016811X0581Y0236R180S2
|
||||||
@ -216,25 +207,25 @@ P arrayDim N
|
|||||||
327TANK_SENSOR D6 -3 A01X+045305Y-016437X0581Y0236R180S2
|
327TANK_SENSOR D6 -3 A01X+045305Y-016437X0581Y0236R180S2
|
||||||
327NET-(CD1-A) R9 -1 A01X+058661Y-010305X0315Y0374R090S2
|
327NET-(CD1-A) R9 -1 A01X+058661Y-010305X0315Y0374R090S2
|
||||||
327WORKING R9 -2 A01X+058661Y-010955X0315Y0374R090S2
|
327WORKING R9 -2 A01X+058661Y-010955X0315Y0374R090S2
|
||||||
317GND J6 -1 D0394PA00X+051921Y-008228X0669Y0669R090S0
|
317GND J6 -1 D0394PA00X+041319Y-014661X0669Y0669R180S0
|
||||||
3173_3V J6 -2 D0394PA00X+050921Y-008228X0669Y0000R090S0
|
3173_3V J6 -2 D0394PA00X+041319Y-013661X0669Y0000R180S0
|
||||||
317SDA J6 -3 D0394PA00X+049921Y-008228X0669Y0000R090S0
|
317SDA J6 -3 D0394PA00X+041319Y-012661X0669Y0000R180S0
|
||||||
317SCL J6 -4 D0394PA00X+048921Y-008228X0669Y0000R090S0
|
317SCL J6 -4 D0394PA00X+041319Y-011661X0669Y0000R180S0
|
||||||
317SQW J6 -5 D0394PA00X+047921Y-008228X0669Y0000R090S0
|
317SQW J6 -5 D0394PA00X+041319Y-010661X0669Y0000R180S0
|
||||||
31732K J6 -6 D0394PA00X+046921Y-008228X0669Y0000R090S0
|
31732K J6 -6 D0394PA00X+041319Y-009661X0669Y0000R180S0
|
||||||
327NET-(D8-K) D8 -1 A01X+040945Y-033243X0384Y0551R270S2
|
327NET-(D8-K) D8 -1 A01X+040945Y-033243X0384Y0551R270S2
|
||||||
327NET-(D8-A) D8 -2 A01X+040945Y-032505X0384Y0551R270S2
|
327NET-(D8-A) D8 -2 A01X+040945Y-032505X0384Y0551R270S2
|
||||||
327NET-(J2-PIN_2) R2 -1 A01X+042943Y-014764X0315Y0374R000S2
|
327NET-(J2-PIN_2) R2 -1 A01X+046457Y-005581X0315Y0374R090S2
|
||||||
327GND R2 -2 A01X+043593Y-014764X0315Y0374R000S2
|
327GND R2 -2 A01X+046457Y-006230X0315Y0374R090S2
|
||||||
327USB_D+ U1 -1 A01X+044124Y-010945X0522Y0236R180S2
|
327USB_D+ U1 -1 A01X+050251Y-009286X0522Y0236R180S2
|
||||||
327GND U1 -2 A01X+044124Y-010571X0522Y0236R180S2
|
327GND U1 -2 A01X+050251Y-008912X0522Y0236R180S2
|
||||||
327USB_D- U1 -3 A01X+044124Y-010197X0522Y0236R180S2
|
327USB_D- U1 -3 A01X+050251Y-008538X0522Y0236R180S2
|
||||||
327SLASH}O2-PAD4) U1 -4 A01X+043228Y-010197X0522Y0236R180S2
|
327SLASH}O2-PAD4) U1 -4 A01X+049355Y-008538X0522Y0236R180S2
|
||||||
327USB_BUS U1 -5 A01X+043228Y-010571X0522Y0236R180S2
|
327USB_BUS U1 -5 A01X+049355Y-008912X0522Y0236R180S2
|
||||||
327SLASH}O1-PAD6) U1 -6 A01X+043228Y-010945X0522Y0236R180S2
|
327SLASH}O1-PAD6) U1 -6 A01X+049355Y-009286X0522Y0236R180S2
|
||||||
327GND D7 -1 A01X+048027Y-025669X0581Y0236R180S2
|
|
||||||
3273_3V D7 -2 A01X+048027Y-024921X0581Y0236R180S2
|
|
||||||
327TEMP D7 -3 A01X+047288Y-025295X0581Y0236R180S2
|
327TEMP D7 -3 A01X+047288Y-025295X0581Y0236R180S2
|
||||||
|
3273_3V D7 -2 A01X+048027Y-024921X0581Y0236R180S2
|
||||||
|
327GND D7 -1 A01X+048027Y-025669X0581Y0236R180S2
|
||||||
327VBAT C8 -1 A01X+042534Y-036024X0463Y0571R180S2
|
327VBAT C8 -1 A01X+042534Y-036024X0463Y0571R180S2
|
||||||
327GND C8 -2 A01X+041718Y-036024X0463Y0571R180S2
|
327GND C8 -2 A01X+041718Y-036024X0463Y0571R180S2
|
||||||
327NET-(R3-PAD1) R3 -1 A01X+057677Y-012933X0315Y0374R090S2
|
327NET-(R3-PAD1) R3 -1 A01X+057677Y-012933X0315Y0374R090S2
|
||||||
@ -270,59 +261,10 @@ P arrayDim N
|
|||||||
327BOOT_SEL C5 -2 A01X+062992Y-009700X0423Y0374R270S2
|
327BOOT_SEL C5 -2 A01X+062992Y-009700X0423Y0374R270S2
|
||||||
327TANK_SENSOR R12 -1 A01X+047215Y-016831X0404Y0551R270S2
|
327TANK_SENSOR R12 -1 A01X+047215Y-016831X0404Y0551R270S2
|
||||||
3273_3V R12 -2 A01X+047215Y-016112X0404Y0551R270S2
|
3273_3V R12 -2 A01X+047215Y-016112X0404Y0551R270S2
|
||||||
327NET-(D2-K) R1 -1 A01X+044488Y-008317X0315Y0374R270S2
|
327NET-(D2-K) R1 -1 A01X+045935Y-007874X0315Y0374R000S2
|
||||||
327GND R1 -2 A01X+044488Y-007667X0315Y0374R270S2
|
327GND R1 -2 A01X+046585Y-007874X0315Y0374R000S2
|
||||||
327EXTRA_1 R20 -1 A01X+048455Y-031890X0315Y0374R180S2
|
327EXTRA_1 R20 -1 A01X+048455Y-031890X0315Y0374R180S2
|
||||||
327NET-(Q3-G) R20 -2 A01X+047805Y-031890X0315Y0374R180S2
|
327NET-(Q3-G) R20 -2 A01X+047805Y-031890X0315Y0374R180S2
|
||||||
327GND U2 -1 A01X+064094Y-005709X0591Y0354R000S2
|
|
||||||
3273_3V U2 -2 A01X+064094Y-006209X0591Y0354R000S2
|
|
||||||
327EN U2 -3 A01X+064094Y-006709X0591Y0354R000S2
|
|
||||||
327FLOW U2 -4 A01X+064094Y-007209X0591Y0354R000S2
|
|
||||||
327TANK_SENSOR U2 -5 A01X+064094Y-007709X0591Y0354R000S2
|
|
||||||
327EXTRA_1 U2 -6 A01X+064094Y-008209X0591Y0354R000S2
|
|
||||||
327ISDAY U2 -7 A01X+064094Y-008709X0591Y0354R000S2
|
|
||||||
327-(U2-IO0-PAD8) U2 -8 A01X+064094Y-009209X0591Y0354R000S2
|
|
||||||
327BOOT_SEL U2 -9 A01X+064094Y-009709X0591Y0354R000S2
|
|
||||||
327(U2-IO8-PAD10) U2 -10 A01X+064094Y-010209X0591Y0354R000S2
|
|
||||||
327LED_ENABLE U2 -11 A01X+064094Y-010709X0591Y0354R000S2
|
|
||||||
327ENABLE_TANK U2 -12 A01X+064094Y-011209X0591Y0354R000S2
|
|
||||||
327USB_D- U2 -13 A01X+064094Y-011709X0591Y0354R000S2
|
|
||||||
327USB_D+ U2 -14 A01X+064094Y-012209X0591Y0354R000S2
|
|
||||||
327BOOT_SEL U2 -15 A01X+070984Y-012209X0591Y0354R000S2
|
|
||||||
327TEMP U2 -16 A01X+070984Y-011709X0591Y0354R000S2
|
|
||||||
327SCL U2 -17 A01X+070984Y-011209X0591Y0354R000S2
|
|
||||||
327SDA U2 -18 A01X+070984Y-010709X0591Y0354R000S2
|
|
||||||
327WORKING U2 -19 A01X+070984Y-010209X0591Y0354R000S2
|
|
||||||
327CD_PROBE U2 -20 A01X+070984Y-009709X0591Y0354R000S2
|
|
||||||
327WARN_LED U2 -21 A01X+070984Y-009209X0591Y0354R000S2
|
|
||||||
327-(U2-NC-PAD22) U2 -22 A01X+070984Y-008709X0591Y0354R000S2
|
|
||||||
327EXTRA_2 U2 -23 A01X+070984Y-008209X0591Y0354R000S2
|
|
||||||
327ESP_RX U2 -24 A01X+070984Y-007709X0591Y0354R000S2
|
|
||||||
327ESP_TX U2 -25 A01X+070984Y-007209X0591Y0354R000S2
|
|
||||||
327CHARGE U2 -26 A01X+070984Y-006709X0591Y0354R000S2
|
|
||||||
327PUMP_ENABLE U2 -27 A01X+070984Y-006209X0591Y0354R000S2
|
|
||||||
327GND U2 -28 A01X+070984Y-005709X0591Y0354R000S2
|
|
||||||
327GND U2 -29_1 A01X+066455Y-007469X0315Y0315R000S2
|
|
||||||
327GND U2 -29_2 A01X+066947Y-007469X0315Y0315R000S2
|
|
||||||
327GND U2 -29_3 A01X+067439Y-007469X0315Y0315R000S2
|
|
||||||
327GND U2 -29_4 A01X+066455Y-007961X0315Y0315R000S2
|
|
||||||
327GND U2 -29_5 A01X+066947Y-007961X0315Y0315R000S2
|
|
||||||
327GND U2 -29_6 A01X+067439Y-007961X0315Y0315R000S2
|
|
||||||
327GND U2 -29_7 A01X+066455Y-008453X0315Y0315R000S2
|
|
||||||
327GND U2 -29_8 A01X+066947Y-008453X0315Y0315R000S2
|
|
||||||
327GND U2 -29_9 A01X+067439Y-008453X0315Y0315R000S2
|
|
||||||
317GND U2 -30_1 D0098PA00X+066701Y-007469X0138Y0000R000S3
|
|
||||||
317GND U2 -30_2 D0098PA00X+067193Y-007469X0138Y0000R000S3
|
|
||||||
317GND U2 -30_3 D0098PA00X+066455Y-007715X0138Y0000R000S3
|
|
||||||
317GND U2 -30_4 D0098PA00X+066947Y-007715X0138Y0000R000S3
|
|
||||||
317GND U2 -30_5 D0098PA00X+067439Y-007715X0138Y0000R000S3
|
|
||||||
317GND U2 -30_6 D0098PA00X+066701Y-007961X0138Y0000R000S3
|
|
||||||
317GND U2 -30_7 D0098PA00X+067193Y-007961X0138Y0000R000S3
|
|
||||||
317GND U2 -30_8 D0098PA00X+066455Y-008207X0138Y0000R000S3
|
|
||||||
317GND U2 -30_9 D0098PA00X+066947Y-008207X0138Y0000R000S3
|
|
||||||
317GND U2 -30_1 D0098PA00X+067439Y-008207X0138Y0000R000S3
|
|
||||||
317GND U2 -30_1 D0098PA00X+066701Y-008453X0138Y0000R000S3
|
|
||||||
317GND U2 -30_1 D0098PA00X+067193Y-008453X0138Y0000R000S3
|
|
||||||
317NET-(D10-K) Extra_-1 D0394PA00X+042283Y-029616X0669Y0787R270S0
|
317NET-(D10-K) Extra_-1 D0394PA00X+042283Y-029616X0669Y0787R270S0
|
||||||
317VBAT Extra_-2 D0394PA00X+042283Y-028632X0669Y0787R270S0
|
317VBAT Extra_-2 D0394PA00X+042283Y-028632X0669Y0787R270S0
|
||||||
327GND D1 -1 A01X+047441Y-014469X0581Y0236R180S2
|
327GND D1 -1 A01X+047441Y-014469X0581Y0236R180S2
|
||||||
@ -334,19 +276,8 @@ P arrayDim N
|
|||||||
327NET-(Q2-G) R23 -2 A01X+047805Y-035728X0315Y0374R180S2
|
327NET-(Q2-G) R23 -2 A01X+047805Y-035728X0315Y0374R180S2
|
||||||
327VBAT R18 -1 A01X+046033Y-028445X0315Y0374R000S2
|
327VBAT R18 -1 A01X+046033Y-028445X0315Y0374R000S2
|
||||||
327NET-(D10-A) R18 -2 A01X+046683Y-028445X0315Y0374R000S2
|
327NET-(D10-A) R18 -2 A01X+046683Y-028445X0315Y0374R000S2
|
||||||
3173_3V U5 -1 D0394PA00X+046339Y-019764X0669Y0669R000S0
|
327NET-(J2-PIN_5) R4 -1 A01X+053150Y-005581X0315Y0374R090S2
|
||||||
317(U5-VBAT-PAD2) U5 -2 D0394PA00X+046339Y-020764X0669Y0000R000S0
|
327GND R4 -2 A01X+053150Y-006230X0315Y0374R090S2
|
||||||
317SDA U5 -3 D0394PA00X+046339Y-021764X0669Y0000R000S0
|
|
||||||
317SCL U5 -4 D0394PA00X+046339Y-022764X0669Y0000R000S0
|
|
||||||
317CD_PROBE U5 -5 D0394PA00X+046339Y-023764X0669Y0000R000S0
|
|
||||||
317GND U5 -6 D0394PA00X+046339Y-024764X0669Y0000R000S0
|
|
||||||
317GND U5 -7 D0394PA00X+062835Y-021063X0669Y0669R000S0
|
|
||||||
317GND U5 -8 D0394PA00X+078583Y-019488X0669Y0669R000S0
|
|
||||||
317GND U5 -9 D0394PA00X+078583Y-034646X0669Y0669R000S0
|
|
||||||
317GND U5 -10 D0394PA00X+062835Y-031693X0669Y0669R000S0
|
|
||||||
317GND U5 -11 D0394PA00X+046102Y-034646X0669Y0669R000S0
|
|
||||||
327NET-(J2-PIN_3) R4 -1 A01X+042943Y-014134X0315Y0374R000S2
|
|
||||||
327GND R4 -2 A01X+043593Y-014134X0315Y0374R000S2
|
|
||||||
327NET-(D10-K) D10 -1 A01X+040945Y-029542X0384Y0551R270S2
|
327NET-(D10-K) D10 -1 A01X+040945Y-029542X0384Y0551R270S2
|
||||||
327NET-(D10-A) D10 -2 A01X+040945Y-028804X0384Y0551R270S2
|
327NET-(D10-A) D10 -2 A01X+040945Y-028804X0384Y0551R270S2
|
||||||
317NET-(J4-PIN_1) J4 -1 D0295PA00X+042323Y-017638X0472Y0689R270S0
|
317NET-(J4-PIN_1) J4 -1 D0295PA00X+042323Y-017638X0472Y0689R270S0
|
||||||
@ -366,12 +297,12 @@ P arrayDim N
|
|||||||
327NET-(CD1-A) CD1 -2 A01X+045177Y-005832X0384Y0551R270S2
|
327NET-(CD1-A) CD1 -2 A01X+045177Y-005832X0384Y0551R270S2
|
||||||
327GND C4 -1 A01X+060630Y-011166X0423Y0374R270S2
|
327GND C4 -1 A01X+060630Y-011166X0423Y0374R270S2
|
||||||
327NET-(C4-PAD2) C4 -2 A01X+060630Y-010487X0423Y0374R270S2
|
327NET-(C4-PAD2) C4 -2 A01X+060630Y-010487X0423Y0374R270S2
|
||||||
317USB_BUS J2 -1 D0295PA00X+041260Y-009803X0472Y0689R090S0
|
317USB_BUS J2 -1 D0295PA00X+047835Y-006142X0472Y0689R000S0
|
||||||
317NET-(J2-PIN_2) J2 -2 D0295PA00X+041260Y-010591X0472Y0689R090S0
|
317NET-(J2-PIN_2) J2 -2 D0295PA00X+048622Y-006142X0472Y0689R000S0
|
||||||
317NET-(J2-PIN_3) J2 -3 D0295PA00X+041260Y-011378X0472Y0689R090S0
|
317USB_D+ J2 -3 D0295PA00X+049409Y-006142X0472Y0689R000S0
|
||||||
317USB_D- J2 -4 D0295PA00X+041260Y-012165X0472Y0689R090S0
|
317USB_D- J2 -4 D0295PA00X+050197Y-006142X0472Y0689R000S0
|
||||||
317USB_D+ J2 -5 D0295PA00X+041260Y-012953X0472Y0689R090S0
|
317NET-(J2-PIN_5) J2 -5 D0295PA00X+050984Y-006142X0472Y0689R000S0
|
||||||
317GND J2 -6 D0295PA00X+041260Y-013740X0472Y0689R090S0
|
317GND J2 -6 D0295PA00X+051772Y-006142X0472Y0689R000S0
|
||||||
3273_3V R15 -1 A01X+049680Y-023228X0315Y0374R180S2
|
3273_3V R15 -1 A01X+049680Y-023228X0315Y0374R180S2
|
||||||
327FLOW R15 -2 A01X+049031Y-023228X0315Y0374R180S2
|
327FLOW R15 -2 A01X+049031Y-023228X0315Y0374R180S2
|
||||||
327NET-(Q1-G) Q1 -1 A01X+048770Y-016831X0354Y0315R090S2
|
327NET-(Q1-G) Q1 -1 A01X+048770Y-016831X0354Y0315R090S2
|
||||||
@ -382,9 +313,9 @@ P arrayDim N
|
|||||||
327NET-(Q2-G) Q2 -1 A01X+047776Y-034142X0354Y0315R270S2
|
327NET-(Q2-G) Q2 -1 A01X+047776Y-034142X0354Y0315R270S2
|
||||||
327GND Q2 -2 A01X+048524Y-034142X0354Y0315R270S2
|
327GND Q2 -2 A01X+048524Y-034142X0354Y0315R270S2
|
||||||
327NET-(D8-K) Q2 -3 A01X+048150Y-033354X0354Y0315R270S2
|
327NET-(D8-K) Q2 -3 A01X+048150Y-033354X0354Y0315R270S2
|
||||||
317VBAT U7 -1 D0433PA00X+042795Y-037835X0750Y0787R180S0
|
317VBAT U7 -1 D0433PA00X+042795Y-040315X0750Y0787R180S0
|
||||||
317GND U7 -2 D0433PA00X+041795Y-037835X0750Y0787R180S0
|
317GND U7 -2 D0433PA00X+041795Y-040315X0750Y0787R180S0
|
||||||
3173_3V U7 -3 D0433PA00X+040795Y-037835X0750Y0787R180S0
|
3173_3V U7 -3 D0433PA00X+040795Y-040315X0750Y0787R180S0
|
||||||
317GND J1 -1 D0394PA00X+044882Y-012047X0669Y0669R000S0
|
317GND J1 -1 D0394PA00X+044882Y-012047X0669Y0669R000S0
|
||||||
317SCL J1 -2 D0394PA00X+044882Y-013047X0669Y0000R000S0
|
317SCL J1 -2 D0394PA00X+044882Y-013047X0669Y0000R000S0
|
||||||
317SDA J1 -3 D0394PA00X+044882Y-014047X0669Y0000R000S0
|
317SDA J1 -3 D0394PA00X+044882Y-014047X0669Y0000R000S0
|
||||||
|
@ -5,20 +5,20 @@ target = "riscv32imac-esp-espidf"
|
|||||||
[target.riscv32imac-esp-espidf]
|
[target.riscv32imac-esp-espidf]
|
||||||
linker = "ldproxy"
|
linker = "ldproxy"
|
||||||
#runner = "espflash flash --monitor --baud 921600 --partition-table partitions.csv -b no-reset" # Select this runner in case of usb ttl
|
#runner = "espflash flash --monitor --baud 921600 --partition-table partitions.csv -b no-reset" # Select this runner in case of usb ttl
|
||||||
runner = "espflash flash --monitor"
|
#runner = "espflash flash --monitor"
|
||||||
#runner = "cargo runner"
|
runner = "cargo runner"
|
||||||
|
|
||||||
|
|
||||||
#runner = "espflash flash --monitor --partition-table partitions.csv -b no-reset" # create upgrade image file for webupload
|
#runner = "espflash flash --monitor --partition-table partitions.csv -b no-reset" # create upgrade image file for webupload
|
||||||
# runner = espflash erase-parts otadata //ensure flash is clean
|
# runner = espflash erase-parts otadata //ensure flash is clean
|
||||||
|
|
||||||
rustflags = ["--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
|
rustflags = [ "--cfg", "espidf_time64"] # Extending time_t for ESP IDF 5: https://github.com/esp-rs/rust/issues/110
|
||||||
|
|
||||||
[unstable]
|
[unstable]
|
||||||
build-std = ["std", "panic_abort"]
|
build-std = ["std", "panic_abort"]
|
||||||
|
|
||||||
[env]
|
[env]
|
||||||
MCU = "esp32c6"
|
MCU="esp32c6"
|
||||||
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
|
# Note: this variable is not used by the pio builder (`cargo build --features pio`)
|
||||||
ESP_IDF_VERSION = "v5.2.1"
|
ESP_IDF_VERSION = "v5.2.1"
|
||||||
CHRONO_TZ_TIMEZONE_FILTER = "UTC|America/New_York|America/Chicago|America/Los_Angeles|Europe/London|Europe/Berlin|Europe/Paris|Asia/Tokyo|Asia/Shanghai|Asia/Kolkata|Australia/Sydney|America/Sao_Paulo|Africa/Johannesburg|Asia/Dubai|Pacific/Auckland"
|
CHRONO_TZ_TIMEZONE_FILTER = "UTC|America/New_York|America/Chicago|America/Los_Angeles|Europe/London|Europe/Berlin|Europe/Paris|Asia/Tokyo|Asia/Shanghai|Asia/Kolkata|Australia/Sydney|America/Sao_Paulo|Africa/Johannesburg|Asia/Dubai|Pacific/Auckland"
|
||||||
|
7
rust/.idea/dictionaries/project.xml
generated
7
rust/.idea/dictionaries/project.xml
generated
@ -1,14 +1,7 @@
|
|||||||
<component name="ProjectDictionaryState">
|
<component name="ProjectDictionaryState">
|
||||||
<dictionary name="project">
|
<dictionary name="project">
|
||||||
<words>
|
<words>
|
||||||
<w>buildtime</w>
|
|
||||||
<w>deepsleep</w>
|
|
||||||
<w>githash</w>
|
|
||||||
<w>lightstate</w>
|
|
||||||
<w>mppt</w>
|
|
||||||
<w>plantstate</w>
|
|
||||||
<w>sntp</w>
|
<w>sntp</w>
|
||||||
<w>vergen</w>
|
|
||||||
</words>
|
</words>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</component>
|
</component>
|
@ -1,11 +1,6 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
<component name="InspectionProjectProfileManager">
|
||||||
<profile version="1.0">
|
<profile version="1.0">
|
||||||
<option name="myName" value="Project Default" />
|
<option name="myName" value="Project Default" />
|
||||||
<inspection_tool class="DuplicatedCode" enabled="true" level="WEAK WARNING" enabled_by_default="true">
|
|
||||||
<Languages>
|
|
||||||
<language minSize="102" name="Rust" />
|
|
||||||
</Languages>
|
|
||||||
</inspection_tool>
|
|
||||||
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
<inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
|
||||||
</profile>
|
</profile>
|
||||||
</component>
|
</component>
|
@ -10,12 +10,15 @@ resolver = "2"
|
|||||||
# Explicitly disable LTO which the Xtensa codegen backend has issues
|
# Explicitly disable LTO which the Xtensa codegen backend has issues
|
||||||
lto = false
|
lto = false
|
||||||
strip = false
|
strip = false
|
||||||
debug = true
|
debug = true
|
||||||
overflow-checks = true
|
overflow-checks = true
|
||||||
panic = "abort"
|
panic = "abort"
|
||||||
incremental = true
|
incremental = true
|
||||||
opt-level = 2
|
opt-level = "s"
|
||||||
|
|
||||||
|
[profile.dev.build-override]
|
||||||
|
opt-level = 1
|
||||||
|
incremental = true
|
||||||
|
|
||||||
[package.metadata.cargo_runner]
|
[package.metadata.cargo_runner]
|
||||||
# The string `$TARGET_FILE` will be replaced with the path from cargo.
|
# The string `$TARGET_FILE` will be replaced with the path from cargo.
|
||||||
@ -35,13 +38,13 @@ command = [
|
|||||||
partition_table = "partitions.csv"
|
partition_table = "partitions.csv"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["std", "esp-idf-svc/native"]
|
default = ["std", "embassy", "esp-idf-svc/native"]
|
||||||
pio = ["esp-idf-svc/pio"]
|
pio = ["esp-idf-svc/pio"]
|
||||||
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
|
std = ["alloc", "esp-idf-svc/binstart", "esp-idf-svc/std"]
|
||||||
alloc = ["esp-idf-svc/alloc"]
|
alloc = ["esp-idf-svc/alloc"]
|
||||||
nightly = ["esp-idf-svc/nightly"]
|
nightly = ["esp-idf-svc/nightly"]
|
||||||
experimental = ["esp-idf-svc/experimental"]
|
experimental = ["esp-idf-svc/experimental"]
|
||||||
#embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]
|
embassy = ["esp-idf-svc/embassy-sync", "esp-idf-svc/critical-section", "esp-idf-svc/embassy-time-driver"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
#ESP stuff
|
#ESP stuff
|
||||||
@ -51,7 +54,7 @@ esp-idf-sys = { version = "0.36.1", features = ["binstart", "native"] }
|
|||||||
esp-idf-svc = { version = "0.51.0", default-features = false }
|
esp-idf-svc = { version = "0.51.0", default-features = false }
|
||||||
embedded-hal = "1.0.0"
|
embedded-hal = "1.0.0"
|
||||||
heapless = { version = "0.8", features = ["serde"] }
|
heapless = { version = "0.8", features = ["serde"] }
|
||||||
embedded-hal-bus = { version = "0.3.0", features = ["std"] }
|
embedded-hal-bus = { version = "0.2.0", features = ["std"] }
|
||||||
|
|
||||||
#Hardware additional driver
|
#Hardware additional driver
|
||||||
ds18b20 = "0.1.1"
|
ds18b20 = "0.1.1"
|
||||||
@ -66,16 +69,16 @@ strum = { version = "0.27.0", features = ["derive"] }
|
|||||||
measurements = "0.11.0"
|
measurements = "0.11.0"
|
||||||
|
|
||||||
#json
|
#json
|
||||||
serde = { version = "1.0.192", features = ["derive"] }
|
serde = { version = "1.0.192", features = ["derive"] }
|
||||||
serde_json = "1.0.108"
|
serde_json = "1.0.108"
|
||||||
|
|
||||||
#timezone
|
#timezone
|
||||||
chrono = { version = "0.4.23", default-features = false, features = ["iana-time-zone", "alloc", "serde"] }
|
chrono = { version = "0.4.23", default-features = false , features = ["iana-time-zone" , "alloc", "serde"] }
|
||||||
chrono-tz = { version = "0.10.3", default-features = false, features = ["filter-by-regex"] }
|
chrono-tz = {version="0.8.0", default-features = false , features = [ "filter-by-regex" ]}
|
||||||
eeprom24x = "0.7.2"
|
eeprom24x = "0.7.2"
|
||||||
url = "2.5.3"
|
url = "2.5.3"
|
||||||
crc = "3.2.1"
|
crc = "3.2.1"
|
||||||
bincode = "2.0.1"
|
bincode = "1.3.3"
|
||||||
ringbuffer = "0.15.0"
|
ringbuffer = "0.15.0"
|
||||||
text-template = "0.1.0"
|
text-template = "0.1.0"
|
||||||
strum_macros = "0.27.0"
|
strum_macros = "0.27.0"
|
||||||
@ -83,7 +86,6 @@ esp-ota = { version = "0.2.2", features = ["log"] }
|
|||||||
unit-enum = "1.4.1"
|
unit-enum = "1.4.1"
|
||||||
pca9535 = { version = "2.0.0", features = ["std"] }
|
pca9535 = { version = "2.0.0", features = ["std"] }
|
||||||
ina219 = { version = "0.2.0", features = ["std"] }
|
ina219 = { version = "0.2.0", features = ["std"] }
|
||||||
embedded-storage = "=0.3.1"
|
|
||||||
|
|
||||||
|
|
||||||
[patch.crates-io]
|
[patch.crates-io]
|
||||||
@ -96,5 +98,5 @@ embedded-storage = "=0.3.1"
|
|||||||
|
|
||||||
[build-dependencies]
|
[build-dependencies]
|
||||||
cc = "=1.1.30"
|
cc = "=1.1.30"
|
||||||
embuild = { version = "0.32.0", features = ["espidf"] }
|
embuild = { version= "0.32.0", features = ["espidf"]}
|
||||||
vergen = { version = "8.2.6", features = ["build", "git", "gitcl"] }
|
vergen = { version = "8.2.6", features = ["build", "git", "gitcl"] }
|
||||||
|
@ -22,22 +22,6 @@ fn main() {
|
|||||||
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
|
|
||||||
// move webpack results to rust webserver src
|
|
||||||
let _ = Command::new("cmd")
|
|
||||||
.arg("/K")
|
|
||||||
.arg("move")
|
|
||||||
.arg("./src_webpack/bundle.js")
|
|
||||||
.arg("./src/webserver")
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
let _ = Command::new("cmd")
|
|
||||||
.arg("/K")
|
|
||||||
.arg("move")
|
|
||||||
.arg("./src_webpack/index.html")
|
|
||||||
.arg("./src/webserver")
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
Err(_) => {
|
Err(_) => {
|
||||||
println!("Assuming build on linux");
|
println!("Assuming build on linux");
|
||||||
@ -50,18 +34,6 @@ fn main() {
|
|||||||
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
println!("stdout: {}", String::from_utf8_lossy(&output.stdout));
|
||||||
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
println!("stderr: {}", String::from_utf8_lossy(&output.stderr));
|
||||||
assert!(output.status.success());
|
assert!(output.status.success());
|
||||||
|
|
||||||
// move webpack results to rust webserver src
|
|
||||||
let _ = Command::new("mv")
|
|
||||||
.arg("./src_webpack/bundle.js")
|
|
||||||
.arg("./src/webserver")
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
let _ = Command::new("mv")
|
|
||||||
.arg("./src_webpack/index.html")
|
|
||||||
.arg("./src/webserver")
|
|
||||||
.output()
|
|
||||||
.unwrap();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
partition_table = "partitions.csv"
|
partition_table="partitions.csv"
|
||||||
[connection]
|
[connection]
|
||||||
serial = "/dev/ttyACM0"
|
serial = "/dev/ttyACM0"
|
||||||
|
baudrate = 921600
|
||||||
[flash]
|
[flash]
|
||||||
size = "16MB"
|
size = "16MB"
|
@ -2,5 +2,5 @@ nvs, data, nvs, , 16k,
|
|||||||
otadata, data, ota, , 8k,
|
otadata, data, ota, , 8k,
|
||||||
phy_init, data, phy, , 4k,
|
phy_init, data, phy, , 4k,
|
||||||
ota_0, app, ota_0, , 3968k,
|
ota_0, app, ota_0, , 3968k,
|
||||||
ota_1, app, ota_1, , 3968k,
|
ota_1, app, ota_0, , 3968k,
|
||||||
storage, data, spiffs, , 8M,
|
storage, data, spiffs, , 8M,
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
|
use crate::to_string;
|
||||||
use anyhow::anyhow;
|
use anyhow::anyhow;
|
||||||
use bq34z100::{Bq34Z100Error, Bq34z100g1, Bq34z100g1Driver};
|
use bq34z100::{Bq34Z100Error, Bq34z100g1, Bq34z100g1Driver};
|
||||||
use embedded_hal_bus::i2c::MutexDevice;
|
use embedded_hal_bus::i2c::MutexDevice;
|
||||||
@ -97,7 +98,6 @@ impl BatteryInteraction for NoBatteryMonitor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//TODO implement this battery monitor kind once controller is complete
|
//TODO implement this battery monitor kind once controller is complete
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct WchI2cSlave {}
|
pub struct WchI2cSlave {}
|
||||||
|
|
||||||
pub struct BQ34Z100G1<'a> {
|
pub struct BQ34Z100G1<'a> {
|
||||||
|
@ -63,14 +63,14 @@ pub struct MqttClient<'a> {
|
|||||||
mqtt_client: EspMqttClient<'a>,
|
mqtt_client: EspMqttClient<'a>,
|
||||||
base_topic: heapless::String<64>,
|
base_topic: heapless::String<64>,
|
||||||
}
|
}
|
||||||
pub struct Esp<'a> {
|
pub struct ESP<'a> {
|
||||||
pub(crate) mqtt_client: Option<MqttClient<'a>>,
|
pub(crate) mqtt_client: Option<MqttClient<'a>>,
|
||||||
pub(crate) wifi_driver: EspWifi<'a>,
|
pub(crate) wifi_driver: EspWifi<'a>,
|
||||||
pub(crate) boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
pub(crate) boot_button: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
||||||
pub(crate) delay: Delay,
|
pub(crate) delay: Delay,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Esp<'_> {
|
impl ESP<'_> {
|
||||||
const SPIFFS_PARTITION_NAME: &'static str = "storage";
|
const SPIFFS_PARTITION_NAME: &'static str = "storage";
|
||||||
const CONFIG_FILE: &'static str = "/spiffs/config.cfg";
|
const CONFIG_FILE: &'static str = "/spiffs/config.cfg";
|
||||||
const BASE_PATH: &'static str = "/spiffs";
|
const BASE_PATH: &'static str = "/spiffs";
|
||||||
@ -240,6 +240,14 @@ impl Esp<'_> {
|
|||||||
println!("Wrote config config {:?}", config);
|
println!("Wrote config config {:?}", config);
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
|
pub(crate) fn delete_config(&self) -> anyhow::Result<()> {
|
||||||
|
let config = Path::new(Self::CONFIG_FILE);
|
||||||
|
if config.exists() {
|
||||||
|
println!("Removing config");
|
||||||
|
fs::remove_file(config)?
|
||||||
|
}
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
pub(crate) fn mount_file_system(&mut self) -> anyhow::Result<()> {
|
pub(crate) fn mount_file_system(&mut self) -> anyhow::Result<()> {
|
||||||
log(LogMessage::MountingFilesystem, 0, 0, "", "");
|
log(LogMessage::MountingFilesystem, 0, 0, "", "");
|
||||||
let base_path = CString::new("/spiffs")?;
|
let base_path = CString::new("/spiffs")?;
|
||||||
@ -300,7 +308,10 @@ impl Esp<'_> {
|
|||||||
OkStd(file) => {
|
OkStd(file) => {
|
||||||
let f = FileInfo {
|
let f = FileInfo {
|
||||||
filename: file.file_name().into_string().unwrap(),
|
filename: file.file_name().into_string().unwrap(),
|
||||||
size: file.metadata().map(|it| it.len()).unwrap_or_default()
|
size: file
|
||||||
|
.metadata()
|
||||||
|
.and_then(|it| Ok(it.len()))
|
||||||
|
.unwrap_or_default()
|
||||||
as usize,
|
as usize,
|
||||||
};
|
};
|
||||||
result.push(f);
|
result.push(f);
|
||||||
|
@ -1,11 +1,7 @@
|
|||||||
use crate::hal::esp::Esp;
|
use crate::config::{BoardHardware, PlantControllerConfig};
|
||||||
use crate::hal::rtc::{BackupHeader, RTCModuleInteraction};
|
use crate::hal::battery::{BatteryInteraction, NoBatteryMonitor};
|
||||||
use crate::hal::water::TankSensor;
|
use crate::hal::esp::ESP;
|
||||||
use crate::hal::{deep_sleep, BoardInteraction, FreePeripherals, Sensor};
|
use crate::hal::{deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor};
|
||||||
use crate::{
|
|
||||||
config::PlantControllerConfig,
|
|
||||||
hal::battery::{BatteryInteraction, NoBatteryMonitor},
|
|
||||||
};
|
|
||||||
use anyhow::{bail, Result};
|
use anyhow::{bail, Result};
|
||||||
use chrono::{DateTime, Utc};
|
use chrono::{DateTime, Utc};
|
||||||
use embedded_hal::digital::OutputPin;
|
use embedded_hal::digital::OutputPin;
|
||||||
@ -15,41 +11,16 @@ use measurements::{Current, Voltage};
|
|||||||
|
|
||||||
pub struct Initial<'a> {
|
pub struct Initial<'a> {
|
||||||
pub(crate) general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
pub(crate) general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
pub(crate) esp: Esp<'a>,
|
pub(crate) esp: ESP<'a>,
|
||||||
pub(crate) config: PlantControllerConfig,
|
pub(crate) config: PlantControllerConfig,
|
||||||
pub(crate) battery: Box<dyn BatteryInteraction + Send>,
|
pub(crate) battery: Box<dyn BatteryInteraction + Send>,
|
||||||
pub rtc: Box<dyn RTCModuleInteraction + Send>,
|
|
||||||
}
|
|
||||||
|
|
||||||
struct NoRTC {}
|
|
||||||
|
|
||||||
impl RTCModuleInteraction for NoRTC {
|
|
||||||
fn get_backup_info(&mut self) -> Result<BackupHeader> {
|
|
||||||
bail!("Please configure board revision")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_backup_config(&mut self) -> Result<Vec<u8>> {
|
|
||||||
bail!("Please configure board revision")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn backup_config(&mut self, _bytes: &[u8]) -> Result<()> {
|
|
||||||
bail!("Please configure board revision")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_rtc_time(&mut self) -> Result<DateTime<Utc>> {
|
|
||||||
bail!("Please configure board revision")
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_rtc_time(&mut self, _time: &DateTime<Utc>) -> Result<()> {
|
|
||||||
bail!("Please configure board revision")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create_initial_board(
|
pub(crate) fn create_initial_board(
|
||||||
free_pins: FreePeripherals,
|
free_pins: FreePeripherals,
|
||||||
fs_mount_error: bool,
|
fs_mount_error: bool,
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
esp: Esp<'static>,
|
esp: ESP<'static>,
|
||||||
) -> Result<Box<dyn BoardInteraction<'static> + Send>> {
|
) -> Result<Box<dyn BoardInteraction<'static> + Send>> {
|
||||||
let mut general_fault = PinDriver::input_output(free_pins.gpio6.downgrade())?;
|
let mut general_fault = PinDriver::input_output(free_pins.gpio6.downgrade())?;
|
||||||
general_fault.set_pull(Pull::Floating)?;
|
general_fault.set_pull(Pull::Floating)?;
|
||||||
@ -63,17 +34,12 @@ pub(crate) fn create_initial_board(
|
|||||||
config,
|
config,
|
||||||
esp,
|
esp,
|
||||||
battery: Box::new(NoBatteryMonitor {}),
|
battery: Box::new(NoBatteryMonitor {}),
|
||||||
rtc: Box::new(NoRTC {}),
|
|
||||||
};
|
};
|
||||||
Ok(Box::new(v))
|
Ok(Box::new(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BoardInteraction<'a> for Initial<'a> {
|
impl<'a> BoardInteraction<'a> for Initial<'a> {
|
||||||
fn get_tank_sensor(&mut self) -> Option<&mut TankSensor<'a>> {
|
fn get_esp(&mut self) -> &mut ESP<'a> {
|
||||||
None
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_esp(&mut self) -> &mut Esp<'a> {
|
|
||||||
&mut self.esp
|
&mut self.esp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,33 +51,48 @@ impl<'a> BoardInteraction<'a> for Initial<'a> {
|
|||||||
&mut self.battery
|
&mut self.battery
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_rtc_module(&mut self) -> &mut Box<dyn RTCModuleInteraction + Send> {
|
fn set_charge_indicator(&mut self, charging: bool) -> Result<()> {
|
||||||
&mut self.rtc
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_charge_indicator(&mut self, _charging: bool) -> Result<()> {
|
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
||||||
deep_sleep(duration_in_ms)
|
deep_sleep(duration_in_ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_backup_info(&mut self) -> Result<BackupHeader> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_backup_config(&mut self) -> Result<Vec<u8>> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn backup_config(&mut self, bytes: &[u8]) -> Result<()> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
|
||||||
fn is_day(&self) -> bool {
|
fn is_day(&self) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
fn light(&mut self, _enable: bool) -> Result<()> {
|
|
||||||
|
fn water_temperature_c(&mut self) -> Result<f32> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pump(&mut self, _plant: usize, _enable: bool) -> Result<()> {
|
fn tank_sensor_voltage(&mut self) -> Result<f32> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
fn light(&mut self, enable: bool) -> Result<()> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
fn fault(&mut self, _plant: usize, _enable: bool) -> Result<()> {
|
fn pump(&mut self, plant: usize, enable: bool) -> Result<()> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
fn fault(&mut self, plant: usize, _enable: bool) -> Result<()> {
|
||||||
fn measure_moisture_hz(&mut self, _plant: usize, _sensor: Sensor) -> Result<f32> {
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
fn measure_moisture_hz(&mut self, plant: usize, sensor: Sensor) -> Result<f32> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,7 +100,18 @@ impl<'a> BoardInteraction<'a> for Initial<'a> {
|
|||||||
let _ = self.general_fault.set_state(enable.into());
|
let _ = self.general_fault.set_state(enable.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_pump(&mut self, _plant: usize) -> Result<()> {
|
fn factory_reset(&mut self) -> Result<()> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_rtc_time(&mut self) -> Result<DateTime<Utc>> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> Result<()> {
|
||||||
|
bail!("Please configure board revision")
|
||||||
|
}
|
||||||
|
fn test_pump(&mut self, plant: usize) -> Result<()> {
|
||||||
bail!("Please configure board revision")
|
bail!("Please configure board revision")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,53 +1,58 @@
|
|||||||
pub(crate) mod battery;
|
pub(crate) mod battery;
|
||||||
mod esp;
|
mod esp;
|
||||||
mod initial_hal;
|
mod initial_hal;
|
||||||
mod rtc;
|
|
||||||
mod v3_hal;
|
mod v3_hal;
|
||||||
mod v4_hal;
|
mod v4_hal;
|
||||||
mod water;
|
|
||||||
|
|
||||||
use crate::hal::rtc::{DS3231Module, RTCModuleInteraction};
|
|
||||||
use crate::hal::water::TankSensor;
|
|
||||||
use crate::{
|
|
||||||
config::{BatteryBoardVersion, BoardVersion, PlantControllerConfig},
|
|
||||||
hal::{
|
|
||||||
battery::{print_battery_bq34z100, BatteryInteraction, NoBatteryMonitor},
|
|
||||||
esp::Esp,
|
|
||||||
},
|
|
||||||
log::{log, LogMessage},
|
|
||||||
};
|
|
||||||
use anyhow::{Ok, Result};
|
|
||||||
use battery::BQ34Z100G1;
|
use battery::BQ34Z100G1;
|
||||||
use bq34z100::Bq34z100g1Driver;
|
use bq34z100::Bq34z100g1Driver;
|
||||||
use ds323x::{DateTimeAccess, Ds323x};
|
|
||||||
use eeprom24x::{Eeprom24x, SlaveAddr, Storage};
|
use crate::log::LogMessage;
|
||||||
|
use ds323x::DateTimeAccess;
|
||||||
|
use esp_ota::mark_app_valid;
|
||||||
|
|
||||||
|
use eeprom24x::Eeprom24xTrait;
|
||||||
use embedded_hal_bus::i2c::MutexDevice;
|
use embedded_hal_bus::i2c::MutexDevice;
|
||||||
use esp_idf_hal::{
|
|
||||||
adc::ADC1,
|
use esp_idf_hal::adc::ADC1;
|
||||||
delay::Delay,
|
use esp_idf_hal::i2c::{APBTickType, I2cConfig, I2cDriver};
|
||||||
gpio::{
|
use esp_idf_hal::units::FromValueType;
|
||||||
Gpio0, Gpio1, Gpio10, Gpio11, Gpio12, Gpio13, Gpio14, Gpio15, Gpio16, Gpio17, Gpio18,
|
use esp_idf_svc::eventloop::EspSystemEventLoop;
|
||||||
Gpio2, Gpio21, Gpio22, Gpio23, Gpio24, Gpio25, Gpio26, Gpio27, Gpio28, Gpio29, Gpio3,
|
use esp_idf_svc::nvs::EspDefaultNvsPartition;
|
||||||
Gpio30, Gpio4, Gpio5, Gpio6, Gpio7, Gpio8, IOPin, PinDriver, Pull,
|
use esp_idf_svc::wifi::EspWifi;
|
||||||
},
|
use esp_idf_sys::esp_restart;
|
||||||
i2c::{APBTickType, I2cConfig, I2cDriver},
|
|
||||||
pcnt::PCNT0,
|
|
||||||
prelude::Peripherals,
|
|
||||||
reset::ResetReason,
|
|
||||||
units::FromValueType,
|
|
||||||
};
|
|
||||||
use esp_idf_svc::{eventloop::EspSystemEventLoop, nvs::EspDefaultNvsPartition, wifi::EspWifi};
|
|
||||||
use esp_idf_sys::{
|
use esp_idf_sys::{
|
||||||
esp_deep_sleep, esp_restart, esp_sleep_enable_ext1_wakeup,
|
esp_deep_sleep, esp_sleep_enable_ext1_wakeup,
|
||||||
esp_sleep_ext1_wakeup_mode_t_ESP_EXT1_WAKEUP_ANY_LOW,
|
esp_sleep_ext1_wakeup_mode_t_ESP_EXT1_WAKEUP_ANY_LOW,
|
||||||
};
|
};
|
||||||
use esp_ota::mark_app_valid;
|
|
||||||
use measurements::{Current, Voltage};
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
|
|
||||||
|
use anyhow::{Ok, Result};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use std::result::Result::Ok as OkStd;
|
use std::result::Result::Ok as OkStd;
|
||||||
use std::sync::Mutex;
|
use std::sync::Mutex;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
|
use crate::config::{BatteryBoardVersion, BoardVersion, PlantControllerConfig};
|
||||||
|
use crate::hal::battery::{print_battery_bq34z100, BatteryInteraction, NoBatteryMonitor};
|
||||||
|
use crate::hal::esp::ESP;
|
||||||
|
use crate::hal::initial_hal::Initial;
|
||||||
|
use crate::log::log;
|
||||||
|
use embedded_hal::digital::OutputPin;
|
||||||
|
use esp_idf_hal::delay::Delay;
|
||||||
|
use esp_idf_hal::gpio::{
|
||||||
|
Gpio0, Gpio1, Gpio10, Gpio11, Gpio12, Gpio13, Gpio14, Gpio15, Gpio16, Gpio17, Gpio18, Gpio2,
|
||||||
|
Gpio21, Gpio22, Gpio23, Gpio24, Gpio25, Gpio26, Gpio27, Gpio28, Gpio29, Gpio3, Gpio30, Gpio4,
|
||||||
|
Gpio5, Gpio6, Gpio7, Gpio8, IOPin, PinDriver, Pull,
|
||||||
|
};
|
||||||
|
use esp_idf_hal::pcnt::PCNT0;
|
||||||
|
use esp_idf_hal::prelude::Peripherals;
|
||||||
|
use esp_idf_hal::reset::ResetReason;
|
||||||
|
use measurements::{Current, Voltage};
|
||||||
|
use pca9535::StandardExpanderInterface;
|
||||||
|
|
||||||
//Only support for 8 right now!
|
//Only support for 8 right now!
|
||||||
pub const PLANT_COUNT: usize = 8;
|
pub const PLANT_COUNT: usize = 8;
|
||||||
const REPEAT_MOIST_MEASURE: usize = 1;
|
const REPEAT_MOIST_MEASURE: usize = 1;
|
||||||
@ -56,6 +61,13 @@ const TANK_MULTI_SAMPLE: usize = 11;
|
|||||||
|
|
||||||
pub static I2C_DRIVER: Lazy<Mutex<I2cDriver<'static>>> = Lazy::new(PlantHal::create_i2c);
|
pub static I2C_DRIVER: Lazy<Mutex<I2cDriver<'static>>> = Lazy::new(PlantHal::create_i2c);
|
||||||
|
|
||||||
|
#[non_exhaustive]
|
||||||
|
struct V3Constants;
|
||||||
|
|
||||||
|
impl V3Constants {}
|
||||||
|
|
||||||
|
const X25: crc::Crc<u16> = crc::Crc::<u16>::new(&crc::CRC_16_IBM_SDLC);
|
||||||
|
|
||||||
fn deep_sleep(duration_in_ms: u64) -> ! {
|
fn deep_sleep(duration_in_ms: u64) -> ! {
|
||||||
unsafe {
|
unsafe {
|
||||||
//if we don't do this here, we might just revert newly flashed firmware
|
//if we don't do this here, we might just revert newly flashed firmware
|
||||||
@ -86,43 +98,53 @@ pub struct HAL<'a> {
|
|||||||
pub board_hal: Box<dyn BoardInteraction<'a> + Send>,
|
pub board_hal: Box<dyn BoardInteraction<'a> + Send>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||||
|
pub struct BackupHeader {
|
||||||
|
pub timestamp: i64,
|
||||||
|
crc16: u16,
|
||||||
|
pub size: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for BackupHeader {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
timestamp: Default::default(),
|
||||||
|
crc16: Default::default(),
|
||||||
|
size: Default::default(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait BoardInteraction<'a> {
|
pub trait BoardInteraction<'a> {
|
||||||
fn get_tank_sensor(&mut self) -> Option<&mut TankSensor<'a>>;
|
fn set_charge_indicator(&mut self, charging: bool) -> Result<()>;
|
||||||
fn get_esp(&mut self) -> &mut Esp<'a>;
|
fn is_day(&self) -> bool;
|
||||||
|
fn get_mptt_voltage(&mut self) -> Result<Voltage>;
|
||||||
|
fn get_mptt_current(&mut self) -> Result<Current>;
|
||||||
|
|
||||||
|
fn get_esp(&mut self) -> &mut ESP<'a>;
|
||||||
fn get_config(&mut self) -> &PlantControllerConfig;
|
fn get_config(&mut self) -> &PlantControllerConfig;
|
||||||
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction + Send>;
|
fn get_battery_monitor(&mut self) -> &mut Box<dyn BatteryInteraction + Send>;
|
||||||
fn get_rtc_module(&mut self) -> &mut Box<dyn RTCModuleInteraction + Send>;
|
|
||||||
fn set_charge_indicator(&mut self, charging: bool) -> Result<()>;
|
|
||||||
fn deep_sleep(&mut self, duration_in_ms: u64) -> !;
|
fn deep_sleep(&mut self, duration_in_ms: u64) -> !;
|
||||||
|
fn get_backup_info(&mut self) -> Result<BackupHeader>;
|
||||||
fn is_day(&self) -> bool;
|
fn get_backup_config(&mut self) -> Result<Vec<u8>>;
|
||||||
|
fn backup_config(&mut self, bytes: &[u8]) -> Result<()>;
|
||||||
//should be multsampled
|
//should be multsampled
|
||||||
|
fn water_temperature_c(&mut self) -> Result<f32>;
|
||||||
|
/// return median tank sensor value in milli volt
|
||||||
|
fn tank_sensor_voltage(&mut self) -> Result<f32>;
|
||||||
fn light(&mut self, enable: bool) -> Result<()>;
|
fn light(&mut self, enable: bool) -> Result<()>;
|
||||||
fn pump(&mut self, plant: usize, enable: bool) -> Result<()>;
|
fn pump(&mut self, plant: usize, enable: bool) -> Result<()>;
|
||||||
fn fault(&mut self, plant: usize, enable: bool) -> Result<()>;
|
fn fault(&mut self, plant: usize, enable: bool) -> Result<()>;
|
||||||
fn measure_moisture_hz(&mut self, plant: usize, sensor: Sensor) -> Result<f32>;
|
fn measure_moisture_hz(&mut self, plant: usize, sensor: Sensor) -> Result<f32>;
|
||||||
fn general_fault(&mut self, enable: bool);
|
fn general_fault(&mut self, enable: bool);
|
||||||
|
fn factory_reset(&mut self) -> Result<()>;
|
||||||
|
fn get_rtc_time(&mut self) -> Result<DateTime<Utc>>;
|
||||||
|
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> Result<()>;
|
||||||
fn test_pump(&mut self, plant: usize) -> Result<()>;
|
fn test_pump(&mut self, plant: usize) -> Result<()>;
|
||||||
fn test(&mut self) -> Result<()>;
|
fn test(&mut self) -> Result<()>;
|
||||||
fn set_config(&mut self, config: PlantControllerConfig) -> Result<()>;
|
fn set_config(&mut self, config: PlantControllerConfig) -> Result<()>;
|
||||||
fn get_mptt_voltage(&mut self) -> anyhow::Result<Voltage>;
|
|
||||||
fn get_mptt_current(&mut self) -> anyhow::Result<Current>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl dyn BoardInteraction<'_> {
|
|
||||||
//the counter is just some arbitrary number that increases whenever some progress was made, try to keep the updates < 10 per second for ux reasons
|
|
||||||
fn progress(&mut self, counter: u32) {
|
|
||||||
let even = counter % 2 == 0;
|
|
||||||
let current = counter / (PLANT_COUNT as u32);
|
|
||||||
for led in 0..PLANT_COUNT {
|
|
||||||
self.fault(led, current == led as u32).unwrap();
|
|
||||||
}
|
|
||||||
let _ = self.general_fault(even.into());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
|
||||||
pub struct FreePeripherals {
|
pub struct FreePeripherals {
|
||||||
pub gpio0: Gpio0,
|
pub gpio0: Gpio0,
|
||||||
pub gpio1: Gpio1,
|
pub gpio1: Gpio1,
|
||||||
@ -217,7 +239,7 @@ impl PlantHal {
|
|||||||
gpio30: peripherals.pins.gpio30,
|
gpio30: peripherals.pins.gpio30,
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut esp = Esp {
|
let mut esp = ESP {
|
||||||
mqtt_client: None,
|
mqtt_client: None,
|
||||||
wifi_driver,
|
wifi_driver,
|
||||||
boot_button,
|
boot_button,
|
||||||
@ -261,30 +283,6 @@ impl PlantHal {
|
|||||||
|
|
||||||
let config = esp.load_config();
|
let config = esp.load_config();
|
||||||
|
|
||||||
println!("Init rtc driver");
|
|
||||||
let mut rtc = Ds323x::new_ds3231(MutexDevice::new(&I2C_DRIVER));
|
|
||||||
|
|
||||||
println!("Init rtc eeprom driver");
|
|
||||||
let eeprom = {
|
|
||||||
Eeprom24x::new_24x32(
|
|
||||||
MutexDevice::new(&I2C_DRIVER),
|
|
||||||
SlaveAddr::Alternative(true, true, true),
|
|
||||||
)
|
|
||||||
};
|
|
||||||
let rtc_time = rtc.datetime();
|
|
||||||
match rtc_time {
|
|
||||||
OkStd(tt) => {
|
|
||||||
println!("Rtc Module reports time at UTC {}", tt);
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
println!("Rtc Module could not be read {:?}", err);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let storage = Storage::new(eeprom, Delay::new(1000));
|
|
||||||
let rtc_module: Box<dyn RTCModuleInteraction + Send> =
|
|
||||||
Box::new(DS3231Module { rtc, storage }) as Box<dyn RTCModuleInteraction + Send>;
|
|
||||||
|
|
||||||
let hal = match config {
|
let hal = match config {
|
||||||
Result::Ok(config) => {
|
Result::Ok(config) => {
|
||||||
let battery_interaction: Box<dyn BatteryInteraction + Send> =
|
let battery_interaction: Box<dyn BatteryInteraction + Send> =
|
||||||
@ -322,10 +320,10 @@ impl PlantHal {
|
|||||||
initial_hal::create_initial_board(free_pins, fs_mount_error, config, esp)?
|
initial_hal::create_initial_board(free_pins, fs_mount_error, config, esp)?
|
||||||
}
|
}
|
||||||
BoardVersion::V3 => {
|
BoardVersion::V3 => {
|
||||||
v3_hal::create_v3(free_pins, esp, config, battery_interaction, rtc_module)?
|
v3_hal::create_v3(free_pins, esp, config, battery_interaction)?
|
||||||
}
|
}
|
||||||
BoardVersion::V4 => {
|
BoardVersion::V4 => {
|
||||||
v4_hal::create_v4(free_pins, esp, config, battery_interaction, rtc_module)?
|
v4_hal::create_v4(free_pins, esp, config, battery_interaction)?
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,132 +0,0 @@
|
|||||||
use anyhow::{anyhow, bail};
|
|
||||||
use bincode::config::Configuration;
|
|
||||||
use bincode::{config, Decode, Encode};
|
|
||||||
use chrono::{DateTime, Utc};
|
|
||||||
use ds323x::{DateTimeAccess, Ds323x};
|
|
||||||
use eeprom24x::addr_size::TwoBytes;
|
|
||||||
use eeprom24x::page_size::B32;
|
|
||||||
use eeprom24x::unique_serial::No;
|
|
||||||
use eeprom24x::Storage;
|
|
||||||
use embedded_hal_bus::i2c::MutexDevice;
|
|
||||||
use embedded_storage::ReadStorage as embedded_storage_ReadStorage;
|
|
||||||
use embedded_storage::Storage as embedded_storage_Storage;
|
|
||||||
use esp_idf_hal::delay::Delay;
|
|
||||||
use esp_idf_hal::i2c::I2cDriver;
|
|
||||||
use serde::{Deserialize, Serialize};
|
|
||||||
use std::result::Result::Ok as OkStd;
|
|
||||||
|
|
||||||
const X25: crc::Crc<u16> = crc::Crc::<u16>::new(&crc::CRC_16_IBM_SDLC);
|
|
||||||
const CONFIG: Configuration = config::standard();
|
|
||||||
|
|
||||||
pub trait RTCModuleInteraction {
|
|
||||||
fn get_backup_info(&mut self) -> anyhow::Result<BackupHeader>;
|
|
||||||
fn get_backup_config(&mut self) -> anyhow::Result<Vec<u8>>;
|
|
||||||
fn backup_config(&mut self, bytes: &[u8]) -> anyhow::Result<()>;
|
|
||||||
fn get_rtc_time(&mut self) -> anyhow::Result<DateTime<Utc>>;
|
|
||||||
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> anyhow::Result<()>;
|
|
||||||
}
|
|
||||||
|
|
||||||
const BACKUP_HEADER_MAX_SIZE: usize = 64;
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Default, Encode, Decode)]
|
|
||||||
pub struct BackupHeader {
|
|
||||||
pub timestamp: i64,
|
|
||||||
crc16: u16,
|
|
||||||
pub size: u16,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct DS3231Module<'a> {
|
|
||||||
pub(crate) rtc:
|
|
||||||
Ds323x<ds323x::interface::I2cInterface<MutexDevice<'a, I2cDriver<'a>>>, ds323x::ic::DS3231>,
|
|
||||||
|
|
||||||
pub(crate) storage: Storage<MutexDevice<'a, I2cDriver<'a>>, B32, TwoBytes, No, Delay>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RTCModuleInteraction for DS3231Module<'_> {
|
|
||||||
fn get_backup_info(&mut self) -> anyhow::Result<BackupHeader> {
|
|
||||||
let mut header_page_buffer = [0_u8; BACKUP_HEADER_MAX_SIZE];
|
|
||||||
|
|
||||||
self.storage
|
|
||||||
.read(0, &mut header_page_buffer)
|
|
||||||
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
|
||||||
|
|
||||||
let (header, len): (BackupHeader, usize) =
|
|
||||||
bincode::decode_from_slice(&header_page_buffer[..], CONFIG)?;
|
|
||||||
|
|
||||||
println!("Raw header is {:?} with size {}", header_page_buffer, len);
|
|
||||||
anyhow::Ok(header)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_backup_config(&mut self) -> anyhow::Result<Vec<u8>> {
|
|
||||||
let mut header_page_buffer = [0_u8; BACKUP_HEADER_MAX_SIZE];
|
|
||||||
|
|
||||||
self.storage
|
|
||||||
.read(0, &mut header_page_buffer)
|
|
||||||
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
|
||||||
let (header, _header_size): (BackupHeader, usize) =
|
|
||||||
bincode::decode_from_slice(&header_page_buffer[..], CONFIG)?;
|
|
||||||
|
|
||||||
let mut data_buffer = vec![0_u8; header.size as usize];
|
|
||||||
//read the specified number of bytes after the header
|
|
||||||
self.storage
|
|
||||||
.read(BACKUP_HEADER_MAX_SIZE as u32, &mut data_buffer)
|
|
||||||
.map_err(|err| anyhow!("Error reading eeprom data {:?}", err))?;
|
|
||||||
|
|
||||||
let checksum = X25.checksum(&data_buffer);
|
|
||||||
if checksum != header.crc16 {
|
|
||||||
bail!(
|
|
||||||
"Invalid checksum, got {} but expected {}",
|
|
||||||
checksum,
|
|
||||||
header.crc16
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
anyhow::Ok(data_buffer)
|
|
||||||
}
|
|
||||||
fn backup_config(&mut self, bytes: &[u8]) -> anyhow::Result<()> {
|
|
||||||
let mut header_page_buffer = [0_u8; BACKUP_HEADER_MAX_SIZE];
|
|
||||||
|
|
||||||
let time = self.get_rtc_time()?.timestamp_millis();
|
|
||||||
let checksum = X25.checksum(bytes);
|
|
||||||
|
|
||||||
let header = BackupHeader {
|
|
||||||
crc16: checksum,
|
|
||||||
timestamp: time,
|
|
||||||
size: bytes.len() as u16,
|
|
||||||
};
|
|
||||||
let config = config::standard();
|
|
||||||
let encoded = bincode::encode_into_slice(&header, &mut header_page_buffer, config)?;
|
|
||||||
println!(
|
|
||||||
"Raw header is {:?} with size {}",
|
|
||||||
header_page_buffer, encoded
|
|
||||||
);
|
|
||||||
self.storage
|
|
||||||
.write(0, &header_page_buffer)
|
|
||||||
.map_err(|err| anyhow!("Error writing header {:?}", err))?;
|
|
||||||
|
|
||||||
//write rest after the header
|
|
||||||
self.storage
|
|
||||||
.write(BACKUP_HEADER_MAX_SIZE as u32, &bytes)
|
|
||||||
.map_err(|err| anyhow!("Error writing body {:?}", err))?;
|
|
||||||
|
|
||||||
anyhow::Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_rtc_time(&mut self) -> anyhow::Result<DateTime<Utc>> {
|
|
||||||
match self.rtc.datetime() {
|
|
||||||
OkStd(rtc_time) => anyhow::Ok(rtc_time.and_utc()),
|
|
||||||
Err(err) => {
|
|
||||||
bail!("Error getting rtc time {:?}", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> anyhow::Result<()> {
|
|
||||||
let naive_time = time.naive_utc();
|
|
||||||
match self.rtc.set_datetime(&naive_time) {
|
|
||||||
OkStd(_) => anyhow::Ok(()),
|
|
||||||
Err(err) => {
|
|
||||||
bail!("Error getting rtc time {:?}", err)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,23 +1,33 @@
|
|||||||
use crate::hal::rtc::RTCModuleInteraction;
|
use crate::config::PlantControllerConfig;
|
||||||
use crate::hal::water::TankSensor;
|
use crate::hal::battery::BatteryInteraction;
|
||||||
|
use crate::hal::esp::ESP;
|
||||||
use crate::hal::{
|
use crate::hal::{
|
||||||
deep_sleep, BoardInteraction, FreePeripherals, Sensor, PLANT_COUNT, REPEAT_MOIST_MEASURE,
|
deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor, V3Constants, I2C_DRIVER,
|
||||||
|
PLANT_COUNT, REPEAT_MOIST_MEASURE, TANK_MULTI_SAMPLE, X25,
|
||||||
};
|
};
|
||||||
use crate::log::{log, LogMessage};
|
use crate::log::{log, LogMessage};
|
||||||
use crate::{
|
use anyhow::{anyhow, bail, Ok, Result};
|
||||||
config::PlantControllerConfig,
|
use chrono::{DateTime, Utc};
|
||||||
hal::{battery::BatteryInteraction, esp::Esp},
|
use ds18b20::Ds18b20;
|
||||||
};
|
use ds323x::{DateTimeAccess, Ds323x};
|
||||||
use anyhow::{bail, Ok, Result};
|
use eeprom24x::{Eeprom24x, Eeprom24xTrait, SlaveAddr};
|
||||||
use embedded_hal::digital::OutputPin;
|
use embedded_hal::digital::OutputPin;
|
||||||
use esp_idf_hal::{
|
use embedded_hal_bus::i2c::MutexDevice;
|
||||||
gpio::{AnyInputPin, IOPin, InputOutput, PinDriver, Pull},
|
use esp_idf_hal::adc::oneshot::config::AdcChannelConfig;
|
||||||
pcnt::{PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex},
|
use esp_idf_hal::adc::oneshot::{AdcChannelDriver, AdcDriver};
|
||||||
|
use esp_idf_hal::adc::{attenuation, Resolution};
|
||||||
|
use esp_idf_hal::delay::Delay;
|
||||||
|
use esp_idf_hal::gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, PinDriver, Pull};
|
||||||
|
use esp_idf_hal::i2c::I2cDriver;
|
||||||
|
use esp_idf_hal::pcnt::{
|
||||||
|
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
||||||
};
|
};
|
||||||
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay};
|
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
|
||||||
use measurements::{Current, Voltage};
|
use measurements::{Current, Voltage};
|
||||||
|
use one_wire_bus::OneWire;
|
||||||
use plant_ctrl2::sipo::ShiftRegister40;
|
use plant_ctrl2::sipo::ShiftRegister40;
|
||||||
use std::result::Result::Ok as OkStd;
|
use std::result::Result::Ok as OkStd;
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
const PUMP8_BIT: usize = 0;
|
const PUMP8_BIT: usize = 0;
|
||||||
const PUMP1_BIT: usize = 1;
|
const PUMP1_BIT: usize = 1;
|
||||||
@ -67,30 +77,38 @@ const FAULT_2: usize = 23;
|
|||||||
pub struct V3<'a> {
|
pub struct V3<'a> {
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
||||||
rtc_module: Box<dyn RTCModuleInteraction + Send>,
|
esp: ESP<'a>,
|
||||||
esp: Esp<'a>,
|
|
||||||
shift_register: ShiftRegister40<
|
shift_register: ShiftRegister40<
|
||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
>,
|
>,
|
||||||
_shift_register_enable_invert:
|
shift_register_enable_invert:
|
||||||
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Output>,
|
PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Output>,
|
||||||
tank_sensor: TankSensor<'a>,
|
tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, esp_idf_hal::adc::ADC1>>,
|
||||||
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
||||||
light: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
light: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
main_pump: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
main_pump: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
|
tank_power: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
signal_counter: PcntDriver<'a>,
|
signal_counter: PcntDriver<'a>,
|
||||||
|
one_wire_bus: OneWire<PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>>,
|
||||||
|
rtc:
|
||||||
|
Ds323x<ds323x::interface::I2cInterface<MutexDevice<'a, I2cDriver<'a>>>, ds323x::ic::DS3231>,
|
||||||
|
eeprom: Eeprom24x<
|
||||||
|
MutexDevice<'a, I2cDriver<'a>>,
|
||||||
|
eeprom24x::page_size::B32,
|
||||||
|
eeprom24x::addr_size::TwoBytes,
|
||||||
|
eeprom24x::unique_serial::No,
|
||||||
|
>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create_v3(
|
pub(crate) fn create_v3(
|
||||||
peripherals: FreePeripherals,
|
peripherals: FreePeripherals,
|
||||||
esp: Esp<'static>,
|
esp: ESP<'static>,
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
||||||
rtc_module: Box<dyn RTCModuleInteraction + Send>,
|
) -> Result<Box<dyn BoardInteraction + Send + '_>> {
|
||||||
) -> Result<Box<dyn BoardInteraction<'static> + Send>> {
|
|
||||||
let mut clock = PinDriver::input_output(peripherals.gpio15.downgrade())?;
|
let mut clock = PinDriver::input_output(peripherals.gpio15.downgrade())?;
|
||||||
clock.set_pull(Pull::Floating)?;
|
clock.set_pull(Pull::Floating)?;
|
||||||
let mut latch = PinDriver::input_output(peripherals.gpio3.downgrade())?;
|
let mut latch = PinDriver::input_output(peripherals.gpio3.downgrade())?;
|
||||||
@ -121,15 +139,39 @@ pub(crate) fn create_v3(
|
|||||||
let ms4 = &mut shift_register.decompose()[MS_4];
|
let ms4 = &mut shift_register.decompose()[MS_4];
|
||||||
ms4.set_high()?;
|
ms4.set_high()?;
|
||||||
|
|
||||||
let one_wire_pin = peripherals.gpio18.downgrade();
|
println!("Init battery driver");
|
||||||
let tank_power_pin = peripherals.gpio11.downgrade();
|
|
||||||
|
|
||||||
let tank_sensor = TankSensor::create(
|
println!("Init rtc driver");
|
||||||
one_wire_pin,
|
let mut rtc = Ds323x::new_ds3231(MutexDevice::new(&I2C_DRIVER));
|
||||||
peripherals.adc1,
|
|
||||||
peripherals.gpio5,
|
println!("Init rtc eeprom driver");
|
||||||
tank_power_pin,
|
let mut eeprom = {
|
||||||
);
|
Eeprom24x::new_24x32(
|
||||||
|
MutexDevice::new(&I2C_DRIVER),
|
||||||
|
SlaveAddr::Alternative(true, true, true),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut one_wire_pin = PinDriver::input_output_od(peripherals.gpio18.downgrade())?;
|
||||||
|
one_wire_pin.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
|
let rtc_time = rtc.datetime();
|
||||||
|
match rtc_time {
|
||||||
|
OkStd(tt) => {
|
||||||
|
println!("Rtc Module reports time at UTC {}", tt);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("Rtc Module could not be read {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match eeprom.read_byte(0) {
|
||||||
|
OkStd(byte) => {
|
||||||
|
println!("Read first byte with status {}", byte);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("Eeprom could not read first byte {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut signal_counter = PcntDriver::new(
|
let mut signal_counter = PcntDriver::new(
|
||||||
peripherals.pcnt0,
|
peripherals.pcnt0,
|
||||||
@ -153,6 +195,15 @@ pub(crate) fn create_v3(
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let adc_config = AdcChannelConfig {
|
||||||
|
attenuation: attenuation::DB_11,
|
||||||
|
resolution: Resolution::Resolution12Bit,
|
||||||
|
calibration: esp_idf_hal::adc::oneshot::config::Calibration::Curve,
|
||||||
|
};
|
||||||
|
let tank_driver = AdcDriver::new(peripherals.adc1)?;
|
||||||
|
let tank_channel: AdcChannelDriver<Gpio5, AdcDriver<esp_idf_hal::adc::ADC1>> =
|
||||||
|
AdcChannelDriver::new(tank_driver, peripherals.gpio5, &adc_config)?;
|
||||||
|
|
||||||
let mut solar_is_day = PinDriver::input(peripherals.gpio7.downgrade())?;
|
let mut solar_is_day = PinDriver::input(peripherals.gpio7.downgrade())?;
|
||||||
solar_is_day.set_pull(Pull::Floating)?;
|
solar_is_day.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
@ -162,11 +213,15 @@ pub(crate) fn create_v3(
|
|||||||
let mut main_pump = PinDriver::input_output(peripherals.gpio2.downgrade())?;
|
let mut main_pump = PinDriver::input_output(peripherals.gpio2.downgrade())?;
|
||||||
main_pump.set_pull(Pull::Floating)?;
|
main_pump.set_pull(Pull::Floating)?;
|
||||||
main_pump.set_low()?;
|
main_pump.set_low()?;
|
||||||
|
let mut tank_power = PinDriver::input_output(peripherals.gpio11.downgrade())?;
|
||||||
|
tank_power.set_pull(Pull::Floating)?;
|
||||||
let mut general_fault = PinDriver::input_output(peripherals.gpio6.downgrade())?;
|
let mut general_fault = PinDriver::input_output(peripherals.gpio6.downgrade())?;
|
||||||
general_fault.set_pull(Pull::Floating)?;
|
general_fault.set_pull(Pull::Floating)?;
|
||||||
general_fault.set_low()?;
|
general_fault.set_low()?;
|
||||||
|
|
||||||
|
let one_wire_bus = OneWire::new(one_wire_pin)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
let mut shift_register_enable_invert = PinDriver::output(peripherals.gpio21.downgrade())?;
|
let mut shift_register_enable_invert = PinDriver::output(peripherals.gpio21.downgrade())?;
|
||||||
|
|
||||||
unsafe { gpio_hold_dis(shift_register_enable_invert.pin()) };
|
unsafe { gpio_hold_dis(shift_register_enable_invert.pin()) };
|
||||||
@ -176,25 +231,44 @@ pub(crate) fn create_v3(
|
|||||||
Ok(Box::new(V3 {
|
Ok(Box::new(V3 {
|
||||||
config,
|
config,
|
||||||
battery_monitor,
|
battery_monitor,
|
||||||
rtc_module,
|
|
||||||
esp,
|
esp,
|
||||||
shift_register,
|
shift_register,
|
||||||
_shift_register_enable_invert: shift_register_enable_invert,
|
shift_register_enable_invert,
|
||||||
tank_sensor,
|
tank_channel,
|
||||||
solar_is_day,
|
solar_is_day,
|
||||||
light,
|
light,
|
||||||
main_pump,
|
main_pump,
|
||||||
|
tank_power,
|
||||||
general_fault,
|
general_fault,
|
||||||
signal_counter,
|
signal_counter,
|
||||||
|
one_wire_bus,
|
||||||
|
rtc,
|
||||||
|
eeprom,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BoardInteraction<'a> for V3<'a> {
|
impl<'a> BoardInteraction<'a> for V3<'a> {
|
||||||
fn get_tank_sensor(&mut self) -> Option<&mut TankSensor<'a>> {
|
fn set_charge_indicator(&mut self, charging: bool) -> Result<()> {
|
||||||
Some(&mut self.tank_sensor)
|
Ok(self.shift_register.decompose()[CHARGING].set_state(charging.into())?)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_esp(&mut self) -> &mut Esp<'a> {
|
fn is_day(&self) -> bool {
|
||||||
|
self.solar_is_day.get_level().into()
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_mptt_voltage(&mut self) -> Result<Voltage> {
|
||||||
|
//if working this is the hardware set mppt voltage
|
||||||
|
if self.is_day() {
|
||||||
|
Ok(Voltage::from_volts(15_f64))
|
||||||
|
} else {
|
||||||
|
Ok(Voltage::from_volts(0_f64))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_mptt_current(&mut self) -> Result<Current> {
|
||||||
|
bail!("Board does not have current sensor")
|
||||||
|
}
|
||||||
|
fn get_esp(&mut self) -> &mut ESP<'a> {
|
||||||
&mut self.esp
|
&mut self.esp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,28 +280,158 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
&mut self.battery_monitor
|
&mut self.battery_monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_rtc_module(&mut self) -> &mut Box<dyn RTCModuleInteraction + Send> {
|
|
||||||
&mut self.rtc_module
|
|
||||||
}
|
|
||||||
fn set_charge_indicator(&mut self, charging: bool) -> Result<()> {
|
|
||||||
Ok(self.shift_register.decompose()[CHARGING].set_state(charging.into())?)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
||||||
let _ = self.shift_register.decompose()[AWAKE].set_low();
|
let _ = self.shift_register.decompose()[AWAKE].set_low();
|
||||||
deep_sleep(duration_in_ms)
|
deep_sleep(duration_in_ms)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_day(&self) -> bool {
|
fn get_backup_info(&mut self) -> Result<BackupHeader> {
|
||||||
self.solar_is_day.get_level().into()
|
let store = bincode::serialize(&BackupHeader::default())?.len();
|
||||||
|
let mut header_page_buffer = vec![0_u8; store];
|
||||||
|
|
||||||
|
self.eeprom
|
||||||
|
.read_data(0, &mut header_page_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
||||||
|
|
||||||
|
println!("Raw header is {:?} with size {}", header_page_buffer, store);
|
||||||
|
let header: BackupHeader = bincode::deserialize(&header_page_buffer)?;
|
||||||
|
Ok(header)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_backup_config(&mut self) -> Result<Vec<u8>> {
|
||||||
|
let store = bincode::serialize(&BackupHeader::default())?.len();
|
||||||
|
let mut header_page_buffer = vec![0_u8; store];
|
||||||
|
|
||||||
|
self.eeprom
|
||||||
|
.read_data(0, &mut header_page_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
||||||
|
|
||||||
|
let header: BackupHeader = bincode::deserialize(&header_page_buffer)?;
|
||||||
|
|
||||||
|
//skip page 0, used by the header
|
||||||
|
let data_start_address = self.eeprom.page_size() as u32;
|
||||||
|
let mut data_buffer = vec![0_u8; header.size];
|
||||||
|
self.eeprom
|
||||||
|
.read_data(data_start_address, &mut data_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom data {:?}", err))?;
|
||||||
|
|
||||||
|
let checksum = X25.checksum(&data_buffer);
|
||||||
|
if checksum != header.crc16 {
|
||||||
|
bail!(
|
||||||
|
"Invalid checksum, got {} but expected {}",
|
||||||
|
checksum,
|
||||||
|
header.crc16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(data_buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn backup_config(&mut self, bytes: &[u8]) -> Result<()> {
|
||||||
|
let time = self.get_rtc_time()?.timestamp_millis();
|
||||||
|
|
||||||
|
let delay = Delay::new_default();
|
||||||
|
|
||||||
|
let checksum = X25.checksum(bytes);
|
||||||
|
let page_size = self.eeprom.page_size();
|
||||||
|
|
||||||
|
let header = BackupHeader {
|
||||||
|
crc16: checksum,
|
||||||
|
timestamp: time,
|
||||||
|
size: bytes.len(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded = bincode::serialize(&header)?;
|
||||||
|
if encoded.len() > page_size {
|
||||||
|
bail!(
|
||||||
|
"Size limit reached header is {}, but firest page is only {}",
|
||||||
|
encoded.len(),
|
||||||
|
page_size
|
||||||
|
)
|
||||||
|
}
|
||||||
|
let as_u8: &[u8] = &encoded;
|
||||||
|
|
||||||
|
match self.eeprom.write_page(0, as_u8) {
|
||||||
|
OkStd(_) => {}
|
||||||
|
Err(err) => bail!("Error writing eeprom {:?}", err),
|
||||||
|
};
|
||||||
|
delay.delay_ms(5);
|
||||||
|
|
||||||
|
let to_write = bytes.chunks(page_size);
|
||||||
|
|
||||||
|
let mut lastiter = 0;
|
||||||
|
let mut current_page = 1;
|
||||||
|
for chunk in to_write {
|
||||||
|
let address = current_page * page_size as u32;
|
||||||
|
self.eeprom
|
||||||
|
.write_page(address, chunk)
|
||||||
|
.map_err(|err| anyhow!("Error writing eeprom {:?}", err))?;
|
||||||
|
current_page += 1;
|
||||||
|
|
||||||
|
let iter = (current_page % 8) as usize;
|
||||||
|
if iter != lastiter {
|
||||||
|
for i in 0..PLANT_COUNT {
|
||||||
|
let _ = self.fault(i, iter == i);
|
||||||
|
}
|
||||||
|
lastiter = iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay.delay_ms(5);
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn water_temperature_c(&mut self) -> Result<f32> {
|
||||||
|
self.one_wire_bus
|
||||||
|
.reset(&mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
let first = self.one_wire_bus.devices(false, &mut self.esp.delay).next();
|
||||||
|
if first.is_none() {
|
||||||
|
bail!("Not found any one wire Ds18b20");
|
||||||
|
}
|
||||||
|
let device_address = first
|
||||||
|
.unwrap()
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
|
let water_temp_sensor = Ds18b20::new::<EspError>(device_address)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
|
water_temp_sensor
|
||||||
|
.start_temp_measurement(&mut self.one_wire_bus, &mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
ds18b20::Resolution::Bits12.delay_for_measurement_time(&mut self.esp.delay);
|
||||||
|
let sensor_data = water_temp_sensor
|
||||||
|
.read_data(&mut self.one_wire_bus, &mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
if sensor_data.temperature == 85_f32 {
|
||||||
|
bail!("Ds18b20 dummy temperature returned");
|
||||||
|
}
|
||||||
|
Ok(sensor_data.temperature / 10_f32)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tank_sensor_voltage(&mut self) -> Result<f32> {
|
||||||
|
self.tank_power.set_high()?;
|
||||||
|
//let stabilize
|
||||||
|
self.esp.delay.delay_ms(100);
|
||||||
|
|
||||||
|
let mut store = [0_u16; TANK_MULTI_SAMPLE];
|
||||||
|
for multisample in 0..TANK_MULTI_SAMPLE {
|
||||||
|
let value = self.tank_channel.read()?;
|
||||||
|
store[multisample] = value;
|
||||||
|
}
|
||||||
|
self.tank_power.set_low()?;
|
||||||
|
|
||||||
|
store.sort();
|
||||||
|
let median_mv = store[6] as f32 / 1000_f32;
|
||||||
|
Ok(median_mv)
|
||||||
|
}
|
||||||
fn light(&mut self, enable: bool) -> Result<()> {
|
fn light(&mut self, enable: bool) -> Result<()> {
|
||||||
unsafe { gpio_hold_dis(self.light.pin()) };
|
unsafe { gpio_hold_dis(self.light.pin()) };
|
||||||
self.light.set_state(enable.into())?;
|
self.light.set_state(enable.into())?;
|
||||||
unsafe { gpio_hold_en(self.light.pin()) };
|
unsafe { gpio_hold_en(self.light.pin()) };
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pump(&mut self, plant: usize, enable: bool) -> Result<()> {
|
fn pump(&mut self, plant: usize, enable: bool) -> Result<()> {
|
||||||
if enable {
|
if enable {
|
||||||
self.main_pump.set_high()?;
|
self.main_pump.set_high()?;
|
||||||
@ -244,6 +448,7 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
7 => PUMP8_BIT,
|
7 => PUMP8_BIT,
|
||||||
_ => bail!("Invalid pump {plant}",),
|
_ => bail!("Invalid pump {plant}",),
|
||||||
};
|
};
|
||||||
|
//currently infallible error, keep for future as result anyway
|
||||||
self.shift_register.decompose()[index].set_state(enable.into())?;
|
self.shift_register.decompose()[index].set_state(enable.into())?;
|
||||||
|
|
||||||
if !enable {
|
if !enable {
|
||||||
@ -330,8 +535,8 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
self.shift_register.decompose()[MS_4].set_low()?;
|
self.shift_register.decompose()[MS_4].set_low()?;
|
||||||
self.shift_register.decompose()[SENSOR_ON].set_high()?;
|
self.shift_register.decompose()[SENSOR_ON].set_high()?;
|
||||||
|
|
||||||
let measurement = 100; //how long to measure and then extrapolate to hz
|
let measurement = 100; // TODO what is this scaling factor? what is its purpose?
|
||||||
let factor = 1000f32 / measurement as f32; //scale raw cound by this number to get hz
|
let factor = 1000f32 / measurement as f32;
|
||||||
|
|
||||||
//give some time to stabilize
|
//give some time to stabilize
|
||||||
self.esp.delay.delay_ms(10);
|
self.esp.delay.delay_ms(10);
|
||||||
@ -365,6 +570,34 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
unsafe { gpio_hold_en(self.general_fault.pin()) };
|
unsafe { gpio_hold_en(self.general_fault.pin()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn factory_reset(&mut self) -> Result<()> {
|
||||||
|
println!("factory resetting");
|
||||||
|
self.esp.delete_config()?;
|
||||||
|
//destroy backup header
|
||||||
|
let dummy: [u8; 0] = [];
|
||||||
|
self.backup_config(&dummy)?;
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_rtc_time(&mut self) -> Result<DateTime<Utc>> {
|
||||||
|
match self.rtc.datetime() {
|
||||||
|
OkStd(rtc_time) => Ok(rtc_time.and_utc()),
|
||||||
|
Err(err) => {
|
||||||
|
bail!("Error getting rtc time {:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> Result<()> {
|
||||||
|
let naive_time = time.naive_utc();
|
||||||
|
match self.rtc.set_datetime(&naive_time) {
|
||||||
|
OkStd(_) => Ok(()),
|
||||||
|
Err(err) => {
|
||||||
|
bail!("Error getting rtc time {:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn test_pump(&mut self, plant: usize) -> Result<()> {
|
fn test_pump(&mut self, plant: usize) -> Result<()> {
|
||||||
self.pump(plant, true)?;
|
self.pump(plant, true)?;
|
||||||
unsafe { vTaskDelay(30000) };
|
unsafe { vTaskDelay(30000) };
|
||||||
@ -410,22 +643,9 @@ impl<'a> BoardInteraction<'a> for V3<'a> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_config(&mut self, config: PlantControllerConfig) -> Result<()> {
|
fn set_config(&mut self, config: PlantControllerConfig) -> anyhow::Result<()> {
|
||||||
self.config = config;
|
self.config = config;
|
||||||
self.esp.save_config(&self.config)?;
|
self.esp.save_config(&self.config)?;
|
||||||
anyhow::Ok(())
|
anyhow::Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_mptt_voltage(&mut self) -> Result<Voltage> {
|
|
||||||
//assuming module to work, these are the hardware set values
|
|
||||||
if self.is_day() {
|
|
||||||
Ok(Voltage::from_volts(15_f64))
|
|
||||||
} else {
|
|
||||||
Ok(Voltage::from_volts(0_f64))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_mptt_current(&mut self) -> Result<Current> {
|
|
||||||
bail!("Board does not have current sensor")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,31 +1,36 @@
|
|||||||
use crate::config::PlantControllerConfig;
|
use crate::config::PlantControllerConfig;
|
||||||
use crate::hal::battery::BatteryInteraction;
|
use crate::hal::battery::BatteryInteraction;
|
||||||
use crate::hal::esp::Esp;
|
use crate::hal::esp::ESP;
|
||||||
use crate::hal::rtc::RTCModuleInteraction;
|
|
||||||
use crate::hal::water::TankSensor;
|
|
||||||
use crate::hal::{
|
use crate::hal::{
|
||||||
deep_sleep, BoardInteraction, FreePeripherals, Sensor, I2C_DRIVER, PLANT_COUNT,
|
deep_sleep, BackupHeader, BoardInteraction, FreePeripherals, Sensor, I2C_DRIVER, PLANT_COUNT,
|
||||||
REPEAT_MOIST_MEASURE,
|
REPEAT_MOIST_MEASURE, TANK_MULTI_SAMPLE, X25,
|
||||||
};
|
};
|
||||||
use crate::log::{log, LogMessage};
|
use crate::log::{log, LogMessage};
|
||||||
use anyhow::bail;
|
use anyhow::{anyhow, bail};
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
|
use ds18b20::Ds18b20;
|
||||||
|
use ds323x::{DateTimeAccess, Ds323x};
|
||||||
|
use eeprom24x::{Eeprom24x, Eeprom24xTrait, SlaveAddr};
|
||||||
use embedded_hal::digital::OutputPin;
|
use embedded_hal::digital::OutputPin;
|
||||||
use embedded_hal_bus::i2c::MutexDevice;
|
use embedded_hal_bus::i2c::MutexDevice;
|
||||||
|
use esp_idf_hal::adc::oneshot::config::AdcChannelConfig;
|
||||||
|
use esp_idf_hal::adc::oneshot::{AdcChannelDriver, AdcDriver};
|
||||||
|
use esp_idf_hal::adc::{attenuation, Resolution};
|
||||||
use esp_idf_hal::delay::Delay;
|
use esp_idf_hal::delay::Delay;
|
||||||
use esp_idf_hal::gpio::{AnyInputPin, IOPin, InputOutput, Output, PinDriver, Pull};
|
use esp_idf_hal::gpio::{AnyInputPin, Gpio5, IOPin, InputOutput, Output, PinDriver, Pull};
|
||||||
use esp_idf_hal::i2c::{I2cDriver, I2cError};
|
use esp_idf_hal::i2c::I2cDriver;
|
||||||
use esp_idf_hal::pcnt::{
|
use esp_idf_hal::pcnt::{
|
||||||
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
PcntChannel, PcntChannelConfig, PcntControlMode, PcntCountMode, PcntDriver, PinIndex,
|
||||||
};
|
};
|
||||||
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en};
|
use esp_idf_sys::{gpio_hold_dis, gpio_hold_en, vTaskDelay, EspError};
|
||||||
use ina219::address::{Address, Pin};
|
use ina219::address::{Address, Pin};
|
||||||
use ina219::calibration::UnCalibrated;
|
use ina219::calibration::{Calibration, UnCalibrated};
|
||||||
use ina219::configuration::{Configuration, OperatingMode};
|
|
||||||
use ina219::errors::InitializationError;
|
|
||||||
use ina219::SyncIna219;
|
use ina219::SyncIna219;
|
||||||
use measurements::{Current, Resistance, Voltage};
|
use measurements::{Current, Resistance, Voltage};
|
||||||
|
use one_wire_bus::OneWire;
|
||||||
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
use pca9535::{GPIOBank, Pca9535Immediate, StandardExpanderInterface};
|
||||||
use std::result::Result::Ok as OkStd;
|
use std::result::Result::Ok as OkStd;
|
||||||
|
use ina219::configuration::{Configuration, OperatingMode};
|
||||||
|
|
||||||
const MS0: u8 = 1_u8;
|
const MS0: u8 = 1_u8;
|
||||||
const MS1: u8 = 0_u8;
|
const MS1: u8 = 0_u8;
|
||||||
@ -40,31 +45,25 @@ pub enum Charger<'a> {
|
|||||||
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
solar_is_day: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, esp_idf_hal::gpio::Input>,
|
||||||
charge_indicator: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
charge_indicator: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
},
|
},
|
||||||
ErrorInit {},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Charger<'_> {
|
impl<'a> Charger<'a> {
|
||||||
pub(crate) fn power_save(&mut self) {
|
pub(crate) fn powersave(&mut self) {
|
||||||
match self {
|
match self { Charger::SolarMpptV1 { mppt_ina, .. } => {
|
||||||
Charger::SolarMpptV1 { mppt_ina, .. } => {
|
let _ = mppt_ina.set_configuration(Configuration {
|
||||||
let _ = mppt_ina
|
reset: Default::default(),
|
||||||
.set_configuration(Configuration {
|
bus_voltage_range: Default::default(),
|
||||||
reset: Default::default(),
|
shunt_voltage_range: Default::default(),
|
||||||
bus_voltage_range: Default::default(),
|
bus_resolution: Default::default(),
|
||||||
shunt_voltage_range: Default::default(),
|
shunt_resolution: Default::default(),
|
||||||
bus_resolution: Default::default(),
|
operating_mode: OperatingMode::PowerDown,
|
||||||
shunt_resolution: Default::default(),
|
}).map_err(|e| {
|
||||||
operating_mode: OperatingMode::PowerDown,
|
println!(
|
||||||
})
|
"Error setting ina mppt configuration during deepsleep preparation{:?}",
|
||||||
.map_err(|e| {
|
|
||||||
println!(
|
|
||||||
"Error setting ina mppt configuration during deep sleep preparation{:?}",
|
|
||||||
e
|
e
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
} }
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
fn set_charge_indicator(&mut self, charging: bool) -> anyhow::Result<()> {
|
fn set_charge_indicator(&mut self, charging: bool) -> anyhow::Result<()> {
|
||||||
match self {
|
match self {
|
||||||
@ -73,7 +72,6 @@ impl Charger<'_> {
|
|||||||
} => {
|
} => {
|
||||||
charge_indicator.set_state(charging.into())?;
|
charge_indicator.set_state(charging.into())?;
|
||||||
}
|
}
|
||||||
_ => {}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -81,7 +79,6 @@ impl Charger<'_> {
|
|||||||
fn is_day(&self) -> bool {
|
fn is_day(&self) -> bool {
|
||||||
match self {
|
match self {
|
||||||
Charger::SolarMpptV1 { solar_is_day, .. } => solar_is_day.get_level().into(),
|
Charger::SolarMpptV1 { solar_is_day, .. } => solar_is_day.get_level().into(),
|
||||||
_ => true,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,9 +87,6 @@ impl Charger<'_> {
|
|||||||
Charger::SolarMpptV1 { mppt_ina, .. } => mppt_ina
|
Charger::SolarMpptV1 { mppt_ina, .. } => mppt_ina
|
||||||
.bus_voltage()
|
.bus_voltage()
|
||||||
.map(|v| Voltage::from_millivolts(v.voltage_mv() as f64))?,
|
.map(|v| Voltage::from_millivolts(v.voltage_mv() as f64))?,
|
||||||
_ => {
|
|
||||||
bail!("hardware error during init")
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(voltage)
|
Ok(voltage)
|
||||||
}
|
}
|
||||||
@ -105,60 +99,82 @@ impl Charger<'_> {
|
|||||||
let current = shunt_voltage.as_volts() / shut_value.as_ohms();
|
let current = shunt_voltage.as_volts() / shut_value.as_ohms();
|
||||||
Current::from_amperes(current)
|
Current::from_amperes(current)
|
||||||
})?,
|
})?,
|
||||||
_ => {
|
|
||||||
bail!("hardware error during init")
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
Ok(current)
|
Ok(current)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct V4<'a> {
|
pub struct V4<'a> {
|
||||||
esp: Esp<'a>,
|
esp: ESP<'a>,
|
||||||
tank_sensor: TankSensor<'a>,
|
|
||||||
charger: Charger<'a>,
|
charger: Charger<'a>,
|
||||||
rtc_module: Box<dyn RTCModuleInteraction + Send>,
|
|
||||||
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
|
tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, esp_idf_hal::adc::ADC1>>,
|
||||||
signal_counter: PcntDriver<'a>,
|
signal_counter: PcntDriver<'a>,
|
||||||
awake: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, Output>,
|
awake: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, Output>,
|
||||||
light: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
light: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
|
tank_power: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
|
one_wire_bus: OneWire<PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>>,
|
||||||
|
rtc:
|
||||||
|
Ds323x<ds323x::interface::I2cInterface<MutexDevice<'a, I2cDriver<'a>>>, ds323x::ic::DS3231>,
|
||||||
|
eeprom: Eeprom24x<
|
||||||
|
MutexDevice<'a, I2cDriver<'a>>,
|
||||||
|
eeprom24x::page_size::B32,
|
||||||
|
eeprom24x::addr_size::TwoBytes,
|
||||||
|
eeprom24x::unique_serial::No,
|
||||||
|
>,
|
||||||
general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
general_fault: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, InputOutput>,
|
||||||
pump_expander: Pca9535Immediate<MutexDevice<'a, I2cDriver<'a>>>,
|
pump_expander: Pca9535Immediate<MutexDevice<'a, I2cDriver<'a>>>,
|
||||||
sensor_expander: Pca9535Immediate<MutexDevice<'a, I2cDriver<'a>>>,
|
sensor_expander: Pca9535Immediate<MutexDevice<'a, I2cDriver<'a>>>,
|
||||||
extra1: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, Output>,
|
|
||||||
extra2: PinDriver<'a, esp_idf_hal::gpio::AnyIOPin, Output>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn create_v4(
|
pub(crate) fn create_v4(
|
||||||
peripherals: FreePeripherals,
|
peripherals: FreePeripherals,
|
||||||
esp: Esp<'static>,
|
esp: ESP<'static>,
|
||||||
config: PlantControllerConfig,
|
config: PlantControllerConfig,
|
||||||
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
battery_monitor: Box<dyn BatteryInteraction + Send>,
|
||||||
rtc_module: Box<dyn RTCModuleInteraction + Send>,
|
) -> anyhow::Result<Box<dyn BoardInteraction + Send + '_>> {
|
||||||
) -> anyhow::Result<Box<dyn BoardInteraction<'static> + Send + 'static>> {
|
let mut awake = PinDriver::output(peripherals.gpio15.downgrade())?;
|
||||||
let mut awake = PinDriver::output(peripherals.gpio21.downgrade())?;
|
|
||||||
awake.set_high()?;
|
awake.set_high()?;
|
||||||
|
|
||||||
let mut general_fault = PinDriver::input_output(peripherals.gpio23.downgrade())?;
|
let mut general_fault = PinDriver::input_output(peripherals.gpio6.downgrade())?;
|
||||||
general_fault.set_pull(Pull::Floating)?;
|
general_fault.set_pull(Pull::Floating)?;
|
||||||
general_fault.set_low()?;
|
general_fault.set_low()?;
|
||||||
|
|
||||||
let mut extra1 = PinDriver::output(peripherals.gpio6.downgrade())?;
|
println!("Init rtc driver");
|
||||||
extra1.set_low()?;
|
let mut rtc = Ds323x::new_ds3231(MutexDevice::new(&I2C_DRIVER));
|
||||||
|
|
||||||
let mut extra2 = PinDriver::output(peripherals.gpio15.downgrade())?;
|
println!("Init rtc eeprom driver");
|
||||||
extra2.set_low()?;
|
let mut eeprom = {
|
||||||
|
Eeprom24x::new_24x32(
|
||||||
|
MutexDevice::new(&I2C_DRIVER),
|
||||||
|
SlaveAddr::Alternative(true, true, true),
|
||||||
|
)
|
||||||
|
};
|
||||||
|
|
||||||
let one_wire_pin = peripherals.gpio18.downgrade();
|
let mut one_wire_pin = PinDriver::input_output_od(peripherals.gpio18.downgrade())?;
|
||||||
let tank_power_pin = peripherals.gpio11.downgrade();
|
one_wire_pin.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
let tank_sensor = TankSensor::create(
|
let one_wire_bus = OneWire::new(one_wire_pin)
|
||||||
one_wire_pin,
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
peripherals.adc1,
|
|
||||||
peripherals.gpio5,
|
let rtc_time = rtc.datetime();
|
||||||
tank_power_pin,
|
match rtc_time {
|
||||||
);
|
OkStd(tt) => {
|
||||||
|
println!("Rtc Module reports time at UTC {}", tt);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("Rtc Module could not be read {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
match eeprom.read_byte(0) {
|
||||||
|
OkStd(byte) => {
|
||||||
|
println!("Read first byte with status {}", byte);
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
println!("Eeprom could not read first byte {:?}", err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let mut signal_counter = PcntDriver::new(
|
let mut signal_counter = PcntDriver::new(
|
||||||
peripherals.pcnt0,
|
peripherals.pcnt0,
|
||||||
@ -182,17 +198,31 @@ pub(crate) fn create_v4(
|
|||||||
},
|
},
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
let adc_config = AdcChannelConfig {
|
||||||
|
attenuation: attenuation::DB_11,
|
||||||
|
resolution: Resolution::Resolution12Bit,
|
||||||
|
calibration: esp_idf_hal::adc::oneshot::config::Calibration::Curve,
|
||||||
|
};
|
||||||
|
let tank_driver = AdcDriver::new(peripherals.adc1)?;
|
||||||
|
let tank_channel: AdcChannelDriver<Gpio5, AdcDriver<esp_idf_hal::adc::ADC1>> =
|
||||||
|
AdcChannelDriver::new(tank_driver, peripherals.gpio5, &adc_config)?;
|
||||||
|
|
||||||
let mut solar_is_day = PinDriver::input(peripherals.gpio7.downgrade())?;
|
let mut solar_is_day = PinDriver::input(peripherals.gpio7.downgrade())?;
|
||||||
solar_is_day.set_pull(Pull::Floating)?;
|
solar_is_day.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
let mut light = PinDriver::input_output(peripherals.gpio10.downgrade())?;
|
let mut light = PinDriver::input_output(peripherals.gpio10.downgrade())?;
|
||||||
light.set_pull(Pull::Floating)?;
|
light.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
|
let mut tank_power = PinDriver::input_output(peripherals.gpio11.downgrade())?;
|
||||||
|
tank_power.set_pull(Pull::Floating)?;
|
||||||
|
|
||||||
let mut charge_indicator = PinDriver::input_output(peripherals.gpio3.downgrade())?;
|
let mut charge_indicator = PinDriver::input_output(peripherals.gpio3.downgrade())?;
|
||||||
charge_indicator.set_pull(Pull::Floating)?;
|
charge_indicator.set_pull(Pull::Floating)?;
|
||||||
charge_indicator.set_low()?;
|
charge_indicator.set_low()?;
|
||||||
|
|
||||||
let mut pump_expander = Pca9535Immediate::new(MutexDevice::new(&I2C_DRIVER), 32);
|
let mut pump_expander = Pca9535Immediate::new(MutexDevice::new(&I2C_DRIVER), 32);
|
||||||
|
|
||||||
|
//todo error handing if init error
|
||||||
for pin in 0..8 {
|
for pin in 0..8 {
|
||||||
let _ = pump_expander.pin_into_output(GPIOBank::Bank0, pin);
|
let _ = pump_expander.pin_into_output(GPIOBank::Bank0, pin);
|
||||||
let _ = pump_expander.pin_into_output(GPIOBank::Bank1, pin);
|
let _ = pump_expander.pin_into_output(GPIOBank::Bank1, pin);
|
||||||
@ -208,65 +238,57 @@ pub(crate) fn create_v4(
|
|||||||
let _ = sensor_expander.pin_set_low(GPIOBank::Bank1, pin);
|
let _ = sensor_expander.pin_set_low(GPIOBank::Bank1, pin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO error handling is not done nicely here, should not break if ina is not responsive
|
||||||
let mut mppt_ina = SyncIna219::new(
|
let mut mppt_ina = SyncIna219::new(
|
||||||
MutexDevice::new(&I2C_DRIVER),
|
MutexDevice::new(&I2C_DRIVER),
|
||||||
Address::from_pins(Pin::Vcc, Pin::Gnd),
|
Address::from_pins(Pin::Vcc, Pin::Gnd),
|
||||||
|
)?;
|
||||||
|
|
||||||
|
mppt_ina.set_configuration(Configuration{
|
||||||
|
reset: Default::default(),
|
||||||
|
bus_voltage_range: Default::default(),
|
||||||
|
shunt_voltage_range: Default::default(),
|
||||||
|
bus_resolution: Default::default(),
|
||||||
|
shunt_resolution: ina219::configuration::Resolution::Avg128,
|
||||||
|
operating_mode: Default::default(),
|
||||||
|
})?;
|
||||||
|
//TODO this is probably laready done untill we are ready first time?, maybee add startup time comparison on access?
|
||||||
|
esp.delay.delay_ms(
|
||||||
|
mppt_ina
|
||||||
|
.configuration()?
|
||||||
|
.conversion_time()
|
||||||
|
.unwrap()
|
||||||
|
.as_millis() as u32,
|
||||||
);
|
);
|
||||||
|
|
||||||
let charger = match mppt_ina {
|
let charger = Charger::SolarMpptV1 {
|
||||||
Ok(mut mppt_ina) => {
|
mppt_ina,
|
||||||
mppt_ina.set_configuration(Configuration {
|
solar_is_day,
|
||||||
reset: Default::default(),
|
charge_indicator,
|
||||||
bus_voltage_range: Default::default(),
|
|
||||||
shunt_voltage_range: Default::default(),
|
|
||||||
bus_resolution: Default::default(),
|
|
||||||
shunt_resolution: ina219::configuration::Resolution::Avg128,
|
|
||||||
operating_mode: Default::default(),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
//TODO this is probably already done until we are ready first time?, maybe add startup time comparison on access?
|
|
||||||
esp.delay.delay_ms(
|
|
||||||
mppt_ina
|
|
||||||
.configuration()?
|
|
||||||
.conversion_time()
|
|
||||||
.unwrap()
|
|
||||||
.as_millis() as u32,
|
|
||||||
);
|
|
||||||
|
|
||||||
Charger::SolarMpptV1 {
|
|
||||||
mppt_ina,
|
|
||||||
solar_is_day,
|
|
||||||
charge_indicator,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Err(_) => Charger::ErrorInit {},
|
|
||||||
};
|
};
|
||||||
|
|
||||||
let v = V4 {
|
let v = V4 {
|
||||||
rtc_module,
|
|
||||||
esp,
|
esp,
|
||||||
awake,
|
awake,
|
||||||
tank_sensor,
|
tank_channel,
|
||||||
signal_counter,
|
signal_counter,
|
||||||
light,
|
light,
|
||||||
|
tank_power,
|
||||||
|
one_wire_bus,
|
||||||
|
rtc,
|
||||||
|
eeprom,
|
||||||
general_fault,
|
general_fault,
|
||||||
pump_expander,
|
pump_expander,
|
||||||
sensor_expander,
|
sensor_expander,
|
||||||
config,
|
config,
|
||||||
battery_monitor,
|
battery_monitor,
|
||||||
charger,
|
charger,
|
||||||
extra1,
|
|
||||||
extra2,
|
|
||||||
};
|
};
|
||||||
Ok(Box::new(v))
|
Ok(Box::new(v))
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> BoardInteraction<'a> for V4<'a> {
|
impl<'a> BoardInteraction<'a> for V4<'a> {
|
||||||
fn get_tank_sensor(&mut self) -> Option<&mut TankSensor<'a>> {
|
fn get_esp(&mut self) -> &mut ESP<'a> {
|
||||||
Some(&mut self.tank_sensor)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn get_esp(&mut self) -> &mut Esp<'a> {
|
|
||||||
&mut self.esp
|
&mut self.esp
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -278,24 +300,161 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
&mut self.battery_monitor
|
&mut self.battery_monitor
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_rtc_module(&mut self) -> &mut Box<dyn RTCModuleInteraction + Send> {
|
|
||||||
&mut self.rtc_module
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_charge_indicator(&mut self, charging: bool) -> anyhow::Result<()> {
|
fn set_charge_indicator(&mut self, charging: bool) -> anyhow::Result<()> {
|
||||||
self.charger.set_charge_indicator(charging)
|
self.charger.set_charge_indicator(charging)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
fn deep_sleep(&mut self, duration_in_ms: u64) -> ! {
|
||||||
self.awake.set_low().unwrap();
|
self.awake.set_low().unwrap();
|
||||||
self.charger.power_save();
|
self.charger.powersave();
|
||||||
deep_sleep(duration_in_ms);
|
deep_sleep(duration_in_ms);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn get_backup_info(&mut self) -> anyhow::Result<BackupHeader> {
|
||||||
|
let store = bincode::serialize(&BackupHeader::default())?.len();
|
||||||
|
let mut header_page_buffer = vec![0_u8; store];
|
||||||
|
|
||||||
|
self.eeprom
|
||||||
|
.read_data(0, &mut header_page_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
||||||
|
|
||||||
|
println!("Raw header is {:?} with size {}", header_page_buffer, store);
|
||||||
|
let header: BackupHeader = bincode::deserialize(&header_page_buffer)?;
|
||||||
|
anyhow::Ok(header)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_backup_config(&mut self) -> anyhow::Result<Vec<u8>> {
|
||||||
|
let store = bincode::serialize(&BackupHeader::default())?.len();
|
||||||
|
let mut header_page_buffer = vec![0_u8; store];
|
||||||
|
|
||||||
|
self.eeprom
|
||||||
|
.read_data(0, &mut header_page_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom header {:?}", err))?;
|
||||||
|
|
||||||
|
let header: BackupHeader = bincode::deserialize(&header_page_buffer)?;
|
||||||
|
|
||||||
|
//skip page 0, used by the header
|
||||||
|
let data_start_address = self.eeprom.page_size() as u32;
|
||||||
|
let mut data_buffer = vec![0_u8; header.size];
|
||||||
|
self.eeprom
|
||||||
|
.read_data(data_start_address, &mut data_buffer)
|
||||||
|
.map_err(|err| anyhow!("Error reading eeprom data {:?}", err))?;
|
||||||
|
|
||||||
|
let checksum = X25.checksum(&data_buffer);
|
||||||
|
if checksum != header.crc16 {
|
||||||
|
bail!(
|
||||||
|
"Invalid checksum, got {} but expected {}",
|
||||||
|
checksum,
|
||||||
|
header.crc16
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
anyhow::Ok(data_buffer)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn backup_config(&mut self, bytes: &[u8]) -> anyhow::Result<()> {
|
||||||
|
let time = self.get_rtc_time()?.timestamp_millis();
|
||||||
|
|
||||||
|
let delay = Delay::new_default();
|
||||||
|
|
||||||
|
let checksum = X25.checksum(bytes);
|
||||||
|
let page_size = self.eeprom.page_size();
|
||||||
|
|
||||||
|
let header = BackupHeader {
|
||||||
|
crc16: checksum,
|
||||||
|
timestamp: time,
|
||||||
|
size: bytes.len(),
|
||||||
|
};
|
||||||
|
|
||||||
|
let encoded = bincode::serialize(&header)?;
|
||||||
|
if encoded.len() > page_size {
|
||||||
|
bail!(
|
||||||
|
"Size limit reached header is {}, but firest page is only {}",
|
||||||
|
encoded.len(),
|
||||||
|
page_size
|
||||||
|
)
|
||||||
|
}
|
||||||
|
let as_u8: &[u8] = &encoded;
|
||||||
|
|
||||||
|
match self.eeprom.write_page(0, as_u8) {
|
||||||
|
OkStd(_) => {}
|
||||||
|
Err(err) => bail!("Error writing eeprom {:?}", err),
|
||||||
|
};
|
||||||
|
delay.delay_ms(5);
|
||||||
|
|
||||||
|
let to_write = bytes.chunks(page_size);
|
||||||
|
|
||||||
|
let mut lastiter = 0;
|
||||||
|
let mut current_page = 1;
|
||||||
|
for chunk in to_write {
|
||||||
|
let address = current_page * page_size as u32;
|
||||||
|
self.eeprom
|
||||||
|
.write_page(address, chunk)
|
||||||
|
.map_err(|err| anyhow!("Error writing eeprom {:?}", err))?;
|
||||||
|
current_page += 1;
|
||||||
|
|
||||||
|
let iter = (current_page % 8) as usize;
|
||||||
|
if iter != lastiter {
|
||||||
|
for i in 0..PLANT_COUNT {
|
||||||
|
let _ = self.fault(i, iter == i);
|
||||||
|
}
|
||||||
|
lastiter = iter;
|
||||||
|
}
|
||||||
|
|
||||||
|
delay.delay_ms(5);
|
||||||
|
}
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn is_day(&self) -> bool {
|
fn is_day(&self) -> bool {
|
||||||
self.charger.is_day()
|
self.charger.is_day()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn water_temperature_c(&mut self) -> anyhow::Result<f32> {
|
||||||
|
self.one_wire_bus
|
||||||
|
.reset(&mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
let first = self.one_wire_bus.devices(false, &mut self.esp.delay).next();
|
||||||
|
if first.is_none() {
|
||||||
|
bail!("Not found any one wire Ds18b20");
|
||||||
|
}
|
||||||
|
let device_address = first
|
||||||
|
.unwrap()
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
|
let water_temp_sensor = Ds18b20::new::<EspError>(device_address)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
|
||||||
|
water_temp_sensor
|
||||||
|
.start_temp_measurement(&mut self.one_wire_bus, &mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
ds18b20::Resolution::Bits12.delay_for_measurement_time(&mut self.esp.delay);
|
||||||
|
let sensor_data = water_temp_sensor
|
||||||
|
.read_data(&mut self.one_wire_bus, &mut self.esp.delay)
|
||||||
|
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
||||||
|
if sensor_data.temperature == 85_f32 {
|
||||||
|
bail!("Ds18b20 dummy temperature returned");
|
||||||
|
}
|
||||||
|
anyhow::Ok(sensor_data.temperature / 10_f32)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn tank_sensor_voltage(&mut self) -> anyhow::Result<f32> {
|
||||||
|
self.tank_power.set_high()?;
|
||||||
|
//let stabilize
|
||||||
|
self.esp.delay.delay_ms(100);
|
||||||
|
|
||||||
|
let mut store = [0_u16; TANK_MULTI_SAMPLE];
|
||||||
|
for multisample in 0..TANK_MULTI_SAMPLE {
|
||||||
|
let value = self.tank_channel.read()?;
|
||||||
|
store[multisample] = value;
|
||||||
|
}
|
||||||
|
self.tank_power.set_low()?;
|
||||||
|
|
||||||
|
store.sort();
|
||||||
|
let median_mv = store[6] as f32 / 1000_f32;
|
||||||
|
anyhow::Ok(median_mv)
|
||||||
|
}
|
||||||
|
|
||||||
fn light(&mut self, enable: bool) -> anyhow::Result<()> {
|
fn light(&mut self, enable: bool) -> anyhow::Result<()> {
|
||||||
unsafe { gpio_hold_dis(self.light.pin()) };
|
unsafe { gpio_hold_dis(self.light.pin()) };
|
||||||
self.light.set_state(enable.into())?;
|
self.light.set_state(enable.into())?;
|
||||||
@ -406,6 +565,35 @@ impl<'a> BoardInteraction<'a> for V4<'a> {
|
|||||||
unsafe { gpio_hold_en(self.general_fault.pin()) };
|
unsafe { gpio_hold_en(self.general_fault.pin()) };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn factory_reset(&mut self) -> anyhow::Result<()> {
|
||||||
|
println!("factory resetting");
|
||||||
|
self.esp.delete_config()?;
|
||||||
|
//destroy backup header
|
||||||
|
let dummy: [u8; 0] = [];
|
||||||
|
self.backup_config(&dummy)?;
|
||||||
|
|
||||||
|
anyhow::Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn get_rtc_time(&mut self) -> anyhow::Result<DateTime<Utc>> {
|
||||||
|
match self.rtc.datetime() {
|
||||||
|
OkStd(rtc_time) => anyhow::Ok(rtc_time.and_utc()),
|
||||||
|
Err(err) => {
|
||||||
|
bail!("Error getting rtc time {:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn set_rtc_time(&mut self, time: &DateTime<Utc>) -> anyhow::Result<()> {
|
||||||
|
let naive_time = time.naive_utc();
|
||||||
|
match self.rtc.set_datetime(&naive_time) {
|
||||||
|
OkStd(_) => anyhow::Ok(()),
|
||||||
|
Err(err) => {
|
||||||
|
bail!("Error getting rtc time {:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn test_pump(&mut self, plant: usize) -> anyhow::Result<()> {
|
fn test_pump(&mut self, plant: usize) -> anyhow::Result<()> {
|
||||||
self.pump(plant, true)?;
|
self.pump(plant, true)?;
|
||||||
self.esp.delay.delay_ms(30000);
|
self.esp.delay.delay_ms(30000);
|
||||||
|
@ -1,124 +0,0 @@
|
|||||||
use crate::hal::TANK_MULTI_SAMPLE;
|
|
||||||
use anyhow::{anyhow, bail};
|
|
||||||
use ds18b20::Ds18b20;
|
|
||||||
use esp_idf_hal::adc::oneshot::config::AdcChannelConfig;
|
|
||||||
use esp_idf_hal::adc::oneshot::{AdcChannelDriver, AdcDriver};
|
|
||||||
use esp_idf_hal::adc::{attenuation, Resolution, ADC1};
|
|
||||||
use esp_idf_hal::delay::Delay;
|
|
||||||
use esp_idf_hal::gpio::{AnyIOPin, Gpio5, InputOutput, PinDriver, Pull};
|
|
||||||
use esp_idf_sys::EspError;
|
|
||||||
use one_wire_bus::OneWire;
|
|
||||||
|
|
||||||
pub struct TankSensor<'a> {
|
|
||||||
one_wire_bus: OneWire<PinDriver<'a, AnyIOPin, InputOutput>>,
|
|
||||||
tank_channel: AdcChannelDriver<'a, Gpio5, AdcDriver<'a, ADC1>>,
|
|
||||||
tank_power: PinDriver<'a, AnyIOPin, InputOutput>,
|
|
||||||
delay: Delay,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<'a> TankSensor<'a> {
|
|
||||||
pub(crate) fn create(
|
|
||||||
one_wire_pin: AnyIOPin,
|
|
||||||
adc1: ADC1,
|
|
||||||
gpio5: Gpio5,
|
|
||||||
tank_power_pin: AnyIOPin,
|
|
||||||
) -> TankSensor<'a> {
|
|
||||||
let mut one_wire_pin =
|
|
||||||
PinDriver::input_output_od(one_wire_pin).expect("Failed to configure pin");
|
|
||||||
one_wire_pin
|
|
||||||
.set_pull(Pull::Floating)
|
|
||||||
.expect("Failed to set pull");
|
|
||||||
|
|
||||||
let adc_config = AdcChannelConfig {
|
|
||||||
attenuation: attenuation::DB_11,
|
|
||||||
resolution: Resolution::Resolution12Bit,
|
|
||||||
calibration: esp_idf_hal::adc::oneshot::config::Calibration::Curve,
|
|
||||||
};
|
|
||||||
let tank_driver = AdcDriver::new(adc1).expect("Failed to configure ADC");
|
|
||||||
let tank_channel = AdcChannelDriver::new(tank_driver, gpio5, &adc_config)
|
|
||||||
.expect("Failed to configure ADC channel");
|
|
||||||
|
|
||||||
let mut tank_power =
|
|
||||||
PinDriver::input_output(tank_power_pin).expect("Failed to configure pin");
|
|
||||||
tank_power
|
|
||||||
.set_pull(Pull::Floating)
|
|
||||||
.expect("Failed to set pull");
|
|
||||||
|
|
||||||
let one_wire_bus =
|
|
||||||
OneWire::new(one_wire_pin).expect("OneWire bus did not pull up after release");
|
|
||||||
|
|
||||||
TankSensor {
|
|
||||||
one_wire_bus,
|
|
||||||
tank_channel,
|
|
||||||
tank_power,
|
|
||||||
delay: Default::default(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn water_temperature_c(&mut self) -> anyhow::Result<f32> {
|
|
||||||
//multisample should be moved to water_temperature_c
|
|
||||||
let mut attempt = 1;
|
|
||||||
let water_temp: Result<f32, anyhow::Error> = loop {
|
|
||||||
let temp = self.single_temperature_c();
|
|
||||||
match &temp {
|
|
||||||
Ok(res) => {
|
|
||||||
println!("Water temp is {}", res);
|
|
||||||
break temp;
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
println!("Could not get water temp {} attempt {}", err, attempt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if attempt == 5 {
|
|
||||||
break temp;
|
|
||||||
}
|
|
||||||
attempt += 1;
|
|
||||||
};
|
|
||||||
water_temp
|
|
||||||
}
|
|
||||||
|
|
||||||
fn single_temperature_c(&mut self) -> anyhow::Result<f32> {
|
|
||||||
self.one_wire_bus
|
|
||||||
.reset(&mut self.delay)
|
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
|
||||||
let first = self.one_wire_bus.devices(false, &mut self.delay).next();
|
|
||||||
if first.is_none() {
|
|
||||||
bail!("Not found any one wire Ds18b20");
|
|
||||||
}
|
|
||||||
let device_address = first
|
|
||||||
.unwrap()
|
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
|
||||||
|
|
||||||
let water_temp_sensor = Ds18b20::new::<EspError>(device_address)
|
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
|
||||||
|
|
||||||
water_temp_sensor
|
|
||||||
.start_temp_measurement(&mut self.one_wire_bus, &mut self.delay)
|
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
|
||||||
ds18b20::Resolution::Bits12.delay_for_measurement_time(&mut self.delay);
|
|
||||||
let sensor_data = water_temp_sensor
|
|
||||||
.read_data(&mut self.one_wire_bus, &mut self.delay)
|
|
||||||
.map_err(|err| -> anyhow::Error { anyhow!("Missing attribute: {:?}", err) })?;
|
|
||||||
if sensor_data.temperature == 85_f32 {
|
|
||||||
bail!("Ds18b20 dummy temperature returned");
|
|
||||||
}
|
|
||||||
anyhow::Ok(sensor_data.temperature / 10_f32)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn tank_sensor_voltage(&mut self) -> anyhow::Result<f32> {
|
|
||||||
self.tank_power.set_high()?;
|
|
||||||
//let stabilize
|
|
||||||
self.delay.delay_ms(100);
|
|
||||||
|
|
||||||
let mut store = [0_u16; TANK_MULTI_SAMPLE];
|
|
||||||
for multisample in 0..TANK_MULTI_SAMPLE {
|
|
||||||
let value = self.tank_channel.read()?;
|
|
||||||
store[multisample] = value;
|
|
||||||
}
|
|
||||||
self.tank_power.set_low()?;
|
|
||||||
|
|
||||||
store.sort();
|
|
||||||
let median_mv = store[6] as f32 / 1000_f32;
|
|
||||||
anyhow::Ok(median_mv)
|
|
||||||
}
|
|
||||||
}
|
|
@ -65,7 +65,7 @@ pub fn get_log() -> Vec<LogEntry> {
|
|||||||
read_copy.push(copy);
|
read_copy.push(copy);
|
||||||
}
|
}
|
||||||
drop(buffer);
|
drop(buffer);
|
||||||
read_copy
|
return read_copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log(message_key: LogMessage, number_a: u32, number_b: u32, txt_short: &str, txt_long: &str) {
|
pub fn log(message_key: LogMessage, number_a: u32, number_b: u32, txt_short: &str, txt_long: &str) {
|
||||||
|
258
rust/src/main.rs
258
rust/src/main.rs
@ -1,38 +1,44 @@
|
|||||||
use crate::{
|
use crate::webserver::webserver::httpd;
|
||||||
config::BoardVersion::INITIAL,
|
use anyhow::bail;
|
||||||
hal::{PlantHal, HAL, PLANT_COUNT},
|
|
||||||
webserver::httpd,
|
|
||||||
};
|
|
||||||
use anyhow::{bail, Context};
|
|
||||||
use chrono::{DateTime, Datelike, Timelike, Utc};
|
use chrono::{DateTime, Datelike, Timelike, Utc};
|
||||||
use chrono_tz::Tz::{self, UTC};
|
use chrono_tz::Tz;
|
||||||
|
use chrono_tz::Tz::UTC;
|
||||||
use esp_idf_hal::delay::Delay;
|
use esp_idf_hal::delay::Delay;
|
||||||
use esp_idf_sys::{
|
use esp_idf_sys::{
|
||||||
esp_ota_get_app_partition_count, esp_ota_get_running_partition, esp_ota_get_state_partition,
|
esp_ota_get_app_partition_count, esp_ota_get_running_partition, esp_ota_get_state_partition,
|
||||||
esp_ota_img_states_t, esp_ota_img_states_t_ESP_OTA_IMG_ABORTED,
|
esp_ota_img_states_t, esp_ota_img_states_t_ESP_OTA_IMG_ABORTED,
|
||||||
esp_ota_img_states_t_ESP_OTA_IMG_INVALID, esp_ota_img_states_t_ESP_OTA_IMG_NEW,
|
esp_ota_img_states_t_ESP_OTA_IMG_INVALID, esp_ota_img_states_t_ESP_OTA_IMG_NEW,
|
||||||
esp_ota_img_states_t_ESP_OTA_IMG_PENDING_VERIFY, esp_ota_img_states_t_ESP_OTA_IMG_UNDEFINED,
|
esp_ota_img_states_t_ESP_OTA_IMG_PENDING_VERIFY, esp_ota_img_states_t_ESP_OTA_IMG_UNDEFINED,
|
||||||
esp_ota_img_states_t_ESP_OTA_IMG_VALID,
|
esp_ota_img_states_t_ESP_OTA_IMG_VALID, vTaskDelay,
|
||||||
};
|
};
|
||||||
use esp_ota::{mark_app_valid, rollback_and_reboot};
|
use esp_ota::{mark_app_valid, rollback_and_reboot};
|
||||||
use hal::battery::BatteryState;
|
use hal::battery::BatteryState;
|
||||||
use log::{log, LogMessage};
|
use log::{log, LogMessage};
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use plant_state::PlantState;
|
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::sync::{atomic::AtomicBool, Arc, Mutex, MutexGuard};
|
use std::sync::MutexGuard;
|
||||||
use tank::*;
|
use std::{
|
||||||
|
fmt::Display,
|
||||||
|
sync::{atomic::AtomicBool, Arc, Mutex},
|
||||||
|
};
|
||||||
mod config;
|
mod config;
|
||||||
mod hal;
|
mod hal;
|
||||||
mod log;
|
mod log;
|
||||||
mod plant_state;
|
mod plant_state;
|
||||||
mod tank;
|
mod tank;
|
||||||
mod webserver;
|
|
||||||
|
|
||||||
|
use crate::config::BoardVersion::INITIAL;
|
||||||
|
use crate::hal::battery::BatteryInteraction;
|
||||||
|
use crate::hal::{BoardInteraction, PlantHal, HAL, PLANT_COUNT};
|
||||||
|
use plant_state::PlantState;
|
||||||
|
use tank::*;
|
||||||
pub static BOARD_ACCESS: Lazy<Mutex<HAL>> = Lazy::new(|| PlantHal::create().unwrap());
|
pub static BOARD_ACCESS: Lazy<Mutex<HAL>> = Lazy::new(|| PlantHal::create().unwrap());
|
||||||
pub static STAY_ALIVE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
|
pub static STAY_ALIVE: Lazy<AtomicBool> = Lazy::new(|| AtomicBool::new(false));
|
||||||
|
|
||||||
|
mod webserver {
|
||||||
|
pub mod webserver;
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
||||||
enum WaitType {
|
enum WaitType {
|
||||||
MissingConfig,
|
MissingConfig,
|
||||||
@ -40,12 +46,6 @@ enum WaitType {
|
|||||||
MqttConfig,
|
MqttConfig,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq)]
|
|
||||||
struct Solar {
|
|
||||||
current_ma: u32,
|
|
||||||
voltage_ma: u32,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl WaitType {
|
impl WaitType {
|
||||||
fn blink_pattern(&self) -> u32 {
|
fn blink_pattern(&self) -> u32 {
|
||||||
match self {
|
match self {
|
||||||
@ -72,7 +72,7 @@ struct LightState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
|
#[derive(Serialize, Deserialize, Debug, PartialEq, Default)]
|
||||||
///mqtt struct to track pump activities
|
///mqtt stuct to track pump activities
|
||||||
struct PumpInfo {
|
struct PumpInfo {
|
||||||
enabled: bool,
|
enabled: bool,
|
||||||
pump_ineffective: bool,
|
pump_ineffective: bool,
|
||||||
@ -160,7 +160,6 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
|
|
||||||
let cur = board
|
let cur = board
|
||||||
.board_hal
|
.board_hal
|
||||||
.get_rtc_module()
|
|
||||||
.get_rtc_time()
|
.get_rtc_time()
|
||||||
.or_else(|err| {
|
.or_else(|err| {
|
||||||
println!("rtc module error: {:?}", err);
|
println!("rtc module error: {:?}", err);
|
||||||
@ -179,7 +178,16 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
println!("cur is {}", cur);
|
println!("cur is {}", cur);
|
||||||
update_charge_indicator(&mut board);
|
match board
|
||||||
|
.board_hal
|
||||||
|
.get_battery_monitor()
|
||||||
|
.average_current_milli_ampere()
|
||||||
|
{
|
||||||
|
Ok(charging) => {
|
||||||
|
let _ = board.board_hal.set_charge_indicator(charging > 20);
|
||||||
|
}
|
||||||
|
Err(_) => {}
|
||||||
|
}
|
||||||
|
|
||||||
if board.board_hal.get_esp().get_restart_to_conf() {
|
if board.board_hal.get_esp().get_restart_to_conf() {
|
||||||
log(LogMessage::ConfigModeSoftwareOverride, 0, 0, "", "");
|
log(LogMessage::ConfigModeSoftwareOverride, 0, 0, "", "");
|
||||||
@ -260,11 +268,10 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
address,
|
address,
|
||||||
ota_state_string,
|
ota_state_string,
|
||||||
&mut board,
|
&mut board,
|
||||||
ip_address,
|
&ip_address,
|
||||||
timezone_time,
|
timezone_time,
|
||||||
);
|
);
|
||||||
publish_battery_state(&mut board);
|
publish_battery_state(&mut board);
|
||||||
let _ = publish_mppt_state(&mut board);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
log(
|
log(
|
||||||
@ -333,12 +340,8 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let mut water_frozen = false;
|
let mut water_frozen = false;
|
||||||
let water_temp = board
|
|
||||||
.board_hal
|
|
||||||
.get_tank_sensor()
|
|
||||||
.context("no sensor")
|
|
||||||
.and_then(|f| f.water_temperature_c());
|
|
||||||
|
|
||||||
|
let water_temp = obtain_tank_temperature(&mut board);
|
||||||
if let Ok(res) = water_temp {
|
if let Ok(res) = water_temp {
|
||||||
if res < WATER_FROZEN_THRESH {
|
if res < WATER_FROZEN_THRESH {
|
||||||
water_frozen = true;
|
water_frozen = true;
|
||||||
@ -421,12 +424,12 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
.state_charge_percent()
|
.state_charge_percent()
|
||||||
.unwrap_or(0.);
|
.unwrap_or(0.);
|
||||||
|
|
||||||
// try to load full battery state if failed the battery state is unknown
|
/// try to load full battery state if failed the battery state is unknown
|
||||||
let battery_state = board
|
let battery_state = board
|
||||||
.board_hal
|
.board_hal
|
||||||
.get_battery_monitor()
|
.get_battery_monitor()
|
||||||
.get_battery_state()
|
.get_battery_state()
|
||||||
.unwrap_or(BatteryState::Unknown);
|
.unwrap_or(hal::battery::BatteryState::Unknown);
|
||||||
|
|
||||||
let mut light_state = LightState {
|
let mut light_state = LightState {
|
||||||
enabled: board.board_hal.get_config().night_lamp.enabled,
|
enabled: board.board_hal.get_config().night_lamp.enabled,
|
||||||
@ -556,24 +559,26 @@ fn safe_main() -> anyhow::Result<()> {
|
|||||||
.deep_sleep(1000 * 1000 * 60 * deep_sleep_duration_minutes as u64);
|
.deep_sleep(1000 * 1000 * 60 * deep_sleep_duration_minutes as u64);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_charge_indicator(board: &mut MutexGuard<HAL>) {
|
fn obtain_tank_temperature(board: &mut MutexGuard<HAL>) -> anyhow::Result<f32> {
|
||||||
//we have mppt controller, ask it for charging current
|
//multisample should be moved to water_temperature_c
|
||||||
if let Ok(current) = board.board_hal.get_mptt_current() {
|
let mut attempt = 1;
|
||||||
let _ = board
|
let water_temp: Result<f32, anyhow::Error> = loop {
|
||||||
.board_hal
|
let temp = board.board_hal.water_temperature_c();
|
||||||
.set_charge_indicator(current.as_milliamperes() > 20_f64);
|
match &temp {
|
||||||
}
|
Ok(res) => {
|
||||||
//fallback to battery controller and ask it instead
|
println!("Water temp is {}", res);
|
||||||
else if let Ok(charging) = board
|
break temp;
|
||||||
.board_hal
|
}
|
||||||
.get_battery_monitor()
|
Err(err) => {
|
||||||
.average_current_milli_ampere()
|
println!("Could not get water temp {} attempt {}", err, attempt)
|
||||||
{
|
}
|
||||||
let _ = board.board_hal.set_charge_indicator(charging > 20);
|
}
|
||||||
} else {
|
if attempt == 5 {
|
||||||
//who knows
|
break temp;
|
||||||
let _ = board.board_hal.set_charge_indicator(false);
|
}
|
||||||
}
|
attempt += 1;
|
||||||
|
};
|
||||||
|
water_temp
|
||||||
}
|
}
|
||||||
|
|
||||||
fn publish_tank_state(
|
fn publish_tank_state(
|
||||||
@ -606,7 +611,7 @@ fn publish_plant_states(
|
|||||||
.zip(&board.board_hal.get_config().plants.clone())
|
.zip(&board.board_hal.get_config().plants.clone())
|
||||||
.enumerate()
|
.enumerate()
|
||||||
{
|
{
|
||||||
match serde_json::to_string(&plant_state.to_mqtt_info(plant_conf, timezone_time)) {
|
match serde_json::to_string(&plant_state.to_mqtt_info(plant_conf, &timezone_time)) {
|
||||||
Ok(state) => {
|
Ok(state) => {
|
||||||
let plant_topic = format!("/plant{}", plant_id + 1);
|
let plant_topic = format!("/plant{}", plant_id + 1);
|
||||||
let _ = board
|
let _ = board
|
||||||
@ -668,7 +673,7 @@ fn try_connect_wifi_sntp_mqtt(board: &mut MutexGuard<HAL>) -> NetworkMode {
|
|||||||
let sntp_mode: SntpMode = match board.board_hal.get_esp().sntp(1000 * 10) {
|
let sntp_mode: SntpMode = match board.board_hal.get_esp().sntp(1000 * 10) {
|
||||||
Ok(new_time) => {
|
Ok(new_time) => {
|
||||||
println!("Using time from sntp");
|
println!("Using time from sntp");
|
||||||
let _ = board.board_hal.get_rtc_module().set_rtc_time(&new_time);
|
let _ = board.board_hal.set_rtc_time(&new_time);
|
||||||
SntpMode::SYNC { current: new_time }
|
SntpMode::SYNC { current: new_time }
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@ -677,7 +682,7 @@ fn try_connect_wifi_sntp_mqtt(board: &mut MutexGuard<HAL>) -> NetworkMode {
|
|||||||
SntpMode::OFFLINE
|
SntpMode::OFFLINE
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let mqtt_connected = if board.board_hal.get_config().network.mqtt_url.is_some() {
|
let mqtt_connected = if let Some(_) = board.board_hal.get_config().network.mqtt_url {
|
||||||
let nw_config = &board.board_hal.get_config().network.clone();
|
let nw_config = &board.board_hal.get_config().network.clone();
|
||||||
match board.board_hal.get_esp().mqtt(nw_config) {
|
match board.board_hal.get_esp().mqtt(nw_config) {
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
@ -732,28 +737,9 @@ fn pump_info(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
fn publish_mppt_state(board: &mut MutexGuard<'_, HAL<'_>>) -> anyhow::Result<()> {
|
|
||||||
let current = board.board_hal.get_mptt_current()?;
|
|
||||||
let voltage = board.board_hal.get_mptt_voltage()?;
|
|
||||||
let solar_state = Solar {
|
|
||||||
current_ma: current.as_milliamperes() as u32,
|
|
||||||
voltage_ma: voltage.as_millivolts() as u32,
|
|
||||||
};
|
|
||||||
if let Ok(serialized_solar_state_bytes) =
|
|
||||||
serde_json::to_string(&solar_state).map(|s| s.into_bytes())
|
|
||||||
{
|
|
||||||
let _ = board
|
|
||||||
.board_hal
|
|
||||||
.get_esp()
|
|
||||||
.mqtt_publish("/mppt", &serialized_solar_state_bytes);
|
|
||||||
}
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
fn publish_battery_state(board: &mut MutexGuard<'_, HAL<'_>>) {
|
fn publish_battery_state(board: &mut MutexGuard<'_, HAL<'_>>) {
|
||||||
let state = board.board_hal.get_battery_monitor().get_battery_state();
|
let state = board.board_hal.get_battery_monitor().get_battery_state();
|
||||||
if let Ok(serialized_battery_state_bytes) =
|
if let Ok(serialized_battery_state_bytes) = serde_json::to_string(&state).map(|s| s.into_bytes())
|
||||||
serde_json::to_string(&state).map(|s| s.into_bytes())
|
|
||||||
{
|
{
|
||||||
let _ = board
|
let _ = board
|
||||||
.board_hal
|
.board_hal
|
||||||
@ -766,59 +752,76 @@ fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
|
|||||||
let delay = wait_type.blink_pattern();
|
let delay = wait_type.blink_pattern();
|
||||||
let mut led_count = 8;
|
let mut led_count = 8;
|
||||||
let mut pattern_step = 0;
|
let mut pattern_step = 0;
|
||||||
let delay_handle = Delay::new_default();
|
|
||||||
loop {
|
loop {
|
||||||
let mut board = BOARD_ACCESS.lock().unwrap();
|
unsafe {
|
||||||
update_charge_indicator(&mut board);
|
let mut board = BOARD_ACCESS.lock().unwrap();
|
||||||
|
|
||||||
match wait_type {
|
//we have mppt controller, ask it for charging current
|
||||||
WaitType::MissingConfig => {
|
if let Ok(current) = board.board_hal.get_mptt_current() {
|
||||||
// Keep existing behavior: circular filling pattern
|
let _ = board.board_hal.set_charge_indicator(current.as_milliamperes() > 20_f64);
|
||||||
led_count %= 8;
|
}
|
||||||
led_count += 1;
|
//fallback to battery controller and ask it instead
|
||||||
for i in 0..8 {
|
else if let Ok(charging) = board
|
||||||
let _ = board.board_hal.fault(i, i < led_count);
|
.board_hal
|
||||||
|
.get_battery_monitor()
|
||||||
|
.average_current_milli_ampere()
|
||||||
|
{
|
||||||
|
let _ = board.board_hal.set_charge_indicator(charging > 20);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//who knows
|
||||||
|
let _ = board.board_hal.set_charge_indicator(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
match wait_type {
|
||||||
|
WaitType::MissingConfig => {
|
||||||
|
// Keep existing behavior: circular filling pattern
|
||||||
|
led_count %= 8;
|
||||||
|
led_count += 1;
|
||||||
|
for i in 0..8 {
|
||||||
|
let _ = board.board_hal.fault(i, i < led_count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WaitType::ConfigButton => {
|
||||||
|
// Alternating pattern: 1010 1010 -> 0101 0101
|
||||||
|
pattern_step = (pattern_step + 1) % 2;
|
||||||
|
for i in 0..8 {
|
||||||
|
let _ = board.board_hal.fault(i, (i + pattern_step) % 2 == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WaitType::MqttConfig => {
|
||||||
|
// Moving dot pattern
|
||||||
|
pattern_step = (pattern_step + 1) % 8;
|
||||||
|
for i in 0..8 {
|
||||||
|
let _ = board.board_hal.fault(i, i == pattern_step);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
WaitType::ConfigButton => {
|
|
||||||
// Alternating pattern: 1010 1010 -> 0101 0101
|
board.board_hal.general_fault(true);
|
||||||
pattern_step = (pattern_step + 1) % 2;
|
drop(board);
|
||||||
for i in 0..8 {
|
vTaskDelay(delay);
|
||||||
let _ = board.board_hal.fault(i, (i + pattern_step) % 2 == 0);
|
let mut board = BOARD_ACCESS.lock().unwrap();
|
||||||
}
|
board.board_hal.general_fault(false);
|
||||||
|
|
||||||
|
// Clear all LEDs
|
||||||
|
for i in 0..8 {
|
||||||
|
let _ = board.board_hal.fault(i, false);
|
||||||
}
|
}
|
||||||
WaitType::MqttConfig => {
|
drop(board);
|
||||||
// Moving dot pattern
|
vTaskDelay(delay);
|
||||||
pattern_step = (pattern_step + 1) % 8;
|
|
||||||
for i in 0..8 {
|
if wait_type == WaitType::MqttConfig
|
||||||
let _ = board.board_hal.fault(i, i == pattern_step);
|
&& !STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed)
|
||||||
}
|
{
|
||||||
|
reboot_now.store(true, std::sync::atomic::Ordering::Relaxed);
|
||||||
|
}
|
||||||
|
if reboot_now.load(std::sync::atomic::Ordering::Relaxed) {
|
||||||
|
//ensure clean http answer
|
||||||
|
Delay::new_default().delay_ms(500);
|
||||||
|
BOARD_ACCESS.lock().unwrap().board_hal.deep_sleep(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
board.board_hal.general_fault(true);
|
|
||||||
drop(board);
|
|
||||||
//cannot use shared delay as that is inside the mutex here
|
|
||||||
delay_handle.delay_ms(delay);
|
|
||||||
let mut board = BOARD_ACCESS.lock().unwrap();
|
|
||||||
board.board_hal.general_fault(false);
|
|
||||||
|
|
||||||
// Clear all LEDs
|
|
||||||
for i in 0..8 {
|
|
||||||
let _ = board.board_hal.fault(i, false);
|
|
||||||
}
|
|
||||||
drop(board);
|
|
||||||
delay_handle.delay_ms(delay);
|
|
||||||
|
|
||||||
if wait_type == WaitType::MqttConfig
|
|
||||||
&& !STAY_ALIVE.load(std::sync::atomic::Ordering::Relaxed)
|
|
||||||
{
|
|
||||||
reboot_now.store(true, std::sync::atomic::Ordering::Relaxed);
|
|
||||||
}
|
|
||||||
if reboot_now.load(std::sync::atomic::Ordering::Relaxed) {
|
|
||||||
//ensure clean http answer
|
|
||||||
Delay::new_default().delay_ms(500);
|
|
||||||
BOARD_ACCESS.lock().unwrap().board_hal.deep_sleep(1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -826,7 +829,7 @@ fn wait_infinity(wait_type: WaitType, reboot_now: Arc<AtomicBool>) -> ! {
|
|||||||
fn main() {
|
fn main() {
|
||||||
let result = safe_main();
|
let result = safe_main();
|
||||||
match result {
|
match result {
|
||||||
// this should not get triggered, safe_main should not return but go into deep sleep with sensible
|
// this should not get triggered, safe_main should not return but go into deep sleep with sensbile
|
||||||
// timeout, this is just a fallback
|
// timeout, this is just a fallback
|
||||||
Ok(_) => {
|
Ok(_) => {
|
||||||
println!("Main app finished, restarting");
|
println!("Main app finished, restarting");
|
||||||
@ -847,14 +850,23 @@ fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn to_string<T: Display>(value: anyhow::Result<T>) -> String {
|
||||||
|
match value {
|
||||||
|
Ok(v) => v.to_string(),
|
||||||
|
Err(err) => {
|
||||||
|
format!("{:?}", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn in_time_range(cur: &DateTime<Tz>, start: u8, end: u8) -> bool {
|
pub fn in_time_range(cur: &DateTime<Tz>, start: u8, end: u8) -> bool {
|
||||||
let current_hour = cur.hour() as u8;
|
let curhour = cur.hour() as u8;
|
||||||
//eg 10-14
|
//eg 10-14
|
||||||
if start < end {
|
if start < end {
|
||||||
current_hour > start && current_hour < end
|
curhour > start && curhour < end
|
||||||
} else {
|
} else {
|
||||||
//eg 20-05
|
//eg 20-05
|
||||||
current_hour > start || current_hour < end
|
curhour > start || curhour < end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
use crate::{
|
|
||||||
config::PlantConfig,
|
|
||||||
hal::{Sensor, HAL},
|
|
||||||
in_time_range,
|
|
||||||
};
|
|
||||||
use chrono::{DateTime, TimeDelta, Utc};
|
use chrono::{DateTime, TimeDelta, Utc};
|
||||||
use chrono_tz::Tz;
|
use chrono_tz::Tz;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::hal::{BoardInteraction, Sensor, HAL};
|
||||||
|
use crate::{config::PlantConfig, in_time_range};
|
||||||
|
|
||||||
const MOIST_SENSOR_MAX_FREQUENCY: f32 = 7500.; // 60kHz (500Hz margin)
|
const MOIST_SENSOR_MAX_FREQUENCY: f32 = 7500.; // 60kHz (500Hz margin)
|
||||||
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels
|
const MOIST_SENSOR_MIN_FREQUENCY: f32 = 150.; // this is really, really dry, think like cactus levels
|
||||||
|
|
||||||
@ -239,11 +237,7 @@ impl PlantState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn to_mqtt_info(
|
pub fn to_mqtt_info(&self, plant_conf: &PlantConfig, current_time: &DateTime<Tz>) -> PlantInfo {
|
||||||
&self,
|
|
||||||
plant_conf: &PlantConfig,
|
|
||||||
current_time: &DateTime<Tz>,
|
|
||||||
) -> PlantInfo<'_> {
|
|
||||||
PlantInfo {
|
PlantInfo {
|
||||||
sensor_a: &self.sensor_a,
|
sensor_a: &self.sensor_a,
|
||||||
sensor_b: &self.sensor_b,
|
sensor_b: &self.sensor_b,
|
||||||
|
@ -100,7 +100,7 @@ macro_rules! ShiftRegisterBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Get embedded-hal output pins to control the shift register outputs
|
/// Get embedded-hal output pins to control the shift register outputs
|
||||||
pub fn decompose(&self) -> [ShiftRegisterPin<'_>; $size] {
|
pub fn decompose(&self) -> [ShiftRegisterPin; $size] {
|
||||||
// Create an uninitialized array of `MaybeUninit`. The `assume_init` is
|
// Create an uninitialized array of `MaybeUninit`. The `assume_init` is
|
||||||
// safe because the type we are claiming to have initialized here is a
|
// safe because the type we are claiming to have initialized here is a
|
||||||
// bunch of `MaybeUninit`s, which do not require initialization.
|
// bunch of `MaybeUninit`s, which do not require initialization.
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
use crate::{config::TankConfig, hal::HAL};
|
|
||||||
use anyhow::Context;
|
|
||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
|
|
||||||
|
use crate::config::TankConfig;
|
||||||
|
use crate::hal::{BoardInteraction, HAL};
|
||||||
|
|
||||||
const OPEN_TANK_VOLTAGE: f32 = 3.0;
|
const OPEN_TANK_VOLTAGE: f32 = 3.0;
|
||||||
pub const WATER_FROZEN_THRESH: f32 = 4.0;
|
pub const WATER_FROZEN_THRESH: f32 = 4.0;
|
||||||
|
|
||||||
@ -152,12 +153,7 @@ impl TankState {
|
|||||||
|
|
||||||
pub fn determine_tank_state(board: &mut std::sync::MutexGuard<'_, HAL<'_>>) -> TankState {
|
pub fn determine_tank_state(board: &mut std::sync::MutexGuard<'_, HAL<'_>>) -> TankState {
|
||||||
if board.board_hal.get_config().tank.tank_sensor_enabled {
|
if board.board_hal.get_config().tank.tank_sensor_enabled {
|
||||||
match board
|
match board.board_hal.tank_sensor_voltage() {
|
||||||
.board_hal
|
|
||||||
.get_tank_sensor()
|
|
||||||
.context("no sensor")
|
|
||||||
.and_then(|f| f.tank_sensor_voltage())
|
|
||||||
{
|
|
||||||
Ok(raw_sensor_value_mv) => TankState::Present(raw_sensor_value_mv),
|
Ok(raw_sensor_value_mv) => TankState::Present(raw_sensor_value_mv),
|
||||||
Err(err) => TankState::Error(TankError::BoardError(err.to_string())),
|
Err(err) => TankState::Error(TankError::BoardError(err.to_string())),
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,10 @@
|
|||||||
//offer ota and config mode
|
//offer ota and config mode
|
||||||
|
|
||||||
|
use crate::hal::battery::BatteryInteraction;
|
||||||
use crate::{
|
use crate::{
|
||||||
config::PlantControllerConfig,
|
determine_tank_state, get_version, log::LogMessage, plant_state::PlantState, BOARD_ACCESS,
|
||||||
determine_tank_state, get_version,
|
|
||||||
hal::PLANT_COUNT,
|
|
||||||
log::LogMessage,
|
|
||||||
plant_state::{MoistureSensorState, PlantState},
|
|
||||||
BOARD_ACCESS,
|
|
||||||
};
|
};
|
||||||
use anyhow::{bail, Context};
|
use anyhow::bail;
|
||||||
use chrono::DateTime;
|
use chrono::DateTime;
|
||||||
use core::result::Result::Ok;
|
use core::result::Result::Ok;
|
||||||
use embedded_svc::http::Method;
|
use embedded_svc::http::Method;
|
||||||
@ -23,6 +19,10 @@ use std::{
|
|||||||
};
|
};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
use crate::config::PlantControllerConfig;
|
||||||
|
use crate::hal::{BoardInteraction, PLANT_COUNT};
|
||||||
|
use crate::plant_state::MoistureSensorState;
|
||||||
|
|
||||||
#[derive(Serialize, Debug)]
|
#[derive(Serialize, Debug)]
|
||||||
struct SSIDList<'a> {
|
struct SSIDList<'a> {
|
||||||
ssids: Vec<&'a String<32>>,
|
ssids: Vec<&'a String<32>>,
|
||||||
@ -60,7 +60,7 @@ pub struct TestPump {
|
|||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
||||||
pub struct WebBackupHeader {
|
pub struct WebBackupHeader {
|
||||||
timestamp: std::string::String,
|
timestamp: std::string::String,
|
||||||
size: u16,
|
size: usize,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize)]
|
#[derive(Deserialize)]
|
||||||
@ -81,10 +81,7 @@ fn write_time(
|
|||||||
tv_usec: 0,
|
tv_usec: 0,
|
||||||
};
|
};
|
||||||
unsafe { settimeofday(&now, core::ptr::null_mut()) };
|
unsafe { settimeofday(&now, core::ptr::null_mut()) };
|
||||||
board
|
board.board_hal.set_rtc_time(&parsed.to_utc())?;
|
||||||
.board_hal
|
|
||||||
.get_rtc_module()
|
|
||||||
.set_rtc_time(&parsed.to_utc())?;
|
|
||||||
anyhow::Ok(None)
|
anyhow::Ok(None)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +97,6 @@ fn get_time(
|
|||||||
.unwrap_or("error".to_string());
|
.unwrap_or("error".to_string());
|
||||||
let rtc = board
|
let rtc = board
|
||||||
.board_hal
|
.board_hal
|
||||||
.get_rtc_module()
|
|
||||||
.get_rtc_time()
|
.get_rtc_time()
|
||||||
.map(|t| t.to_rfc3339())
|
.map(|t| t.to_rfc3339())
|
||||||
.unwrap_or("error".to_string());
|
.unwrap_or("error".to_string());
|
||||||
@ -174,9 +170,7 @@ fn backup_config(
|
|||||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||||
let all = read_up_to_bytes_from_request(request, Some(3072))?;
|
let all = read_up_to_bytes_from_request(request, Some(3072))?;
|
||||||
let mut board = BOARD_ACCESS.lock().expect("board access");
|
let mut board = BOARD_ACCESS.lock().expect("board access");
|
||||||
|
board.board_hal.backup_config(&all)?;
|
||||||
//TODO how to handle progress here? prior versions animated the fault leds while running
|
|
||||||
board.board_hal.get_rtc_module().backup_config(&all)?;
|
|
||||||
anyhow::Ok(Some("saved".to_owned()))
|
anyhow::Ok(Some("saved".to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -184,7 +178,7 @@ fn get_backup_config(
|
|||||||
_request: &mut Request<&mut EspHttpConnection>,
|
_request: &mut Request<&mut EspHttpConnection>,
|
||||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||||
let mut board = BOARD_ACCESS.lock().expect("board access");
|
let mut board = BOARD_ACCESS.lock().expect("board access");
|
||||||
let json = match board.board_hal.get_rtc_module().get_backup_config() {
|
let json = match board.board_hal.get_backup_config() {
|
||||||
Ok(config) => from_utf8(&config)?.to_owned(),
|
Ok(config) => from_utf8(&config)?.to_owned(),
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
println!("Error get backup config {:?}", err);
|
println!("Error get backup config {:?}", err);
|
||||||
@ -198,7 +192,7 @@ fn backup_info(
|
|||||||
_request: &mut Request<&mut EspHttpConnection>,
|
_request: &mut Request<&mut EspHttpConnection>,
|
||||||
) -> Result<Option<std::string::String>, anyhow::Error> {
|
) -> Result<Option<std::string::String>, anyhow::Error> {
|
||||||
let mut board = BOARD_ACCESS.lock().expect("Should never fail");
|
let mut board = BOARD_ACCESS.lock().expect("Should never fail");
|
||||||
let header = board.board_hal.get_rtc_module().get_backup_info();
|
let header = board.board_hal.get_backup_info();
|
||||||
let json = match header {
|
let json = match header {
|
||||||
Ok(h) => {
|
Ok(h) => {
|
||||||
let timestamp = DateTime::from_timestamp_millis(h.timestamp).unwrap();
|
let timestamp = DateTime::from_timestamp_millis(h.timestamp).unwrap();
|
||||||
@ -208,9 +202,10 @@ fn backup_info(
|
|||||||
};
|
};
|
||||||
serde_json::to_string(&wbh)?
|
serde_json::to_string(&wbh)?
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(_) => {
|
||||||
|
//TODO make better
|
||||||
let wbh = WebBackupHeader {
|
let wbh = WebBackupHeader {
|
||||||
timestamp: err.to_string(),
|
timestamp: "no backup".to_owned(),
|
||||||
size: 0,
|
size: 0,
|
||||||
};
|
};
|
||||||
serde_json::to_string(&wbh)?
|
serde_json::to_string(&wbh)?
|
||||||
@ -226,7 +221,7 @@ fn set_config(
|
|||||||
let config: PlantControllerConfig = serde_json::from_slice(&all)?;
|
let config: PlantControllerConfig = serde_json::from_slice(&all)?;
|
||||||
|
|
||||||
let mut board = BOARD_ACCESS.lock().expect("board access");
|
let mut board = BOARD_ACCESS.lock().expect("board access");
|
||||||
board.board_hal.set_config(config)?;
|
board.board_hal.set_config(config);
|
||||||
anyhow::Ok(Some("saved".to_owned()))
|
anyhow::Ok(Some("saved".to_owned()))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,12 +280,7 @@ fn tank_info(
|
|||||||
let mut board = BOARD_ACCESS.lock().unwrap();
|
let mut board = BOARD_ACCESS.lock().unwrap();
|
||||||
let tank_info = determine_tank_state(&mut board);
|
let tank_info = determine_tank_state(&mut board);
|
||||||
//should be multsampled
|
//should be multsampled
|
||||||
|
let water_temp = board.board_hal.water_temperature_c();
|
||||||
let water_temp = board
|
|
||||||
.board_hal
|
|
||||||
.get_tank_sensor()
|
|
||||||
.context("no sensor")
|
|
||||||
.and_then(|f| f.water_temperature_c());
|
|
||||||
Ok(Some(serde_json::to_string(&tank_info.as_mqtt_info(
|
Ok(Some(serde_json::to_string(&tank_info.as_mqtt_info(
|
||||||
&board.board_hal.get_config().tank,
|
&board.board_hal.get_config().tank,
|
||||||
&water_temp,
|
&water_temp,
|
||||||
@ -351,7 +341,6 @@ fn ota(
|
|||||||
|
|
||||||
let iter = (total_read / 1024) % 8;
|
let iter = (total_read / 1024) % 8;
|
||||||
if iter != lastiter {
|
if iter != lastiter {
|
||||||
board.board_hal.general_fault(iter % 5 == 0);
|
|
||||||
for i in 0..PLANT_COUNT {
|
for i in 0..PLANT_COUNT {
|
||||||
let _ = board.board_hal.fault(i, iter == i);
|
let _ = board.board_hal.fault(i, iter == i);
|
||||||
}
|
}
|
File diff suppressed because it is too large
Load Diff
@ -1,65 +1,61 @@
|
|||||||
import {Controller} from "./main";
|
import { Controller } from "./main";
|
||||||
import {BackupHeader} from "./api";
|
import {BackupHeader} from "./api";
|
||||||
|
|
||||||
export class SubmitView {
|
export class SubmitView {
|
||||||
json: HTMLDivElement;
|
json: HTMLDivElement;
|
||||||
submitFormBtn: HTMLButtonElement;
|
submitFormBtn: HTMLButtonElement;
|
||||||
submit_status: HTMLElement;
|
submit_status: HTMLElement;
|
||||||
backupBtn: HTMLButtonElement;
|
backupBtn: HTMLButtonElement;
|
||||||
restoreBackupBtn: HTMLButtonElement;
|
restoreBackupBtn: HTMLButtonElement;
|
||||||
backuptimestamp: HTMLElement;
|
backuptimestamp: HTMLElement;
|
||||||
backupsize: HTMLElement;
|
backupsize: HTMLElement;
|
||||||
backupjson: HTMLElement;
|
backupjson: HTMLElement;
|
||||||
|
|
||||||
constructor(controller: Controller) {
|
constructor(controller: Controller) {
|
||||||
(document.getElementById("submitview") as HTMLElement).innerHTML = require("./submitview.html")
|
(document.getElementById("submitview") as HTMLElement).innerHTML = require("./submitview.html")
|
||||||
|
|
||||||
let showJson = document.getElementById('showJson') as HTMLButtonElement
|
let showJson = document.getElementById('showJson') as HTMLButtonElement
|
||||||
let rawdata = document.getElementById('rawdata') as HTMLElement
|
let rawdata = document.getElementById('rawdata') as HTMLElement
|
||||||
this.json = document.getElementById('json') as HTMLDivElement
|
this.json = document.getElementById('json') as HTMLDivElement
|
||||||
this.backupjson = document.getElementById('backupjson') as HTMLDivElement
|
this.backupjson = document.getElementById('backupjson') as HTMLDivElement
|
||||||
this.submitFormBtn = document.getElementById("submit") as HTMLButtonElement
|
this.submitFormBtn = document.getElementById("submit") as HTMLButtonElement
|
||||||
this.backupBtn = document.getElementById("backup") as HTMLButtonElement
|
this.backupBtn = document.getElementById("backup") as HTMLButtonElement
|
||||||
this.restoreBackupBtn = document.getElementById("restorebackup") as HTMLButtonElement
|
this.restoreBackupBtn = document.getElementById("restorebackup") as HTMLButtonElement
|
||||||
this.backuptimestamp = document.getElementById("backuptimestamp") as HTMLElement
|
this.backuptimestamp = document.getElementById("backuptimestamp") as HTMLElement
|
||||||
this.backupsize = document.getElementById("backupsize") as HTMLElement
|
this.backupsize = document.getElementById("backupsize") as HTMLElement
|
||||||
this.submit_status = document.getElementById("submit_status") as HTMLElement
|
this.submit_status = document.getElementById("submit_status") as HTMLElement
|
||||||
this.submitFormBtn.onclick = () => {
|
this.submitFormBtn.onclick = () => {
|
||||||
controller.uploadConfig(this.json.textContent as string, (status: string) => {
|
controller.uploadConfig(this.json.textContent as string, (status: string) => {
|
||||||
this.submit_status.innerHTML = status;
|
this.submit_status.innerHTML = status;
|
||||||
});
|
});
|
||||||
}
|
|
||||||
this.backupBtn.onclick = () => {
|
|
||||||
controller.progressview.addIndeterminate("backup", "Backup to EEPROM running")
|
|
||||||
controller.backupConfig(this.json.textContent as string).then(saveStatus => {
|
|
||||||
controller.getBackupInfo().then(r => {
|
|
||||||
controller.progressview.removeProgress("backup")
|
|
||||||
this.submit_status.innerHTML = saveStatus;
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.restoreBackupBtn.onclick = () => {
|
|
||||||
controller.getBackupConfig();
|
|
||||||
}
|
|
||||||
showJson.onclick = () => {
|
|
||||||
if (rawdata.style.display == "none") {
|
|
||||||
rawdata.style.display = "flex";
|
|
||||||
} else {
|
|
||||||
rawdata.style.display = "none";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
this.backupBtn.onclick = () => {
|
||||||
setBackupInfo(header: BackupHeader) {
|
controller.backupConfig(this.json.textContent as string, (status: string) => {
|
||||||
this.backuptimestamp.innerText = header.timestamp
|
this.submit_status.innerHTML = status;
|
||||||
this.backupsize.innerText = header.size.toString()
|
});
|
||||||
}
|
}
|
||||||
|
this.restoreBackupBtn.onclick = () => {
|
||||||
setJson(pretty: string) {
|
controller.getBackupConfig();
|
||||||
this.json.textContent = pretty
|
|
||||||
}
|
}
|
||||||
|
showJson.onclick = () => {
|
||||||
setBackupJson(pretty: string) {
|
if (rawdata.style.display == "none"){
|
||||||
this.backupjson.textContent = pretty
|
rawdata.style.display = "flex";
|
||||||
|
} else {
|
||||||
|
rawdata.style.display = "none";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setBackupInfo(header: BackupHeader) {
|
||||||
|
this.backuptimestamp.innerText = header.timestamp
|
||||||
|
this.backupsize.innerText = header.size.toString()
|
||||||
|
}
|
||||||
|
|
||||||
|
setJson(pretty: string) {
|
||||||
|
this.json.textContent = pretty
|
||||||
|
}
|
||||||
|
|
||||||
|
setBackupJson(pretty: string) {
|
||||||
|
this.backupjson.textContent = pretty
|
||||||
|
}
|
||||||
}
|
}
|
@ -49,7 +49,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
output: {
|
output: {
|
||||||
filename: 'bundle.js',
|
filename: 'bundle.js',
|
||||||
path: path.resolve(__dirname, '.'),
|
path: path.resolve(__dirname, '../src/webserver'),
|
||||||
},
|
},
|
||||||
devServer: {
|
devServer: {
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user