From 168483335e7a1d20daaa449cea46fb736c77c7ad Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Wed, 16 Dec 2020 15:27:49 +0000 Subject: [PATCH 1/2] Create Arduino ZIP --- arduino/etl.h | 80 +++++++++++++++++++++++++++++++++++++++ create_arduino_library.py | 48 +++++++++++++++++++++++ 2 files changed, 128 insertions(+) create mode 100644 arduino/etl.h create mode 100644 create_arduino_library.py diff --git a/arduino/etl.h b/arduino/etl.h new file mode 100644 index 00000000..4ea7c9eb --- /dev/null +++ b/arduino/etl.h @@ -0,0 +1,80 @@ +#if defined(TEENSYDUINO) + + #if defined(__AVR_ATmega32U4__) + #define BOARD "Teensy 2.0" + #elif defined(__AVR_AT90USB1286__) + #define BOARD "Teensy++ 2.0" + #elif defined(__MK20DX128__) + #define BOARD "Teensy 3.0" + #elif defined(__MK20DX256__) + #define BOARD "Teensy 3.2" // and Teensy 3.1 (obsolete) + #elif defined(__MKL26Z64__) + #define BOARD "Teensy LC" + #elif defined(__MK64FX512__) + #define BOARD "Teensy 3.5" + #elif defined(__MK66FX1M0__) + #define BOARD "Teensy 3.6" + #else + #error "Unknown board" + #endif + +#else // --------------- Arduino ------------------ + + #if defined(ARDUINO_AVR_ADK) + #define BOARD "Mega Adk" + #elif defined(ARDUINO_AVR_BT) // Bluetooth + #define BOARD "Bt" + #elif defined(ARDUINO_AVR_DUEMILANOVE) + #define BOARD "Duemilanove" + #elif defined(ARDUINO_AVR_ESPLORA) + #define BOARD "Esplora" + #elif defined(ARDUINO_AVR_ETHERNET) + #define BOARD "Ethernet" + #elif defined(ARDUINO_AVR_FIO) + #define BOARD "Fio" + #elif defined(ARDUINO_AVR_GEMMA) + #define BOARD "Gemma" + #elif defined(ARDUINO_AVR_LEONARDO) + #define BOARD "Leonardo" + #elif defined(ARDUINO_AVR_LILYPAD) + #define BOARD "Lilypad" + #elif defined(ARDUINO_AVR_LILYPAD_USB) + #define BOARD "Lilypad Usb" + #elif defined(ARDUINO_AVR_MEGA) + #define BOARD "Mega" + #elif defined(ARDUINO_AVR_MEGA2560) + #define BOARD "Mega 2560" + #elif defined(ARDUINO_AVR_MICRO) + #define BOARD "Micro" + #elif defined(ARDUINO_AVR_MINI) + #define BOARD "Mini" + #elif defined(ARDUINO_AVR_NANO) + #define BOARD "Nano" + #elif defined(ARDUINO_AVR_NG) + #define BOARD "NG" + #elif defined(ARDUINO_AVR_PRO) + #define BOARD "Pro" + #elif defined(ARDUINO_AVR_ROBOT_CONTROL) + #define BOARD "Robot Ctrl" + #elif defined(ARDUINO_AVR_ROBOT_MOTOR) + #define BOARD "Robot Motor" + #elif defined(ARDUINO_AVR_UNO) + #define BOARD "Uno" + #elif defined(ARDUINO_AVR_YUN) + #define BOARD "Yun" + + // These boards must be installed separately: + #elif defined(ARDUINO_SAM_DUE) + #define BOARD "Due" + #elif defined(ARDUINO_SAMD_ZERO) + #define BOARD "Zero" + #elif defined(ARDUINO_ARC32_TOOLS) + #define BOARD "101" + #else + #error "Unknown board" + #endif + +#endif + +#include +#include \ No newline at end of file diff --git a/create_arduino_library.py b/create_arduino_library.py new file mode 100644 index 00000000..d4fbbec9 --- /dev/null +++ b/create_arduino_library.py @@ -0,0 +1,48 @@ + +import shutil +import os + +# https://arduino.github.io/arduino-cli/latest/library-specification/ + +# +# Some Constants +library_name = 'Embedded_Template_Library' + +# +# Get the current Path of the script +dirname = os.path.dirname(__file__) +dest = os.path.join(dirname, library_name) +print('The destination folder is ', dest) + +# +# Copy the ETL to the Arduino-Library Folder +src = os.path.join(dirname, 'include') +print('The source folder is ', src) +print('The destination folder is ', dest) +shutil.copytree(src, os.path.join(dest, 'src'), dirs_exist_ok=True) +print('Done adding ETL...') + +# +# Add files from the arduino folder +filename = 'etl.h' +src = os.path.join(os.path.join(dirname, 'arduino'), filename) +print('The source is ', src) +print('The destination is ', os.path.join(os.path.join(dest, 'src'), filename)) +shutil.copyfile(src, os.path.join(os.path.join(dest, 'src'), filename)) +print('Done adding Arduino...') + +# +# Add any additional file (library.properties) +filename = 'library.properties' +shutil.copyfile(os.path.join(dirname, filename), os.path.join(dest, filename)) +print('Done adding additional files...') + +# +# Zip the Folder to be Arduino-Compatible +print('Make archive...') +shutil.make_archive(os.path.join(os.path.join(dirname, 'arduino'), library_name), 'zip', dest) + +# +# Remove temporary directory +print('Removing temporary files...') +shutil.rmtree(dest) From e890e3782ebbacc91b7bca1f29ec7a07bec4266e Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Sun, 20 Dec 2020 16:43:49 +0000 Subject: [PATCH 2/2] Arduino compatibility --- .gitignore | 1 + arduino/Embedded_Template_Library.h | 80 +++++++++++++++++++++++++++++ arduino/create_arduino_library.py | 47 +++++++++++++++++ arduino/etl.h | 80 ----------------------------- create_arduino_library.py | 48 ----------------- include/etl/algorithm.h | 4 ++ include/etl/private/minmax_pop.h | 7 ++- include/etl/private/minmax_push.h | 10 ++-- include/etl/version.h | 2 +- library.json | 6 +-- library.properties | 6 +-- support/Release notes.txt | 4 ++ test/vs2019/etl.vcxproj | 2 + test/vs2019/etl.vcxproj.filters | 11 +++- 14 files changed, 162 insertions(+), 146 deletions(-) create mode 100644 arduino/Embedded_Template_Library.h create mode 100644 arduino/create_arduino_library.py delete mode 100644 arduino/etl.h delete mode 100644 create_arduino_library.py diff --git a/.gitignore b/.gitignore index 806bcd81..8441530d 100644 --- a/.gitignore +++ b/.gitignore @@ -277,3 +277,4 @@ test/Makefile test/vs2019/enc_temp_folder test/vs2019/.leu test/etl_test_log.txt +temp/create_arduino_library.py diff --git a/arduino/Embedded_Template_Library.h b/arduino/Embedded_Template_Library.h new file mode 100644 index 00000000..df5fdcf4 --- /dev/null +++ b/arduino/Embedded_Template_Library.h @@ -0,0 +1,80 @@ + +#ifndef ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED +#define ETL_EMBEDDED_TEMPLATE_LIBRARY_INCLUDED + +#if defined(TEENSYDUINO) + + #if defined(__AVR_ATmega32U4__) + #define ARDUINO_BOARD "Teensy 2.0" + #elif defined(__AVR_AT90USB1286__) + #define ARDUINO_BOARD "Teensy++ 2.0" + #elif defined(__MK20DX128__) + #define ARDUINO_BOARD "Teensy 3.0" + #elif defined(__MK20DX256__) + #define ARDUINO_BOARD "Teensy 3.2" // and Teensy 3.1 + #elif defined(__MKL26Z64__) + #define ARDUINO_BOARD "Teensy LC" + #elif defined(__MK64FX512__) + #define ARDUINO_BOARD "Teensy 3.5" + #elif defined(__MK66FX1M0__) + #define ARDUINO_BOARD "Teensy 3.6" + #else + #error "Unknown" + #endif + +#else // --------------- Arduino ------------------ + + #if defined(ARDUINO_AVR_ADK) + #define ARDUINO_BOARD "Mega Adk" + #elif defined(ARDUINO_AVR_BT) + #define ARDUINO_BOARD "Bt" + #elif defined(ARDUINO_AVR_DUEMILANOVE) + #define ARDUINO_BOARD "Duemilanove" + #elif defined(ARDUINO_AVR_ESPLORA) + #define ARDUINO_BOARD "Esplora" + #elif defined(ARDUINO_AVR_ETHERNET) + #define ARDUINO_BOARD "Ethernet" + #elif defined(ARDUINO_AVR_FIO) + #define ARDUINO_BOARD "Fio" + #elif defined(ARDUINO_AVR_GEMMA) + #define ARDUINO_BOARD "Gemma" + #elif defined(ARDUINO_AVR_LEONARDO) + #define ARDUINO_BOARD "Leonardo" + #elif defined(ARDUINO_AVR_LILYPAD) + #define ARDUINO_BOARD "Lilypad" + #elif defined(ARDUINO_AVR_LILYPAD_USB) + #define ARDUINO_BOARD "Lilypad Usb" + #elif defined(ARDUINO_AVR_MEGA) + #define ARDUINO_BOARD "Mega" + #elif defined(ARDUINO_AVR_MEGA2560) + #define ARDUINO_BOARD "Mega 2560" + #elif defined(ARDUINO_AVR_MICRO) + #define ARDUINO_BOARD "Micro" + #elif defined(ARDUINO_AVR_MINI) + #define ARDUINO_BOARD "Mini" + #elif defined(ARDUINO_AVR_NANO) + #define ARDUINO_BOARD "Nano" + #elif defined(ARDUINO_AVR_NG) + #define ARDUINO_BOARD "NG" + #elif defined(ARDUINO_AVR_PRO) + #define ARDUINO_BOARD "Pro" + #elif defined(ARDUINO_AVR_ROBOT_CONTROL) + #define ARDUINO_BOARD "Robot Ctrl" + #elif defined(ARDUINO_AVR_ROBOT_MOTOR) + #define ARDUINO_BOARD "Robot Motor" + #elif defined(ARDUINO_AVR_UNO) + #define ARDUINO_BOARD "Uno" + #elif defined(ARDUINO_AVR_YUN) + #define ARDUINO_BOARD "Yun" + #elif defined(ARDUINO_SAM_DUE) + #define ARDUINO_BOARD "Due" + #elif defined(ARDUINO_SAMD_ZERO) + #define ARDUINO_BOARD "Zero" + #elif defined(ARDUINO_ARC32_TOOLS) + #define ARDUINO_BOARD "101" + #else + #error "Unknown" + #endif +#endif + +#endif \ No newline at end of file diff --git a/arduino/create_arduino_library.py b/arduino/create_arduino_library.py new file mode 100644 index 00000000..b2f6f101 --- /dev/null +++ b/arduino/create_arduino_library.py @@ -0,0 +1,47 @@ + +import shutil +import os + +# Get the current Path of the script +arduino_dir = os.path.dirname(__file__) +print('arduino_dir ', arduino_dir) + +etl_dir = os.path.dirname(arduino_dir) +print('etl_dir ', etl_dir) + +etl_include_dir = os.path.join(etl_dir, 'include') +print('etl_include_dir ', etl_include_dir) + +common_dir = os.path.dirname(etl_dir) +print('common_dir ', common_dir) + +etl_arduino_dir = os.path.join(common_dir, 'etl-arduino') +print('etl_arduino_dir ', etl_arduino_dir) + +etl_arduino_src_dir = os.path.join(etl_arduino_dir, 'src') +print('etl_arduino_src_dir ', etl_arduino_src_dir) + +print('') + +# Copy the library properties +filename = 'library.properties' +source = os.path.join(etl_dir, filename) +destination = os.path.join(etl_arduino_dir, filename) +print('source = ', source) +print('destination = ', destination) +shutil.copyfile(source, destination) + +# Copy the Arduino ETL header +filename = 'Embedded_Template_Library.h' +source = os.path.join(arduino_dir, filename) +destination = os.path.join(etl_arduino_src_dir, filename) +print('source = ', source) +print('destination = ', destination) +shutil.copyfile(source, destination) + +# Copy the ETL headers +source = etl_include_dir +destination = etl_arduino_src_dir +print('source = ', source) +print('destination = ', destination) +shutil.copytree(source, destination, dirs_exist_ok = True) diff --git a/arduino/etl.h b/arduino/etl.h deleted file mode 100644 index 4ea7c9eb..00000000 --- a/arduino/etl.h +++ /dev/null @@ -1,80 +0,0 @@ -#if defined(TEENSYDUINO) - - #if defined(__AVR_ATmega32U4__) - #define BOARD "Teensy 2.0" - #elif defined(__AVR_AT90USB1286__) - #define BOARD "Teensy++ 2.0" - #elif defined(__MK20DX128__) - #define BOARD "Teensy 3.0" - #elif defined(__MK20DX256__) - #define BOARD "Teensy 3.2" // and Teensy 3.1 (obsolete) - #elif defined(__MKL26Z64__) - #define BOARD "Teensy LC" - #elif defined(__MK64FX512__) - #define BOARD "Teensy 3.5" - #elif defined(__MK66FX1M0__) - #define BOARD "Teensy 3.6" - #else - #error "Unknown board" - #endif - -#else // --------------- Arduino ------------------ - - #if defined(ARDUINO_AVR_ADK) - #define BOARD "Mega Adk" - #elif defined(ARDUINO_AVR_BT) // Bluetooth - #define BOARD "Bt" - #elif defined(ARDUINO_AVR_DUEMILANOVE) - #define BOARD "Duemilanove" - #elif defined(ARDUINO_AVR_ESPLORA) - #define BOARD "Esplora" - #elif defined(ARDUINO_AVR_ETHERNET) - #define BOARD "Ethernet" - #elif defined(ARDUINO_AVR_FIO) - #define BOARD "Fio" - #elif defined(ARDUINO_AVR_GEMMA) - #define BOARD "Gemma" - #elif defined(ARDUINO_AVR_LEONARDO) - #define BOARD "Leonardo" - #elif defined(ARDUINO_AVR_LILYPAD) - #define BOARD "Lilypad" - #elif defined(ARDUINO_AVR_LILYPAD_USB) - #define BOARD "Lilypad Usb" - #elif defined(ARDUINO_AVR_MEGA) - #define BOARD "Mega" - #elif defined(ARDUINO_AVR_MEGA2560) - #define BOARD "Mega 2560" - #elif defined(ARDUINO_AVR_MICRO) - #define BOARD "Micro" - #elif defined(ARDUINO_AVR_MINI) - #define BOARD "Mini" - #elif defined(ARDUINO_AVR_NANO) - #define BOARD "Nano" - #elif defined(ARDUINO_AVR_NG) - #define BOARD "NG" - #elif defined(ARDUINO_AVR_PRO) - #define BOARD "Pro" - #elif defined(ARDUINO_AVR_ROBOT_CONTROL) - #define BOARD "Robot Ctrl" - #elif defined(ARDUINO_AVR_ROBOT_MOTOR) - #define BOARD "Robot Motor" - #elif defined(ARDUINO_AVR_UNO) - #define BOARD "Uno" - #elif defined(ARDUINO_AVR_YUN) - #define BOARD "Yun" - - // These boards must be installed separately: - #elif defined(ARDUINO_SAM_DUE) - #define BOARD "Due" - #elif defined(ARDUINO_SAMD_ZERO) - #define BOARD "Zero" - #elif defined(ARDUINO_ARC32_TOOLS) - #define BOARD "101" - #else - #error "Unknown board" - #endif - -#endif - -#include -#include \ No newline at end of file diff --git a/create_arduino_library.py b/create_arduino_library.py deleted file mode 100644 index d4fbbec9..00000000 --- a/create_arduino_library.py +++ /dev/null @@ -1,48 +0,0 @@ - -import shutil -import os - -# https://arduino.github.io/arduino-cli/latest/library-specification/ - -# -# Some Constants -library_name = 'Embedded_Template_Library' - -# -# Get the current Path of the script -dirname = os.path.dirname(__file__) -dest = os.path.join(dirname, library_name) -print('The destination folder is ', dest) - -# -# Copy the ETL to the Arduino-Library Folder -src = os.path.join(dirname, 'include') -print('The source folder is ', src) -print('The destination folder is ', dest) -shutil.copytree(src, os.path.join(dest, 'src'), dirs_exist_ok=True) -print('Done adding ETL...') - -# -# Add files from the arduino folder -filename = 'etl.h' -src = os.path.join(os.path.join(dirname, 'arduino'), filename) -print('The source is ', src) -print('The destination is ', os.path.join(os.path.join(dest, 'src'), filename)) -shutil.copyfile(src, os.path.join(os.path.join(dest, 'src'), filename)) -print('Done adding Arduino...') - -# -# Add any additional file (library.properties) -filename = 'library.properties' -shutil.copyfile(os.path.join(dirname, filename), os.path.join(dest, filename)) -print('Done adding additional files...') - -# -# Zip the Folder to be Arduino-Compatible -print('Make archive...') -shutil.make_archive(os.path.join(os.path.join(dirname, 'arduino'), library_name), 'zip', dest) - -# -# Remove temporary directory -print('Removing temporary files...') -shutil.rmtree(dest) diff --git a/include/etl/algorithm.h b/include/etl/algorithm.h index 5debe70e..b01f90d2 100644 --- a/include/etl/algorithm.h +++ b/include/etl/algorithm.h @@ -53,6 +53,8 @@ SOFTWARE. #include #endif +#include "private/minmax_push.h" + namespace etl { // Declare prototypes of the ETL's sort functions @@ -3417,4 +3419,6 @@ namespace etl #endif } +#include "private/minmax_pop.h" + #endif diff --git a/include/etl/private/minmax_pop.h b/include/etl/private/minmax_pop.h index f46e46a1..f7ee5c0e 100644 --- a/include/etl/private/minmax_pop.h +++ b/include/etl/private/minmax_pop.h @@ -33,7 +33,6 @@ SOFTWARE. * This file is intended to evaluated multiple times by design. */ -#if defined(ETL_COMPILER_MICROSOFT) - #pragma pop_macro("min") - #pragma pop_macro("max") -#endif +#pragma pop_macro("min") +#pragma pop_macro("max") + diff --git a/include/etl/private/minmax_push.h b/include/etl/private/minmax_push.h index 290a2024..465b6189 100644 --- a/include/etl/private/minmax_push.h +++ b/include/etl/private/minmax_push.h @@ -33,9 +33,7 @@ SOFTWARE. * This file is intended to evaluated multiple times by design. */ -#if defined(ETL_COMPILER_MICROSOFT) - #pragma push_macro("min") - #pragma push_macro("max") - #undef min - #undef max -#endif +#pragma push_macro("min") +#pragma push_macro("max") +#undef min +#undef max diff --git a/include/etl/version.h b/include/etl/version.h index 306423b4..be5b7221 100644 --- a/include/etl/version.h +++ b/include/etl/version.h @@ -39,7 +39,7 @@ SOFTWARE. #define ETL_VERSION_MAJOR 19 #define ETL_VERSION_MINOR 3 -#define ETL_VERSION_PATCH 5 +#define ETL_VERSION_PATCH 6 #define ETL_VERSION ETL_STRINGIFY(ETL_VERSION_MAJOR) "." ETL_STRINGIFY(ETL_VERSION_MINOR) "." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_W ETL_STRINGIFY(ETL_VERSION_MAJOR) L"." ETL_STRINGIFY(ETL_VERSION_MINOR) L"." ETL_STRINGIFY(ETL_VERSION_PATCH) #define ETL_VERSION_U16 ETL_STRINGIFY(ETL_VERSION_MAJOR) u"." ETL_STRINGIFY(ETL_VERSION_MINOR) u"." ETL_STRINGIFY(ETL_VERSION_PATCH) diff --git a/library.json b/library.json index 9baacb26..de037bb3 100644 --- a/library.json +++ b/library.json @@ -1,13 +1,13 @@ { - "name": "Embedded Template Library", - "version": "19.3.5", + "name": "ETL Embedded Template Library", + "version": "19.3.6", "author s": { "name": "John Wellbelove", "email": "john.wellbelove@etlcpp.com" }, "homepage": "https://www.etlcpp.com/", "license": "MIT", - "description": "A C++ template library tailored for embedded systems.", + "description": "ETL. A C++ template library tailored for embedded systems.", "repository": { "type": "git", "url": "https://github.com/ETLCPP/etl.git" diff --git a/library.properties b/library.properties index a0d9a127..45f6c180 100644 --- a/library.properties +++ b/library.properties @@ -1,9 +1,9 @@ -name=Embedded Template Library -version=19.3.5 +name=Embedded Template Library ETL +version=19.3.6 author= John Wellbelove maintainer=John Wellbelove license=MIT -sentence=A C++ template library tailored for embedded systems. +sentence=ETL. A C++ template library tailored for embedded systems. paragraph= category=Other url=https://www.etlcpp.com/ diff --git a/support/Release notes.txt b/support/Release notes.txt index 7fe529ca..18bb0267 100644 --- a/support/Release notes.txt +++ b/support/Release notes.txt @@ -1,3 +1,7 @@ +=============================================================================== +19.3.6 +Arduino compatibility mods. + =============================================================================== 19.3.5 Change std::move to etl::move in etl::forward_list diff --git a/test/vs2019/etl.vcxproj b/test/vs2019/etl.vcxproj index 4c5a0dbf..554808e7 100644 --- a/test/vs2019/etl.vcxproj +++ b/test/vs2019/etl.vcxproj @@ -1240,6 +1240,7 @@ + @@ -1983,6 +1984,7 @@ + diff --git a/test/vs2019/etl.vcxproj.filters b/test/vs2019/etl.vcxproj.filters index 1d896976..20cf7365 100644 --- a/test/vs2019/etl.vcxproj.filters +++ b/test/vs2019/etl.vcxproj.filters @@ -85,6 +85,9 @@ {74399f00-a7a3-47e3-9b27-d01fb2b5ce87} + + {afc65d0e-d846-4e30-8723-06c8cefa3a36} + @@ -900,6 +903,9 @@ ETL\Utilities\Mutex + + ETL\Arduino + @@ -1510,6 +1516,9 @@ Resource Files + + ETL\Arduino + @@ -1548,4 +1557,4 @@ Resource Files\Images - + \ No newline at end of file