From 7cc8ed7fc267e041d414c316ae87012334cfffbc Mon Sep 17 00:00:00 2001 From: Alexander Carlisi Date: Tue, 9 Jul 2024 20:23:21 -0400 Subject: [PATCH] Refactor MeMegaPi.h and MeMegaPi.cpp to use external declarations for mePort, encoder_Port, megapi_dc_Port, and megaPi_slots --- src/MeMegaPi.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/MeMegaPi.h | 36 +++++------------------------------- 2 files changed, 41 insertions(+), 31 deletions(-) create mode 100644 src/MeMegaPi.cpp diff --git a/src/MeMegaPi.cpp b/src/MeMegaPi.cpp new file mode 100644 index 00000000..f0a826b6 --- /dev/null +++ b/src/MeMegaPi.cpp @@ -0,0 +1,36 @@ +#include "MeMegaPi.h" + +MePort_Sig mePort[17] = +{ + { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, + { 16, 17 }, { A8, A9 }, { A10, A11 }, { A13, A12 }, { NC, NC }, + { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, + { NC, NC },{ NC, NC }, +}; + +Encoder_port_type encoder_Port[6] = +{ + { NC, NC, NC, NC, NC}, + //NET2 NET1 PWM DIR1 DIR2 + { 18, 31, 12, 34, 35}, + //ENB A ENB B PWMB DIR B1 DIR B2 + { 19, 38, 8, 37, 36}, + { 3, 49, 9, 43, 42}, + { 2, A1, 5, A4, A5}, + { NC, NC, NC, NC, NC}, +}; + +megapi_dc_type megapi_dc_Port[14] = +{ + {NC,NC,NC}, {33,32,11}, {40,41, 7}, {47,48, 6}, {A3,A2, 4}, + {NC,NC,NC}, {NC,NC,NC}, {NC,NC,NC}, {NC,NC,NC}, {35,34,12}, + {36,37, 8}, {42,43, 9}, {A5,A4, 5}, +}; + +megaPi_slot_type megaPi_slots[4] = +{ + {35, 34, 33, 32, 31, 18, 12, 11}, + {36, 37, 40, 41, 38, 19, 8, 7}, + {42, 43, 47, 48, 49, 3, 9, 6}, + {A5, A4, A3, A2, A1, 2, 5, 4}, // for megapi +}; \ No newline at end of file diff --git a/src/MeMegaPi.h b/src/MeMegaPi.h index e3554da1..bba44cf4 100644 --- a/src/MeMegaPi.h +++ b/src/MeMegaPi.h @@ -87,39 +87,13 @@ #define PORT4A PORT_4 #define PORT4B PORT_12 - MePort_Sig mePort[17] = - { - { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, - { 16, 17 }, { A8, A9 }, { A10, A11 }, { A13, A12 }, { NC, NC }, - { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, { NC, NC }, - { NC, NC },{ NC, NC }, - }; +extern MePort_Sig mePort[17]; -Encoder_port_type encoder_Port[6] = -{ - { NC, NC, NC, NC, NC}, - //NET2 NET1 PWM DIR1 DIR2 - { 18, 31, 12, 34, 35}, - //ENB A ENB B PWMB DIR B1 DIR B2 - { 19, 38, 8, 37, 36}, - { 3, 49, 9, 43, 42}, - { 2, A1, 5, A4, A5}, - { NC, NC, NC, NC, NC}, -}; +extern Encoder_port_type encoder_Port[6]; -megapi_dc_type megapi_dc_Port[14] = -{ - {NC,NC,NC}, {33,32,11}, {40,41, 7}, {47,48, 6}, {A3,A2, 4}, - {NC,NC,NC}, {NC,NC,NC}, {NC,NC,NC}, {NC,NC,NC}, {35,34,12}, - {36,37, 8}, {42,43, 9}, {A5,A4, 5}, -}; +extern megapi_dc_type megapi_dc_Port[14]; + +extern megaPi_slot_type megaPi_slots[4]; -megaPi_slot_type megaPi_slots[4] = -{ - {35, 34, 33, 32, 31, 18, 12, 11}, - {36, 37, 40, 41, 38, 19, 8, 7}, - {42, 43, 47, 48, 49, 3, 9, 6}, - {A5, A4, A3, A2, A1, 2, 5, 4}, // for megapi -}; //for step motor on board #endif // MeMegaPi_H