From 1d5897d2d22973e50252e91065ec2479f608fbea Mon Sep 17 00:00:00 2001 From: peteGSX Date: Sat, 10 Dec 2022 19:14:32 +1000 Subject: [PATCH] A bit lost --- EX-IOExpanderPinMaps.h | 13 ++++++----- IO_EXIOExpander.h | 48 ++++----------------------------------- myEX-IOExpander.example.h | 5 ++-- 3 files changed, 14 insertions(+), 52 deletions(-) diff --git a/EX-IOExpanderPinMaps.h b/EX-IOExpanderPinMaps.h index b4fed55..46d03a9 100644 --- a/EX-IOExpanderPinMaps.h +++ b/EX-IOExpanderPinMaps.h @@ -26,11 +26,12 @@ * Any modifications to this file will be overwritten by future software updates. */ -#define DEFAULT_NANO_DIGITAL_PINMAP new EXIODigitalPinMap(12,2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A6,A7) -#define DEFAULT_NANO_ANALOGUE_PINMAP new EXIOAnaloguePinMap(6,A0,A1,A2,A3,A6,A7) +#define DEFAULT_NANO_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13 +#define DEFAULT_NANO_ANALOGUE_PINMAP A0,A1,A2,A3,A6,A7 -#define DEFAULT_UNO_DIGITAL_PINMAP new EXIODigitalPinMap(12,2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A6,A7) -#define DEFAULT_UNO_ANALOGUE_PINMAP new EXIOAnaloguePinMap(4,A0,A1,A2,A3) +#define DEFAULT_UNO_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13 +#define DEFAULT_UNO_ANALOGUE_PINMAP A0,A1,A2,A3 -#define DEFAULT_MEGA_DIGITAL_PINMAP new EXIODigitalPinMap(12,2,3,4,5,6,7,8,9,10,11,12,13,A0,A1,A2,A3,A6,A7) -#define DEFAULT_MEGA_ANALOGUE_PINMAP new EXIOAnaloguePinMap(4,A0,A1,A2,A3) +#define DEFAULT_MEGA_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,22,23,24,25,26,27,28,29, \ + 30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49 +#define DEFAULT_MEGA_ANALOGUE_PINMAP A0,A1,A2,A3,A5,A6,A7,A8,A9,A10,A11,A12,A13,A14,A15 diff --git a/IO_EXIOExpander.h b/IO_EXIOExpander.h index 2157b79..0521ac7 100644 --- a/IO_EXIOExpander.h +++ b/IO_EXIOExpander.h @@ -27,8 +27,8 @@ * #include "IO_EX-IOExpander.h" * * void halSetup() { -* // EXIOExpander::create(vpin, num_vpins, i2c_address, digital_pinmap, analogue_pinmap); -* EXIOExpander::create(800, 18, 0x90, DEFAULT_NANO_DIGITAL_PINMAP, DEFAULT_NANO_ANALOGUE_PINMAP); +* // EXIOExpander::create(vpin, num_vpins, i2c_address); +* EXIOExpander::create(800, 18, 0x90); } */ @@ -44,58 +44,22 @@ #include "myEX-IOExpander.h" #endif -///////////////////////////////////////////////////////////////////////////////////////////////////// -/* - * EXIODigitalPinMap class for EX-IOExpander. - */ -class EXIODigitalPinMap { - public: - EXIODigitalPinMap(uint8_t numDigitalPins, uint8_t...); - EXIODigitalPinMap() = default; - - private: - EXIODigitalPinMap(uint8_t numDigitalPins, ...) { - _numDigitalPins = numDigitalPins; - uint8_t _digitalPinMap[_numDigitalPins]; - va_list _pinList; - va_start(_pinList, _numDigitalPins); - for (uint8_t pin = 0; pin < _numDigitalPins; pin++) { - _digitalPinMap[pin] = va_arg(_pinList, int); - } - va_end(_pinList); - } - - uint8_t _numDigitalPins; -}; - -///////////////////////////////////////////////////////////////////////////////////////////////////// -/* - * EXIOAnaloguePinMap class for EX-IOExpander. - */ -class EXIOAnaloguePinMap { - public: - EXIOAnaloguePinMap(uint8_t numAnaloguePins, ...); - EXIOAnaloguePinMap() = default; -}; - ///////////////////////////////////////////////////////////////////////////////////////////////////// /* * IODevice subclass for EX-IOExpander. */ class EXIOExpander : public IODevice { public: - static void create(VPIN vpin, int nPins, uint8_t i2cAddress, EXIODigitalPinMap digitalPinMap, EXIOAnaloguePinMap analoguePinMap) { - if (checkNoOverlap(vpin, nPins, i2cAddress)) new EXIOExpander(vpin, nPins, i2cAddress, digitalPinMap, analoguePinMap); + static void create(VPIN vpin, int nPins, uint8_t i2cAddress) { + if (checkNoOverlap(vpin, nPins, i2cAddress)) new EXIOExpander(vpin, nPins, i2cAddress); } private: // Constructor - EXIOExpander(VPIN firstVpin, int nPins, uint8_t i2cAddress, EXIODigitalPinMap digitalPinMap, EXIOAnaloguePinMap analoguePinMap) { + EXIOExpander(VPIN firstVpin, int nPins, uint8_t i2cAddress) { _firstVpin = firstVpin; _nPins = nPins; _i2cAddress = i2cAddress; - _digitalPinMap = digitalPinMap; - _analoguePinMap = analoguePinMap; addDevice(this); } @@ -117,8 +81,6 @@ private: } uint8_t _i2cAddress; - EXIODigitalPinMap _digitalPinMap; - EXIOAnaloguePinMap _analoguePinMap; enum { REG_EXIOINIT = 0x00, // Flag to initialise setup procedure diff --git a/myEX-IOExpander.example.h b/myEX-IOExpander.example.h index 3402c92..94e378e 100644 --- a/myEX-IOExpander.example.h +++ b/myEX-IOExpander.example.h @@ -16,8 +16,7 @@ #ifndef MYEX_IOEXPANDER_H #define MYEX_IOEXPANDER_H -#define MY_CUSTOM_NANO F("MY_NANO_PINMAP"), \ - new EXIODigitalPinMap(12,2,3,4,5,6,7,8,9,10,11,12,13) \ - new EXIOAnaloguePinMap(4,A0,A1,A2,A3) +#define MY_NANO_DIGITAL_PINMAP 2,3,4,5,6,7,8,9,10,11,12,13 +#define MY_NANO_ANALOGUE_PINMAP A0,A1,A2,A3 #endif \ No newline at end of file