1
0
mirror of https://github.com/DCC-EX/CommandStation-EX.git synced 2024-11-26 17:46:14 +01:00
CommandStation-EX/EXRAIL2.h

317 lines
12 KiB
C
Raw Normal View History

/*
2022-01-07 02:28:35 +01:00
* © 2021 Neil McKechnie
* © 2020-2022 Chris Harlow
* © 2022-2023 Colin Murdoch
2023-01-27 17:03:39 +01:00
* © 2023 Harald Barth
2022-01-07 02:28:35 +01:00
* All rights reserved.
*
* This file is part of CommandStation-EX
*
* 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 EXRAIL2_H
#define EXRAIL2_H
#include "FSH.h"
#include "IODevice.h"
#include "Turnouts.h"
2023-09-02 00:29:49 +02:00
#include "Turntables.h"
// The following are the operation codes (or instructions) for a kind of virtual machine.
// Each instruction is normally 3 bytes long with an operation code followed by a parameter.
// In cases where more than one parameter is required, the first parameter is followed by one
// or more OPCODE_PAD instructions with the subsequent parameters. This wastes a byte but makes
// searching easier as a parameter can never be confused with an opcode.
//
enum OPCODE : byte {OPCODE_THROW,OPCODE_CLOSE,OPCODE_TOGGLE_TURNOUT,
OPCODE_FWD,OPCODE_REV,OPCODE_SPEED,OPCODE_INVERT_DIRECTION,
OPCODE_RESERVE,OPCODE_FREE,
OPCODE_AT,OPCODE_AFTER,
OPCODE_AFTEROVERLOAD,OPCODE_AUTOSTART,
2022-03-18 14:46:07 +01:00
OPCODE_ATGTE,OPCODE_ATLT,
2022-04-17 11:10:22 +02:00
OPCODE_ATTIMEOUT1,OPCODE_ATTIMEOUT2,
OPCODE_LATCH,OPCODE_UNLATCH,OPCODE_SET,OPCODE_RESET,
OPCODE_BLINK,
2022-04-17 11:10:22 +02:00
OPCODE_ENDIF,OPCODE_ELSE,
2022-01-03 20:15:44 +01:00
OPCODE_DELAY,OPCODE_DELAYMINS,OPCODE_DELAYMS,OPCODE_RANDWAIT,
2021-09-06 13:27:21 +02:00
OPCODE_FON,OPCODE_FOFF,OPCODE_XFON,OPCODE_XFOFF,
OPCODE_FTOGGLE,OPCODE_XFTOGGLE,
2021-11-24 12:56:55 +01:00
OPCODE_RED,OPCODE_GREEN,OPCODE_AMBER,OPCODE_DRIVE,
OPCODE_SERVO,OPCODE_SIGNAL,OPCODE_TURNOUT,OPCODE_WAITFOR,
OPCODE_PAD,OPCODE_FOLLOW,OPCODE_CALL,OPCODE_RETURN,
2023-04-20 00:16:32 +02:00
#ifndef DISABLE_PROG
OPCODE_JOIN,OPCODE_UNJOIN,OPCODE_READ_LOCO1,OPCODE_READ_LOCO2,
2023-04-20 00:16:32 +02:00
#endif
OPCODE_POM,
OPCODE_START,OPCODE_SETLOCO,OPCODE_SETFREQ,OPCODE_SENDLOCO,OPCODE_FORGET,
OPCODE_PAUSE, OPCODE_RESUME,OPCODE_POWEROFF,OPCODE_POWERON,
2021-08-10 17:32:23 +02:00
OPCODE_ONCLOSE, OPCODE_ONTHROW, OPCODE_SERVOTURNOUT, OPCODE_PINTURNOUT,
2024-02-15 21:05:27 +01:00
OPCODE_PRINT,OPCODE_DCCACTIVATE,OPCODE_ASPECT,
2022-04-17 11:10:22 +02:00
OPCODE_ONACTIVATE,OPCODE_ONDEACTIVATE,
OPCODE_ROSTER,OPCODE_KILLALL,
2022-04-17 11:10:22 +02:00
OPCODE_ROUTE,OPCODE_AUTOMATION,OPCODE_SEQUENCE,
OPCODE_ENDTASK,OPCODE_ENDEXRAIL,
OPCODE_SET_TRACK,OPCODE_SET_POWER,
OPCODE_ONRED,OPCODE_ONAMBER,OPCODE_ONGREEN,
2022-12-30 00:46:42 +01:00
OPCODE_ONCHANGE,
OPCODE_ONCLOCKTIME,
OPCODE_ONTIME,
2023-09-02 00:29:49 +02:00
OPCODE_TTADDPOSITION,OPCODE_DCCTURNTABLE,OPCODE_EXTTTURNTABLE,
2023-10-12 20:37:38 +02:00
OPCODE_ONROTATE,OPCODE_ROTATE,OPCODE_WAITFORTT,
OPCODE_LCC,OPCODE_LCCX,OPCODE_ONLCC,
OPCODE_ACON, OPCODE_ACOF,
OPCODE_ONACON, OPCODE_ONACOF,
2023-08-12 20:10:35 +02:00
OPCODE_ONOVERLOAD,
2023-11-07 17:27:26 +01:00
OPCODE_ROUTE_ACTIVE,OPCODE_ROUTE_INACTIVE,OPCODE_ROUTE_HIDDEN,
2023-11-17 11:45:36 +01:00
OPCODE_ROUTE_DISABLED,
2023-11-23 11:41:35 +01:00
OPCODE_STASH,OPCODE_CLEAR_STASH,OPCODE_CLEAR_ALL_STASH,OPCODE_PICKUP_STASH,
2024-09-28 13:29:12 +02:00
OPCODE_ONBUTTON,OPCODE_ONSENSOR,
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
OPCODE_NEOPIXEL,
2024-09-28 13:29:12 +02:00
OPCODE_ONBLOCKENTER,OPCODE_ONBLOCKEXIT,
2022-04-17 11:10:22 +02:00
// OPcodes below this point are skip-nesting IF operations
// placed here so that they may be skipped as a group
// see skipIfBlock()
IF_TYPE_OPCODES, // do not move this...
2022-04-17 10:58:32 +02:00
OPCODE_IFRED,OPCODE_IFAMBER,OPCODE_IFGREEN,
2022-04-17 11:10:22 +02:00
OPCODE_IFGTE,OPCODE_IFLT,
OPCODE_IFTIMEOUT,
OPCODE_IF,OPCODE_IFNOT,
OPCODE_IFRANDOM,OPCODE_IFRESERVE,
2022-12-30 00:46:42 +01:00
OPCODE_IFCLOSED,OPCODE_IFTHROWN,
OPCODE_IFRE,
2023-10-12 20:37:38 +02:00
OPCODE_IFLOCO,
OPCODE_IFTTPOSITION
};
// Ensure thrunge_lcd is put last as there may be more than one display,
// sequentially numbered from thrunge_lcd.
enum thrunger: byte {
2023-05-01 15:25:45 +02:00
thrunge_print, thrunge_broadcast, thrunge_withrottle,
thrunge_serial,thrunge_parse,
thrunge_serial1, thrunge_serial2, thrunge_serial3,
thrunge_serial4, thrunge_serial5, thrunge_serial6,
2024-03-08 21:33:11 +01:00
thrunge_lcn,thrunge_message,
thrunge_lcd, // Must be last!!
};
enum BlinkState: byte {
not_blink_task,
blink_low, // blink task running with pin LOW
blink_high, // blink task running with pin high
at_timeout // ATTIMEOUT timed out flag
};
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
enum SignalType {
sigtypeVIRTUAL,
sigtypeSIGNAL,
sigtypeSIGNALH,
sigtypeDCC,
sigtypeDCCX,
sigtypeSERVO,
sigtypeNEOPIXEL,
sigtypeContinuation, // neopixels require a second line
sigtypeNoMoreSignals
};
struct SIGNAL_DEFINITION {
SignalType type;
VPIN id;
VPIN redpin,amberpin,greenpin;
};
// Flag bits for compile time features.
static const byte FEATURE_SIGNAL= 0x80;
static const byte FEATURE_LCC = 0x40;
static const byte FEATURE_ROSTER= 0x20;
2023-11-10 20:25:24 +01:00
static const byte FEATURE_ROUTESTATE= 0x10;
2023-11-23 11:41:35 +01:00
static const byte FEATURE_STASH = 0x08;
static const byte FEATURE_BLINK = 0x04;
2024-04-13 11:16:26 +02:00
static const byte FEATURE_SENSOR = 0x02;
2024-09-28 13:29:12 +02:00
static const byte FEATURE_BLOCK = 0x01;
// Flag bits for status of hardware and TPL
static const byte SECTION_FLAG = 0x80;
2022-04-17 10:58:32 +02:00
static const byte LATCH_FLAG = 0x40;
static const byte TASK_FLAG = 0x20;
static const byte SPARE_FLAG = 0x10;
static const byte SIGNAL_MASK = 0x0C;
static const byte SIGNAL_RED = 0x08;
static const byte SIGNAL_AMBER = 0x0C;
static const byte SIGNAL_GREEN = 0x04;
static const byte MAX_STACK_DEPTH=4;
static const short MAX_FLAGS=256;
#define FLAGOVERFLOW(x) x>=MAX_FLAGS
class LookList {
public:
2021-11-18 15:57:09 +01:00
LookList(int16_t size);
void chain(LookList* chainTo);
2021-11-18 15:57:09 +01:00
void add(int16_t lookup, int16_t result);
2023-11-09 20:27:52 +01:00
int16_t find(int16_t value); // finds result value
int16_t findPosition(int16_t value); // finds index
2023-11-10 20:25:24 +01:00
int16_t size();
void stream(Print * _stream);
2024-09-28 13:29:12 +02:00
void handleEvent(const FSH* reason,int16_t id, int16_t loco=0);
2023-11-10 21:13:33 +01:00
2021-11-18 15:57:09 +01:00
private:
int16_t m_size;
int16_t m_loaded;
int16_t * m_lookupArray;
int16_t * m_resultArray;
LookList* m_chain;
};
class RMFT2 {
public:
static void begin();
static void loop();
2024-09-28 13:29:12 +02:00
RMFT2(int progCounter, int16_t cab=0);
~RMFT2();
static void readLocoCallback(int16_t cv);
static void createNewTask(int route, uint16_t cab);
2021-09-03 23:39:13 +02:00
static void turnoutEvent(int16_t id, bool closed);
static void activateEvent(int16_t addr, bool active);
2022-12-30 00:46:42 +01:00
static void changeEvent(int16_t id, bool change);
static void clockEvent(int16_t clocktime, bool change);
2023-09-02 00:29:49 +02:00
static void rotateEvent(int16_t id, bool change);
2023-08-12 20:10:35 +02:00
static void powerEvent(int16_t track, bool overload);
2024-09-28 13:29:12 +02:00
static void blockEvent(int16_t block, int16_t loco, bool entering);
2024-02-16 13:20:58 +01:00
static bool signalAspectEvent(int16_t address, byte aspect );
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
// Throttle Info Access functions built by exrail macros
static const byte rosterNameCount;
static const int16_t HIGHFLASH routeIdList[];
static const int16_t HIGHFLASH automationIdList[];
static const int16_t HIGHFLASH rosterIdList[];
static const FSH * getRouteDescription(int16_t id);
2022-04-08 17:13:15 +02:00
static char getRouteType(int16_t id);
static const FSH * getTurnoutDescription(int16_t id);
static const FSH * getRosterName(int16_t id);
static const FSH * getRosterFunctions(int16_t id);
2023-09-02 00:29:49 +02:00
static const FSH * getTurntableDescription(int16_t id);
2023-09-06 07:16:46 +02:00
static const FSH * getTurntablePositionDescription(int16_t turntableId, uint8_t positionId);
2024-10-23 12:58:26 +02:00
static void startNonRecursiveTask(const FSH* reason, int16_t id,int pc, uint16_t loco=0);
2024-04-13 11:16:26 +02:00
static bool readSensor(uint16_t sensorId);
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
static bool isSignal(int16_t id,char rag);
static SIGNAL_DEFINITION getSignalSlot(int16_t slotno);
2024-04-13 11:16:26 +02:00
private:
static void ComandFilter(Print * stream, byte & opcode, byte & paramCount, int16_t p[]);
static bool parseSlash(Print * stream, byte & paramCount, int16_t p[]) ;
static void streamFlags(Print* stream);
static bool setFlag(VPIN id,byte onMask, byte OffMask=0);
static bool getFlag(VPIN id,byte mask);
static int16_t progtrackLocoId;
static void doSignal(int16_t id,char rag);
static void setTurnoutHiddenState(Turnout * t);
2023-09-02 10:45:59 +02:00
#ifndef IO_NO_HAL
2023-09-02 00:29:49 +02:00
static void setTurntableHiddenState(Turntable * tto);
2023-09-02 10:45:59 +02:00
#endif
static LookList* LookListLoader(OPCODE op1,
OPCODE op2=OPCODE_ENDEXRAIL,OPCODE op3=OPCODE_ENDEXRAIL);
static uint16_t getOperand(int progCounter,byte n);
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
static void killBlinkOnVpin(VPIN pin,uint16_t count=1);
static RMFT2 * loopTask;
static RMFT2 * pausingTask;
void delayMe(long millisecs);
bool skipIfBlock();
bool readLoco();
void loop2();
void kill(const FSH * reason=NULL,int operand=0);
2021-08-10 17:32:23 +02:00
void printMessage(uint16_t id); // Built by RMFTMacros.h
void printMessage2(const FSH * msg);
void thrungeString(uint32_t strfar, thrunger mode, byte id=0);
uint16_t getOperand(byte n);
2024-09-28 13:29:12 +02:00
void pause();
void resume();
static bool diag;
2023-11-21 22:14:54 +01:00
static const HIGHFLASH3 byte RouteCode[];
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
static const HIGHFLASH SIGNAL_DEFINITION SignalDefinitions[];
static byte flags[MAX_FLAGS];
static Print * LCCSerial;
static LookList * routeLookup;
NeoPixel support commit 2bbb5c111907cab37e5c068dc18e084f404f2a2e Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 20 12:13:21 2024 +0100 EXRAIL use neopixel range instead of loop commit 3aabb51888d61d88c3c26a3617eccaa74e3f64d4 Author: Asbelos <asbelos@btinternet.com> Date: Wed Sep 18 17:06:00 2024 +0100 Neopixel signals with blue-tint See Release Notes file commit 8e6fe6df21bc758ee1b715d97c254a4c1488ffe2 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 12 08:35:26 2024 +0100 HAL write range commit 66e57b5ab2e7938bf5f97960ab73017749d8fc4b Author: Asbelos <asbelos@btinternet.com> Date: Sun Sep 8 09:26:37 2024 +0100 Killblink on neopixel set. commit 360c42667500fdd93e35e688c7461731bc8dc50d Merge: dd16e0d b026417 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 16:45:29 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit dd16e0da972a414cac66755b61b6922691f88030 Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 13:00:26 2024 +0100 Notes commit e823db3d244919f5529d22c71de8f4de834e21dd Author: Asbelos <asbelos@btinternet.com> Date: Sat Sep 7 11:16:30 2024 +0100 Neopixel change to 8,8,8 commit d3d6cc97fb68ee2314a3d4a3e10f92542044c124 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 13:25:44 2024 +0100 Neopixel <o> cmd commit 03d8d5f93d477246e8ceecf6500133845a0d5129 Author: Asbelos <asbelos@btinternet.com> Date: Fri Sep 6 08:08:18 2024 +0100 Its working!! commit 235f3c82b5c8e94106bc63dfd5f2957b423f1601 Author: Asbelos <asbelos@btinternet.com> Date: Thu Sep 5 22:02:29 2024 +0100 Update IO_NeoPixel.h commit 530b77bbab4605a3fdfdec735ef01d0b56ef543c Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 15:04:40 2024 +0100 NEOPIXEL driver and macros commit 2a895fbbd531e3ee778962eec59144a602cba9bc Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 11:26:17 2024 +0100 First compile neopixel driver commit c6f2db79094d3b0a0c5322c859868e9025bcb6eb Merge: a7df84b 7395aa4 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 10:07:12 2024 +0100 Merge branch 'devel' into devel-pauls-i2c-devices commit a7df84b01cc474c31356456bc1db220c800743cb Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:56:05 2024 +0100 NEOPIXEL EXRAIL commit ead6e5afa11d526d9a366eeb6013e7eaa16bcb76 Author: Asbelos <asbelos@btinternet.com> Date: Tue Sep 3 09:55:36 2024 +0100 NEOPIXEL EXRAIL commit 0cb175544e4771415c22d6bdc5ed0c331ce76f95 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 17:29:10 2024 +0800 More TCA8418 commit 208205180193aec382fcc25423fb6a81a078e407 Author: pmantoine <pma-github@milleng.com.au> Date: Sat Feb 24 13:02:34 2024 +0800 TCA8418 initial HAL driver scaffolding
2024-09-22 13:36:19 +02:00
static LookList * signalLookup;
static LookList * onThrowLookup;
static LookList * onCloseLookup;
static LookList * onActivateLookup;
static LookList * onDeactivateLookup;
static LookList * onRedLookup;
static LookList * onAmberLookup;
static LookList * onGreenLookup;
2022-12-30 00:46:42 +01:00
static LookList * onChangeLookup;
static LookList * onClockLookup;
2023-09-06 23:58:19 +02:00
#ifndef IO_NO_HAL
2023-09-02 00:29:49 +02:00
static LookList * onRotateLookup;
2023-09-06 23:58:19 +02:00
#endif
static LookList * onOverloadLookup;
2024-09-28 13:29:12 +02:00
static LookList * onBlockEnterLookup;
static LookList * onBlockExitLookup;
static const int countLCCLookup;
static int onLCCLookup[];
static const byte compileFeatures;
static void manageRouteState(uint16_t id, byte state);
static void manageRouteCaption(uint16_t id, const FSH* caption);
2023-11-09 20:27:52 +01:00
static byte * routeStateArray;
2023-11-10 20:25:24 +01:00
static const FSH ** routeCaptionArray;
2023-11-23 11:41:35 +01:00
static int16_t * stashArray;
static int16_t maxStashId;
// Local variables - exist for each instance/task
RMFT2 *next; // loop chain
int progCounter; // Byte offset of next route opcode in ROUTES table
unsigned long delayStart; // Used by opcodes that must be recalled before completing
unsigned long delayTime;
2022-01-03 11:15:10 +01:00
union {
unsigned long waitAfter; // Used by OPCODE_AFTER
unsigned long timeoutStart; // Used by OPCODE_ATTIMEOUT
VPIN blinkPin; // Used by blink tasks
2022-01-03 11:15:10 +01:00
};
byte taskId;
BlinkState blinkState; // includes AT_TIMEOUT flag.
2021-09-04 11:38:38 +02:00
uint16_t loco;
bool invert;
2024-09-28 13:29:12 +02:00
byte pauseSpeed;
int onEventStartPosition;
byte stackDepth;
int callStack[MAX_STACK_DEPTH];
};
2023-11-10 20:25:24 +01:00
#define GET_OPCODE GETHIGHFLASH(RMFT2::RouteCode,progCounter)
#define SKIPOP progCounter+=3
// IO_I2CDFPlayer commands and values
enum : uint8_t{
DF_PLAY = 0x0F,
DF_VOL = 0x06,
DF_FOLDER = 0x2B, // Not a DFPlayer command, used to set folder nr where audio file is
DF_REPEATPLAY = 0x08,
DF_STOPPLAY = 0x16,
DF_EQ = 0x07, // Set equaliser, require parameter NORMAL, POP, ROCK, JAZZ, CLASSIC or BASS
DF_RESET = 0x0C,
DF_DACON = 0x1A,
DF_SETAM = 0x2A, // Set audio mixer 1 or 2 for this DFPLayer
DF_NORMAL = 0x00, // Equalizer parameters
DF_POP = 0x01,
DF_ROCK = 0x02,
DF_JAZZ = 0x03,
DF_CLASSIC = 0x04,
DF_BASS = 0x05,
};
#endif