1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-24 13:21:23 +01:00

A bit lost

This commit is contained in:
peteGSX 2022-12-10 19:14:32 +10:00
parent 7bc0433197
commit 1d5897d2d2
3 changed files with 14 additions and 52 deletions

View File

@ -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

View File

@ -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

View File

@ -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