mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-12-25 05:31:24 +01:00
Brief start on PWM
This commit is contained in:
parent
4d31cd64a5
commit
e53ed7b46d
@ -59,8 +59,6 @@ private:
|
|||||||
_firstVpin = firstVpin;
|
_firstVpin = firstVpin;
|
||||||
_nPins = nPins;
|
_nPins = nPins;
|
||||||
_i2cAddress = i2cAddress;
|
_i2cAddress = i2cAddress;
|
||||||
_digitalPinBytes = (nPins+7)/8;
|
|
||||||
_digitalInputStates=(byte*) calloc(_digitalPinBytes,1);
|
|
||||||
addDevice(this);
|
addDevice(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,10 +68,13 @@ private:
|
|||||||
if (I2CManager.exists(_i2cAddress)) {
|
if (I2CManager.exists(_i2cAddress)) {
|
||||||
_command2Buffer[0] = EXIOINIT;
|
_command2Buffer[0] = EXIOINIT;
|
||||||
_command2Buffer[1] = _nPins;
|
_command2Buffer[1] = _nPins;
|
||||||
// Send config, if EXIOINITA returned, we're good, setup analogue input buffer, otherwise go offline
|
// Send config, if EXIOPINS returned, we're good, setup pin buffers, otherwise go offline
|
||||||
I2CManager.read(_i2cAddress, _receive2Buffer, 2, _command2Buffer, 2);
|
I2CManager.read(_i2cAddress, _receive3Buffer, 3, _command2Buffer, 2);
|
||||||
if (_receive2Buffer[0] == EXIOINITA) {
|
if (_receive3Buffer[0] == EXIOPINS) {
|
||||||
_numAnaloguePins = _receive2Buffer[1];
|
_numDigitalPins = _receive3Buffer[1];
|
||||||
|
_numAnaloguePins = _receive3Buffer[2];
|
||||||
|
_digitalPinBytes = (_numDigitalPins + 7)/8;
|
||||||
|
_digitalInputStates=(byte*) calloc(_digitalPinBytes,1);
|
||||||
_analoguePinBytes = _numAnaloguePins * 2;
|
_analoguePinBytes = _numAnaloguePins * 2;
|
||||||
_analogueInputStates = (byte*) calloc(_analoguePinBytes, 1);
|
_analogueInputStates = (byte*) calloc(_analoguePinBytes, 1);
|
||||||
_analoguePinMap = (uint8_t*) calloc(_numAnaloguePins, 1);
|
_analoguePinMap = (uint8_t*) calloc(_numAnaloguePins, 1);
|
||||||
@ -165,6 +166,11 @@ private:
|
|||||||
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
I2CManager.write(_i2cAddress, _digitalOutBuffer, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override {
|
||||||
|
int pin = vpin - _firstVpin;
|
||||||
|
DIAG(F("Write %d to pin %d, param 1 %d, param 2 %d"), value, pin, param1, param2);
|
||||||
|
}
|
||||||
|
|
||||||
void _display() override {
|
void _display() override {
|
||||||
DIAG(F("EX-IOExpander I2C:x%x v%d.%d.%d Vpins %d-%d %S"),
|
DIAG(F("EX-IOExpander I2C:x%x v%d.%d.%d Vpins %d-%d %S"),
|
||||||
_i2cAddress, _majorVer, _minorVer, _patchVer,
|
_i2cAddress, _majorVer, _minorVer, _patchVer,
|
||||||
@ -173,8 +179,8 @@ private:
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint8_t _i2cAddress;
|
uint8_t _i2cAddress;
|
||||||
|
uint8_t _numDigitalPins = 0;
|
||||||
uint8_t _numAnaloguePins = 0;
|
uint8_t _numAnaloguePins = 0;
|
||||||
uint8_t numDigitalPins = 0;
|
|
||||||
byte _digitalOutBuffer[3];
|
byte _digitalOutBuffer[3];
|
||||||
uint8_t _versionBuffer[3];
|
uint8_t _versionBuffer[3];
|
||||||
uint8_t _majorVer = 0;
|
uint8_t _majorVer = 0;
|
||||||
@ -186,7 +192,7 @@ private:
|
|||||||
uint8_t _analoguePinBytes = 0;
|
uint8_t _analoguePinBytes = 0;
|
||||||
byte _command1Buffer[1];
|
byte _command1Buffer[1];
|
||||||
byte _command2Buffer[2];
|
byte _command2Buffer[2];
|
||||||
byte _receive2Buffer[2];
|
byte _receive3Buffer[3];
|
||||||
uint8_t* _analoguePinMap;
|
uint8_t* _analoguePinMap;
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
@ -198,7 +204,8 @@ private:
|
|||||||
EXIOWRD = 0xE5, // Flag for digital write
|
EXIOWRD = 0xE5, // Flag for digital write
|
||||||
EXIORDD = 0xE6, // Flag to read digital input
|
EXIORDD = 0xE6, // Flag to read digital input
|
||||||
EXIOENAN = 0xE7, // Flag eo enable an analogue pin
|
EXIOENAN = 0xE7, // Flag eo enable an analogue pin
|
||||||
EXIOINITA = 0xE8, // Flag we're receiving analogue pin info
|
EXIOINITA = 0xE8, // Flag we're receiving analogue pin mappings
|
||||||
|
EXIOPINS = 0xE9, // Flag we're receiving pin counts for buffers
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -139,7 +139,7 @@ private:
|
|||||||
DIAG(F("Servo Write Vpin:%d Value:%d"), vpin, value);
|
DIAG(F("Servo Write Vpin:%d Value:%d"), vpin, value);
|
||||||
#endif
|
#endif
|
||||||
int pin = vpin - _firstVpin;
|
int pin = vpin - _firstVpin;
|
||||||
VPIN slavePin = vpin - _firstVpin + _firstSlavePin;
|
// VPIN slavePin = vpin - _firstVpin + _firstSlavePin;
|
||||||
if (value) value = 1;
|
if (value) value = 1;
|
||||||
|
|
||||||
struct ServoData *s = _servoData[pin];
|
struct ServoData *s = _servoData[pin];
|
||||||
|
Loading…
Reference in New Issue
Block a user