From 35f7ac3d77519fc260ac340d8ff7a67be1ee7d84 Mon Sep 17 00:00:00 2001 From: Asbelos Date: Tue, 11 Jan 2022 11:22:20 +0000 Subject: [PATCH] Teensy compatibility issues --- I2CManager_Wire.h | 10 ++++------ RMFT2.cpp | 2 +- SerialManager.cpp | 9 ++++++--- SerialManager.h | 4 ++-- version.h | 2 +- 5 files changed, 14 insertions(+), 13 deletions(-) diff --git a/I2CManager_Wire.h b/I2CManager_Wire.h index fb41f86..26deb74 100644 --- a/I2CManager_Wire.h +++ b/I2CManager_Wire.h @@ -98,22 +98,20 @@ uint8_t I2CManagerClass::read(uint8_t address, uint8_t readBuffer[], uint8_t rea * returned in the I2CRB as for the asynchronous version. ***************************************************************************/ void I2CManagerClass::queueRequest(I2CRB *req) { - uint8_t status; switch (req->operation) { case OPERATION_READ: - status = read(req->i2cAddress, req->readBuffer, req->readLen, NULL, 0, req); + req->status = read(req->i2cAddress, req->readBuffer, req->readLen, NULL, 0, req); break; case OPERATION_SEND: - status = write(req->i2cAddress, req->writeBuffer, req->writeLen, req); + req->status = write(req->i2cAddress, req->writeBuffer, req->writeLen, req); break; case OPERATION_SEND_P: - status = write_P(req->i2cAddress, req->writeBuffer, req->writeLen, req); + req->status = write_P(req->i2cAddress, req->writeBuffer, req->writeLen, req); break; case OPERATION_REQUEST: - status = read(req->i2cAddress, req->readBuffer, req->readLen, req->writeBuffer, req->writeLen, req); + req->status = read(req->i2cAddress, req->readBuffer, req->readLen, req->writeBuffer, req->writeLen, req); break; } - req->status = status; } /*************************************************************************** diff --git a/RMFT2.cpp b/RMFT2.cpp index 8fedce4..dac96a6 100644 --- a/RMFT2.cpp +++ b/RMFT2.cpp @@ -681,7 +681,7 @@ void RMFT2::loop2() { break; case OPCODE_IFRANDOM: // do block on random percentage - if (random(100)>=operand) if (!skipIfBlock()) return; + if ((int16_t)random(100)>=operand) if (!skipIfBlock()) return; break; case OPCODE_IFRESERVE: // do block if we successfully RERSERVE diff --git a/SerialManager.cpp b/SerialManager.cpp index 53c04c7..6fbdf61 100644 --- a/SerialManager.cpp +++ b/SerialManager.cpp @@ -22,26 +22,29 @@ #include "DCCEXParser.h" SerialManager * SerialManager::first=NULL; - SerialManager::SerialManager(HardwareSerial * myserial) { + SerialManager::SerialManager(Stream * myserial) { serial=myserial; next=first; first=this; bufferLength=0; - myserial->begin(115200); inCommandPayload=false; } void SerialManager::init() { #ifdef SERIAL3_COMMANDS + Serial3.begin(115200); new SerialManager(&Serial3); #endif #ifdef SERIAL2_COMMANDS + Serial2.begin(115200); new SerialManager(&Serial2); #endif #ifdef SERIAL1_COMMANDS + Serial1.begin(115200); new SerialManager(&Serial1); #endif - new SerialManager(&Serial); + Serial.begin(115200); + new SerialManager(&Serial); } void SerialManager::broadcast(RingStream * ring) { diff --git a/SerialManager.h b/SerialManager.h index 32960d5..fb58cba 100644 --- a/SerialManager.h +++ b/SerialManager.h @@ -37,10 +37,10 @@ public: private: static SerialManager * first; - SerialManager(HardwareSerial * myserial); + SerialManager(Stream * myserial); void loop2(); void broadcast2(RingStream * ring); - HardwareSerial * serial; + Stream * serial; SerialManager * next; byte bufferLength; byte buffer[COMMAND_BUFFER_SIZE]; diff --git a/version.h b/version.h index 1e9776c..01326c6 100644 --- a/version.h +++ b/version.h @@ -3,7 +3,7 @@ #include "StringFormatter.h" -#define VERSION "3.2.0 rc10" +#define VERSION "3.2.0 rc11" // 3.2.0 Major functional and non-functional changes. // New HAL added for I/O (digital and analogue inputs and outputs, servos etc). // Support for MCP23008, MCP23017 and PCF9584 I2C GPIO Extender modules.