mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-27 01:56:14 +01:00
Speedup SETFREQ
Avoid calling the DCC packets for setfreq macro.
This commit is contained in:
parent
d705626f4a
commit
a8b4e39733
14
DCC.cpp
14
DCC.cpp
|
@ -271,6 +271,20 @@ uint32_t DCC::getFunctionMap(int cab) {
|
||||||
return (reg<0)?0:speedTable[reg].functions;
|
return (reg<0)?0:speedTable[reg].functions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// saves DC frequency (0..3) in spare functions 29,30,31
|
||||||
|
void DCC::setDCFreq(int cab,byte freq) {
|
||||||
|
if (cab==0 || freq>3) return;
|
||||||
|
auto reg=lookupSpeedTable(cab,true);
|
||||||
|
// drop and replace F29,30,31 (top 3 bits)
|
||||||
|
auto newFunctions=speedTable[reg].functions & 0x1FFFFFFFUL;
|
||||||
|
if (freq==1) newFunctions |= (1UL<<29); // F29
|
||||||
|
else if (freq==2) newFunctions |= (1UL<<30); // F30
|
||||||
|
else if (freq==3) newFunctions |= (1UL<<31); // F31
|
||||||
|
if (newFunctions==speedTable[reg].functions) return; // no change
|
||||||
|
speedTable[reg].functions=newFunctions;
|
||||||
|
CommandDistributor::broadcastLoco(reg);
|
||||||
|
}
|
||||||
|
|
||||||
void DCC::setAccessory(int address, byte port, bool gate, byte onoff /*= 2*/) {
|
void DCC::setAccessory(int address, byte port, bool gate, byte onoff /*= 2*/) {
|
||||||
// onoff is tristate:
|
// onoff is tristate:
|
||||||
// 0 => send off packet
|
// 0 => send off packet
|
||||||
|
|
1
DCC.h
1
DCC.h
|
@ -70,6 +70,7 @@ public:
|
||||||
static void changeFn(int cab, int16_t functionNumber);
|
static void changeFn(int cab, int16_t functionNumber);
|
||||||
static int8_t getFn(int cab, int16_t functionNumber);
|
static int8_t getFn(int cab, int16_t functionNumber);
|
||||||
static uint32_t getFunctionMap(int cab);
|
static uint32_t getFunctionMap(int cab);
|
||||||
|
static void setDCFreq(int cab,byte freq);
|
||||||
static void updateGroupflags(byte &flags, int16_t functionNumber);
|
static void updateGroupflags(byte &flags, int16_t functionNumber);
|
||||||
static void setAccessory(int address, byte port, bool gate, byte onoff = 2);
|
static void setAccessory(int address, byte port, bool gate, byte onoff = 2);
|
||||||
static bool setExtendedAccessory(int16_t address, int16_t value, byte repeats=3);
|
static bool setExtendedAccessory(int16_t address, int16_t value, byte repeats=3);
|
||||||
|
|
36
EXRAIL2.cpp
36
EXRAIL2.cpp
|
@ -716,41 +716,7 @@ void RMFT2::loop2() {
|
||||||
|
|
||||||
case OPCODE_SETFREQ:
|
case OPCODE_SETFREQ:
|
||||||
// Frequency is default 0, or 1, 2,3
|
// Frequency is default 0, or 1, 2,3
|
||||||
//if (loco) DCC::setFn(loco,operand,true);
|
DCC::setDCFreq(loco,operand);
|
||||||
switch (operand) {
|
|
||||||
case 0: // default - all F-s off
|
|
||||||
if (loco) {
|
|
||||||
DCC::setFn(loco,29,false);
|
|
||||||
DCC::setFn(loco,30,false);
|
|
||||||
DCC::setFn(loco,31,false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
if (loco) {
|
|
||||||
DCC::setFn(loco,29,true);
|
|
||||||
DCC::setFn(loco,30,false);
|
|
||||||
DCC::setFn(loco,31,false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
if (loco) {
|
|
||||||
DCC::setFn(loco,29,false);
|
|
||||||
DCC::setFn(loco,30,true);
|
|
||||||
DCC::setFn(loco,31,false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
if (loco) {
|
|
||||||
DCC::setFn(loco,29,false);
|
|
||||||
DCC::setFn(loco,30,false);
|
|
||||||
DCC::setFn(loco,31,true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
; // do nothing
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OPCODE_RESUME:
|
case OPCODE_RESUME:
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.64"
|
#define VERSION "5.2.65"
|
||||||
|
// 5.2.65 - Speedup Exrail SETFREQ
|
||||||
// 5.2.64 - Bugfix: <0 PROG> updated to undo JOIN
|
// 5.2.64 - Bugfix: <0 PROG> updated to undo JOIN
|
||||||
// 5.2.63 - Implement WIFI_LED for ESP32, ESPduino32 and EX-CSB1, that is turned on when STA mode connects or AP mode is up
|
// 5.2.63 - Implement WIFI_LED for ESP32, ESPduino32 and EX-CSB1, that is turned on when STA mode connects or AP mode is up
|
||||||
// - Add BOOSTER_INPUT definitions for ESPduino32 and EX-CSB1 to config.example.h
|
// - Add BOOSTER_INPUT definitions for ESPduino32 and EX-CSB1 to config.example.h
|
||||||
|
|
Loading…
Reference in New Issue
Block a user