MaslowCNC / Firmware

Maslow Firmware
GNU General Public License v3.0
261 stars 136 forks source link

Define aux pins at runtime #419

Closed blurfl closed 6 years ago

blurfl commented 6 years ago

This addresses issue #417 . In order to make use of all the AUX pins including the ones that change between board versions, it seems like they should be defined at runtime based on the board version much as the INx, ENx and ENCODERxy pins are. This code does that, moving them into System.cpp to be defined with those others. I've also added comments to Probe.cpp and Spindle.cpp to tell where the active pins are assigned.

Note 1, I've left the debug print statements in until testers have evaluated the PR. The 'dummyPin' uses an AUX pin that differs between board versions. The v1.0 board should show '1', the v1.1 and v1.2 boards should show '60'.

Note 2, I've created a function to assign the AUX pins that are currently used to the variables that need them. The function takes all the AUX pins values as parameters. This was done to allow defining them without raising the compiler complaint about unused #defines. I feel having the AUX pins defined even if they are not currently used will make it easier for others to make use of them in the future.

BarbourSmith commented 6 years ago

Wonderful!!!

I will test this against all of the PCB versions tomorrow and report back what it reports back 😀

BarbourSmith commented 6 years ago

I tested this against version 1.0, 1.1, and 1.2b of the hardware and they all look good.

I did not test every aux pin for every version because I didn't really have a good way to do that, but we can be sure that this will at the very least not break any existing functionality.

I have full compiler warnings turned on, and when compiling the firmware I did see a new warning:

Archiving built core (caching) in: C:\Users\Bar\AppData\Local\Temp\arduino_cache_196560\core\core_arduino_avr_mega_cpu_atmega2560_a94ab6aaf61dfb93b4a8079c694a14c2.a
sketch\System.cpp: In function 'setupAxes':

sketch\System.cpp:214:18: warning: 'AUX6' may be used uninitialized in this function [-Wmaybe-uninitialized]

   dummyPin = AUX6;

I think we're ready to merge. @blurfl do you want to take out some of the print statements before I do?

blurfl commented 6 years ago

Yes, I'll take the print statements and the dummy pin out. Could it wait until tomorrow?

BarbourSmith commented 6 years ago

Absolutely! No rush

BarbourSmith commented 6 years ago

Looks good to merge!! 👍 👍