mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-26 09:36:13 +01:00
Merge branch 'devel' into devel-railcom2
This commit is contained in:
commit
0da9df648f
|
@ -577,7 +577,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
{
|
{
|
||||||
if (params > 1) break;
|
if (params > 1) break;
|
||||||
if (params==0) { // All
|
if (params==0) { // All
|
||||||
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::ON);
|
TrackManager::setTrackPower(TRACK_ALL, POWERMODE::ON);
|
||||||
}
|
}
|
||||||
if (params==1) {
|
if (params==1) {
|
||||||
if (p[0]=="MAIN"_hk) { // <1 MAIN>
|
if (p[0]=="MAIN"_hk) { // <1 MAIN>
|
||||||
|
@ -610,7 +610,7 @@ void DCCEXParser::parseOne(Print *stream, byte *com, RingStream * ringStream)
|
||||||
if (params > 1) break;
|
if (params > 1) break;
|
||||||
if (params==0) { // All
|
if (params==0) { // All
|
||||||
TrackManager::setJoin(false);
|
TrackManager::setJoin(false);
|
||||||
TrackManager::setTrackPower(TRACK_MODE_ALL, POWERMODE::OFF);
|
TrackManager::setTrackPower(TRACK_ALL, POWERMODE::OFF);
|
||||||
}
|
}
|
||||||
if (params==1) {
|
if (params==1) {
|
||||||
if (p[0]=="MAIN"_hk) { // <0 MAIN>
|
if (p[0]=="MAIN"_hk) { // <0 MAIN>
|
||||||
|
|
|
@ -70,9 +70,9 @@ HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5 - F446RE
|
||||||
defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
||||||
// Nucleo-144 boards don't have Serial1 defined by default
|
// Nucleo-144 boards don't have Serial1 defined by default
|
||||||
HardwareSerial Serial6(PG9, PG14); // Rx=PG9, Tx=PG14 -- USART6
|
HardwareSerial Serial6(PG9, PG14); // Rx=PG9, Tx=PG14 -- USART6
|
||||||
HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5
|
HardwareSerial Serial2(PD6, PD5); // Rx=PD6, Tx=PD5 -- UART2
|
||||||
#if !defined(ARDUINO_NUCLEO_F412ZG)
|
#if !defined(ARDUINO_NUCLEO_F412ZG) // F412ZG does not have UART5
|
||||||
HardwareSerial Serial2(PD6, PD5); // Rx=PD6, Tx=PD5 -- UART5
|
HardwareSerial Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5
|
||||||
#endif
|
#endif
|
||||||
// Serial3 is defined to use USART3 by default, but is in fact used as the diag console
|
// Serial3 is defined to use USART3 by default, but is in fact used as the diag console
|
||||||
// via the debugger on the Nucleo-144. It is therefore unavailable for other DCC-EX uses like WiFi, DFPlayer, etc.
|
// via the debugger on the Nucleo-144. It is therefore unavailable for other DCC-EX uses like WiFi, DFPlayer, etc.
|
||||||
|
@ -328,7 +328,7 @@ void DCCTimer::DCCEXanalogWriteFrequencyInternal(uint8_t pin, uint32_t frequency
|
||||||
if (pin_timer[pin] != NULL)
|
if (pin_timer[pin] != NULL)
|
||||||
{
|
{
|
||||||
pin_timer[pin]->setPWM(pin_channel[pin], pin, frequency, 0); // set frequency in Hertz, 0% dutycycle
|
pin_timer[pin]->setPWM(pin_channel[pin], pin, frequency, 0); // set frequency in Hertz, 0% dutycycle
|
||||||
DIAG(F("DCCEXanalogWriteFrequency::Pin %d on Timer %d, frequency %d"), pin, pin_channel[pin], frequency);
|
DIAG(F("DCCEXanalogWriteFrequency::Pin %d on Timer Channel %d, frequency %d"), pin, pin_channel[pin], frequency);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DIAG(F("DCCEXanalogWriteFrequency::failed to allocate HardwareTimer instance!"));
|
DIAG(F("DCCEXanalogWriteFrequency::failed to allocate HardwareTimer instance!"));
|
||||||
|
|
|
@ -63,6 +63,10 @@
|
||||||
// playing sounds with IO_I2CDFPlayer
|
// playing sounds with IO_I2CDFPlayer
|
||||||
#define PLAYSOUND ANOUT
|
#define PLAYSOUND ANOUT
|
||||||
|
|
||||||
|
// SEG7 is a helper to create ANOUT from a 7-segment request
|
||||||
|
#define SEG7(vpin,value,format) \
|
||||||
|
ANOUT(vpin,(value & 0xFFFF),TM1638::DF_##format,((uint32_t)value)>>16)
|
||||||
|
|
||||||
// helper macro to strip leading zeros off time inputs
|
// helper macro to strip leading zeros off time inputs
|
||||||
// (10#mins)%100)
|
// (10#mins)%100)
|
||||||
#define STRIP_ZERO(value) 10##value%100
|
#define STRIP_ZERO(value) 10##value%100
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
/*
|
/*
|
||||||
|
* © 2024 Morten "Doc" Nielsen
|
||||||
|
* © 2023-2024 Paul M. Antoine
|
||||||
* © 2022 Bruno Sanches
|
* © 2022 Bruno Sanches
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
* © 2020-2022 Harald Barth
|
* © 2020-2022 Harald Barth
|
||||||
* © 2020-2021 Chris Harlow
|
* © 2020-2024 Chris Harlow
|
||||||
* © 2020 Gregor Baues
|
* © 2020 Gregor Baues
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -36,9 +38,14 @@
|
||||||
MDNS mdns(udp);
|
MDNS mdns(udp);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
//extern void looptimer(unsigned long timeout, const FSH* message);
|
||||||
|
#define looptimer(a,b)
|
||||||
|
|
||||||
bool EthernetInterface::connected=false;
|
bool EthernetInterface::connected=false;
|
||||||
EthernetServer * EthernetInterface::server= nullptr;
|
EthernetServer * EthernetInterface::server= nullptr;
|
||||||
EthernetClient EthernetInterface::clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
EthernetClient EthernetInterface::clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
||||||
|
bool EthernetInterface::inUse[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
||||||
uint8_t EthernetInterface::buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv
|
uint8_t EthernetInterface::buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv
|
||||||
RingStream * EthernetInterface::outboundRing = nullptr;
|
RingStream * EthernetInterface::outboundRing = nullptr;
|
||||||
|
|
||||||
|
@ -47,12 +54,13 @@ RingStream * EthernetInterface::outboundRing = nullptr;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void EthernetInterface::setup() // STM32 VERSION
|
void EthernetInterface::setup()
|
||||||
{
|
{
|
||||||
DIAG(F("Ethernet begin"
|
DIAG(F("Ethernet starting"
|
||||||
#ifdef DO_MDNS
|
#ifdef DO_MDNS
|
||||||
" with mDNS"
|
" (with mDNS)"
|
||||||
#endif
|
#endif
|
||||||
|
" Please be patient, especially if no cable is connected!"
|
||||||
));
|
));
|
||||||
|
|
||||||
#ifdef STM32_ETHERNET
|
#ifdef STM32_ETHERNET
|
||||||
|
@ -116,6 +124,47 @@ void EthernetInterface::setup() // STM32 VERSION
|
||||||
connected=true;
|
connected=true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined (STM32_ETHERNET)
|
||||||
|
void EthernetInterface::acceptClient() { // STM32 version
|
||||||
|
auto client=server->available();
|
||||||
|
if (!client) return;
|
||||||
|
// check for existing client
|
||||||
|
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
|
||||||
|
if (inUse[socket] && client == clients[socket]) return;
|
||||||
|
|
||||||
|
// new client
|
||||||
|
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
|
||||||
|
{
|
||||||
|
if (!inUse[socket])
|
||||||
|
{
|
||||||
|
clients[socket] = client;
|
||||||
|
inUse[socket]=true;
|
||||||
|
if (Diag::ETHERNET)
|
||||||
|
DIAG(F("Ethernet: New client socket %d"), socket);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DIAG(F("Ethernet OVERFLOW"));
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
void EthernetInterface::acceptClient() { // non-STM32 version
|
||||||
|
auto client=server->accept();
|
||||||
|
if (!client) return;
|
||||||
|
auto socket=client.getSocketNumber();
|
||||||
|
clients[socket]=client;
|
||||||
|
inUse[socket]=true;
|
||||||
|
if (Diag::ETHERNET)
|
||||||
|
DIAG(F("Ethernet: New client socket %d"), socket);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void EthernetInterface::dropClient(byte socket)
|
||||||
|
{
|
||||||
|
clients[socket].stop();
|
||||||
|
inUse[socket]=false;
|
||||||
|
CommandDistributor::forget(socket);
|
||||||
|
if (Diag::ETHERNET) DIAG(F("Ethernet: Disconnect %d "), socket);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Main loop for the EthernetInterface
|
* @brief Main loop for the EthernetInterface
|
||||||
|
@ -124,7 +173,8 @@ void EthernetInterface::setup() // STM32 VERSION
|
||||||
void EthernetInterface::loop()
|
void EthernetInterface::loop()
|
||||||
{
|
{
|
||||||
if (!connected) return;
|
if (!connected) return;
|
||||||
|
looptimer(5000, F("E.loop"));
|
||||||
|
|
||||||
static bool warnedAboutLink=false;
|
static bool warnedAboutLink=false;
|
||||||
if (Ethernet.linkStatus() == LinkOFF){
|
if (Ethernet.linkStatus() == LinkOFF){
|
||||||
if (warnedAboutLink) return;
|
if (warnedAboutLink) return;
|
||||||
|
@ -132,7 +182,8 @@ void EthernetInterface::loop()
|
||||||
warnedAboutLink=true;
|
warnedAboutLink=true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
looptimer(5000, F("E.loop warn"));
|
||||||
|
|
||||||
// link status must be ok here
|
// link status must be ok here
|
||||||
if (warnedAboutLink) {
|
if (warnedAboutLink) {
|
||||||
DIAG(F("Ethernet link RESTORED"));
|
DIAG(F("Ethernet link RESTORED"));
|
||||||
|
@ -142,6 +193,8 @@ void EthernetInterface::loop()
|
||||||
#ifdef DO_MDNS
|
#ifdef DO_MDNS
|
||||||
// Always do this because we don't want traffic to intefere with being found!
|
// Always do this because we don't want traffic to intefere with being found!
|
||||||
mdns.run();
|
mdns.run();
|
||||||
|
looptimer(5000, F("E.mdns"));
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -161,50 +214,22 @@ void EthernetInterface::loop()
|
||||||
//DIAG(F("maintained"));
|
//DIAG(F("maintained"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
looptimer(5000, F("E.maintain"));
|
||||||
|
|
||||||
|
// get client from the server
|
||||||
|
acceptClient();
|
||||||
|
|
||||||
// get client from the server
|
// handle disconnected sockets because STM32 library doesnt
|
||||||
#if defined (STM32_ETHERNET)
|
// do the read==0 response.
|
||||||
// STM32Ethernet doesn't use accept(), just available()
|
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
|
||||||
auto client = server->available();
|
{
|
||||||
if (client) {
|
if (inUse[socket] && !clients[socket].connected()) dropClient(socket);
|
||||||
// check for new client
|
}
|
||||||
byte socket;
|
|
||||||
bool sockfound = false;
|
|
||||||
for (socket = 0; socket < MAX_SOCK_NUM; socket++)
|
|
||||||
{
|
|
||||||
if (client == clients[socket])
|
|
||||||
{
|
|
||||||
sockfound = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sockfound)
|
|
||||||
{ // new client
|
|
||||||
for (socket = 0; socket < MAX_SOCK_NUM; socket++)
|
|
||||||
{
|
|
||||||
if (!clients[socket])
|
|
||||||
{
|
|
||||||
clients[socket] = client;
|
|
||||||
sockfound=true;
|
|
||||||
if (Diag::ETHERNET)
|
|
||||||
DIAG(F("Ethernet: New client socket %d"), socket);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!sockfound) DIAG(F("new Ethernet OVERFLOW"));
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
auto client = server->accept();
|
|
||||||
if (client) clients[client.getSocketNumber()]=client;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
// check for incoming data from all possible clients
|
// check for incoming data from all possible clients
|
||||||
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
|
for (byte socket = 0; socket < MAX_SOCK_NUM; socket++)
|
||||||
{
|
{
|
||||||
if (!clients[socket]) continue; // socket is not in use
|
if (!inUse[socket]) continue; // socket is not in use
|
||||||
|
|
||||||
// read any bytes from this client
|
// read any bytes from this client
|
||||||
auto count = clients[socket].read(buffer, MAX_ETH_BUFFER);
|
auto count = clients[socket].read(buffer, MAX_ETH_BUFFER);
|
||||||
|
@ -216,14 +241,13 @@ void EthernetInterface::loop()
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet s=%d, c=%d b=:%e"), socket, count, buffer);
|
if (Diag::ETHERNET) DIAG(F("Ethernet s=%d, c=%d b=:%e"), socket, count, buffer);
|
||||||
// execute with data going directly back
|
// execute with data going directly back
|
||||||
CommandDistributor::parse(socket,buffer,outboundRing);
|
CommandDistributor::parse(socket,buffer,outboundRing);
|
||||||
|
//looptimer(5000, F("Ethloop2 parse"));
|
||||||
return; // limit the amount of processing that takes place within 1 loop() cycle.
|
return; // limit the amount of processing that takes place within 1 loop() cycle.
|
||||||
}
|
}
|
||||||
|
|
||||||
// count=0 The client has disconnected
|
// count=0 The client has disconnected
|
||||||
clients[socket].stop();
|
dropClient(socket);
|
||||||
CommandDistributor::forget(socket);
|
}
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet: disconnect %d "), socket);
|
|
||||||
}
|
|
||||||
|
|
||||||
WiThrottle::loop(outboundRing);
|
WiThrottle::loop(outboundRing);
|
||||||
|
|
||||||
|
@ -245,9 +269,11 @@ void EthernetInterface::loop()
|
||||||
tmpbuf[i] = outboundRing->read();
|
tmpbuf[i] = outboundRing->read();
|
||||||
}
|
}
|
||||||
tmpbuf[count]=0;
|
tmpbuf[count]=0;
|
||||||
if (Diag::ETHERNET) DIAG(F("Ethernet reply s=%d, c=%d, b:%e"),
|
if (inUse[socketOut]) {
|
||||||
|
if (Diag::ETHERNET) DIAG(F("Ethernet reply s=%d, c=%d, b:%e"),
|
||||||
socketOut,count,tmpbuf);
|
socketOut,count,tmpbuf);
|
||||||
clients[socketOut].write(tmpbuf,count);
|
clients[socketOut].write(tmpbuf,count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
/*
|
/*
|
||||||
|
* © 2023-2024 Paul M. Antoine
|
||||||
* © 2021 Neil McKechnie
|
* © 2021 Neil McKechnie
|
||||||
* © 2021 Mike S
|
* © 2021 Mike S
|
||||||
* © 2021 Fred Decker
|
* © 2021 Fred Decker
|
||||||
* © 2020-2021 Chris Harlow
|
* © 2020-2022 Harald Barth
|
||||||
|
* © 2020-2024 Chris Harlow
|
||||||
* © 2020 Gregor Baues
|
* © 2020 Gregor Baues
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -35,6 +37,7 @@
|
||||||
#if defined (ARDUINO_TEENSY41)
|
#if defined (ARDUINO_TEENSY41)
|
||||||
#include <NativeEthernet.h> //TEENSY Ethernet Treiber
|
#include <NativeEthernet.h> //TEENSY Ethernet Treiber
|
||||||
#include <NativeEthernetUdp.h>
|
#include <NativeEthernetUdp.h>
|
||||||
|
#define MAX_SOCK_NUM 4
|
||||||
#elif defined (ARDUINO_NUCLEO_F429ZI) || defined (ARDUINO_NUCLEO_F439ZI) || defined (ARDUINO_NUCLEO_F4X9ZI)
|
#elif defined (ARDUINO_NUCLEO_F429ZI) || defined (ARDUINO_NUCLEO_F439ZI) || defined (ARDUINO_NUCLEO_F4X9ZI)
|
||||||
#include <LwIP.h>
|
#include <LwIP.h>
|
||||||
// #include "STM32lwipopts.h"
|
// #include "STM32lwipopts.h"
|
||||||
|
@ -67,8 +70,12 @@ class EthernetInterface {
|
||||||
static bool connected;
|
static bool connected;
|
||||||
static EthernetServer * server;
|
static EthernetServer * server;
|
||||||
static EthernetClient clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
static EthernetClient clients[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
||||||
|
static bool inUse[MAX_SOCK_NUM]; // accept up to MAX_SOCK_NUM client connections at the same time; This depends on the chipset used on the Shield
|
||||||
static uint8_t buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv
|
static uint8_t buffer[MAX_ETH_BUFFER+1]; // buffer used by TCP for the recv
|
||||||
static RingStream * outboundRing;
|
static RingStream * outboundRing;
|
||||||
|
static void acceptClient();
|
||||||
|
static void dropClient(byte socketnum);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* © 2022-23 Paul M Antoine
|
* © 2022-24 Paul M Antoine
|
||||||
* © 2023, Neil McKechnie
|
* © 2023, Neil McKechnie
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
|
@ -38,8 +38,9 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
#if defined(I2C_USE_INTERRUPTS) && defined(ARDUINO_ARCH_STM32)
|
#if defined(I2C_USE_INTERRUPTS) && defined(ARDUINO_ARCH_STM32)
|
||||||
#if defined(ARDUINO_NUCLEO_F401RE) || defined(ARDUINO_NUCLEO_F411RE) || defined(ARDUINO_NUCLEO_F446RE) \
|
#if defined(ARDUINO_NUCLEO_F401RE) || defined(ARDUINO_NUCLEO_F411RE) || defined(ARDUINO_NUCLEO_F446RE) \
|
||||||
|| defined(ARDUINO_NUCLEO_F412ZG) || defined(ARDUINO_NUCLEO_F413ZH) \
|
|| defined(ARDUINO_NUCLEO_F412ZG) || defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F446ZE) \
|
||||||
|| defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F446ZE)
|
|| defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
||||||
|
|
||||||
// Assume I2C1 for now - default I2C bus on Nucleo-F411RE and likely all Nucleo-64
|
// Assume I2C1 for now - default I2C bus on Nucleo-F411RE and likely all Nucleo-64
|
||||||
// and Nucleo-144 variants
|
// and Nucleo-144 variants
|
||||||
I2C_TypeDef *s = I2C1;
|
I2C_TypeDef *s = I2C1;
|
||||||
|
@ -184,7 +185,7 @@ void I2CManagerClass::I2C_init()
|
||||||
GPIOB->OTYPER |= (1<<8) | (1<<9); // PB8 and PB9 set to open drain output capability
|
GPIOB->OTYPER |= (1<<8) | (1<<9); // PB8 and PB9 set to open drain output capability
|
||||||
GPIOB->OSPEEDR |= (3<<(8*2)) | (3<<(9*2)); // PB8 and PB9 set to High Speed mode
|
GPIOB->OSPEEDR |= (3<<(8*2)) | (3<<(9*2)); // PB8 and PB9 set to High Speed mode
|
||||||
GPIOB->PUPDR &= ~((3<<(8*2)) | (3<<(9*2))); // Clear all PUPDR bits for PB8 and PB9
|
GPIOB->PUPDR &= ~((3<<(8*2)) | (3<<(9*2))); // Clear all PUPDR bits for PB8 and PB9
|
||||||
GPIOB->PUPDR |= (1<<(8*2)) | (1<<(9*2)); // PB8 and PB9 set to pull-up capability
|
// GPIOB->PUPDR |= (1<<(8*2)) | (1<<(9*2)); // PB8 and PB9 set to pull-up capability
|
||||||
// Alt Function High register routing pins PB8 and PB9 for I2C1:
|
// Alt Function High register routing pins PB8 and PB9 for I2C1:
|
||||||
// Bits (3:2:1:0) = 0:1:0:0 --> AF4 for pin PB8
|
// Bits (3:2:1:0) = 0:1:0:0 --> AF4 for pin PB8
|
||||||
// Bits (7:6:5:4) = 0:1:0:0 --> AF4 for pin PB9
|
// Bits (7:6:5:4) = 0:1:0:0 --> AF4 for pin PB9
|
||||||
|
|
|
@ -571,6 +571,7 @@ protected:
|
||||||
#include "IO_TCA8418.h"
|
#include "IO_TCA8418.h"
|
||||||
#include "IO_NeoPixel.h"
|
#include "IO_NeoPixel.h"
|
||||||
#include "IO_I2CRailcom.h"
|
#include "IO_I2CRailcom.h"
|
||||||
|
#include "IO_TM1638.h"
|
||||||
|
|
||||||
|
|
||||||
#endif // iodevice_h
|
#endif // iodevice_h
|
||||||
|
|
217
IO_TM1638.cpp
Normal file
217
IO_TM1638.cpp
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
/*
|
||||||
|
* © 2024, Chris Harlow. All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is part of DCC++EX API
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* It is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* Credit to https://github.com/dvarrel/TM1638 for the basic formulae.*/
|
||||||
|
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "IODevice.h"
|
||||||
|
#include "DIAG.h"
|
||||||
|
|
||||||
|
|
||||||
|
const uint8_t HIGHFLASH _digits[16]={
|
||||||
|
0b00111111,0b00000110,0b01011011,0b01001111,
|
||||||
|
0b01100110,0b01101101,0b01111101,0b00000111,
|
||||||
|
0b01111111,0b01101111,0b01110111,0b01111100,
|
||||||
|
0b00111001,0b01011110,0b01111001,0b01110001
|
||||||
|
};
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
TM1638::TM1638(VPIN firstVpin, byte clk_pin,byte dio_pin,byte stb_pin){
|
||||||
|
_firstVpin = firstVpin;
|
||||||
|
_nPins = 8;
|
||||||
|
_clk_pin = clk_pin;
|
||||||
|
_stb_pin = stb_pin;
|
||||||
|
_dio_pin = dio_pin;
|
||||||
|
pinMode(clk_pin,OUTPUT);
|
||||||
|
pinMode(stb_pin,OUTPUT);
|
||||||
|
pinMode(dio_pin,OUTPUT);
|
||||||
|
_pulse = PULSE1_16;
|
||||||
|
|
||||||
|
_buttons=0;
|
||||||
|
_leds=0;
|
||||||
|
_lastLoop=micros();
|
||||||
|
addDevice(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TM1638::create(VPIN firstVpin, byte clk_pin,byte dio_pin,byte stb_pin) {
|
||||||
|
if (checkNoOverlap(firstVpin,8))
|
||||||
|
new TM1638(firstVpin, clk_pin,dio_pin,stb_pin);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::_begin() {
|
||||||
|
displayClear();
|
||||||
|
test();
|
||||||
|
_display();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TM1638::_loop(unsigned long currentMicros) {
|
||||||
|
if (currentMicros - _lastLoop > (1000000UL/LoopHz)) {
|
||||||
|
_buttons=getButtons();// Read the buttons
|
||||||
|
_lastLoop=currentMicros;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::_display() {
|
||||||
|
DIAG(F("TM1638 Configured on Vpins:%u-%u"), _firstVpin, _firstVpin+_nPins-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// digital read gets button state
|
||||||
|
int TM1638::_read(VPIN vpin) {
|
||||||
|
byte pin=vpin - _firstVpin;
|
||||||
|
bool result=bitRead(_buttons,pin);
|
||||||
|
// DIAG(F("TM1638 read (%d) buttons %x = %d"),pin,_buttons,result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// digital write sets led state
|
||||||
|
void TM1638::_write(VPIN vpin, int value) {
|
||||||
|
// TODO.. skip if no state change
|
||||||
|
writeLed(vpin - _firstVpin + 1,value!=0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Analog write sets digit displays
|
||||||
|
|
||||||
|
void TM1638::_writeAnalogue(VPIN vpin, int lowBytes, uint8_t mode, uint16_t highBytes) {
|
||||||
|
// mode is in DataFormat defined above.
|
||||||
|
byte formatLength=mode & 0x0F; // last 4 bits
|
||||||
|
byte formatType=mode & 0xF0; //
|
||||||
|
int8_t leftDigit=vpin-_firstVpin; // 0..7 from left
|
||||||
|
int8_t rightDigit=leftDigit+formatLength-1; // 0..7 from left
|
||||||
|
|
||||||
|
// loading is done right to left startDigit first
|
||||||
|
int8_t startDigit=7-rightDigit; // reverse as 7 on left
|
||||||
|
int8_t lastDigit=7-leftDigit; // reverse as 7 on left
|
||||||
|
uint32_t value=highBytes;
|
||||||
|
value<<=16;
|
||||||
|
value |= (uint16_t)lowBytes;
|
||||||
|
|
||||||
|
//DIAG(F("TM1638 fl=%d ft=%x sd=%d ld=%d v=%l vx=%X"),
|
||||||
|
// formatLength,formatType,startDigit,lastDigit,value,value);
|
||||||
|
while(startDigit<=lastDigit) {
|
||||||
|
switch (formatType) {
|
||||||
|
case _DF_DECIMAL:// decimal (leading zeros)
|
||||||
|
displayDig(startDigit,GETHIGHFLASH(_digits,(value%10)));
|
||||||
|
value=value/10;
|
||||||
|
break;
|
||||||
|
case _DF_HEX:// HEX (leading zeros)
|
||||||
|
displayDig(startDigit,GETHIGHFLASH(_digits,(value & 0x0F)));
|
||||||
|
value>>=4;
|
||||||
|
break;
|
||||||
|
case _DF_RAW:// Raw 7-segment pattern
|
||||||
|
displayDig(startDigit,value & 0xFF);
|
||||||
|
value>>=8;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
DIAG(F("TM1368 invalid mode 0x%x"),mode);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
startDigit++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t TM1638::getButtons(){
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, LOW);
|
||||||
|
writeData(INSTRUCTION_READ_KEY);
|
||||||
|
pinMode(_dio_pin, INPUT);
|
||||||
|
ArduinoPins::fastWriteDigital(_clk_pin, LOW);
|
||||||
|
uint8_t buttons=0;
|
||||||
|
for (uint8_t eachByte=0; eachByte<4;eachByte++) {
|
||||||
|
uint8_t value = 0;
|
||||||
|
for (uint8_t eachBit = 0; eachBit < 8; eachBit++) {
|
||||||
|
ArduinoPins::fastWriteDigital(_clk_pin, HIGH);
|
||||||
|
value |= ArduinoPins::fastReadDigital(_dio_pin) << eachBit;
|
||||||
|
ArduinoPins::fastWriteDigital(_clk_pin, LOW);
|
||||||
|
}
|
||||||
|
buttons |= value << eachByte;
|
||||||
|
delayMicroseconds(1);
|
||||||
|
}
|
||||||
|
pinMode(_dio_pin, OUTPUT);
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, HIGH);
|
||||||
|
return buttons;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TM1638::displayDig(uint8_t digitId, uint8_t pgfedcba){
|
||||||
|
if (digitId>7) return;
|
||||||
|
setDataInstruction(DISPLAY_TURN_ON | _pulse);
|
||||||
|
setDataInstruction(INSTRUCTION_WRITE_DATA| INSTRUCTION_ADDRESS_FIXED);
|
||||||
|
writeDataAt(FIRST_DISPLAY_ADDRESS+14-(digitId*2), pgfedcba);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::displayClear(){
|
||||||
|
setDataInstruction(DISPLAY_TURN_ON | _pulse);
|
||||||
|
setDataInstruction(INSTRUCTION_WRITE_DATA | INSTRUCTION_ADDRESS_FIXED);
|
||||||
|
for (uint8_t i=0;i<15;i+=2){
|
||||||
|
writeDataAt(FIRST_DISPLAY_ADDRESS+i,0x00);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::writeLed(uint8_t num,bool state){
|
||||||
|
if ((num<1) | (num>8)) return;
|
||||||
|
setDataInstruction(DISPLAY_TURN_ON | _pulse);
|
||||||
|
setDataInstruction(INSTRUCTION_WRITE_DATA | INSTRUCTION_ADDRESS_FIXED);
|
||||||
|
writeDataAt(FIRST_DISPLAY_ADDRESS + (num*2-1), state);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void TM1638::writeData(uint8_t data){
|
||||||
|
for (uint8_t i = 0; i < 8; i++) {
|
||||||
|
ArduinoPins::fastWriteDigital(_dio_pin, data & 1);
|
||||||
|
data >>= 1;
|
||||||
|
ArduinoPins::fastWriteDigital(_clk_pin, HIGH);
|
||||||
|
ArduinoPins::fastWriteDigital(_clk_pin, LOW);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::writeDataAt(uint8_t displayAddress, uint8_t data){
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, LOW);
|
||||||
|
writeData(displayAddress);
|
||||||
|
writeData(data);
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, HIGH);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::setDataInstruction(uint8_t dataInstruction){
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, LOW);
|
||||||
|
writeData(dataInstruction);
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, HIGH);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
void TM1638::test(){
|
||||||
|
DIAG(F("TM1638 test"));
|
||||||
|
uint8_t val=0;
|
||||||
|
for(uint8_t i=0;i<5;i++){
|
||||||
|
setDataInstruction(DISPLAY_TURN_ON | _pulse);
|
||||||
|
setDataInstruction(INSTRUCTION_WRITE_DATA| INSTRUCTION_ADDRESS_AUTO);
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, LOW);
|
||||||
|
writeData(FIRST_DISPLAY_ADDRESS);
|
||||||
|
for(uint8_t i=0;i<16;i++)
|
||||||
|
writeData(val);
|
||||||
|
ArduinoPins::fastWriteDigital(_stb_pin, HIGH);
|
||||||
|
delay(1000);
|
||||||
|
val = ~val;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
134
IO_TM1638.h
Normal file
134
IO_TM1638.h
Normal file
|
@ -0,0 +1,134 @@
|
||||||
|
/*
|
||||||
|
* © 2024, Chris Harlow. All rights reserved.
|
||||||
|
*
|
||||||
|
* This file is part of DCC++EX API
|
||||||
|
*
|
||||||
|
* This is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* It is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with CommandStation. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef IO_TM1638_h
|
||||||
|
#define IO_TM1638_h
|
||||||
|
#include <Arduino.h>
|
||||||
|
#include "IODevice.h"
|
||||||
|
#include "DIAG.h"
|
||||||
|
|
||||||
|
class TM1638 : public IODevice {
|
||||||
|
private:
|
||||||
|
|
||||||
|
uint8_t _buttons;
|
||||||
|
uint8_t _leds;
|
||||||
|
unsigned long _lastLoop;
|
||||||
|
static const int LoopHz=20;
|
||||||
|
|
||||||
|
static const byte
|
||||||
|
INSTRUCTION_WRITE_DATA=0x40,
|
||||||
|
INSTRUCTION_READ_KEY=0x42,
|
||||||
|
INSTRUCTION_ADDRESS_AUTO=0x40,
|
||||||
|
INSTRUCTION_ADDRESS_FIXED=0x44,
|
||||||
|
INSTRUCTION_NORMAL_MODE=0x40,
|
||||||
|
INSTRUCTION_TEST_MODE=0x48,
|
||||||
|
|
||||||
|
FIRST_DISPLAY_ADDRESS=0xC0,
|
||||||
|
|
||||||
|
DISPLAY_TURN_OFF=0x80,
|
||||||
|
DISPLAY_TURN_ON=0x88;
|
||||||
|
|
||||||
|
|
||||||
|
uint8_t _clk_pin;
|
||||||
|
uint8_t _stb_pin;
|
||||||
|
uint8_t _dio_pin;
|
||||||
|
uint8_t _pulse;
|
||||||
|
bool _isOn;
|
||||||
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
TM1638(VPIN firstVpin, byte clk_pin,byte dio_pin,byte stb_pin);
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum DigitFormat : byte {
|
||||||
|
// last 4 bits are length.
|
||||||
|
// DF_1.. DF_8 decimal
|
||||||
|
DF_1=0x01,DF_2=0x02,DF_3=0x03,DF_4=0x04,
|
||||||
|
DF_5=0x05,DF_6=0x06,DF_7=0x07,DF_8=0x08,
|
||||||
|
// DF_1X.. DF_8X HEX
|
||||||
|
DF_1X=0x11,DF_2X=0x12,DF_3X=0x13,DF_4X=0x14,
|
||||||
|
DF_5X=0x15,DF_6X=0x16,DF_7X=0x17,DF_8X=0x18,
|
||||||
|
// DF_1R .. DF_4R raw 7 segmnent data
|
||||||
|
// only 4 because HAL analogWrite only passes 4 bytes
|
||||||
|
DF_1R=0x21,DF_2R=0x22,DF_3R=0x23,DF_4R=0x24,
|
||||||
|
|
||||||
|
// bits of data conversion type (ored with length)
|
||||||
|
_DF_DECIMAL=0x00,// right adjusted decimal unsigned leading zeros
|
||||||
|
_DF_HEX=0x10, // right adjusted hex leading zeros
|
||||||
|
_DF_RAW=0x20 // bytes are raw 7-segment pattern (max length 4)
|
||||||
|
};
|
||||||
|
|
||||||
|
static void create(VPIN firstVpin, byte clk_pin,byte dio_pin,byte stb_pin);
|
||||||
|
|
||||||
|
// Functions overridden in IODevice
|
||||||
|
void _begin();
|
||||||
|
void _loop(unsigned long currentMicros) override ;
|
||||||
|
void _writeAnalogue(VPIN vpin, int value, uint8_t param1, uint16_t param2) override;
|
||||||
|
void _display() override ;
|
||||||
|
int _read(VPIN pin) override;
|
||||||
|
void _write(VPIN pin,int value) override;
|
||||||
|
|
||||||
|
// Device driving functions
|
||||||
|
private:
|
||||||
|
enum pulse_t {
|
||||||
|
PULSE1_16,
|
||||||
|
PULSE2_16,
|
||||||
|
PULSE4_16,
|
||||||
|
PULSE10_16,
|
||||||
|
PULSE11_16,
|
||||||
|
PULSE12_16,
|
||||||
|
PULSE13_16,
|
||||||
|
PULSE14_16
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn getButtons
|
||||||
|
* @return state of 8 buttons
|
||||||
|
*/
|
||||||
|
uint8_t getButtons();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn writeLed
|
||||||
|
* @brief put led ON or OFF
|
||||||
|
* @param num num of led(1-8)
|
||||||
|
* @param state (true or false)
|
||||||
|
*/
|
||||||
|
void writeLed(uint8_t num, bool state);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn displayDig
|
||||||
|
* @brief set 7 segment display + dot
|
||||||
|
* @param digitId num of digit(0-7)
|
||||||
|
* @param val value 8 bits
|
||||||
|
*/
|
||||||
|
void displayDig(uint8_t digitId, uint8_t pgfedcba);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fn displayClear
|
||||||
|
* @brief switch off all leds and segment display
|
||||||
|
*/
|
||||||
|
void displayClear();
|
||||||
|
void test();
|
||||||
|
void writeData(uint8_t data);
|
||||||
|
void writeDataAt(uint8_t displayAddress, uint8_t data);
|
||||||
|
void setDisplayMode(uint8_t displayMode);
|
||||||
|
void setDataInstruction(uint8_t dataInstruction);
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -54,4 +54,43 @@ static_assert("MAIN"_hk == 11339,"Keyword hasher error");
|
||||||
static_assert("SLOW"_hk == -17209,"Keyword hasher error");
|
static_assert("SLOW"_hk == -17209,"Keyword hasher error");
|
||||||
static_assert("SPEED28"_hk == -17064,"Keyword hasher error");
|
static_assert("SPEED28"_hk == -17064,"Keyword hasher error");
|
||||||
static_assert("SPEED128"_hk == 25816,"Keyword hasher error");
|
static_assert("SPEED128"_hk == 25816,"Keyword hasher error");
|
||||||
|
|
||||||
|
// Compile time converter from "abcd"_s7 to the 7 segment nearest equivalent
|
||||||
|
|
||||||
|
constexpr uint8_t seg7Digits[]={
|
||||||
|
0b00111111,0b00000110,0b01011011,0b01001111, // 0..3
|
||||||
|
0b01100110,0b01101101,0b01111101,0b00000111, // 4..7
|
||||||
|
0b01111111,0b01101111 // 8..9
|
||||||
|
};
|
||||||
|
|
||||||
|
constexpr uint8_t seg7Letters[]={
|
||||||
|
0b01110111,0b01111100,0b00111001,0b01011110, // ABCD
|
||||||
|
0b01111001,0b01110001,0b00111101,0b01110110, // EFGH
|
||||||
|
0b00000100,0b00011110,0b01110010,0b00111000, //IJKL
|
||||||
|
0b01010101,0b01010100,0b01011100,0b01110011, // MNOP
|
||||||
|
0b10111111,0b01010000,0b01101101,0b01111000, // QRST
|
||||||
|
0b00111110,0b00011100,0b01101010,0b01001001, //UVWX
|
||||||
|
0b01100110,0b01011011 //YZ
|
||||||
|
};
|
||||||
|
constexpr uint8_t seg7Space=0b00000000;
|
||||||
|
constexpr uint8_t seg7Minus=0b01000000;
|
||||||
|
constexpr uint8_t seg7Equals=0b01001000;
|
||||||
|
|
||||||
|
|
||||||
|
constexpr uint32_t CompiletimeSeg7(const char * sv, uint32_t running, size_t rlen) {
|
||||||
|
return (*sv==0 || rlen==0) ? running << (8*rlen) : CompiletimeSeg7(sv+1,
|
||||||
|
(*sv >= '0' && *sv <= '9') ? (running<<8) | seg7Digits[*sv-'0'] :
|
||||||
|
(*sv >= 'A' && *sv <= 'Z') ? (running<<8) | seg7Letters[*sv-'A'] :
|
||||||
|
(*sv >= 'a' && *sv <= 'z') ? (running<<8) | seg7Letters[*sv-'a'] :
|
||||||
|
(*sv == '-') ? (running<<8) | seg7Minus :
|
||||||
|
(*sv == '=') ? (running<<8) | seg7Equals :
|
||||||
|
(running<<8) | seg7Space,
|
||||||
|
rlen-1
|
||||||
|
); //
|
||||||
|
}
|
||||||
|
|
||||||
|
constexpr uint32_t operator""_s7(const char * keyword, size_t len)
|
||||||
|
{
|
||||||
|
return CompiletimeSeg7(keyword,0*len,4);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
|
@ -576,7 +576,7 @@ void MotorDriver::checkPowerOverload(bool useProgLimit, byte trackno) {
|
||||||
DIAG(F("TRACK %c ALERT FAULT"), trackno + 'A');
|
DIAG(F("TRACK %c ALERT FAULT"), trackno + 'A');
|
||||||
}
|
}
|
||||||
setPower(POWERMODE::ALERT);
|
setPower(POWERMODE::ALERT);
|
||||||
if ((trackMode & TRACK_MODE_AUTOINV) && (trackMode & (TRACK_MODE_MAIN|TRACK_MODE_EXT|TRACK_MODE_BOOST))){
|
if ((trackMode & TRACK_MODIFIER_AUTO) && (trackMode & (TRACK_MODE_MAIN|TRACK_MODE_EXT|TRACK_MODE_BOOST))){
|
||||||
DIAG(F("TRACK %c INVERT"), trackno + 'A');
|
DIAG(F("TRACK %c INVERT"), trackno + 'A');
|
||||||
invertOutput();
|
invertOutput();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,21 +29,33 @@
|
||||||
#include <wiring_private.h>
|
#include <wiring_private.h>
|
||||||
|
|
||||||
// use powers of two so we can do logical and/or on the track modes in if clauses.
|
// use powers of two so we can do logical and/or on the track modes in if clauses.
|
||||||
// RACK_MODE_DCX is (TRACK_MODE_DC|TRACK_MODE_INV)
|
// For example TRACK_MODE_DC_INV is (TRACK_MODE_DC|TRACK_MODIFIER_INV)
|
||||||
template<class T> inline T operator~ (T a) { return (T)~(int)a; }
|
template<class T> inline T operator~ (T a) { return (T)~(int)a; }
|
||||||
template<class T> inline T operator| (T a, T b) { return (T)((int)a | (int)b); }
|
template<class T> inline T operator| (T a, T b) { return (T)((int)a | (int)b); }
|
||||||
template<class T> inline T operator& (T a, T b) { return (T)((int)a & (int)b); }
|
template<class T> inline T operator& (T a, T b) { return (T)((int)a & (int)b); }
|
||||||
template<class T> inline T operator^ (T a, T b) { return (T)((int)a ^ (int)b); }
|
template<class T> inline T operator^ (T a, T b) { return (T)((int)a ^ (int)b); }
|
||||||
enum TRACK_MODE : byte {TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PROG = 4,
|
enum TRACK_MODE : byte {
|
||||||
TRACK_MODE_DC = 8, TRACK_MODE_EXT = 16,
|
// main modes
|
||||||
|
TRACK_MODE_NONE = 1, TRACK_MODE_MAIN = 2, TRACK_MODE_PROG = 4,
|
||||||
|
TRACK_MODE_DC = 8, TRACK_MODE_EXT = 16,
|
||||||
|
// modifiers
|
||||||
|
TRACK_MODIFIER_INV = 64, TRACK_MODIFIER_AUTO = 128,
|
||||||
#ifdef ARDUINO_ARCH_ESP32
|
#ifdef ARDUINO_ARCH_ESP32
|
||||||
TRACK_MODE_BOOST = 32,
|
TRACK_MODE_BOOST = 32,
|
||||||
|
TRACK_MODE_BOOST_INV = TRACK_MODE_BOOST|TRACK_MODIFIER_INV,
|
||||||
|
TRACK_MODE_BOOST_AUTO = TRACK_MODE_BOOST|TRACK_MODIFIER_AUTO,
|
||||||
#else
|
#else
|
||||||
TRACK_MODE_BOOST = 0,
|
TRACK_MODE_BOOST = 0,
|
||||||
|
TRACK_MODE_BOOST_INV = 0,
|
||||||
|
TRACK_MODE_BOOST_AUTO = 0,
|
||||||
#endif
|
#endif
|
||||||
TRACK_MODE_ALL = TRACK_MODE_MAIN|TRACK_MODE_PROG|TRACK_MODE_DC|TRACK_MODE_EXT|TRACK_MODE_BOOST,
|
// derived modes; TRACK_ALL is calles that so it does not match TRACK_MODE_*
|
||||||
TRACK_MODE_INV = 64,
|
TRACK_ALL = TRACK_MODE_MAIN|TRACK_MODE_PROG|TRACK_MODE_DC|TRACK_MODE_EXT|TRACK_MODE_BOOST,
|
||||||
TRACK_MODE_DCX = TRACK_MODE_DC|TRACK_MODE_INV, TRACK_MODE_AUTOINV = 128};
|
TRACK_MODE_MAIN_INV = TRACK_MODE_MAIN|TRACK_MODIFIER_INV,
|
||||||
|
TRACK_MODE_MAIN_AUTO = TRACK_MODE_MAIN|TRACK_MODIFIER_AUTO,
|
||||||
|
TRACK_MODE_DC_INV = TRACK_MODE_DC|TRACK_MODIFIER_INV,
|
||||||
|
TRACK_MODE_DCX = TRACK_MODE_DC_INV // DCX is other name for historical reasons
|
||||||
|
};
|
||||||
|
|
||||||
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
|
#define setHIGH(fastpin) *fastpin.inout |= fastpin.maskHIGH
|
||||||
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
|
#define setLOW(fastpin) *fastpin.inout &= fastpin.maskLOW
|
||||||
|
@ -261,7 +273,7 @@ class MotorDriver {
|
||||||
#endif
|
#endif
|
||||||
inline void setMode(TRACK_MODE m) {
|
inline void setMode(TRACK_MODE m) {
|
||||||
trackMode = m;
|
trackMode = m;
|
||||||
invertOutput(trackMode & TRACK_MODE_INV);
|
invertOutput(trackMode & TRACK_MODIFIER_INV);
|
||||||
};
|
};
|
||||||
inline void invertOutput() { // toggles output inversion
|
inline void invertOutput() { // toggles output inversion
|
||||||
invertPhase = !invertPhase;
|
invertPhase = !invertPhase;
|
||||||
|
|
|
@ -75,11 +75,19 @@
|
||||||
#define SAMD_STANDARD_MOTOR_SHIELD STANDARD_MOTOR_SHIELD
|
#define SAMD_STANDARD_MOTOR_SHIELD STANDARD_MOTOR_SHIELD
|
||||||
#define STM32_STANDARD_MOTOR_SHIELD STANDARD_MOTOR_SHIELD
|
#define STM32_STANDARD_MOTOR_SHIELD STANDARD_MOTOR_SHIELD
|
||||||
|
|
||||||
|
#if defined(ARDUINO_NUCLEO_F429ZI) || defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
||||||
|
// EX 8874 based shield connected to a 3V3 system with 12-bit (4096) ADC
|
||||||
|
// The Ethernet capable STM32 models cannot use Channel B BRAKE on D8, and must use the ALT pin of D6,
|
||||||
|
// AND cannot use Channel B PWN on D11, but must use the ALT pin of D5
|
||||||
|
#define EX8874_SHIELD F("EX8874"), \
|
||||||
|
new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 1.27, 5000, A4), \
|
||||||
|
new MotorDriver( 5, 13, UNUSED_PIN, 6, A1, 1.27, 5000, A5)
|
||||||
|
#else
|
||||||
// EX 8874 based shield connected to a 3V3 system with 12-bit (4096) ADC
|
// EX 8874 based shield connected to a 3V3 system with 12-bit (4096) ADC
|
||||||
#define EX8874_SHIELD F("EX8874"), \
|
#define EX8874_SHIELD F("EX8874"), \
|
||||||
new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 1.27, 5000, A4), \
|
new MotorDriver( 3, 12, UNUSED_PIN, 9, A0, 1.27, 5000, A4), \
|
||||||
new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.27, 5000, A5)
|
new MotorDriver(11, 13, UNUSED_PIN, 8, A1, 1.27, 5000, A5)
|
||||||
|
#endif
|
||||||
|
|
||||||
#elif defined(ARDUINO_ARCH_ESP32)
|
#elif defined(ARDUINO_ARCH_ESP32)
|
||||||
// STANDARD shield on an ESPDUINO-32 (ESP32 in Uno form factor). The shield must be eiter the
|
// STANDARD shield on an ESPDUINO-32 (ESP32 in Uno form factor). The shield must be eiter the
|
||||||
|
|
84
Release_Notes/TM1638.md
Normal file
84
Release_Notes/TM1638.md
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
## TM1638 ##
|
||||||
|
|
||||||
|
The TM1638 board provides a very cheap way of implementing 8 buttons, 8 leds and an 8 digit 7segment display in a package requiring just 5 Dupont wires (vcc, gnd + 3 GPIO pins) from the command station without soldering.
|
||||||
|
|
||||||
|
|
||||||
|
This is ideal for prototyping and testing, simulating sensors and signals, displaying states etc. For a built layout, this could provide a control for things that are not particularly suited to throttle 'route' buttons, perhaps lineside automations or fiddle yard lane selection.
|
||||||
|
|
||||||
|
By adding a simple HAL statement to myAutomation.h it creates 8 buttons/sensors and 8 leds.
|
||||||
|
|
||||||
|
`HAL(TM1638,500,29,31,33)`
|
||||||
|
Creates VPINs 500-507 And desscribes the GPIO pins used to connect the clk,dio,stb pins on the TM1638 board.
|
||||||
|
|
||||||
|
Setting each of the VPINs will control the associated LED (using for example SET, RESET or BLINK in Exrail or `<z 500> <z -501> from a command).
|
||||||
|
|
||||||
|
Unlike most pins, you can also read the same pin number and get the button state, using Exrail IF/AT/ONBUTTON etc.
|
||||||
|
|
||||||
|
For example:
|
||||||
|
`
|
||||||
|
HAL(TM1638,500,29,31,33)
|
||||||
|
`
|
||||||
|
All the folowing examples assume you are using VPIN 500 as the first, leftmost, led/button on the TM1638 board.
|
||||||
|
|
||||||
|
|
||||||
|
`ONBUTTON(500)
|
||||||
|
SET(500) // light the first led
|
||||||
|
BLINK(501,500,500) // blink the second led
|
||||||
|
SETLOCO(3) FWD(50) // set a loco going
|
||||||
|
AT(501) STOP // press second button to stop
|
||||||
|
RESET(500) RESET(501) // turn leds off
|
||||||
|
DONE
|
||||||
|
`
|
||||||
|
|
||||||
|
Buttons behave like any other sensor, so using `<S 500 500 1>` will cause the command station to issue `<Q 500>` and `<q 500>` messages when the first button is pressed or released.
|
||||||
|
|
||||||
|
Exrail `JMRI_SENSOR(500,8)` will create `<S` commands for all 8 buttons.
|
||||||
|
|
||||||
|
## Using the 7 Segment display ##
|
||||||
|
|
||||||
|
The 8 digit display can be treated as 8 separate digits (left most being the same VPIN as the leftmost button and led) or be written to in sections of any length. Writing uses the existing analogue interface to the common HAL but is awkward to use directly. To make this easier from Exrail, a SEG7 macro provides a remapping to the ANOUT facility that makes more sense.
|
||||||
|
|
||||||
|
SEG7(vpin,value,format)
|
||||||
|
|
||||||
|
The vpin determins which digit to start writing at.
|
||||||
|
The value can be a 32bit unsigned integer but is interpreted differentlky according to the format.
|
||||||
|
|
||||||
|
Format values:
|
||||||
|
1..8 give the length (number of display digits) to fill, and defaults to decimal number with leading zeros.
|
||||||
|
|
||||||
|
1X..8X give the length but display in hex.
|
||||||
|
|
||||||
|
1R..4R treats each byte of the value as raw 7-segment patterns so that it can write letters and symbols using any compination of the 7segments and deciml point.
|
||||||
|
|
||||||
|
There is a useful description here:
|
||||||
|
https://jetpackacademy.com/wp-content/uploads/2018/06/TM1638_cheat_sheet_download.pdf
|
||||||
|
|
||||||
|
|
||||||
|
e.g. SEG7(500,3,4)
|
||||||
|
writes 0003 to first 4 digits of the display
|
||||||
|
SEG7(504,0xcafe,4X)
|
||||||
|
writes CAFE to the last 4 digits
|
||||||
|
SEG7(500,0xdeadbeef,8X)
|
||||||
|
writes dEAdbEEF to all 8 digits.
|
||||||
|
|
||||||
|
Writing raw segment patters requires knowledge of the bit pattern to segment relationship:
|
||||||
|
` 0
|
||||||
|
== 0 ==
|
||||||
|
5| | 1
|
||||||
|
== 6 ==
|
||||||
|
4 | | 2
|
||||||
|
== 3 ==
|
||||||
|
7=decimal point
|
||||||
|
|
||||||
|
Thus Letter A is segments 6 5 4 2 1 0, in bits that is (0 bit on right)
|
||||||
|
0b01110111 or 0x77
|
||||||
|
This is not easy to do my hand and thus a new string type suffix has been introduced to make simple text messages. Note that the HAL interface only has width for 32 bits which is only 4 symbols so writing 8 digits requires two calls.
|
||||||
|
|
||||||
|
e.g. SEG7(500,"Hell"_s7,4R) SEG7(504,"o"_s7,4R)
|
||||||
|
DELAY(1000)
|
||||||
|
SEG7(500,"Worl"_s7,4R) SEG7(504,"d"_s7,4R)
|
||||||
|
|
||||||
|
Note that some letters like k,m,v,x do not have particularly readable 7-segment representations.
|
||||||
|
|
||||||
|
Credit to https://github.com/dvarrel/TM1638 for the basic formulae.
|
||||||
|
|
|
@ -151,8 +151,8 @@ void TrackManager::setDCCSignal( bool on) {
|
||||||
HAVE_PORTD(shadowPORTD=PORTD);
|
HAVE_PORTD(shadowPORTD=PORTD);
|
||||||
HAVE_PORTE(shadowPORTE=PORTE);
|
HAVE_PORTE(shadowPORTE=PORTE);
|
||||||
HAVE_PORTF(shadowPORTF=PORTF);
|
HAVE_PORTF(shadowPORTF=PORTF);
|
||||||
HAVE_PORTG(shadowPORTF=PORTG);
|
HAVE_PORTG(shadowPORTG=PORTG);
|
||||||
HAVE_PORTH(shadowPORTF=PORTH);
|
HAVE_PORTH(shadowPORTH=PORTH);
|
||||||
APPLY_BY_MODE(TRACK_MODE_MAIN,setSignal(on));
|
APPLY_BY_MODE(TRACK_MODE_MAIN,setSignal(on));
|
||||||
HAVE_PORTA(PORTA=shadowPORTA);
|
HAVE_PORTA(PORTA=shadowPORTA);
|
||||||
HAVE_PORTB(PORTB=shadowPORTB);
|
HAVE_PORTB(PORTB=shadowPORTB);
|
||||||
|
@ -160,8 +160,8 @@ void TrackManager::setDCCSignal( bool on) {
|
||||||
HAVE_PORTD(PORTD=shadowPORTD);
|
HAVE_PORTD(PORTD=shadowPORTD);
|
||||||
HAVE_PORTE(PORTE=shadowPORTE);
|
HAVE_PORTE(PORTE=shadowPORTE);
|
||||||
HAVE_PORTF(PORTF=shadowPORTF);
|
HAVE_PORTF(PORTF=shadowPORTF);
|
||||||
HAVE_PORTG(shadowPORTF=PORTG);
|
HAVE_PORTG(PORTG=shadowPORTG);
|
||||||
HAVE_PORTH(shadowPORTF=PORTH);
|
HAVE_PORTH(PORTH=shadowPORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setPROGSignal(), called from interrupt context
|
// setPROGSignal(), called from interrupt context
|
||||||
|
@ -173,8 +173,8 @@ void TrackManager::setPROGSignal( bool on) {
|
||||||
HAVE_PORTD(shadowPORTD=PORTD);
|
HAVE_PORTD(shadowPORTD=PORTD);
|
||||||
HAVE_PORTE(shadowPORTE=PORTE);
|
HAVE_PORTE(shadowPORTE=PORTE);
|
||||||
HAVE_PORTF(shadowPORTF=PORTF);
|
HAVE_PORTF(shadowPORTF=PORTF);
|
||||||
HAVE_PORTG(shadowPORTF=PORTG);
|
HAVE_PORTG(shadowPORTG=PORTG);
|
||||||
HAVE_PORTH(shadowPORTF=PORTH);
|
HAVE_PORTH(shadowPORTH=PORTH);
|
||||||
APPLY_BY_MODE(TRACK_MODE_PROG,setSignal(on));
|
APPLY_BY_MODE(TRACK_MODE_PROG,setSignal(on));
|
||||||
HAVE_PORTA(PORTA=shadowPORTA);
|
HAVE_PORTA(PORTA=shadowPORTA);
|
||||||
HAVE_PORTB(PORTB=shadowPORTB);
|
HAVE_PORTB(PORTB=shadowPORTB);
|
||||||
|
@ -182,8 +182,8 @@ void TrackManager::setPROGSignal( bool on) {
|
||||||
HAVE_PORTD(PORTD=shadowPORTD);
|
HAVE_PORTD(PORTD=shadowPORTD);
|
||||||
HAVE_PORTE(PORTE=shadowPORTE);
|
HAVE_PORTE(PORTE=shadowPORTE);
|
||||||
HAVE_PORTF(PORTF=shadowPORTF);
|
HAVE_PORTF(PORTF=shadowPORTF);
|
||||||
HAVE_PORTG(shadowPORTF=PORTG);
|
HAVE_PORTG(PORTG=shadowPORTG);
|
||||||
HAVE_PORTH(shadowPORTF=PORTH);
|
HAVE_PORTH(PORTH=shadowPORTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
// setDCSignal(), called from normal context
|
// setDCSignal(), called from normal context
|
||||||
|
@ -389,11 +389,15 @@ bool TrackManager::parseEqualSign(Print *stream, int16_t params, int16_t p[])
|
||||||
if (params>1 && (p[0]<0 || p[0]>=MAX_TRACKS))
|
if (params>1 && (p[0]<0 || p[0]>=MAX_TRACKS))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (params==2 && p[1]=="MAIN"_hk) // <= id MAIN>
|
if (params==2 && p[1]=="MAIN"_hk) // <= id MAIN>
|
||||||
return setTrackMode(p[0],TRACK_MODE_MAIN);
|
return setTrackMode(p[0],TRACK_MODE_MAIN);
|
||||||
|
if (params==2 && p[1]=="MAIN_INV"_hk) // <= id MAIN_INV>
|
||||||
|
return setTrackMode(p[0],TRACK_MODE_MAIN_INV);
|
||||||
|
if (params==2 && p[1]=="MAIN_AUTO"_hk) // <= id MAIN_AUTO>
|
||||||
|
return setTrackMode(p[0],TRACK_MODE_MAIN_AUTO);
|
||||||
|
|
||||||
#ifndef DISABLE_PROG
|
#ifndef DISABLE_PROG
|
||||||
if (params==2 && p[1]=="PROG"_hk) // <= id PROG>
|
if (params==2 && p[1]=="PROG"_hk) // <= id PROG>
|
||||||
return setTrackMode(p[0],TRACK_MODE_PROG);
|
return setTrackMode(p[0],TRACK_MODE_PROG);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -404,20 +408,27 @@ bool TrackManager::parseEqualSign(Print *stream, int16_t params, int16_t p[])
|
||||||
return setTrackMode(p[0],TRACK_MODE_EXT);
|
return setTrackMode(p[0],TRACK_MODE_EXT);
|
||||||
#ifdef BOOSTER_INPUT
|
#ifdef BOOSTER_INPUT
|
||||||
if (TRACK_MODE_BOOST != 0 && // compile time optimization
|
if (TRACK_MODE_BOOST != 0 && // compile time optimization
|
||||||
params==2 && p[1]=="BOOST"_hk) // <= id BOOST>
|
params==2 && p[1]=="BOOST"_hk) // <= id BOOST>
|
||||||
return setTrackMode(p[0],TRACK_MODE_BOOST);
|
return setTrackMode(p[0],TRACK_MODE_BOOST);
|
||||||
|
if (TRACK_MODE_BOOST_INV != 0 && // compile time optimization
|
||||||
|
params==2 && p[1]=="BOOST_INV"_hk) // <= id BOOST_INV>
|
||||||
|
return setTrackMode(p[0],TRACK_MODE_BOOST_INV);
|
||||||
|
if (TRACK_MODE_BOOST_AUTO != 0 && // compile time optimization
|
||||||
|
params==2 && p[1]=="BOOST_AUTO"_hk) // <= id BOOST_AUTO>
|
||||||
|
return setTrackMode(p[0],TRACK_MODE_BOOST_AUTO);
|
||||||
#endif
|
#endif
|
||||||
if (params==2 && p[1]=="AUTO"_hk) // <= id AUTO>
|
if (params==2 && p[1]=="AUTO"_hk) // <= id AUTO>
|
||||||
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_AUTOINV);
|
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODIFIER_AUTO);
|
||||||
|
|
||||||
if (params==2 && p[1]=="INV"_hk) // <= id INV>
|
if (params==2 && p[1]=="INV"_hk) // <= id INV>
|
||||||
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODE_INV);
|
return setTrackMode(p[0], track[p[0]]->getMode() | TRACK_MODIFIER_INV);
|
||||||
|
|
||||||
if (params==3 && p[1]=="DC"_hk && p[2]>0) // <= id DC cab>
|
if (params==3 && p[1]=="DC"_hk && p[2]>0) // <= id DC cab>
|
||||||
return setTrackMode(p[0],TRACK_MODE_DC,p[2]);
|
return setTrackMode(p[0],TRACK_MODE_DC,p[2]);
|
||||||
|
|
||||||
if (params==3 && p[1]=="DCX"_hk && p[2]>0) // <= id DCX cab>
|
if (params==3 && (p[1]=="DC_INV"_hk || // <= id DC_INV cab>
|
||||||
return setTrackMode(p[0],TRACK_MODE_DC|TRACK_MODE_INV,p[2]);
|
p[1]=="DCX"_hk) && p[2]>0) // <= id DCX cab>
|
||||||
|
return setTrackMode(p[0],TRACK_MODE_DC_INV,p[2]);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -426,9 +437,9 @@ const FSH* TrackManager::getModeName(TRACK_MODE tm) {
|
||||||
const FSH *modename=F("---");
|
const FSH *modename=F("---");
|
||||||
|
|
||||||
if (tm & TRACK_MODE_MAIN) {
|
if (tm & TRACK_MODE_MAIN) {
|
||||||
if(tm & TRACK_MODE_AUTOINV)
|
if(tm & TRACK_MODIFIER_AUTO)
|
||||||
modename=F("MAIN A");
|
modename=F("MAIN A");
|
||||||
else if (tm & TRACK_MODE_INV)
|
else if (tm & TRACK_MODIFIER_INV)
|
||||||
modename=F("MAIN I>\n");
|
modename=F("MAIN I>\n");
|
||||||
else
|
else
|
||||||
modename=F("MAIN");
|
modename=F("MAIN");
|
||||||
|
@ -442,15 +453,15 @@ const FSH* TrackManager::getModeName(TRACK_MODE tm) {
|
||||||
else if(tm & TRACK_MODE_EXT)
|
else if(tm & TRACK_MODE_EXT)
|
||||||
modename=F("EXT");
|
modename=F("EXT");
|
||||||
else if(tm & TRACK_MODE_BOOST) {
|
else if(tm & TRACK_MODE_BOOST) {
|
||||||
if(tm & TRACK_MODE_AUTOINV)
|
if(tm & TRACK_MODIFIER_AUTO)
|
||||||
modename=F("BOOST A");
|
modename=F("BOOST A");
|
||||||
else if (tm & TRACK_MODE_INV)
|
else if (tm & TRACK_MODIFIER_INV)
|
||||||
modename=F("BOOST I");
|
modename=F("BOOST I");
|
||||||
else
|
else
|
||||||
modename=F("BOOST");
|
modename=F("BOOST");
|
||||||
}
|
}
|
||||||
else if (tm & TRACK_MODE_DC) {
|
else if (tm & TRACK_MODE_DC) {
|
||||||
if (tm & TRACK_MODE_INV)
|
if (tm & TRACK_MODIFIER_INV)
|
||||||
modename=F("DCX");
|
modename=F("DCX");
|
||||||
else
|
else
|
||||||
modename=F("DC");
|
modename=F("DC");
|
||||||
|
|
|
@ -72,8 +72,9 @@ Stream * WifiInterface::wifiStream;
|
||||||
#elif defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F429ZI) \
|
#elif defined(ARDUINO_NUCLEO_F413ZH) || defined(ARDUINO_NUCLEO_F429ZI) \
|
||||||
|| defined(ARDUINO_NUCLEO_F446ZE) || defined(ARDUINO_NUCLEO_F412ZG) \
|
|| defined(ARDUINO_NUCLEO_F446ZE) || defined(ARDUINO_NUCLEO_F412ZG) \
|
||||||
|| defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
|| defined(ARDUINO_NUCLEO_F439ZI) || defined(ARDUINO_NUCLEO_F4X9ZI)
|
||||||
#define NUM_SERIAL 2
|
#define NUM_SERIAL 3
|
||||||
#define SERIAL1 Serial6
|
#define SERIAL1 Serial6
|
||||||
|
#define SERIAL3 Serial2
|
||||||
#else
|
#else
|
||||||
#warning This variant of Nucleo not yet explicitly supported
|
#warning This variant of Nucleo not yet explicitly supported
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -202,7 +202,7 @@ monitor_speed = 115200
|
||||||
monitor_echo = yes
|
monitor_echo = yes
|
||||||
|
|
||||||
[env:Nucleo-F411RE]
|
[env:Nucleo-F411RE]
|
||||||
platform = ststm32
|
platform = ststm32 @ 17.6.0
|
||||||
board = nucleo_f411re
|
board = nucleo_f411re
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -211,7 +211,7 @@ monitor_speed = 115200
|
||||||
monitor_echo = yes
|
monitor_echo = yes
|
||||||
|
|
||||||
[env:Nucleo-F446RE]
|
[env:Nucleo-F446RE]
|
||||||
platform = ststm32
|
platform = ststm32 @ 17.6.0
|
||||||
board = nucleo_f446re
|
board = nucleo_f446re
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -223,7 +223,7 @@ monitor_echo = yes
|
||||||
; tested as yet
|
; tested as yet
|
||||||
;
|
;
|
||||||
[env:Nucleo-F401RE]
|
[env:Nucleo-F401RE]
|
||||||
platform = ststm32
|
platform = ststm32 @ 17.6.0
|
||||||
board = nucleo_f401re
|
board = nucleo_f401re
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -236,7 +236,7 @@ monitor_echo = yes
|
||||||
; installed before you can let PlatformIO see this
|
; installed before you can let PlatformIO see this
|
||||||
;
|
;
|
||||||
; [env:Nucleo-F413ZH]
|
; [env:Nucleo-F413ZH]
|
||||||
; platform = ststm32
|
; platform = ststm32 @ 17.6.0
|
||||||
; board = nucleo_f413zh
|
; board = nucleo_f413zh
|
||||||
; framework = arduino
|
; framework = arduino
|
||||||
; lib_deps = ${env.lib_deps}
|
; lib_deps = ${env.lib_deps}
|
||||||
|
@ -248,7 +248,7 @@ monitor_echo = yes
|
||||||
; installed before you can let PlatformIO see this
|
; installed before you can let PlatformIO see this
|
||||||
;
|
;
|
||||||
[env:Nucleo-F446ZE]
|
[env:Nucleo-F446ZE]
|
||||||
platform = ststm32
|
platform = ststm32 @ 17.6.0
|
||||||
board = nucleo_f446ze
|
board = nucleo_f446ze
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
|
@ -260,8 +260,8 @@ monitor_echo = yes
|
||||||
; installed before you can let PlatformIO see this
|
; installed before you can let PlatformIO see this
|
||||||
;
|
;
|
||||||
; [env:Nucleo-F412ZG]
|
; [env:Nucleo-F412ZG]
|
||||||
; platform = ststm32
|
; platform = ststm32 @ 17.6.0
|
||||||
; board = blah_f412zg
|
; board = nucleo_f412zg
|
||||||
; framework = arduino
|
; framework = arduino
|
||||||
; lib_deps = ${env.lib_deps}
|
; lib_deps = ${env.lib_deps}
|
||||||
; build_flags = -std=c++17 -Os -g2 -Wunused-variable
|
; build_flags = -std=c++17 -Os -g2 -Wunused-variable
|
||||||
|
@ -272,12 +272,12 @@ monitor_echo = yes
|
||||||
; Experimental - Ethernet work still in progress
|
; Experimental - Ethernet work still in progress
|
||||||
;
|
;
|
||||||
[env:Nucleo-F429ZI]
|
[env:Nucleo-F429ZI]
|
||||||
platform = ststm32
|
platform = ststm32 @ 17.6.0
|
||||||
board = nucleo_f429zi
|
board = nucleo_f429zi
|
||||||
framework = arduino
|
framework = arduino
|
||||||
lib_deps = ${env.lib_deps}
|
lib_deps = ${env.lib_deps}
|
||||||
stm32duino/STM32Ethernet @ ^1.3.0
|
stm32duino/STM32Ethernet @ ^1.4.0
|
||||||
stm32duino/STM32duino LwIP @ ^2.1.2
|
stm32duino/STM32duino LwIP @ ^2.1.3
|
||||||
MDNS_Generic
|
MDNS_Generic
|
||||||
lib_ignore = WiFi101
|
lib_ignore = WiFi101
|
||||||
WiFi101_Generic
|
WiFi101_Generic
|
||||||
|
@ -289,18 +289,29 @@ monitor_speed = 115200
|
||||||
monitor_echo = yes
|
monitor_echo = yes
|
||||||
upload_protocol = stlink
|
upload_protocol = stlink
|
||||||
|
|
||||||
; [env:Nucleo-F429ZI]
|
; Experimental - Ethernet work still in progress
|
||||||
; platform = ststm32
|
;
|
||||||
; board = nucleo_f429zi
|
[env:Nucleo-F439ZI]
|
||||||
; framework = arduino
|
platform = ststm32 @ 17.6.0
|
||||||
; lib_deps = ${env.lib_deps}
|
; board = nucleo_f439zi
|
||||||
; arduino-libraries/Ethernet @ ^2.0.1
|
; Temporarily treat it as an F429ZI (they are code compatible) until
|
||||||
; stm32duino/STM32Ethernet @ ^1.3.0
|
; the PR to PlatformIO to update the F439ZI JSON file is available
|
||||||
; stm32duino/STM32duino LwIP @ ^2.1.2
|
; PMA - 28-Sep-2024
|
||||||
; build_flags = -std=c++17 -Os -g2 -Wunused-variable
|
board = nucleo_f429zi
|
||||||
; monitor_speed = 115200
|
framework = arduino
|
||||||
; monitor_echo = yes
|
lib_deps = ${env.lib_deps}
|
||||||
; upload_protocol = stlink
|
stm32duino/STM32Ethernet @ ^1.4.0
|
||||||
|
stm32duino/STM32duino LwIP @ ^2.1.3
|
||||||
|
MDNS_Generic
|
||||||
|
lib_ignore = WiFi101
|
||||||
|
WiFi101_Generic
|
||||||
|
WiFiEspAT
|
||||||
|
WiFiMulti_Generic
|
||||||
|
WiFiNINA_Generic
|
||||||
|
build_flags = -std=c++17 -Os -g2 -Wunused-variable
|
||||||
|
monitor_speed = 115200
|
||||||
|
monitor_echo = yes
|
||||||
|
upload_protocol = stlink
|
||||||
|
|
||||||
[env:Teensy3_2]
|
[env:Teensy3_2]
|
||||||
platform = teensy
|
platform = teensy
|
||||||
|
|
|
@ -3,8 +3,13 @@
|
||||||
|
|
||||||
#include "StringFormatter.h"
|
#include "StringFormatter.h"
|
||||||
|
|
||||||
#define VERSION "5.2.80"
|
#define VERSION "5.2.85"
|
||||||
// 5.2.80 - EthernetInterface upgrade
|
// 5.2.85 - IO_TM1638 driver, SEG7 Exrail macro and _s7 segment pattern generator.
|
||||||
|
// 5.2.84 - Fix TrackManager setDCCSignal and setPROGSignal for STM32 shadowing of PORTG/PORTH - this time it really is correct!
|
||||||
|
// 5.2.83 - Various STM32 related fixes for serial ports, I2C pullups now turned off, and shadowing of PORTG/PORTH for TrackManager now correct
|
||||||
|
// 5.2.82 - TrackManager and EXRAIL: Introduce more consistent names for <= ...> and SET_TRACK
|
||||||
|
// 5.2.81 - STM32 Ethernet boards support, also now have specific EX8874 motor driver definition
|
||||||
|
// 5.2.80 - EthernetInterface upgrade, including STM32 Ethernet support
|
||||||
// 5.2.79 - serial manager loop that handles quoted strings
|
// 5.2.79 - serial manager loop that handles quoted strings
|
||||||
// - WiFiESP32 reconfig
|
// - WiFiESP32 reconfig
|
||||||
// 5.2.78 - NeoPixel support.
|
// 5.2.78 - NeoPixel support.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user