diff --git a/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_pro b/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_pro index babcd68..4496911 100644 --- a/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_pro +++ b/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_pro @@ -429,7 +429,7 @@ "uuid": "08a39202-f0bc-425a-a79b-1d2766a907c0" } ], - "used_designators": "U1-2,SW1-3,J1", + "used_designators": "U1-2,SW1-3,Display1,J1", "variants": [] }, "sheets": [ diff --git a/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_sch b/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_sch index 4dd5889..5272aeb 100644 --- a/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_sch +++ b/KugelmühleSchaltplan/KugelmühleSchaltplan.kicad_sch @@ -5,6 +5,269 @@ (uuid "08a39202-f0bc-425a-a79b-1d2766a907c0") (paper "A4") (lib_symbols + (symbol "Conn_01x04_Pin_1" + (pin_names + (offset 1.016) + (hide yes) + ) + (exclude_from_sim no) + (in_bom yes) + (on_board yes) + (in_pos_files yes) + (duplicate_pin_numbers_are_jumpers no) + (property "Reference" "MotorTreiber" + (at 0.635 7.62 0) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Value" "" + (at 0.635 5.08 0) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Footprint" "Package_DFN_QFN:HVQFN-24-1EP_4x4mm_P0.5mm_EP2.1x2.1mm" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (hide yes) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Datasheet" "" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (hide yes) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Description" "Generic connector, single row, 01x04, script generated" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (hide yes) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "ki_locked" "" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "ki_keywords" "connector" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (hide yes) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "ki_fp_filters" "Connector*:*_1x??_*" + (at 0 0 0) + (show_name no) + (do_not_autoplace no) + (hide yes) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (symbol "Conn_01x04_Pin_1_1_1" + (rectangle + (start 0.8636 2.667) + (end 0 2.413) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type outline) + ) + ) + (rectangle + (start 0.8636 0.127) + (end 0 -0.127) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type outline) + ) + ) + (rectangle + (start 0.8636 -2.413) + (end 0 -2.667) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type outline) + ) + ) + (rectangle + (start 0.8636 -4.953) + (end 0 -5.207) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type outline) + ) + ) + (polyline + (pts + (xy 1.27 2.54) (xy 0.8636 2.54) + ) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type none) + ) + ) + (polyline + (pts + (xy 1.27 0) (xy 0.8636 0) + ) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type none) + ) + ) + (polyline + (pts + (xy 1.27 -2.54) (xy 0.8636 -2.54) + ) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type none) + ) + ) + (polyline + (pts + (xy 1.27 -5.08) (xy 0.8636 -5.08) + ) + (stroke + (width 0.1524) + (type default) + ) + (fill + (type none) + ) + ) + (pin passive line + (at 5.08 0 180) + (length 3.81) + (name "<...>" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (number "CLK" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + ) + (pin passive line + (at 5.08 -2.54 180) + (length 3.81) + (name "<...>" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (number "DIR" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + ) + (pin passive line + (at 5.08 -5.08 180) + (length 3.81) + (name "Pin_4" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (number "EN" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + ) + (pin passive line + (at 5.08 2.54 180) + (length 3.81) + (name "GND" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (number "GND" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + ) + ) + (embedded_fonts no) + ) (symbol "Connector:Conn_01x04_Pin" (pin_names (offset 1.016) @@ -15,9 +278,9 @@ (on_board yes) (in_pos_files yes) (duplicate_pin_numbers_are_jumpers no) - (property "Reference" "J" - (at 0 5.08 0) - (show_name no) + (property "Reference" "J1" + (at 0.635 7.62 0) + (show_name yes) (do_not_autoplace no) (effects (font @@ -25,9 +288,9 @@ ) ) ) - (property "Value" "Conn_01x04_Pin" - (at 0 -7.62 0) - (show_name no) + (property "Value" "Diplay" + (at 0.635 5.08 0) + (show_name yes) (do_not_autoplace no) (effects (font @@ -35,7 +298,7 @@ ) ) ) - (property "Footprint" "" + (property "Footprint" "Package_DFN_QFN:HVQFN-24-1EP_4x4mm_P0.5mm_EP2.1x2.1mm" (at 0 0 0) (show_name no) (do_not_autoplace no) @@ -194,16 +457,16 @@ ) ) (pin passive line - (at 5.08 2.54 180) + (at 5.08 -5.08 180) (length 3.81) - (name "Pin_1" + (name "Pin_4" (effects (font (size 1.27 1.27) ) ) ) - (number "1" + (number "GND" (effects (font (size 1.27 1.27) @@ -214,14 +477,32 @@ (pin passive line (at 5.08 0 180) (length 3.81) - (name "Pin_2" + (name "<...>" (effects (font (size 1.27 1.27) ) ) ) - (number "2" + (number "SCL" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + ) + (pin passive line + (at 5.08 2.54 180) + (length 3.81) + (name "SDA" + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (number "SDA" (effects (font (size 1.27 1.27) @@ -232,32 +513,14 @@ (pin passive line (at 5.08 -2.54 180) (length 3.81) - (name "Pin_3" + (name "<...>" (effects (font (size 1.27 1.27) ) ) ) - (number "3" - (effects - (font - (size 1.27 1.27) - ) - ) - ) - ) - (pin passive line - (at 5.08 -5.08 180) - (length 3.81) - (name "Pin_4" - (effects - (font - (size 1.27 1.27) - ) - ) - ) - (number "4" + (number "VCC" (effects (font (size 1.27 1.27) @@ -1216,9 +1479,545 @@ (embedded_fonts no) ) ) + (junction + (at 121.92 144.78) + (diameter 0) + (color 0 0 0 0) + (uuid "3f4aad72-333a-41ac-8a33-004d56d05d4e") + ) + (junction + (at 73.66 72.39) + (diameter 0) + (color 0 0 0 0) + (uuid "454608f1-aeb8-4ae7-a648-85f48964cd3a") + ) + (junction + (at 163.83 80.01) + (diameter 0) + (color 0 0 0 0) + (uuid "47322e5d-43c6-404a-8084-1570b91d6298") + ) + (junction + (at 73.66 86.36) + (diameter 0) + (color 0 0 0 0) + (uuid "c2b3b985-a89c-47be-a6a2-e4e880afd361") + ) + (junction + (at 73.66 60.96) + (diameter 0) + (color 0 0 0 0) + (uuid "f010694d-3526-44fe-98ff-3b23815a6c3e") + ) + (junction + (at 167.64 80.01) + (diameter 0) + (color 0 0 0 0) + (uuid "f8707d1c-b191-405d-9129-e9c882e0e150") + ) + (wire + (pts + (xy 97.79 118.11) (xy 97.79 76.2) + ) + (stroke + (width 0) + (type default) + ) + (uuid "014ead51-9680-4dd6-86b5-00998759ff2f") + ) + (wire + (pts + (xy 121.92 144.78) (xy 162.56 144.78) + ) + (stroke + (width 0) + (type default) + ) + (uuid "040cf67e-4bd3-4bc1-8c3a-bcd9e5e4edc2") + ) + (wire + (pts + (xy 107.95 101.6) (xy 107.95 95.25) + ) + (stroke + (width 0) + (type default) + ) + (uuid "1d1bab62-99e8-4b52-b8ce-49ff1b7ff4d1") + ) + (wire + (pts + (xy 140.97 128.27) (xy 167.64 128.27) + ) + (stroke + (width 0) + (type default) + ) + (uuid "24a48fa0-5e80-4b86-a4b7-7dcf72769fd6") + ) + (wire + (pts + (xy 156.21 95.25) (xy 176.53 95.25) + ) + (stroke + (width 0) + (type default) + ) + (uuid "28a2cc89-28bf-4c95-816e-8bbee0fab722") + ) + (wire + (pts + (xy 78.74 72.39) (xy 73.66 72.39) + ) + (stroke + (width 0) + (type default) + ) + (uuid "31fe600a-d65f-4a14-bf08-7779d94ab58a") + ) + (wire + (pts + (xy 88.9 60.96) (xy 106.68 60.96) + ) + (stroke + (width 0) + (type default) + ) + (uuid "32c69609-b62c-423d-a683-bae687351e12") + ) + (wire + (pts + (xy 106.68 80.01) (xy 110.49 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "3f663840-7c10-4393-8eaa-774530e1aede") + ) + (wire + (pts + (xy 92.71 104.14) (xy 92.71 144.78) + ) + (stroke + (width 0) + (type default) + ) + (uuid "415aef43-4643-4f1f-a48e-f80f09c19e42") + ) + (wire + (pts + (xy 177.8 80.01) (xy 167.64 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "4f531d26-8f3e-48aa-9d4c-d67fece056bf") + ) + (wire + (pts + (xy 78.74 86.36) (xy 73.66 86.36) + ) + (stroke + (width 0) + (type default) + ) + (uuid "4fa3013a-fc10-4569-a20d-875260aef9f7") + ) + (wire + (pts + (xy 179.07 99.06) (xy 156.21 99.06) + ) + (stroke + (width 0) + (type default) + ) + (uuid "55957ce7-1d13-4c61-aeaf-b48d9b66829c") + ) + (wire + (pts + (xy 163.83 80.01) (xy 156.21 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "5ba5e3c9-74b2-4d66-8d08-35fe7557a711") + ) + (wire + (pts + (xy 107.95 95.25) (xy 110.49 95.25) + ) + (stroke + (width 0) + (type default) + ) + (uuid "5e998706-acea-4e65-80da-2813ff2fdf84") + ) + (wire + (pts + (xy 92.71 144.78) (xy 121.92 144.78) + ) + (stroke + (width 0) + (type default) + ) + (uuid "625324c2-1e3e-404c-955d-16deab625f8f") + ) + (wire + (pts + (xy 73.66 86.36) (xy 73.66 106.68) + ) + (stroke + (width 0) + (type default) + ) + (uuid "7804fabd-61ae-4deb-ae95-f271d35b4db0") + ) + (wire + (pts + (xy 167.64 80.01) (xy 163.83 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "78cb884a-659b-42b7-8d94-b643577883b8") + ) + (wire + (pts + (xy 73.66 72.39) (xy 73.66 60.96) + ) + (stroke + (width 0) + (type default) + ) + (uuid "78d4fd7d-9988-41ac-808b-f07dbb0569d0") + ) + (wire + (pts + (xy 102.87 99.06) (xy 102.87 91.44) + ) + (stroke + (width 0) + (type default) + ) + (uuid "84e2548a-a568-4ca8-9c47-ca8c80686d37") + ) + (wire + (pts + (xy 185.42 88.9) (xy 177.8 88.9) + ) + (stroke + (width 0) + (type default) + ) + (uuid "88e176da-3809-4d5f-88b3-4d4f8776672b") + ) + (wire + (pts + (xy 73.66 60.96) (xy 73.66 48.26) + ) + (stroke + (width 0) + (type default) + ) + (uuid "89f6893f-cda9-4ff9-b651-e0e4f8adbdd8") + ) + (wire + (pts + (xy 121.92 128.27) (xy 121.92 144.78) + ) + (stroke + (width 0) + (type default) + ) + (uuid "8b0e9533-820f-48aa-8513-aab047267bd8") + ) + (wire + (pts + (xy 177.8 88.9) (xy 177.8 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "8b21c44c-f273-4e35-a660-3d6b089d9a4d") + ) + (wire + (pts + (xy 109.22 87.63) (xy 110.49 87.63) + ) + (stroke + (width 0) + (type default) + ) + (uuid "9002a192-1085-43bf-ac13-fa029bc29100") + ) + (wire + (pts + (xy 102.87 91.44) (xy 110.49 91.44) + ) + (stroke + (width 0) + (type default) + ) + (uuid "91175461-9052-4727-b73f-626b7ab3c042") + ) + (wire + (pts + (xy 105.41 83.82) (xy 110.49 83.82) + ) + (stroke + (width 0) + (type default) + ) + (uuid "91a22082-1a30-4ad1-a759-9b2bd217047c") + ) + (wire + (pts + (xy 73.66 72.39) (xy 73.66 86.36) + ) + (stroke + (width 0) + (type default) + ) + (uuid "97b6368e-d3d4-4daf-b6e3-c9f857b20c2a") + ) + (wire + (pts + (xy 69.85 104.14) (xy 92.71 104.14) + ) + (stroke + (width 0) + (type default) + ) + (uuid "ae9b1fb5-a310-4395-a413-4d909abed7ec") + ) + (wire + (pts + (xy 78.74 60.96) (xy 73.66 60.96) + ) + (stroke + (width 0) + (type default) + ) + (uuid "b22fbf97-1fd3-4635-a1ac-87ab25e4450a") + ) + (wire + (pts + (xy 88.9 86.36) (xy 109.22 86.36) + ) + (stroke + (width 0) + (type default) + ) + (uuid "b3716176-e0ca-4f8f-a7a1-24e828bc9e23") + ) + (wire + (pts + (xy 125.73 128.27) (xy 121.92 128.27) + ) + (stroke + (width 0) + (type default) + ) + (uuid "b9155000-a0bf-4fbc-a4bb-1dba9e619093") + ) + (wire + (pts + (xy 162.56 144.78) (xy 162.56 83.82) + ) + (stroke + (width 0) + (type default) + ) + (uuid "c18e5549-78f7-4bef-b063-6a996bc0d92c") + ) + (wire + (pts + (xy 156.21 91.44) (xy 185.42 91.44) + ) + (stroke + (width 0) + (type default) + ) + (uuid "c211721b-66ee-4219-ba57-72fe79d9acf7") + ) + (wire + (pts + (xy 163.83 48.26) (xy 163.83 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "c46e1020-a514-4603-8925-761d5b34a1a6") + ) + (wire + (pts + (xy 176.53 93.98) (xy 185.42 93.98) + ) + (stroke + (width 0) + (type default) + ) + (uuid "c6108d17-5c8f-4ed0-a930-83c941d1bf7c") + ) + (wire + (pts + (xy 69.85 101.6) (xy 107.95 101.6) + ) + (stroke + (width 0) + (type default) + ) + (uuid "ccded785-fe43-488a-97ca-55954c18a4a3") + ) + (wire + (pts + (xy 97.79 76.2) (xy 110.49 76.2) + ) + (stroke + (width 0) + (type default) + ) + (uuid "ce19278b-58f9-4804-a47e-674691fd9cea") + ) + (wire + (pts + (xy 176.53 93.98) (xy 176.53 95.25) + ) + (stroke + (width 0) + (type default) + ) + (uuid "d3176749-d367-4ea0-835a-3947c461b024") + ) + (wire + (pts + (xy 106.68 60.96) (xy 106.68 80.01) + ) + (stroke + (width 0) + (type default) + ) + (uuid "d5ce48cc-a922-447e-85bd-dd74cfce28d0") + ) + (wire + (pts + (xy 179.07 96.52) (xy 179.07 99.06) + ) + (stroke + (width 0) + (type default) + ) + (uuid "d959dd47-3196-4a70-a752-b22cffdfd4b0") + ) + (wire + (pts + (xy 105.41 72.39) (xy 105.41 83.82) + ) + (stroke + (width 0) + (type default) + ) + (uuid "e20ea9fd-8af1-4631-8d4d-004dea03001e") + ) + (wire + (pts + (xy 185.42 96.52) (xy 179.07 96.52) + ) + (stroke + (width 0) + (type default) + ) + (uuid "e4103f9f-84d1-45c6-89a4-9ea907f6c015") + ) + (wire + (pts + (xy 162.56 83.82) (xy 156.21 83.82) + ) + (stroke + (width 0) + (type default) + ) + (uuid "e66e8d21-40ca-45a3-8fc7-757bbf36dc52") + ) + (wire + (pts + (xy 167.64 80.01) (xy 167.64 128.27) + ) + (stroke + (width 0) + (type default) + ) + (uuid "eb52d608-283e-4968-8745-f3e2c2844d33") + ) + (wire + (pts + (xy 69.85 106.68) (xy 73.66 106.68) + ) + (stroke + (width 0) + (type default) + ) + (uuid "eb60a395-4c73-4fd5-8f61-9e99bfeb0d28") + ) + (wire + (pts + (xy 109.22 86.36) (xy 109.22 87.63) + ) + (stroke + (width 0) + (type default) + ) + (uuid "ed4fa6ce-1c21-43ec-8893-99d6ba1d35e4") + ) + (wire + (pts + (xy 69.85 99.06) (xy 102.87 99.06) + ) + (stroke + (width 0) + (type default) + ) + (uuid "edc3368b-cb53-486f-9b5d-97c4d9c4de44") + ) + (wire + (pts + (xy 88.9 72.39) (xy 105.41 72.39) + ) + (stroke + (width 0) + (type default) + ) + (uuid "eede9df0-ad9c-484e-822b-5196002dc06f") + ) + (wire + (pts + (xy 133.35 118.11) (xy 97.79 118.11) + ) + (stroke + (width 0) + (type default) + ) + (uuid "f05fe509-0725-4c8e-ae89-6db03a745fd3") + ) + (wire + (pts + (xy 73.66 48.26) (xy 163.83 48.26) + ) + (stroke + (width 0) + (type default) + ) + (uuid "f2329298-1ffe-4fcb-b3de-52abdfaf19de") + ) (symbol (lib_id "Switch:SW_Push") - (at 207.01 114.3 0) + (at 83.82 86.36 0) (unit 1) (body_style 1) (exclude_from_sim no) @@ -1229,7 +2028,7 @@ (fields_autoplaced yes) (uuid "0ecb6888-f4b4-438a-88e8-a422ad205b84") (property "Reference" "buttonStop" - (at 207.01 106.68 0) + (at 83.82 78.74 0) (show_name no) (do_not_autoplace no) (effects @@ -1239,7 +2038,7 @@ ) ) (property "Value" "SW_Push" - (at 207.01 109.22 0) + (at 83.82 81.28 0) (show_name no) (do_not_autoplace no) (effects @@ -1249,7 +2048,7 @@ ) ) (property "Footprint" "Button_Switch_SMD:Nidec_Copal_SH-7040B" - (at 207.01 109.22 0) + (at 83.82 81.28 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1260,7 +2059,7 @@ ) ) (property "Datasheet" "" - (at 207.01 109.22 0) + (at 83.82 81.28 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1271,7 +2070,7 @@ ) ) (property "Description" "Push button switch, generic, two pins" - (at 207.01 114.3 0) + (at 83.82 86.36 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1298,7 +2097,7 @@ ) (symbol (lib_id "Connector:Conn_01x04_Pin") - (at 74.93 38.1 0) + (at 64.77 101.6 0) (unit 1) (body_style 1) (exclude_from_sim no) @@ -1308,8 +2107,8 @@ (dnp no) (fields_autoplaced yes) (uuid "27876009-53a2-4650-ba67-221ea18f35d0") - (property "Reference" "J1" - (at 75.565 30.48 0) + (property "Reference" "Display" + (at 65.405 93.98 0) (show_name no) (do_not_autoplace no) (effects @@ -1318,8 +2117,8 @@ ) ) ) - (property "Value" "Diplay" - (at 75.565 33.02 0) + (property "Value" "" + (at 65.405 96.52 0) (show_name no) (do_not_autoplace no) (effects @@ -1329,7 +2128,7 @@ ) ) (property "Footprint" "Package_DFN_QFN:HVQFN-24-1EP_4x4mm_P0.5mm_EP2.1x2.1mm" - (at 74.93 38.1 0) + (at 64.77 101.6 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1340,7 +2139,7 @@ ) ) (property "Datasheet" "" - (at 74.93 38.1 0) + (at 64.77 101.6 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1351,7 +2150,7 @@ ) ) (property "Description" "Generic connector, single row, 01x04, script generated" - (at 74.93 38.1 0) + (at 64.77 101.6 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1361,22 +2160,22 @@ ) ) ) - (pin "3" + (pin "SDA" (uuid "c9c57965-15d6-459c-bf6a-b318a5a98035") ) - (pin "1" + (pin "VCC" (uuid "1324a5c4-da82-4572-8475-aafd89d3754e") ) - (pin "2" + (pin "SCL" (uuid "518b75bc-1c6a-450a-ba80-f38270122c51") ) - (pin "4" + (pin "GND" (uuid "652ec2a9-9e81-408b-99ea-e509d9679231") ) (instances (project "KugelmühleSchaltplan" (path "/08a39202-f0bc-425a-a79b-1d2766a907c0" - (reference "J1") + (reference "Display") (unit 1) ) ) @@ -1407,6 +2206,7 @@ ) (property "Value" "XIAO-ESP32-C6-SMD" (at 136.7633 107.95 0) + (hide yes) (show_name no) (do_not_autoplace no) (effects @@ -1532,7 +2332,7 @@ ) (symbol (lib_id "Sensor_Temperature:LM35-LP") - (at 139.7 34.29 0) + (at 133.35 128.27 90) (unit 1) (body_style 1) (exclude_from_sim no) @@ -1543,29 +2343,27 @@ (fields_autoplaced yes) (uuid "ad1f4f7f-a9d9-4342-8775-68685cf988f6") (property "Reference" "U2" - (at 130.81 33.0199 0) + (at 133.35 138.43 90) (show_name no) (do_not_autoplace no) (effects (font (size 1.27 1.27) ) - (justify right) ) ) (property "Value" "LM35-LP" - (at 130.81 35.5599 0) + (at 133.35 140.97 90) (show_name no) (do_not_autoplace no) (effects (font (size 1.27 1.27) ) - (justify right) ) ) (property "Footprint" "Package_TO_SOT_THT:TO-92_Inline" - (at 140.97 40.64 0) + (at 139.7 127 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1577,7 +2375,7 @@ ) ) (property "Datasheet" "http://www.ti.com/lit/ds/symlink/lm35.pdf" - (at 139.7 34.29 0) + (at 133.35 128.27 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1588,7 +2386,7 @@ ) ) (property "Description" "Precision centigrade temperature sensor, TO-92" - (at 139.7 34.29 0) + (at 133.35 128.27 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1617,8 +2415,10 @@ ) ) (symbol - (lib_id "Switch:SW_Push") - (at 207.01 102.87 0) + (lib_name "Conn_01x04_Pin_1") + (lib_id "Connector:Conn_01x04_Pin") + (at 190.5 91.44 0) + (mirror y) (unit 1) (body_style 1) (exclude_from_sim no) @@ -1626,10 +2426,9 @@ (on_board yes) (in_pos_files yes) (dnp no) - (fields_autoplaced yes) - (uuid "e3d1ac0f-c92d-4cd0-ae2b-cad42e548773") - (property "Reference" "SWbuttonMinus" - (at 207.01 95.25 0) + (uuid "bdb44891-6bcc-44e0-a59b-b1bd1284b722") + (property "Reference" "MotorTreiber" + (at 189.865 83.82 0) (show_name no) (do_not_autoplace no) (effects @@ -1638,8 +2437,8 @@ ) ) ) - (property "Value" "SW_Push" - (at 207.01 97.79 0) + (property "Value" "" + (at 189.865 86.36 0) (show_name no) (do_not_autoplace no) (effects @@ -1648,8 +2447,8 @@ ) ) ) - (property "Footprint" "Button_Switch_SMD:Nidec_Copal_SH-7040B" - (at 207.01 97.79 0) + (property "Footprint" "Package_DFN_QFN:HVQFN-24-1EP_4x4mm_P0.5mm_EP2.1x2.1mm" + (at 190.5 91.44 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1660,7 +2459,93 @@ ) ) (property "Datasheet" "" - (at 207.01 97.79 0) + (at 190.5 91.44 0) + (hide yes) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Description" "Generic connector, single row, 01x04, script generated" + (at 190.5 91.44 0) + (hide yes) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (pin "EN" + (uuid "54893520-fde1-4fa3-abd3-72be719f3b98") + ) + (pin "CLK" + (uuid "347cd0a9-c832-4a8e-9180-8d57ce00bb8f") + ) + (pin "DIR" + (uuid "9603dc51-d52c-4c26-a80a-64a0b8f50fb1") + ) + (pin "GND" + (uuid "b335123a-b068-4e2e-ab91-6bdf29972de1") + ) + (instances + (project "KugelmühleSchaltplan" + (path "/08a39202-f0bc-425a-a79b-1d2766a907c0" + (reference "MotorTreiber") + (unit 1) + ) + ) + ) + ) + (symbol + (lib_id "Switch:SW_Push") + (at 83.82 72.39 0) + (unit 1) + (body_style 1) + (exclude_from_sim no) + (in_bom yes) + (on_board yes) + (in_pos_files yes) + (dnp no) + (fields_autoplaced yes) + (uuid "e3d1ac0f-c92d-4cd0-ae2b-cad42e548773") + (property "Reference" "SWbuttonMinus" + (at 83.82 64.77 0) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Value" "SW_Push" + (at 83.82 67.31 0) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Footprint" "Button_Switch_SMD:Nidec_Copal_SH-7040B" + (at 83.82 67.31 0) + (hide yes) + (show_name no) + (do_not_autoplace no) + (effects + (font + (size 1.27 1.27) + ) + ) + ) + (property "Datasheet" "" + (at 83.82 67.31 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1671,7 +2556,7 @@ ) ) (property "Description" "Push button switch, generic, two pins" - (at 207.01 102.87 0) + (at 83.82 72.39 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1698,7 +2583,7 @@ ) (symbol (lib_id "Switch:SW_Push") - (at 207.01 91.44 0) + (at 83.82 60.96 0) (unit 1) (body_style 1) (exclude_from_sim no) @@ -1709,7 +2594,7 @@ (fields_autoplaced yes) (uuid "ebc0ae61-3b52-4d66-bb5d-763303762925") (property "Reference" "buttonPlus" - (at 207.01 83.82 0) + (at 83.82 53.34 0) (show_name no) (do_not_autoplace no) (effects @@ -1719,7 +2604,7 @@ ) ) (property "Value" "SW_Push" - (at 207.01 86.36 0) + (at 83.82 55.88 0) (show_name no) (do_not_autoplace no) (effects @@ -1729,7 +2614,7 @@ ) ) (property "Footprint" "Button_Switch_SMD:Nidec_Copal_SH-7040B" - (at 207.01 86.36 0) + (at 83.82 55.88 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1740,7 +2625,7 @@ ) ) (property "Datasheet" "" - (at 207.01 86.36 0) + (at 83.82 55.88 0) (hide yes) (show_name no) (do_not_autoplace no) @@ -1751,7 +2636,7 @@ ) ) (property "Description" "Push button switch, generic, two pins" - (at 207.01 91.44 0) + (at 83.82 60.96 0) (hide yes) (show_name no) (do_not_autoplace no) diff --git a/KugelmühleSchaltplan/KugelmühleSchaltplan.pdf b/KugelmühleSchaltplan/KugelmühleSchaltplan.pdf new file mode 100644 index 0000000..3a248b3 Binary files /dev/null and b/KugelmühleSchaltplan/KugelmühleSchaltplan.pdf differ diff --git a/KugelmühleSchaltplan/~KugelmühleSchaltplan.kicad_pcb.lck b/KugelmühleSchaltplan/~KugelmühleSchaltplan.kicad_pcb.lck new file mode 100644 index 0000000..d1ea0c9 --- /dev/null +++ b/KugelmühleSchaltplan/~KugelmühleSchaltplan.kicad_pcb.lck @@ -0,0 +1 @@ +{"hostname":"JANNIS-PC","username":"janni"} \ No newline at end of file diff --git a/display_ui.cpp b/display_ui.cpp index 4e90fab..5cfa867 100644 --- a/display_ui.cpp +++ b/display_ui.cpp @@ -2,7 +2,27 @@ #include #include -// U8g2-Objekt bleibt gekapselt in dieser Datei +// Bitmaps & Animation-Dateien aus Lopaka +//#include "Clock.h" +//#include "Clock.h" +//#include "fire_flames.h" + +uint32_t lastDispTime = 0; + +// Statische Bitmap aus Lopaka +static const unsigned char image_paint_27_bits[] U8X8_PROGMEM = { + 0x00,0x04,0x00,0x00,0x00,0x00,0x00,0x04,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x80, + 0x00,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00, + 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00, + 0x00,0x00,0x01,0x00 +}; + +// Animations-Zähler +//static uint8_t fire_flames_frame = 0; +//static uint8_t Clock_frame = 0; + +// U8g2-Display-Objekt static U8G2_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE); void initDisplay() { @@ -11,10 +31,86 @@ void initDisplay() { u8g2.begin(); } +// ############################################################# +// ANIMATIONEN BERECHNEN & ZEICHNEN +// ############################################################# +static void updateAnimations() { + //fire_flames_frame = (millis() / 77) % 8; + //Clock_frame = (millis() / 200) % 143; +} + +static void drawAnimation_fire_flames() { + //u8g2.setDrawColor(1); + // u8g2.drawXBMP(80, 30, 21, 32, fire_flames_frames[fire_flames_frame]); +} + +static void drawAnimation_Clock() { + //u8g2.setDrawColor(1); + // u8g2.drawXBMP(104, 40, 21, 21, Clock_frames[Clock_frame]); +} + // ############################################################# // HAUPTANZEIGE // ############################################################# -static void drawHomeScreen(int currentSpeed, int curH, int curM, bool timeValid, bool timerActive) { +static void drawHomeScreen(int currentSpeed, int curH, int curM, bool timeValid, bool timerActive, SystemSettings settings, int curTemp) { + u8g2.setFontMode(1); + u8g2.setBitmapMode(1); + u8g2.setDrawColor(1); // 1 = Weiß (an) + + // 1. Feste Beschriftungen + u8g2.setFont(u8g2_font_5x7_tr); + u8g2.drawStr(7, 8, "Geschw"); + u8g2.drawStr(7, 19, "Zeituhr"); + u8g2.drawStr(7, 30, "Temp"); + + // 2. Dynamischer Wert: Geschwindigkeit + char speedBuf[10]; + snprintf(speedBuf, sizeof(speedBuf), "%d", currentSpeed); + u8g2.drawStr(51, 8, speedBuf); + + // 3. Dynamische Zeitschaltuhr: Start- und Endzeit + char startBuf[8]; + char endBuf[8]; + snprintf(startBuf, sizeof(startBuf), "%02d:%02d", settings.startHour, settings.startMin); + snprintf(endBuf, sizeof(endBuf), "%02d:%02d", settings.endHour, settings.endMin); + + u8g2.drawStr(51, 19, startBuf); + u8g2.drawLine(79, 16, 83, 16); // Bindestrich zwischen Zeiten + u8g2.drawStr(89, 19, endBuf); + + // 4. Dynamische Temperatur (Ist & Soll/Max) + // Hinweis: Hier kannst du später deine reale Sensortemperatur übergeben + char curTempBuf[10]; + snprintf(curTempBuf, sizeof(curTempBuf), "%d", curTemp); + u8g2.drawStr(52, 30, curTempBuf); + u8g2.drawLine(67, 24, 67, 29); // Trennstrich + + char maxTempBuf[8]; + snprintf(maxTempBuf, sizeof(maxTempBuf), "%d", settings.maxTemp); + u8g2.drawStr(74, 30, maxTempBuf); + + // 5. Große aktuelle Uhrzeit unten links + u8g2.setFont(u8g2_font_6x10_tr); + char timeBuf[10]; + if (timeValid) { + snprintf(timeBuf, sizeof(timeBuf), "%02d:%02d", curH, curM); + } else { + snprintf(timeBuf, sizeof(timeBuf), "--:--"); + } + u8g2.drawStr(4, 60, timeBuf); + + // 6. Lopaka Deko-Bitmap + u8g2.drawXBMP(28, 4, 16, 26, image_paint_27_bits); + + // 7. Lopaka Animationen abspielen + //drawAnimation_fire_flames(); + //drawAnimation_Clock(); +} + +// ############################################################# +// Zeitschaltuhr +// ############################################################# +static void drawTimerScreen(TimeEditStep timeEditStep, uint8_t settingIdx, const SystemSettings& settings){ } @@ -24,17 +120,10 @@ static void drawHomeScreen(int currentSpeed, int curH, int curM, bool timeValid, static void drawSettingsScreen(uint8_t settingIdx, TimeEditStep timeEditStep, const SystemSettings& s) { if(timeEditStep != EDIT_NONE){ - drawTimerScreen(TimeEditStep timeEditStep, uint8_t settingIdx, const SystemSettings& s); + drawTimerScreen(timeEditStep, settingIdx, s); } } -// ############################################################# -// Zeitschaltuhr -// ############################################################# -static void drawTimerScreen(TimeEditStep timeEditStep, uint8_t settingIdx, const SystemSettings& s){ - -} - // ############################################################# // Main Funktion // ############################################################# @@ -43,15 +132,18 @@ void updateDisplay(bool inSettings, TimeEditStep editStep, const SystemSettings& settings, int currentSpeed, - int curH, int curM, bool timeValid) { + int curH, int curM, bool timeValid, int curTemp) { + if (millis() - lastDispTime >= 50) { + lastDispTime = millis(); - u8g2.clearBuffer(); + u8g2.clearBuffer(); - if (inSettings) { - drawSettingsScreen(settingIdx, editStep, settings); - }else{ - drawHomeScreen(currentSpeed, curH, curM, timeValid, settings.timerEnabled); - } + if (inSettings) { + drawSettingsScreen(settingIdx, editStep, settings); + }else{ + drawHomeScreen(currentSpeed, curH, curM, timeValid, settings.timerEnabled, settings, curTemp); + } - u8g2.sendBuffer(); + u8g2.sendBuffer(); + } } \ No newline at end of file diff --git a/display_ui.h b/display_ui.h index 1ae8fb0..0751512 100644 --- a/display_ui.h +++ b/display_ui.h @@ -10,4 +10,4 @@ void updateDisplay(bool inSettings, TimeEditStep editStep, const SystemSettings& settings, int currentSpeed, - int curH, int curM, bool timeValid); \ No newline at end of file + int curH, int curM, bool timeValid, int curTemp); \ No newline at end of file diff --git a/jentest.ino b/jentest.ino new file mode 100644 index 0000000..34e0e96 --- /dev/null +++ b/jentest.ino @@ -0,0 +1,393 @@ +#include +#include +#include + + +const char* ssid = "Stockfeld"; +const char* password = "70691554384740972413"; + +// NTP-Server & Zeitzone für Deutschland +const char* ntpServer = "pool.ntp.org"; +const char* tzInfo = "CET-1CEST,M3.5.0,M10.5.0/3"; + +FastAccelStepperEngine engine = FastAccelStepperEngine(); +FastAccelStepper *stepper = NULL; + +// ################ Variabeln ################ +const uint32_t MAX_SPEED_HZ = 106000; +const int32_t COLDTEMP_C = 50; + +bool clickPlus = 0; +bool clickMinus = 0; +bool clickStop = 0; +bool holdPlus = 0; +bool holdMinus = 0; +bool holdStop = 0; + +bool shouldRun = true; +int lastSpeed = 0; + +int32_t lastControl = 0; +uint32_t lastPlotTime = 0; + +bool autoStop = false; +bool bSettings = false; +uint32_t curTemp = 0; + +struct tm timeinfo; + +TimeEditStep timeEditStep = EDIT_NONE; + +// fest in den Speicher schreiben +Preferences prefs; + +SystemSettings settings; + +//##################################### +//########### Hilfsfunktion ########### +//##################################### + +// Überladung des Präfix-Operators (++timeEditStep) +TimeEditStep& operator++(TimeEditStep& step) { + step = (step == EDIT_END_MIN) ? EDIT_NONE : static_cast(step + 1); + return step; +} + +// Werte aus dem Flash speicher laden +void loadSettings() { + // Namespace öffnen (Name max. 15 Zeichen, "true" = read-only) + prefs.begin("timer_cfg", true); + + // Werte auslesen + settings.startHour = prefs.getUChar("s_hour", 0); + settings.startMin = prefs.getUChar("s_min", 0); + settings.endHour = prefs.getUChar("e_hour", 0); + settings.endMin = prefs.getUChar("e_min", 0); + settings.timerEnabled = prefs.getBool("t_on", false); + settings.maxTemp = prefs.getShort("max_temp", 70); + settings.accelRate = prefs.getInt("accel_rate", 2000); + + prefs.end(); + Serial.println("[NVS] Einstellungen erfolgreich geladen."); +} + +// Save Settings in Flash Speichern +void saveSettings() { + prefs.begin("timer_cfg", false); // "false" = Read/Write + + prefs.putUChar("s_hour", settings.startHour); + prefs.putUChar("s_min", settings.startMin); + prefs.putUChar("e_hour", settings.endHour); + prefs.putUChar("e_min", settings.endMin); + prefs.putBool("t_on", settings.timerEnabled); + prefs.putShort("max_temp", settings.maxTemp); + prefs.putInt("accel_rate", settings.accelRate); + + prefs.end(); + Serial.println("[NVS] Einstellungen im Flash gespeichert."); +} + +void initWiFiAndTime() { + WiFi.begin(ssid, password); + + // Zeitzone und NTP-Server setzen + configTzTime(tzInfo, ntpServer); + + // Warten auf Verbindung (optional mit Timeout) + int retries = 0; + while (WiFi.status() != WL_CONNECTED && retries < 20) { + delay(500); + retries++; + } +} + +//####################################################### +//####################### Setup ######################### +//####################################################### +void setup() { + Serial.begin(115200); + delay(1000); // Zeit für USB-CDC-Verbindung geben + + // Daten aus Flash speicher laden + loadSettings(); + + engine.init(); + stepper = engine.stepperConnectToPin(stepPinStepper); + + if (stepper) { + stepper->setDirectionPin(dirPinStepper); + stepper->setEnablePin(enablePinStepper, true); + stepper->setAutoEnable(true); + stepper->setSpeedInHz(MAX_SPEED_HZ); + } + + // Pin Config + pinMode(buttonPlus, INPUT_PULLUP); + pinMode(buttonMinus, INPUT_PULLUP); + pinMode(buttonStop, INPUT_PULLUP); + + initWiFiAndTime(); + + initDisplay(); + + // Start Animation +} + +bool getCurrentTime(int &hour, int &minute, int &second) { + if (!getLocalTime(&timeinfo, 50)) { // 50ms Timeout + return false; // Noch keine NTP-Zeit synchronisiert + } + hour = timeinfo.tm_hour; + minute = timeinfo.tm_min; + second = timeinfo.tm_sec; + return true; +} + +// Rückgabe von Flanken (Klick) und Pegel (Halten) +void getInputs(bool &clickPlus, bool &clickMinus, bool &clickStop, + bool &holdPlus, bool &holdMinus, bool &holdStop) { + + // Physische Pegel einlesen (Active-Low) + bool curPlus = (digitalRead(buttonPlus) == LOW); + bool curMinus = (digitalRead(buttonMinus) == LOW); + bool curStop = (digitalRead(buttonStop) == LOW); + + // Speicher für vorherigen Durchlauf + static bool lastPlus = false; + static bool lastMinus = false; + static bool lastStop = false; + + // Nur bei Veränderung true (Sperre) + clickPlus = (curPlus && !lastPlus); + clickMinus = (curMinus && !lastMinus); + clickStop = (curStop && !lastStop); + + // Dauerzustand (für Stepper-Handbetrieb) + holdPlus = curPlus; + holdMinus = curMinus; + holdStop = curStop; + + // Zustand für nächsten Durchlauf merken + lastPlus = curPlus; + lastMinus = curMinus; + lastStop = curStop; +} + +// Liefert die Aktuelle Temperatur in °C +int getTempInC(uint8_t senTemp){ + int milliVolt = analogReadMilliVolts(senTemp); + return ((milliVolt - 500)/10); +} + +// Liefert true wenn der Timer aktuell Active ist und false wenn nicht aktiv +bool isTimerActiveNow(int curH, int curM, int startH, int startM, int endH, int endM) { + int current = curH * 60 + curM; + int start = startH * 60 + startM; + int end = endH * 60 + endM; + + // Fall A: Zeitfenster am selben Tag (z. B. 08:00 bis 16:00) + if (start <= end) { + return (current >= start && current < end); + } + // Fall B: Zeitfenster über Mitternacht (z. B. 22:00 bis 04:00) + else { + return (current >= start || current < end); + } +} + +// Die Funktion behandelt das gesammte Einstellungs menu +void setting(){ + //######### Timer Edit ######### + if (timeEditStep != EDIT_NONE) { + //PLUS GEDRÜCKT: Wert erhöhen + if (clickPlus || holdPlus) { + switch (timeEditStep) { + case EDIT_START_HOUR: + settings.startHour = (settings.startHour + 1) % 24; + break; + case EDIT_START_MIN: + settings.startMin = (settings.startMin + 5) % 60; + break; + case EDIT_END_HOUR: + settings.endHour = (settings.endHour + 1) % 24; + break; + case EDIT_END_MIN: + settings.endMin = (settings.endMin + 5) % 60; + break; + default: break; + } + } + + // MINUS GEDRÜCKT: Wert verringern + if (clickMinus) { + switch (timeEditStep) { + case EDIT_START_HOUR: + settings.startHour = (settings.startHour == 0) ? 23 : settings.startHour - 1; + break; + case EDIT_START_MIN: + settings.startMin = (settings.startMin == 0) ? 59 : settings.startMin -5; + break; + case EDIT_END_HOUR: + settings.endHour = (settings.endHour == 0) ? 23 : settings.endHour - 1; + break; + case EDIT_END_MIN: + settings.endMin = (settings.endMin == 0) ? 59 : settings.endMin - 5; + break; + default: break; + } + } + + // STOP GEDRÜCKT: Zum nächsten Wert springen + if (clickStop) { + ++timeEditStep; + } + + return; // Wichtig: Rest der Funktion überspringen, solange editiert wird! + } + + //######### Max Temp Edit ######### + if(settings.editMaxTemp){ + if(clickPlus){ + settings.maxTemp = (settings.maxTemp + 5) % 140; + } + if(clickPlus){ + settings.maxTemp = (settings.maxTemp == 0) ? -20 : settings.maxTemp - 5; + } + if(clickStop){ + settings.editMaxTemp = false; + } + return; // Wichtig: Rest der Funktion überspringen, solange editiert wird! + } + + //######### Beschleunigung Edit ######### + if(settings.editAcc){ + if(clickPlus){ + settings.accelRate = (settings.accelRate + 1000) % 20000; + } + if(clickPlus){ + settings.accelRate = (settings.accelRate == 0) ? 0 : settings.accelRate - 1000; + } + if(clickStop){ + settings.editAcc = false; + } + return; // Wichtig: Rest der Funktion überspringen, solange editiert wird! + } + + + //######### Menü ######### + // Menü bewegen + if(clickPlus){ + if(settings.settingIdx <= 2){ + settings.settingIdx++; + } + } + if(clickMinus){ + if(settings.settingIdx >=1){ + settings.settingIdx--; + } + } + + // Stop zum bestätigen + if (clickStop) { + if (settings.settingIdx == 0) { + // Zeitschaltuhr-Einstellung starten + timeEditStep = EDIT_START_HOUR; + } + else if (settings.settingIdx == 1) { + // Zeitschaltuhr ON/OFF + settings.timerEnabled = !settings.timerEnabled; + }else if (settings.settingIdx == 2) { + // Temperatur Grenze einstellen + settings.editMaxTemp = true; + }else if (settings.settingIdx == 3) { + // Beschleunigung + settings.editAcc = true; + }else if (settings.settingIdx == 4) { + // Menü verlassen + bSettings = false; + // Einstellungen Speichern + saveSettings(); + } + } +} + +void printStatus(FastAccelStepper *stepper, int speed, int clickPlus, int clickMinus){ + // Plotter-Ausgabe alle 50 ms (überflutet den Bus nicht) + if (millis() - lastPlotTime >= 50) { + lastPlotTime = millis(); + + int32_t currentSpeed = stepper->getCurrentSpeedInUs() == 0 ? 0 : (1000000 / stepper->getCurrentSpeedInUs()); + + // Format kompatibel für den Arduino Serial Plotter + Serial.print("Current_Speed_U/Min:"); + Serial.print((60*currentSpeed)/3200); + Serial.print(" Accel_Control:"); + Serial.print(speed); + Serial.print(" Btn_Up:"); + Serial.print(clickPlus ? 5000 : 0); + Serial.print(" Btn_Down:"); + Serial.print(clickMinus ? -5000 : 0); + Serial.println(); + } +} + +//############################################################# +//#################### MAIN ################################### +//############################################################# +void loop() { + int32_t speed = 0; + + if (!stepper) { + Serial.println("[HALT] Kein Stepper-Objekt aktiv."); + delay(1000); + return; + } + + // Inputs + getInputs(clickPlus, clickMinus, clickStop, holdPlus, holdMinus, holdStop); + curTemp = getTempInC(senTemp); + + // zeitschaltuhr prüfen + int curH, curM, curS; + if (settings.timerEnabled && getCurrentTime(curH, curM, curS)) { + shouldRun = isTimerActiveNow(curH, curM, settings.startHour, settings.startMin, settings.endHour, settings.endMin); + } + + if(curTemp >= settings.maxTemp || !shouldRun){ + autoStop = true; + }else if(curTemp <= COLDTEMP_C){ + autoStop = false; + } + + // Main Control + if(bSettings){ + setting(); + }else if(clickStop || autoStop){ + stepper->stopMove(); + speed = 0; + if(clickStop && clickPlus){ + bSettings = true; + } + }else if(holdPlus){ + speed = settings.accelRate; + }else if(holdMinus){ + speed = -settings.accelRate; + }else{ + speed = 0; + } + + // Action + if (speed != lastSpeed) { + stepper->moveByAcceleration(speed, true); + lastSpeed = speed; + } + + int32_t currentSpeed = stepper->getCurrentSpeedInUs() == 0 ? 0 : (1000000 / stepper->getCurrentSpeedInUs()); + + bool timeIsValid = getCurrentTime(curH, curM, curS); + updateDisplay(bSettings, settings.settingIdx, timeEditStep, settings, currentSpeed, curH, curM, timeIsValid, curTemp); + + // Status ausgabe auf Terminal + printStatus(stepper, speed, clickPlus, clickMinus); + +} \ No newline at end of file diff --git a/main.ino b/main.ino index cd7bebd..a9d6271 100644 --- a/main.ino +++ b/main.ino @@ -265,27 +265,6 @@ void setting(){ } } -void updateDisplay(){ - if (millis() - lastDispTime >= 50) { - lastDispTime = millis(); - int32_t currentSpeed = stepper->getCurrentSpeedInUs() == 0 ? 0 : (1000000 / stepper->getCurrentSpeedInUs()); - - // einstellungs fenster - if(bSettings){ - // Mein Menu - - // Uhrzeit - - // Cursor mit settingIdx - //EDIT_START_HOUR - //EDIT_START_MIN - //EDIT_END_HOUR - //EDIT_END_MIN - - } - } -} - void printStatus(FastAccelStepper *stepper, int speed, int clickPlus, int clickMinus){ // Plotter-Ausgabe alle 50 ms (überflutet den Bus nicht) if (millis() - lastPlotTime >= 50) { @@ -339,7 +318,7 @@ void loop() { // Main Control if(bSettings){ - settings() + setting() }else if(clickStop || autoStop){ stepper->stopMove(); speed = 0; @@ -360,7 +339,10 @@ void loop() { lastSpeed = speed; } - updateDisplay() + int32_t currentSpeed = stepper->getCurrentSpeedInUs() == 0 ? 0 : (1000000 / stepper->getCurrentSpeedInUs()); + + bool timeIsValid = getCurrentTime(curH, curM); + updateDisplay(bSettings, settings.settingIdx, timeEditStep, &settings, currentSpeed, timeIsValid, curTemp); // Status ausgabe auf Terminal printStatus(stepper, speed, clickPlus, clickMinus); diff --git a/types.h b/types.h index 9adf501..87e59ca 100644 --- a/types.h +++ b/types.h @@ -1,53 +1,23 @@ #pragma once #include #include +#include #include #include -const char* ssid = "DEIN_WLAN_NAME"; -const char* password = "DEIN_PASSWORT"; - -// NTP-Server & Zeitzone für Deutschland -const char* ntpServer = "pool.ntp.org"; -const char* tzInfo = "CET-1CEST,M3.5.0,M10.5.0/3"; - -FastAccelStepperEngine engine = FastAccelStepperEngine(); -FastAccelStepper *stepper = NULL; - // Pins -#define dirPinStepper D1 -#define enablePinStepper D2 -#define stepPinStepper D3 +#define dirPinStepper D8 +#define enablePinStepper D7 +#define stepPinStepper D9 -#define buttonPlus D7 -#define buttonMinus D8 -#define buttonStop D9 +#define buttonPlus D1 +#define buttonMinus D2 +#define buttonStop D3 #define senTemp D0 #define I2C_SDA D4 #define I2C_SCL D5 -// ################ Variabeln ################ -const uint32_t MAX_SPEED_HZ = 106000; -const int32_t COLDTEMP_C = 50; - -bool clickPlus = 0; -bool clickMinus = 0; -bool clickStop = 0; -bool holdPlus = 0; -bool holdMinus = 0; -bool holdStop = 0; - -int32_t lastControl = 0; -uint32_t lastPlotTime = 0; - -uint32_t lastDispTime = 0; -bool autoStop = false; -bool bSettings = false; -uint32_t curTemp = 0; - -struct tm timeinfo; - struct settings{ int settingIdx = 0; int startHour = 0; @@ -59,7 +29,7 @@ struct settings{ int16_t maxTemp = 70; //in °C bool editAcc = false; int32_t accelRate = 2000; -} +}; enum TimeEditStep { EDIT_NONE = 0, // Normales Menü (Navigation) @@ -69,20 +39,20 @@ enum TimeEditStep { EDIT_END_MIN // 4. End-Minute einstellen (0-59) }; -TimeEditStep timeEditStep = EDIT_NONE; -// fest in den Speicher schreiben -Preferences prefs; // Dein Einstellungs-Struct struct SystemSettings { - uint8_t startHour = 0; - uint8_t startMin = 0; - uint8_t endHour = 0; - uint8_t endMin = 0; + int settingIdx = 0; + int startHour = 0; + int startMin = 0; + int endHour = 0; + int endMin = 0; bool timerEnabled = false; - int16_t maxTemp = 70; - int32_t accelRate = 2000; + bool editMaxTemp = false; + int16_t maxTemp = 70; //in °C + bool editAcc = false; + int32_t accelRate = 2000; }; -SystemSettings settings; +