diff --git a/src/Arduboy2Core.cpp b/src/Arduboy2Core.cpp index 7ccbaae..cef7f21 100644 --- a/src/Arduboy2Core.cpp +++ b/src/Arduboy2Core.cpp @@ -73,6 +73,10 @@ const PROGMEM uint8_t lcdBootProgram[] = { }; +//======================================== +//========== class Arduboy2Core ========== +//======================================== + Arduboy2Core::Arduboy2Core() { } void Arduboy2Core::boot() @@ -572,11 +576,12 @@ void Arduboy2Core::exitToBootloader() while (true) { } } -// Replacement main() that eliminates the USB stack code. -// Used by the ARDUBOY_NO_USB macro. This should not be called -// directly from a sketch. -void Arduboy2Core::mainNoUSB() +//========================================= +//========== class Arduboy2NoUSB ========== +//========================================= + +void Arduboy2NoUSB::mainNoUSB() { // disable USB UDCON = _BV(DETACH); @@ -598,11 +603,11 @@ void Arduboy2Core::mainNoUSB() bitClear(DOWN_BUTTON_DDR, DOWN_BUTTON_BIT); // Delay to give time for the pin to be pulled high if it was floating - delayShort(10); + Arduboy2Core::delayShort(10); // if the DOWN button is pressed if (bitRead(DOWN_BUTTON_PORTIN, DOWN_BUTTON_BIT) == 0) { - exitToBootloader(); + Arduboy2Core::exitToBootloader(); } // The remainder is a copy of the Arduino main() function with the diff --git a/src/Arduboy2Core.h b/src/Arduboy2Core.h index 13cc73d..d1d4763 100644 --- a/src/Arduboy2Core.h +++ b/src/Arduboy2Core.h @@ -248,9 +248,9 @@ /** \brief * Eliminate the USB stack to free up code space. * - * \note - * **WARNING:** Removing the USB code will make it impossible for sketch - * uploader programs to automatically force a reset into the bootloader! + * \warning + * Removing the USB code will make it impossible for sketch uploader + * programs to automatically force a reset into the bootloader! * This means that a user will manually have to invoke a reset in order to * upload a new sketch, after one without USB has be been installed. * Be aware that the timing for the point that a reset must be initiated can @@ -303,10 +303,20 @@ */ #define ARDUBOY_NO_USB int main() __attribute__ ((OS_main)); \ int main() { \ - Arduboy2Core::mainNoUSB(); \ + Arduboy2NoUSB::mainNoUSB(); \ return 0; \ } +// A replacement for the Arduino main() function that eliminates the USB code. +// Used by the ARDUBOY_NO_USB macro. +class Arduboy2NoUSB +{ + friend int main(); + + private: + static void mainNoUSB(); +}; + /** \brief * Lower level functions generally dealing directly with the hardware. @@ -322,7 +332,7 @@ int main() { \ * that this may eliminate the need to create an entire local copy of the * library, in order to extend the functionality, in most circumstances. */ -class Arduboy2Core +class Arduboy2Core : public Arduboy2NoUSB { friend class Arduboy2Ex; @@ -828,11 +838,6 @@ class Arduboy2Core */ static void exitToBootloader(); - // Replacement main() that eliminates the USB stack code. - // Used by the ARDUBOY_NO_USB macro. This should not be called - // directly from a sketch. - static void mainNoUSB(); - protected: // internals static void setCPUSpeed8MHz();