1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-22 23:56:13 +01:00

EXRAIL use neopixel range instead of loop

This commit is contained in:
Asbelos 2024-09-20 12:13:21 +01:00
parent 3aabb51888
commit 2bbb5c1119
3 changed files with 28 additions and 25 deletions

View File

@ -1021,10 +1021,8 @@ void RMFT2::loop2() {
{ {
VPIN vpin=operand>0?operand:-operand; VPIN vpin=operand>0?operand:-operand;
auto count=getOperand(3); auto count=getOperand(3);
for (auto pix=vpin;pix<vpin+count;pix++) { killBlinkOnVpin(vpin,count);
killBlinkOnVpin(pix); IODevice::writeAnalogueRange(vpin,getOperand(1),operand>0,getOperand(2),count);
IODevice::writeAnalogue(pix,getOperand(1),operand>0,getOperand(2));
}
} }
break; 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 // This function is used when setting pins so that a SET or RESET
// will cause any blink task on that pin to terminate. // will cause any blink task on that pin to terminate.
// It will be compiled out of existence if no BLINK feature is used. // 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; if (!(compileFeatures & FEATURE_BLINK)) return;
RMFT2 * stoptask=loopTask; // stop when we get back to here
RMFT2 * task=loopTask; RMFT2 * task=loopTask;
VPIN lastPin=pin+count-1;
while(task) { while(task) {
auto nextTask=task->next;
if ( if (
(task->blinkState==blink_high || task->blinkState==blink_low) (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(); task->kill();
return; }
} task=nextTask;
task=task->next; if (task==stoptask) return;
if (task==loopTask) return;
} }
} }

View File

@ -220,7 +220,7 @@ private:
static LookList* LookListLoader(OPCODE op1, static LookList* LookListLoader(OPCODE op1,
OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL); OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL);
static uint16_t getOperand(int progCounter,byte n); 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 * loopTask;
static RMFT2 * pausingTask; static RMFT2 * pausingTask;
void delayMe(long millisecs); void delayMe(long millisecs);

View File

@ -49,34 +49,34 @@ static const FSH * guessI2CDeviceType(uint8_t address) {
if (address == 0x1A) if (address == 0x1A)
// 0x09-0x18 selectable, but for now handle the default // 0x09-0x18 selectable, but for now handle the default
return F("Piicodev 865/915MHz Transceiver"); return F("Piicodev 865/915MHz Transceiver");
else if (address == 0x1C) if (address == 0x1C)
return F("QMC6310 Magnetometer"); return F("QMC6310 Magnetometer");
else if (address >= 0x20 && address <= 0x26) if (address >= 0x20 && address <= 0x26)
return F("GPIO Expander"); return F("GPIO Expander");
else if (address == 0x27) if (address == 0x27)
return F("GPIO Expander or LCD Display"); return F("GPIO Expander or LCD Display");
else if (address == 0x29) if (address == 0x29)
return F("Time-of-flight sensor"); return F("Time-of-flight sensor");
else if (address == 0x34) if (address == 0x34)
return F("TCA8418 keypad scanner"); return F("TCA8418 keypad scanner");
else if (address >= 0x3c && address <= 0x3d) if (address >= 0x3c && address <= 0x3d)
// 0x3c can also be an HMC883L magnetometer // 0x3c can also be an HMC883L magnetometer
return F("OLED Display or HMC583L 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"); return F("SC16IS75x UART");
else if (address >= 0x48 && address <= 0x4f) if (address >= 0x48 && address <= 0x4f)
return F("Analogue Inputs or PWM"); return F("Analogue Inputs or PWM");
else if (address >= 0x40 && address <= 0x4f) if (address >= 0x40 && address <= 0x4f)
return F("PWM"); return F("PWM");
else if (address >= 0x50 && address <= 0x5f) if (address >= 0x50 && address <= 0x5f)
return F("EEPROM"); return F("EEPROM");
else if (address == 0x60) if (address >= 0x60 && address <= 0x68)
return F("Adafruit NeoPixel Driver"); return F("Adafruit NeoPixel Driver");
else if (address == 0x68) if (address == 0x68)
return F("Real-time clock"); return F("Real-time clock");
else if (address >= 0x70 && address <= 0x77) if (address >= 0x70 && address <= 0x77)
return F("I2C Mux"); return F("I2C Mux");
else // Unknown type
return F("?"); return F("?");
} }