From 2bbb5c111907cab37e5c068dc18e084f404f2a2e Mon Sep 17 00:00:00 2001 From: Asbelos Date: Fri, 20 Sep 2024 12:13:21 +0100 Subject: [PATCH] EXRAIL use neopixel range instead of loop --- EXRAIL2.cpp | 23 +++++++++++++---------- EXRAIL2.h | 2 +- I2CManager.cpp | 28 ++++++++++++++-------------- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/EXRAIL2.cpp b/EXRAIL2.cpp index 84bdac4..d796d2a 100644 --- a/EXRAIL2.cpp +++ b/EXRAIL2.cpp @@ -1021,10 +1021,8 @@ void RMFT2::loop2() { { VPIN vpin=operand>0?operand:-operand; auto count=getOperand(3); - for (auto pix=vpin;pix0,getOperand(2)); - } + killBlinkOnVpin(vpin,count); + IODevice::writeAnalogueRange(vpin,getOperand(1),operand>0,getOperand(2),count); } break; @@ -1338,19 +1336,24 @@ void RMFT2::powerEvent(int16_t track, bool overload) { // This function is used when setting pins so that a SET or RESET // will cause any blink task on that pin to terminate. // It will be compiled out of existence if no BLINK feature is used. -void RMFT2::killBlinkOnVpin(VPIN pin) { +void RMFT2::killBlinkOnVpin(VPIN pin, uint16_t count) { if (!(compileFeatures & FEATURE_BLINK)) return; + RMFT2 * stoptask=loopTask; // stop when we get back to here RMFT2 * task=loopTask; + VPIN lastPin=pin+count-1; while(task) { + auto nextTask=task->next; if ( (task->blinkState==blink_high || task->blinkState==blink_low) - && task->blinkPin==pin) { + && task->blinkPin>=pin + && task->blinkPin<=lastPin + ) { + if (diag) DIAG(F("kill blink %d"),task->blinkPin,lastPin); task->kill(); - return; - } - task=task->next; - if (task==loopTask) return; + } + task=nextTask; + if (task==stoptask) return; } } diff --git a/EXRAIL2.h b/EXRAIL2.h index a816a16..ff45a69 100644 --- a/EXRAIL2.h +++ b/EXRAIL2.h @@ -220,7 +220,7 @@ private: static LookList* LookListLoader(OPCODE op1, OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL); static uint16_t getOperand(int progCounter,byte n); - static void killBlinkOnVpin(VPIN pin); + static void killBlinkOnVpin(VPIN pin,uint16_t count=1); static RMFT2 * loopTask; static RMFT2 * pausingTask; void delayMe(long millisecs); diff --git a/I2CManager.cpp b/I2CManager.cpp index d13e081..59f455f 100644 --- a/I2CManager.cpp +++ b/I2CManager.cpp @@ -49,34 +49,34 @@ static const FSH * guessI2CDeviceType(uint8_t address) { if (address == 0x1A) // 0x09-0x18 selectable, but for now handle the default return F("Piicodev 865/915MHz Transceiver"); - else if (address == 0x1C) + if (address == 0x1C) return F("QMC6310 Magnetometer"); - else if (address >= 0x20 && address <= 0x26) + if (address >= 0x20 && address <= 0x26) return F("GPIO Expander"); - else if (address == 0x27) + if (address == 0x27) return F("GPIO Expander or LCD Display"); - else if (address == 0x29) + if (address == 0x29) return F("Time-of-flight sensor"); - else if (address == 0x34) + if (address == 0x34) return F("TCA8418 keypad scanner"); - else if (address >= 0x3c && address <= 0x3d) + if (address >= 0x3c && address <= 0x3d) // 0x3c can also be an HMC883L magnetometer return F("OLED Display or HMC583L Magnetometer"); - else if (address >= 0x48 && address <= 0x57) // SC16IS752x UART detection + if (address >= 0x48 && address <= 0x57) // SC16IS752x UART detection return F("SC16IS75x UART"); - else if (address >= 0x48 && address <= 0x4f) + if (address >= 0x48 && address <= 0x4f) return F("Analogue Inputs or PWM"); - else if (address >= 0x40 && address <= 0x4f) + if (address >= 0x40 && address <= 0x4f) return F("PWM"); - else if (address >= 0x50 && address <= 0x5f) + if (address >= 0x50 && address <= 0x5f) return F("EEPROM"); - else if (address == 0x60) + if (address >= 0x60 && address <= 0x68) return F("Adafruit NeoPixel Driver"); - else if (address == 0x68) + if (address == 0x68) return F("Real-time clock"); - else if (address >= 0x70 && address <= 0x77) + if (address >= 0x70 && address <= 0x77) return F("I2C Mux"); - else + // Unknown type return F("?"); }