mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-30 11:36:13 +01:00
Throttle fix
This commit is contained in:
parent
54ef92085b
commit
257a81f969
6
DCC.cpp
6
DCC.cpp
|
@ -26,6 +26,7 @@ void DCC::setThrottle( uint16_t cab, uint8_t tSpeed, bool tDirection) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void DCC::setThrottle2( uint16_t cab, uint8_t tSpeed, bool tDirection) {
|
void DCC::setThrottle2( uint16_t cab, uint8_t tSpeed, bool tDirection) {
|
||||||
|
|
||||||
uint8_t b[5];
|
uint8_t b[5];
|
||||||
uint8_t nB = 0;
|
uint8_t nB = 0;
|
||||||
|
|
||||||
|
@ -34,12 +35,7 @@ void DCC::setThrottle2( uint16_t cab, uint8_t tSpeed, bool tDirection) {
|
||||||
|
|
||||||
b[nB++] = lowByte(cab);
|
b[nB++] = lowByte(cab);
|
||||||
b[nB++] = 0x3F; // 128-step speed control byte
|
b[nB++] = 0x3F; // 128-step speed control byte
|
||||||
if (tSpeed > 0)
|
|
||||||
b[nB++] = tSpeed + (tSpeed > 0) + tDirection * 128; // max speed is 126, but speed codes range from 2-127 (0=stop, 1=emergency stop)
|
b[nB++] = tSpeed + (tSpeed > 0) + tDirection * 128; // max speed is 126, but speed codes range from 2-127 (0=stop, 1=emergency stop)
|
||||||
else {
|
|
||||||
b[nB++] = 1;
|
|
||||||
tSpeed = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DCCWaveform::mainTrack.schedulePacket(b, nB, 0);
|
DCCWaveform::mainTrack.schedulePacket(b, nB, 0);
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
#include "Hardware.h"
|
#include "Hardware.h"
|
||||||
#include "Config.h"
|
#include "Config.h"
|
||||||
|
#include "DIAG.h"
|
||||||
|
|
||||||
void Hardware::init() {
|
void Hardware::init() {
|
||||||
pinMode(MAIN_POWER_PIN, OUTPUT);
|
pinMode(MAIN_POWER_PIN, OUTPUT);
|
||||||
|
@ -35,6 +36,7 @@ int Hardware::getCurrentMilliamps(bool isMainTrack) {
|
||||||
int pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN;
|
int pin = isMainTrack ? MAIN_SENSE_PIN : PROG_SENSE_PIN;
|
||||||
float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR;
|
float factor = isMainTrack ? MAIN_SENSE_FACTOR : PROG_SENSE_FACTOR;
|
||||||
int rawCurrent = analogRead(pin);
|
int rawCurrent = analogRead(pin);
|
||||||
|
// DIAG(F("\nCurrent on %d pin %d = %d"),isMainTrack,pin,rawCurrent);
|
||||||
return (int)(rawCurrent * factor);
|
return (int)(rawCurrent * factor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user