1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-12-23 04:41:24 +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;
auto count=getOperand(3);
for (auto pix=vpin;pix<vpin+count;pix++) {
killBlinkOnVpin(pix);
IODevice::writeAnalogue(pix,getOperand(1),operand>0,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;
}
}

View File

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

View File

@ -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("?");
}