2021-08-03 23:12:25 +02:00
|
|
|
/*
|
2022-01-07 02:28:35 +01:00
|
|
|
* © 2021 Neil McKechnie
|
|
|
|
* © 2020-2022 Chris Harlow
|
2023-08-12 19:40:48 +02:00
|
|
|
* © 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.
|
2021-08-03 23:12:25 +02:00
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
2021-11-22 12:10:26 +01:00
|
|
|
|
2022-01-30 18:31:26 +01:00
|
|
|
#ifndef EXRAILMacros_H
|
|
|
|
#define EXRAILMacros_H
|
2021-08-03 23:12:25 +02:00
|
|
|
|
2021-09-09 11:12:27 +02:00
|
|
|
// remove normal code LCD & SERIAL macros (will be restored later)
|
2021-08-20 20:18:30 +02:00
|
|
|
#undef LCD
|
2021-09-09 11:12:27 +02:00
|
|
|
#undef SERIAL
|
2021-08-20 20:18:30 +02:00
|
|
|
|
|
|
|
|
|
|
|
// This file will include and build the EXRAIL script and associated helper tricks.
|
2021-11-22 12:10:26 +01:00
|
|
|
// It does this by including myAutomation.h several times, each with a set of macros to
|
2021-08-20 20:18:30 +02:00
|
|
|
// extract the relevant parts.
|
|
|
|
|
2021-08-03 23:12:25 +02:00
|
|
|
// The entire automation script is contained within a byte array RMFT2::RouteCode[]
|
|
|
|
// made up of opcode and parameter pairs.
|
|
|
|
// ech opcode is a 1 byte operation plus 2 byte operand.
|
|
|
|
// The array is normally built using the macros below as this makes it easier
|
|
|
|
// to manage the cases where:
|
|
|
|
// - padding must be applied to ensure the correct alignment of the next instruction
|
|
|
|
// - large parameters must be split up
|
|
|
|
// - multiple parameters aligned correctly
|
|
|
|
// - a single macro requires multiple operations
|
|
|
|
|
2021-08-20 20:18:30 +02:00
|
|
|
// Descriptive texts for routes and animations are created in a sepaerate function which
|
|
|
|
// can be called to emit a list of routes/automatuions in a form suitable for Withrottle.
|
2021-08-03 23:12:25 +02:00
|
|
|
|
2023-02-12 00:37:09 +01:00
|
|
|
// PRINT(msg), LCD(row,msg) and SCREEN(display,row,msg) are implemented in a separate pass to create
|
2021-08-20 20:18:30 +02:00
|
|
|
// a getMessageText(id) function.
|
2021-08-03 23:12:25 +02:00
|
|
|
|
2021-08-20 20:18:30 +02:00
|
|
|
// CAUTION: The macros below are multiple passed over myAutomation.h
|
2021-08-10 17:32:23 +02:00
|
|
|
|
2022-04-08 12:41:50 +02:00
|
|
|
|
|
|
|
// helper macro for turnout descriptions, creates NULL for missing description
|
2022-04-03 12:19:04 +02:00
|
|
|
#define O_DESC(id, desc) case id: return ("" desc)[0]?F("" desc):NULL;
|
2023-09-06 21:33:26 +02:00
|
|
|
// helper macro for turntable descriptions, creates NULL for missing description
|
|
|
|
#define T_DESC(tid,pid,desc) if(turntableId==tid && positionId==pid) return ("" desc)[0]?F("" desc):NULL;
|
2022-04-08 12:41:50 +02:00
|
|
|
// helper macro for turnout description as HIDDEN
|
2022-04-13 00:10:29 +02:00
|
|
|
#define HIDDEN "\x01"
|
2022-04-03 12:19:04 +02:00
|
|
|
|
2024-02-03 20:05:56 +01:00
|
|
|
// PLAYSOUND is alias of ANOUT to make the user experience of a Conductor beter for
|
|
|
|
// playing sounds with IO_I2CDFPlayer
|
|
|
|
#define PLAYSOUND ANOUT
|
|
|
|
|
2024-10-10 20:42:27 +02:00
|
|
|
// SEG7 is a helper to create ANOUT from a 7-segment request
|
2024-10-10 20:38:35 +02:00
|
|
|
#define SEG7(vpin,value,format) \
|
|
|
|
ANOUT(vpin,(value & 0xFFFF),TM1638::DF_##format,((uint32_t)value)>>16)
|
|
|
|
|
2023-01-11 18:36:11 +01:00
|
|
|
// helper macro to strip leading zeros off time inputs
|
|
|
|
// (10#mins)%100)
|
|
|
|
#define STRIP_ZERO(value) 10##value%100
|
|
|
|
|
2023-09-24 16:40:42 +02:00
|
|
|
// These constants help EXRAIL macros convert Track Power e.g. SET_POWER(A ON|OFF).
|
|
|
|
//const byte TRACK_POWER_0=0, TRACK_POWER_OFF=0;
|
|
|
|
//const byte TRACK_POWER_1=1, TRACK_POWER_ON=1;
|
|
|
|
|
2024-09-22 13:36:19 +02:00
|
|
|
// NEOPIXEL RG generator for NEOPIXEL_SIGNAL
|
|
|
|
#define NeoRGB(red,green,blue) (((uint32_t)(red & 0xff)<<16) | ((uint32_t)(green & 0xff)<<8) | (uint32_t)(blue & 0xff))
|
2023-09-24 16:40:42 +02:00
|
|
|
|
2021-11-27 12:29:26 +01:00
|
|
|
// Pass 1 Implements aliases
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef ALIAS
|
2024-05-21 21:04:11 +02:00
|
|
|
#define ALIAS(name,value...) const int name= #value[0] ? value+0: -__COUNTER__ ;
|
2021-08-10 17:32:23 +02:00
|
|
|
#include "myAutomation.h"
|
|
|
|
|
2024-01-14 03:03:42 +01:00
|
|
|
// Pass 1d Detect sequence duplicates.
|
|
|
|
// This pass generates no runtime data or code
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef AUTOMATION
|
|
|
|
#define AUTOMATION(id, description) id,
|
|
|
|
#undef ROUTE
|
|
|
|
#define ROUTE(id, description) id,
|
|
|
|
#undef SEQUENCE
|
|
|
|
#define SEQUENCE(id) id,
|
|
|
|
constexpr int16_t compileTimeSequenceList[]={
|
|
|
|
#include "myAutomation.h"
|
|
|
|
0
|
|
|
|
};
|
|
|
|
constexpr int16_t stuffSize=sizeof(compileTimeSequenceList)/sizeof(int16_t) - 1;
|
|
|
|
|
|
|
|
|
|
|
|
// Compile time function to check for sequence nos.
|
2024-03-05 20:59:29 +01:00
|
|
|
constexpr bool hasseq(const int16_t value, const int16_t pos=0 ) {
|
2024-01-14 03:03:42 +01:00
|
|
|
return pos>=stuffSize? false :
|
|
|
|
compileTimeSequenceList[pos]==value
|
|
|
|
|| hasseq(value,pos+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Compile time function to check for duplicate sequence nos.
|
2024-03-05 20:59:29 +01:00
|
|
|
constexpr bool hasdup(const int16_t value, const int16_t pos ) {
|
2024-01-14 03:03:42 +01:00
|
|
|
return pos>=stuffSize? false :
|
|
|
|
compileTimeSequenceList[pos]==value
|
|
|
|
|| hasseq(value,pos+1)
|
|
|
|
|| hasdup(compileTimeSequenceList[pos],pos+1);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static_assert(!hasdup(compileTimeSequenceList[0],1),"Duplicate SEQUENCE/ROUTE/AUTOMATION detected");
|
|
|
|
|
|
|
|
//pass 1s static asserts to
|
|
|
|
// - check call and follows etc for existing sequence numbers
|
|
|
|
// - check range on LATCH/UNLATCH
|
|
|
|
// This pass generates no runtime data or code
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
2024-02-15 21:05:27 +01:00
|
|
|
#undef ASPECT
|
2024-02-19 21:02:01 +01:00
|
|
|
#define ASPECT(address,value) static_assert(address <=2044, "invalid Address"); \
|
|
|
|
static_assert(address>=-3, "Invalid value");
|
2024-01-14 03:03:42 +01:00
|
|
|
#undef CALL
|
|
|
|
#define CALL(id) static_assert(hasseq(id),"Sequence not found");
|
|
|
|
#undef FOLLOW
|
|
|
|
#define FOLLOW(id) static_assert(hasseq(id),"Sequence not found");
|
|
|
|
#undef START
|
|
|
|
#define START(id) static_assert(hasseq(id),"Sequence not found");
|
|
|
|
#undef SENDLOCO
|
|
|
|
#define SENDLOCO(cab,id) static_assert(hasseq(id),"Sequence not found");
|
|
|
|
#undef LATCH
|
|
|
|
#define LATCH(id) static_assert(id>=0 && id<MAX_FLAGS,"Id out of valid range 0-255" );
|
|
|
|
#undef UNLATCH
|
|
|
|
#define UNLATCH(id) static_assert(id>=0 && id<MAX_FLAGS,"Id out of valid range 0-255" );
|
|
|
|
#undef RESERVE
|
|
|
|
#define RESERVE(id) static_assert(id>=0 && id<MAX_FLAGS,"Id out of valid range 0-255" );
|
|
|
|
#undef FREE
|
|
|
|
#define FREE(id) static_assert(id>=0 && id<MAX_FLAGS,"Id out of valid range 0-255" );
|
|
|
|
#undef SPEED
|
|
|
|
#define SPEED(speed) static_assert(speed>=0 && speed<128,"Speed out of valid range 0-127");
|
|
|
|
#undef FWD
|
|
|
|
#define FWD(speed) static_assert(speed>=0 && speed<128,"Speed out of valid range 0-127");
|
|
|
|
#undef REV
|
|
|
|
#define REV(speed) static_assert(speed>=0 && speed<128,"Speed out of valid range 0-127");
|
|
|
|
|
|
|
|
#include "myAutomation.h"
|
|
|
|
|
2024-04-09 21:45:28 +02:00
|
|
|
// Pass 1g Implants STEALTH_GLOBAL in correct place
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef STEALTH_GLOBAL
|
|
|
|
#define STEALTH_GLOBAL(code...) code
|
|
|
|
#include "myAutomation.h"
|
|
|
|
|
2023-09-09 21:30:48 +02:00
|
|
|
// Pass 1h Implements HAL macro by creating exrailHalSetup function
|
|
|
|
// Also allows creating EXTurntable object
|
2022-06-15 12:44:46 +02:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef HAL
|
|
|
|
#define HAL(haltype,params...) haltype::create(params);
|
2024-01-14 21:20:22 +01:00
|
|
|
#undef HAL_IGNORE_DEFAULTS
|
|
|
|
#define HAL_IGNORE_DEFAULTS ignore_defaults=true;
|
2024-02-07 23:11:27 +01:00
|
|
|
#undef JMRI_SENSOR
|
|
|
|
#define JMRI_SENSOR(vpin,count...) Sensor::createMultiple(vpin,##count);
|
2024-02-09 12:54:53 +01:00
|
|
|
#undef CONFIGURE_SERVO
|
|
|
|
#define CONFIGURE_SERVO(vpin,pos1,pos2,profile) IODevice::configureServo(vpin,pos1,pos2,PCA9685::profile);
|
2024-01-14 21:20:22 +01:00
|
|
|
bool exrailHalSetup() {
|
|
|
|
bool ignore_defaults=false;
|
2022-06-15 12:44:46 +02:00
|
|
|
#include "myAutomation.h"
|
2024-01-14 21:20:22 +01:00
|
|
|
return ignore_defaults;
|
2022-06-15 12:44:46 +02:00
|
|
|
}
|
|
|
|
|
2023-10-13 14:59:06 +02:00
|
|
|
// Pass 1c detect compile time featurtes
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef SIGNAL
|
|
|
|
#define SIGNAL(redpin,amberpin,greenpin) | FEATURE_SIGNAL
|
|
|
|
#undef SIGNALH
|
|
|
|
#define SIGNALH(redpin,amberpin,greenpin) | FEATURE_SIGNAL
|
|
|
|
#undef SERVO_SIGNAL
|
|
|
|
#define SERVO_SIGNAL(vpin,redval,amberval,greenval) | FEATURE_SIGNAL
|
|
|
|
#undef DCC_SIGNAL
|
|
|
|
#define DCC_SIGNAL(id,addr,subaddr) | FEATURE_SIGNAL
|
2024-02-16 12:49:02 +01:00
|
|
|
#undef DCCX_SIGNAL
|
|
|
|
#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) | FEATURE_SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#undef NEOPIXEL_SIGNAL
|
|
|
|
#define NEOPIXEL_SIGNAL(sigid,redcolour,ambercolour,greencolour) | FEATURE_SIGNAL
|
2023-10-13 14:59:06 +02:00
|
|
|
#undef VIRTUAL_SIGNAL
|
|
|
|
#define VIRTUAL_SIGNAL(id) | FEATURE_SIGNAL
|
|
|
|
|
|
|
|
#undef LCC
|
|
|
|
#define LCC(eventid) | FEATURE_LCC
|
|
|
|
#undef LCCX
|
|
|
|
#define LCCX(senderid,eventid) | FEATURE_LCC
|
|
|
|
#undef ONLCC
|
|
|
|
#define ONLCC(senderid,eventid) | FEATURE_LCC
|
2024-06-13 14:01:33 +02:00
|
|
|
#undef ACON
|
|
|
|
#define ACON(eventid) | FEATURE_LCC
|
|
|
|
#undef ACOF
|
|
|
|
#define ACOF(eventid) | FEATURE_LCC
|
|
|
|
#undef ONACON
|
|
|
|
#define ONACON(eventid) | FEATURE_LCC
|
|
|
|
#undef ONACOF
|
|
|
|
#define ONACOF(eventid) | FEATURE_LCC
|
2023-11-10 20:25:24 +01:00
|
|
|
#undef ROUTE_ACTIVE
|
|
|
|
#define ROUTE_ACTIVE(id) | FEATURE_ROUTESTATE
|
|
|
|
#undef ROUTE_INACTIVE
|
|
|
|
#define ROUTE_INACTIVE(id) | FEATURE_ROUTESTATE
|
|
|
|
#undef ROUTE_HIDDEN
|
|
|
|
#define ROUTE_HIDDEN(id) | FEATURE_ROUTESTATE
|
2023-11-17 11:45:36 +01:00
|
|
|
#undef ROUTE_DISABLED
|
|
|
|
#define ROUTE_DISABLED(id) | FEATURE_ROUTESTATE
|
2023-11-10 20:25:24 +01:00
|
|
|
#undef ROUTE_CAPTION
|
|
|
|
#define ROUTE_CAPTION(id,caption) | FEATURE_ROUTESTATE
|
2023-10-13 14:59:06 +02:00
|
|
|
|
2023-11-23 11:41:35 +01:00
|
|
|
#undef CLEAR_STASH
|
|
|
|
#define CLEAR_STASH(id) | FEATURE_STASH
|
|
|
|
#undef CLEAR_ALL_STASH
|
|
|
|
#define CLEAR_ALL_STASH | FEATURE_STASH
|
|
|
|
#undef PICKUP_STASH
|
|
|
|
#define PICKUP_STASH(id) | FEATURE_STASH
|
|
|
|
#undef STASH
|
|
|
|
#define STASH(id) | FEATURE_STASH
|
2024-04-09 21:45:28 +02:00
|
|
|
#undef BLINK
|
|
|
|
#define BLINK(vpin,onDuty,offDuty) | FEATURE_BLINK
|
2024-04-13 11:16:26 +02:00
|
|
|
#undef ONBUTTON
|
|
|
|
#define ONBUTTON(vpin) | FEATURE_SENSOR
|
|
|
|
#undef ONSENSOR
|
|
|
|
#define ONSENSOR(vpin) | FEATURE_SENSOR
|
2024-09-28 13:29:12 +02:00
|
|
|
#undef ONBLOCKENTER
|
|
|
|
#define ONBLOCKENTER(blockid) | FEATURE_BLOCK
|
|
|
|
#undef ONBLOCKEXIT
|
|
|
|
#define ONBLOCKEXIT(blockid) | FEATURE_BLOCK
|
2023-11-23 11:41:35 +01:00
|
|
|
|
2023-10-13 14:59:06 +02:00
|
|
|
const byte RMFT2::compileFeatures = 0
|
|
|
|
#include "myAutomation.h"
|
|
|
|
;
|
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
// Pass 2 create throttle route list
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-08-10 17:32:23 +02:00
|
|
|
#undef ROUTE
|
2022-04-03 12:19:04 +02:00
|
|
|
#define ROUTE(id, description) id,
|
2023-11-21 22:14:54 +01:00
|
|
|
const int16_t HIGHFLASH RMFT2::routeIdList[]= {
|
2021-11-27 12:29:26 +01:00
|
|
|
#include "myAutomation.h"
|
2023-05-23 10:57:45 +02:00
|
|
|
INT16_MAX};
|
2022-04-08 17:13:15 +02:00
|
|
|
// Pass 2a create throttle automation list
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef AUTOMATION
|
2022-04-08 17:13:15 +02:00
|
|
|
#define AUTOMATION(id, description) id,
|
2023-11-21 21:16:20 +01:00
|
|
|
const int16_t HIGHFLASH RMFT2::automationIdList[]= {
|
2021-11-27 12:29:26 +01:00
|
|
|
#include "myAutomation.h"
|
2023-05-23 10:57:45 +02:00
|
|
|
INT16_MAX};
|
2022-04-03 12:19:04 +02:00
|
|
|
|
|
|
|
// Pass 3 Create route descriptions:
|
|
|
|
#undef ROUTE
|
|
|
|
#define ROUTE(id, description) case id: return F(description);
|
|
|
|
#undef AUTOMATION
|
|
|
|
#define AUTOMATION(id, description) case id: return F(description);
|
|
|
|
const FSH * RMFT2::getRouteDescription(int16_t id) {
|
|
|
|
switch(id) {
|
|
|
|
#include "myAutomation.h"
|
|
|
|
default: break;
|
|
|
|
}
|
2022-04-12 19:47:06 +02:00
|
|
|
return F("");
|
2021-11-27 12:29:26 +01:00
|
|
|
}
|
2021-08-10 17:32:23 +02:00
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
// Pass 4... Create Text sending functions
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-08-12 09:53:52 +02:00
|
|
|
const int StringMacroTracker1=__COUNTER__;
|
2022-12-16 14:14:48 +01:00
|
|
|
#define THRUNGE(msg,mode) \
|
|
|
|
case (__COUNTER__ - StringMacroTracker1) : {\
|
2023-11-21 21:16:20 +01:00
|
|
|
static const char HIGHFLASH thrunge[]=msg;\
|
2022-12-16 14:14:48 +01:00
|
|
|
strfar=(uint32_t)GETFARPTR(thrunge);\
|
|
|
|
tmode=mode;\
|
|
|
|
break;\
|
|
|
|
}
|
2022-03-07 17:30:47 +01:00
|
|
|
#undef BROADCAST
|
2022-12-16 14:14:48 +01:00
|
|
|
#define BROADCAST(msg) THRUNGE(msg,thrunge_broadcast)
|
2022-03-31 23:04:40 +02:00
|
|
|
#undef PARSE
|
2022-12-16 14:14:48 +01:00
|
|
|
#define PARSE(msg) THRUNGE(msg,thrunge_parse)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef PRINT
|
2022-12-16 14:14:48 +01:00
|
|
|
#define PRINT(msg) THRUNGE(msg,thrunge_print)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef LCN
|
2022-12-16 14:14:48 +01:00
|
|
|
#define LCN(msg) THRUNGE(msg,thrunge_lcn)
|
2024-03-08 21:33:11 +01:00
|
|
|
#undef MESSAGE
|
|
|
|
#define MESSAGE(msg) THRUNGE(msg,thrunge_message)
|
|
|
|
|
2023-11-07 17:27:26 +01:00
|
|
|
#undef ROUTE_CAPTION
|
|
|
|
#define ROUTE_CAPTION(id,caption) \
|
|
|
|
case (__COUNTER__ - StringMacroTracker1) : {\
|
2023-11-10 20:25:24 +01:00
|
|
|
manageRouteCaption(id,F(caption));\
|
2023-11-07 17:27:26 +01:00
|
|
|
return;\
|
|
|
|
}
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef SERIAL
|
2022-12-16 14:14:48 +01:00
|
|
|
#define SERIAL(msg) THRUNGE(msg,thrunge_serial)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef SERIAL1
|
2022-12-16 14:14:48 +01:00
|
|
|
#define SERIAL1(msg) THRUNGE(msg,thrunge_serial1)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef SERIAL2
|
2022-12-16 14:14:48 +01:00
|
|
|
#define SERIAL2(msg) THRUNGE(msg,thrunge_serial2)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef SERIAL3
|
2022-12-16 14:14:48 +01:00
|
|
|
#define SERIAL3(msg) THRUNGE(msg,thrunge_serial3)
|
|
|
|
#undef SERIAL4
|
|
|
|
#define SERIAL4(msg) THRUNGE(msg,thrunge_serial4)
|
|
|
|
#undef SERIAL5
|
|
|
|
#define SERIAL5(msg) THRUNGE(msg,thrunge_serial5)
|
|
|
|
#undef SERIAL6
|
|
|
|
#define SERIAL6(msg) THRUNGE(msg,thrunge_serial6)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef LCD
|
2022-12-16 14:14:48 +01:00
|
|
|
#define LCD(id,msg) \
|
|
|
|
case (__COUNTER__ - StringMacroTracker1) : {\
|
2023-11-21 21:16:20 +01:00
|
|
|
static const char HIGHFLASH thrunge[]=msg;\
|
2022-12-16 14:14:48 +01:00
|
|
|
strfar=(uint32_t)GETFARPTR(thrunge);\
|
|
|
|
tmode=thrunge_lcd; \
|
|
|
|
lcdid=id;\
|
|
|
|
break;\
|
2023-02-11 16:47:50 +01:00
|
|
|
}
|
2023-02-12 00:37:09 +01:00
|
|
|
#undef SCREEN
|
|
|
|
#define SCREEN(display,id,msg) \
|
2023-02-11 16:47:50 +01:00
|
|
|
case (__COUNTER__ - StringMacroTracker1) : {\
|
2023-11-21 22:14:54 +01:00
|
|
|
static const char HIGHFLASH thrunge[]=msg;\
|
2023-02-11 16:47:50 +01:00
|
|
|
strfar=(uint32_t)GETFARPTR(thrunge);\
|
|
|
|
tmode=(thrunger)(thrunge_lcd+display); \
|
|
|
|
lcdid=id;\
|
|
|
|
break;\
|
2022-12-16 14:14:48 +01:00
|
|
|
}
|
2023-11-30 12:32:39 +01:00
|
|
|
#undef STEALTH
|
|
|
|
#define STEALTH(code...) case (__COUNTER__ - StringMacroTracker1) : {code} return;
|
2023-05-01 15:25:45 +02:00
|
|
|
#undef WITHROTTLE
|
|
|
|
#define WITHROTTLE(msg) THRUNGE(msg,thrunge_withrottle)
|
2021-08-20 20:18:30 +02:00
|
|
|
|
2021-11-27 12:29:26 +01:00
|
|
|
void RMFT2::printMessage(uint16_t id) {
|
2022-12-16 14:14:48 +01:00
|
|
|
thrunger tmode;
|
|
|
|
uint32_t strfar=0;
|
|
|
|
byte lcdid=0;
|
2021-11-27 12:29:26 +01:00
|
|
|
switch(id) {
|
|
|
|
#include "myAutomation.h"
|
2021-12-28 20:06:47 +01:00
|
|
|
default: break ;
|
2021-11-27 12:29:26 +01:00
|
|
|
}
|
2022-12-16 14:14:48 +01:00
|
|
|
if (strfar) thrungeString(strfar,tmode,lcdid);
|
2021-11-27 12:29:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
// Pass 5: Turnout descriptions (optional)
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-08-10 17:32:23 +02:00
|
|
|
#undef TURNOUT
|
2022-04-03 12:19:04 +02:00
|
|
|
#define TURNOUT(id,addr,subaddr,description...) O_DESC(id,description)
|
2023-11-01 21:19:59 +01:00
|
|
|
#undef TURNOUTL
|
|
|
|
#define TURNOUTL(id,addr,description...) O_DESC(id,description)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef PIN_TURNOUT
|
2022-04-03 12:19:04 +02:00
|
|
|
#define PIN_TURNOUT(id,pin,description...) O_DESC(id,description)
|
2021-11-27 12:29:26 +01:00
|
|
|
#undef SERVO_TURNOUT
|
2022-04-03 12:19:04 +02:00
|
|
|
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...) O_DESC(id,description)
|
2022-03-24 12:56:06 +01:00
|
|
|
#undef VIRTUAL_TURNOUT
|
2022-04-03 12:19:04 +02:00
|
|
|
#define VIRTUAL_TURNOUT(id,description...) O_DESC(id,description)
|
2021-11-27 12:29:26 +01:00
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
const FSH * RMFT2::getTurnoutDescription(int16_t turnoutid) {
|
2021-11-27 12:29:26 +01:00
|
|
|
switch (turnoutid) {
|
|
|
|
#include "myAutomation.h"
|
2022-04-03 12:19:04 +02:00
|
|
|
default:break;
|
2021-11-27 12:29:26 +01:00
|
|
|
}
|
2022-04-03 12:19:04 +02:00
|
|
|
return NULL;
|
2021-11-27 12:29:26 +01:00
|
|
|
}
|
|
|
|
|
2023-09-02 00:29:49 +02:00
|
|
|
// Pass to get turntable descriptions (optional)
|
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef DCC_TURNTABLE
|
2023-09-08 23:22:10 +02:00
|
|
|
#define DCC_TURNTABLE(id,home,description...) O_DESC(id,description)
|
2023-09-02 00:29:49 +02:00
|
|
|
#undef EXTT_TURNTABLE
|
2023-10-16 21:06:35 +02:00
|
|
|
#define EXTT_TURNTABLE(id,vpin,home,description...) O_DESC(id,description)
|
2023-09-02 00:29:49 +02:00
|
|
|
|
|
|
|
const FSH * RMFT2::getTurntableDescription(int16_t turntableId) {
|
|
|
|
switch (turntableId) {
|
|
|
|
#include "myAutomation.h"
|
|
|
|
default:break;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pass to get turntable position descriptions (optional)
|
2023-09-06 21:33:26 +02:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef TT_ADDPOSITION
|
2023-09-08 23:22:10 +02:00
|
|
|
#define TT_ADDPOSITION(turntable_id,position,value,home,description...) T_DESC(turntable_id,position,description)
|
2023-09-06 21:33:26 +02:00
|
|
|
|
|
|
|
const FSH * RMFT2::getTurntablePositionDescription(int16_t turntableId, uint8_t positionId) {
|
2024-03-04 15:20:48 +01:00
|
|
|
(void)turntableId;
|
|
|
|
(void)positionId;
|
2023-09-06 21:33:26 +02:00
|
|
|
#include "myAutomation.h"
|
|
|
|
return NULL;
|
|
|
|
}
|
2023-09-02 00:29:49 +02:00
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
// Pass 6: Roster IDs (count)
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-12-26 19:24:04 +01:00
|
|
|
#undef ROSTER
|
2023-05-23 18:59:03 +02:00
|
|
|
#define ROSTER(cabid,name,funcmap...) +(cabid <= 0 ? 0 : 1)
|
2021-12-26 19:24:04 +01:00
|
|
|
const byte RMFT2::rosterNameCount=0
|
2022-04-03 12:19:04 +02:00
|
|
|
#include "myAutomation.h"
|
|
|
|
;
|
|
|
|
|
|
|
|
// Pass 6: Roster IDs
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-12-26 19:24:04 +01:00
|
|
|
#undef ROSTER
|
2022-04-03 12:19:04 +02:00
|
|
|
#define ROSTER(cabid,name,funcmap...) cabid,
|
2023-11-21 22:14:54 +01:00
|
|
|
const int16_t HIGHFLASH RMFT2::rosterIdList[]={
|
2022-04-03 12:19:04 +02:00
|
|
|
#include "myAutomation.h"
|
2023-05-23 10:57:45 +02:00
|
|
|
INT16_MAX};
|
2021-12-26 19:24:04 +01:00
|
|
|
|
2022-04-03 12:19:04 +02:00
|
|
|
// Pass 7: Roster names getter
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-12-26 19:24:04 +01:00
|
|
|
#undef ROSTER
|
2022-04-03 12:19:04 +02:00
|
|
|
#define ROSTER(cabid,name,funcmap...) case cabid: return F(name);
|
|
|
|
const FSH * RMFT2::getRosterName(int16_t id) {
|
|
|
|
switch(id) {
|
2021-12-26 19:24:04 +01:00
|
|
|
#include "myAutomation.h"
|
2022-04-12 19:47:06 +02:00
|
|
|
default: break;
|
2022-04-03 12:19:04 +02:00
|
|
|
}
|
2022-04-12 19:47:06 +02:00
|
|
|
return F("");
|
2022-04-03 12:19:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Pass to get roster functions
|
|
|
|
#undef ROSTER
|
2021-12-26 19:24:04 +01:00
|
|
|
#define ROSTER(cabid,name,funcmap...) case cabid: return F("" funcmap);
|
2022-04-03 12:19:04 +02:00
|
|
|
const FSH * RMFT2::getRosterFunctions(int16_t id) {
|
|
|
|
switch(id) {
|
2021-12-26 19:24:04 +01:00
|
|
|
#include "myAutomation.h"
|
2022-04-03 12:19:04 +02:00
|
|
|
default: break;
|
|
|
|
}
|
2023-05-25 09:27:41 +02:00
|
|
|
return NULL;
|
2022-04-03 12:19:04 +02:00
|
|
|
}
|
2021-12-26 19:24:04 +01:00
|
|
|
|
2022-01-03 13:43:06 +01:00
|
|
|
// Pass 8 Signal definitions
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2022-01-03 13:43:06 +01:00
|
|
|
#undef SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#define SIGNAL(redpin,amberpin,greenpin) {sigtypeSIGNAL,redpin,redpin,amberpin,greenpin},
|
2022-03-18 14:46:07 +01:00
|
|
|
#undef SIGNALH
|
2024-09-22 13:36:19 +02:00
|
|
|
#define SIGNALH(redpin,amberpin,greenpin) {sigtypeSIGNALH,redpin,redpin,amberpin,greenpin},
|
2022-02-06 14:56:51 +01:00
|
|
|
#undef SERVO_SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#define SERVO_SIGNAL(vpin,redval,amberval,greenval) {sigtypeSERVO,vpin,redval,amberval,greenval},
|
2022-06-18 13:31:54 +02:00
|
|
|
#undef DCC_SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#define DCC_SIGNAL(id,addr,subaddr) {sigtypeDCC,id,addr,subaddr,0},
|
2024-02-16 12:49:02 +01:00
|
|
|
#undef DCCX_SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect) {sigtypeDCCX,id,redAspect,amberAspect,greenAspect},
|
|
|
|
#undef NEOPIXEL_SIGNAL
|
|
|
|
#define NEOPIXEL_SIGNAL(id,redRGB,amberRGB,greenRGB) \
|
|
|
|
{sigtypeNEOPIXEL,id,((VPIN)((redRGB)>>8)), ((VPIN)((amberRGB)>>8)), ((VPIN)((greenRGB)>>8))},\
|
|
|
|
{sigtypeContinuation,id,((VPIN)((redRGB) & 0xff)), ((VPIN)((amberRGB) & 0xFF)), ((VPIN)((greenRGB) & 0xFF))},
|
2022-06-18 13:31:54 +02:00
|
|
|
#undef VIRTUAL_SIGNAL
|
2024-09-22 13:36:19 +02:00
|
|
|
#define VIRTUAL_SIGNAL(id) {sigtypeVIRTUAL,id,0,0,0},
|
2022-06-18 13:31:54 +02:00
|
|
|
|
2024-09-22 13:36:19 +02:00
|
|
|
const HIGHFLASH SIGNAL_DEFINITION RMFT2::SignalDefinitions[] = {
|
2022-01-03 13:43:06 +01:00
|
|
|
#include "myAutomation.h"
|
2024-09-22 13:36:19 +02:00
|
|
|
{sigtypeNoMoreSignals,0,0,0,0}
|
|
|
|
};
|
2022-01-03 13:43:06 +01:00
|
|
|
|
2024-06-13 14:01:33 +02:00
|
|
|
// Pass 9 ONLCC/ ONMERG counter and lookup array
|
2023-10-13 14:59:06 +02:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
|
|
|
#undef ONLCC
|
|
|
|
#define ONLCC(sender,event) +1
|
2024-06-13 14:01:33 +02:00
|
|
|
#undef ONACON
|
|
|
|
#define ONACON(event) +1
|
|
|
|
#undef ONACOF
|
|
|
|
#define ONACOF(event) +1
|
2023-10-13 14:59:06 +02:00
|
|
|
|
|
|
|
const int RMFT2::countLCCLookup=0
|
|
|
|
#include "myAutomation.h"
|
|
|
|
;
|
|
|
|
int RMFT2::onLCCLookup[RMFT2::countLCCLookup];
|
|
|
|
|
2021-12-26 19:24:04 +01:00
|
|
|
// Last Pass : create main routes table
|
2021-11-27 12:29:26 +01:00
|
|
|
// Only undef the macros, not dummy them.
|
|
|
|
#define RMFT2_UNDEF_ONLY
|
2022-01-30 18:31:26 +01:00
|
|
|
#include "EXRAIL2MacroReset.h"
|
2021-11-22 12:10:26 +01:00
|
|
|
// Define internal helper macros.
|
|
|
|
// Everything we generate here has to be compile-time evaluated to
|
|
|
|
// a constant.
|
|
|
|
#define V(val) (byte)(((int16_t)(val))&0x00FF),(byte)(((int16_t)(val)>>8)&0x00FF)
|
2021-08-20 20:18:30 +02:00
|
|
|
// Define macros for route code creation
|
2021-11-22 12:10:26 +01:00
|
|
|
|
|
|
|
#define ACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1 | 1),
|
2022-01-05 11:00:11 +01:00
|
|
|
#define ACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<1 | 1),
|
2024-07-10 11:58:22 +02:00
|
|
|
#define AFTER(sensor_id,timer...) OPCODE_AT,V(sensor_id),OPCODE_AFTER,V(sensor_id),OPCODE_PAD,V(#timer[0]?timer+0:500),
|
2023-09-05 13:21:09 +02:00
|
|
|
#define AFTEROVERLOAD(track_id) OPCODE_AFTEROVERLOAD,V(TRACK_NUMBER_##track_id),
|
2022-03-21 17:29:35 +01:00
|
|
|
#define ALIAS(name,value...)
|
2021-08-03 23:12:25 +02:00
|
|
|
#define AMBER(signal_id) OPCODE_AMBER,V(signal_id),
|
2023-02-04 21:56:12 +01:00
|
|
|
#define ANOUT(vpin,value,param1,param2) OPCODE_SERVO,V(vpin),OPCODE_PAD,V(value),OPCODE_PAD,V(param1),OPCODE_PAD,V(param2),
|
2024-02-15 21:05:27 +01:00
|
|
|
#define ASPECT(address,value) OPCODE_ASPECT,V((address<<5) | (value & 0x1F)),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define AT(sensor_id) OPCODE_AT,V(sensor_id),
|
2022-03-18 14:46:07 +01:00
|
|
|
#define ATGTE(sensor_id,value) OPCODE_ATGTE,V(sensor_id),OPCODE_PAD,V(value),
|
|
|
|
#define ATLT(sensor_id,value) OPCODE_ATLT,V(sensor_id),OPCODE_PAD,V(value),
|
2022-01-03 11:15:10 +01:00
|
|
|
#define ATTIMEOUT(sensor_id,timeout) OPCODE_ATTIMEOUT1,0,0,OPCODE_ATTIMEOUT2,V(sensor_id),OPCODE_PAD,V(timeout/100L),
|
2021-11-27 12:29:26 +01:00
|
|
|
#define AUTOMATION(id, description) OPCODE_AUTOMATION, V(id),
|
2021-11-22 12:10:26 +01:00
|
|
|
#define AUTOSTART OPCODE_AUTOSTART,0,0,
|
2024-04-09 21:45:28 +02:00
|
|
|
#define BLINK(vpin,onDuty,offDuty) OPCODE_BLINK,V(vpin),OPCODE_PAD,V(onDuty),OPCODE_PAD,V(offDuty),
|
2022-03-07 17:30:47 +01:00
|
|
|
#define BROADCAST(msg) PRINT(msg)
|
2021-08-03 23:12:25 +02:00
|
|
|
#define CALL(route) OPCODE_CALL,V(route),
|
2023-11-23 11:41:35 +01:00
|
|
|
#define CLEAR_STASH(id) OPCODE_CLEAR_STASH,V(id),
|
|
|
|
#define CLEAR_ALL_STASH OPCODE_CLEAR_ALL_STASH,V(0),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define CLOSE(id) OPCODE_CLOSE,V(id),
|
2024-02-09 12:54:53 +01:00
|
|
|
#define CONFIGURE_SERVO(vpin,pos1,pos2,profile)
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-09-08 23:22:10 +02:00
|
|
|
#define DCC_TURNTABLE(id,home,description...) OPCODE_DCCTURNTABLE,V(id),OPCODE_PAD,V(home),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2021-11-27 12:29:26 +01:00
|
|
|
#define DEACTIVATE(addr,subaddr) OPCODE_DCCACTIVATE,V(addr<<3 | subaddr<<1),
|
2022-01-05 11:00:11 +01:00
|
|
|
#define DEACTIVATEL(addr) OPCODE_DCCACTIVATE,V((addr+3)<<1),
|
2022-01-03 20:15:44 +01:00
|
|
|
#define DELAY(ms) ms<30000?OPCODE_DELAYMS:OPCODE_DELAY,V(ms/(ms<30000?1L:100L)),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define DELAYMINS(mindelay) OPCODE_DELAYMINS,V(mindelay),
|
2022-01-04 22:26:21 +01:00
|
|
|
#define DELAYRANDOM(mindelay,maxdelay) DELAY(mindelay) OPCODE_RANDWAIT,V((maxdelay-mindelay)/100L),
|
2022-06-18 13:31:54 +02:00
|
|
|
#define DCC_SIGNAL(id,add,subaddr)
|
2024-02-16 12:49:02 +01:00
|
|
|
#define DCCX_SIGNAL(id,redAspect,amberAspect,greenAspect)
|
2021-11-27 12:29:26 +01:00
|
|
|
#define DONE OPCODE_ENDTASK,0,0,
|
|
|
|
#define DRIVE(analogpin) OPCODE_DRIVE,V(analogpin),
|
2022-01-02 20:41:57 +01:00
|
|
|
#define ELSE OPCODE_ELSE,0,0,
|
2021-11-27 12:29:26 +01:00
|
|
|
#define ENDEXRAIL
|
2021-11-22 12:10:26 +01:00
|
|
|
#define ENDIF OPCODE_ENDIF,0,0,
|
2021-11-27 12:29:26 +01:00
|
|
|
#define ENDTASK OPCODE_ENDTASK,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define ESTOP OPCODE_SPEED,V(1),
|
2023-09-02 00:29:49 +02:00
|
|
|
#define EXRAIL
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-10-16 21:06:35 +02:00
|
|
|
#define EXTT_TURNTABLE(id,vpin,home,description...) OPCODE_EXTTTURNTABLE,V(id),OPCODE_PAD,V(vpin),OPCODE_PAD,V(home),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2021-08-27 18:01:18 +02:00
|
|
|
#define FADE(pin,value,ms) OPCODE_SERVO,V(pin),OPCODE_PAD,V(value),OPCODE_PAD,V(PCA9685::ProfileType::UseDuration|PCA9685::NoPowerOff),OPCODE_PAD,V(ms/100L),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define FOFF(func) OPCODE_FOFF,V(func),
|
|
|
|
#define FOLLOW(route) OPCODE_FOLLOW,V(route),
|
|
|
|
#define FON(func) OPCODE_FON,V(func),
|
2022-03-24 11:40:49 +01:00
|
|
|
#define FORGET OPCODE_FORGET,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define FREE(blockid) OPCODE_FREE,V(blockid),
|
2024-04-09 21:45:28 +02:00
|
|
|
#define FTOGGLE(func) OPCODE_FTOGGLE,V(func),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define FWD(speed) OPCODE_FWD,V(speed),
|
|
|
|
#define GREEN(signal_id) OPCODE_GREEN,V(signal_id),
|
2022-06-15 12:44:46 +02:00
|
|
|
#define HAL(haltype,params...)
|
2024-01-14 21:20:22 +01:00
|
|
|
#define HAL_IGNORE_DEFAULTS
|
2021-08-03 23:12:25 +02:00
|
|
|
#define IF(sensor_id) OPCODE_IF,V(sensor_id),
|
2022-04-17 10:58:32 +02:00
|
|
|
#define IFAMBER(signal_id) OPCODE_IFAMBER,V(signal_id),
|
2021-12-29 12:15:31 +01:00
|
|
|
#define IFCLOSED(turnout_id) OPCODE_IFCLOSED,V(turnout_id),
|
2022-04-17 10:58:32 +02:00
|
|
|
#define IFGREEN(signal_id) OPCODE_IFGREEN,V(signal_id),
|
2021-11-30 14:52:22 +01:00
|
|
|
#define IFGTE(sensor_id,value) OPCODE_IFGTE,V(sensor_id),OPCODE_PAD,V(value),
|
2023-01-27 13:05:36 +01:00
|
|
|
#define IFLOCO(loco_id) OPCODE_IFLOCO,V(loco_id),
|
2021-11-30 14:52:22 +01:00
|
|
|
#define IFLT(sensor_id,value) OPCODE_IFLT,V(sensor_id),OPCODE_PAD,V(value),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define IFNOT(sensor_id) OPCODE_IFNOT,V(sensor_id),
|
|
|
|
#define IFRANDOM(percent) OPCODE_IFRANDOM,V(percent),
|
2022-04-17 10:58:32 +02:00
|
|
|
#define IFRED(signal_id) OPCODE_IFRED,V(signal_id),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define IFRESERVE(block) OPCODE_IFRESERVE,V(block),
|
2021-12-29 12:15:31 +01:00
|
|
|
#define IFTHROWN(turnout_id) OPCODE_IFTHROWN,V(turnout_id),
|
2022-01-03 11:15:10 +01:00
|
|
|
#define IFTIMEOUT OPCODE_IFTIMEOUT,0,0,
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-09-02 00:29:49 +02:00
|
|
|
#define IFTTPOSITION(id,position) OPCODE_IFTTPOSITION,V(id),OPCODE_PAD,V(position),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2022-12-30 00:46:42 +01:00
|
|
|
#define IFRE(sensor_id,value) OPCODE_IFRE,V(sensor_id),OPCODE_PAD,V(value),
|
2021-11-22 12:10:26 +01:00
|
|
|
#define INVERT_DIRECTION OPCODE_INVERT_DIRECTION,0,0,
|
2024-02-07 23:11:27 +01:00
|
|
|
#define JMRI_SENSOR(vpin,count...)
|
2021-11-22 12:10:26 +01:00
|
|
|
#define JOIN OPCODE_JOIN,0,0,
|
2022-03-31 22:52:43 +02:00
|
|
|
#define KILLALL OPCODE_KILLALL,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define LATCH(sensor_id) OPCODE_LATCH,V(sensor_id),
|
2023-10-13 14:59:06 +02:00
|
|
|
#define LCC(eventid) OPCODE_LCC,V(eventid),
|
|
|
|
#define LCCX(sender,event) OPCODE_LCCX,V(event),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>32)&0xFFFF),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>16)&0xFFFF),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>0)&0xFFFF),
|
2024-06-13 14:01:33 +02:00
|
|
|
#define ACON(eventid) OPCODE_ACON,V(((uint32_t)eventid >>16) & 0xFFFF),OPCODE_PAD,V(eventid & 0xFFFF),
|
|
|
|
#define ACOF(eventid) OPCODE_ACOF,V(((uint32_t)eventid >>16) & 0xFFFF),OPCODE_PAD,V(eventid & 0xFFFF),
|
|
|
|
#define ONACON(eventid) OPCODE_ONACON,V((uint32_t)(eventid) >>16),OPCODE_PAD,V(eventid & 0xFFFF),
|
|
|
|
#define ONACOF(eventid) OPCODE_ONACOF,V((uint32_t)(eventid) >>16),OPCODE_PAD,V(eventid & 0xFFFF),
|
2021-09-08 17:21:04 +02:00
|
|
|
#define LCD(id,msg) PRINT(msg)
|
2023-02-12 00:37:09 +01:00
|
|
|
#define SCREEN(display,id,msg) PRINT(msg)
|
2023-11-30 12:32:39 +01:00
|
|
|
#define STEALTH(code...) PRINT(dummy)
|
2024-04-09 21:45:28 +02:00
|
|
|
#define STEALTH_GLOBAL(code...)
|
2021-09-08 17:21:04 +02:00
|
|
|
#define LCN(msg) PRINT(msg)
|
2024-03-08 21:33:11 +01:00
|
|
|
#define MESSAGE(msg) PRINT(msg)
|
2022-08-13 22:48:03 +02:00
|
|
|
#define MOVETT(id,steps,activity) OPCODE_SERVO,V(id),OPCODE_PAD,V(steps),OPCODE_PAD,V(EXTurntable::activity),OPCODE_PAD,V(0),
|
2024-09-22 13:36:19 +02:00
|
|
|
#define NEOPIXEL(id,r,g,b,count...) OPCODE_NEOPIXEL,V(id),\
|
|
|
|
OPCODE_PAD,V(((r & 0xff)<<8) | (g & 0xff)),\
|
|
|
|
OPCODE_PAD,V((b & 0xff)),\
|
|
|
|
OPCODE_PAD,V(#count[0]?(count+0):1),
|
|
|
|
|
|
|
|
#define NEOPIXEL_SIGNAL(sigid,redcolour,ambercolour,greencolour)
|
2021-11-25 12:36:05 +01:00
|
|
|
#define ONACTIVATE(addr,subaddr) OPCODE_ONACTIVATE,V(addr<<2|subaddr),
|
|
|
|
#define ONACTIVATEL(linear) OPCODE_ONACTIVATE,V(linear+3),
|
2022-06-17 12:48:37 +02:00
|
|
|
#define ONAMBER(signal_id) OPCODE_ONAMBER,V(signal_id),
|
2024-09-28 13:29:12 +02:00
|
|
|
#define ONBLOCKENTER(block_id) OPCODE_ONBLOCKENTER,V(block_id),
|
|
|
|
#define ONBLOCKEXIT(block_id) OPCODE_ONBLOCKEXIT,V(block_id),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define ONCLOSE(turnout_id) OPCODE_ONCLOSE,V(turnout_id),
|
2023-10-13 14:59:06 +02:00
|
|
|
#define ONLCC(sender,event) OPCODE_ONLCC,V(event),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>32)&0xFFFF),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>16)&0xFFFF),\
|
|
|
|
OPCODE_PAD,V((((uint64_t)sender)>>0)&0xFFFF),
|
2023-01-11 18:36:11 +01:00
|
|
|
#define ONTIME(value) OPCODE_ONTIME,V(value),
|
|
|
|
#define ONCLOCKTIME(hours,mins) OPCODE_ONTIME,V((STRIP_ZERO(hours)*60)+STRIP_ZERO(mins)),
|
2023-04-12 13:07:08 +02:00
|
|
|
#define ONCLOCKMINS(mins) ONCLOCKTIME(25,mins)
|
2023-08-12 19:40:48 +02:00
|
|
|
#define ONOVERLOAD(track_id) OPCODE_ONOVERLOAD,V(TRACK_NUMBER_##track_id),
|
2021-11-27 12:29:26 +01:00
|
|
|
#define ONDEACTIVATE(addr,subaddr) OPCODE_ONDEACTIVATE,V(addr<<2|subaddr),
|
|
|
|
#define ONDEACTIVATEL(linear) OPCODE_ONDEACTIVATE,V(linear+3),
|
2022-06-17 12:48:37 +02:00
|
|
|
#define ONGREEN(signal_id) OPCODE_ONGREEN,V(signal_id),
|
|
|
|
#define ONRED(signal_id) OPCODE_ONRED,V(signal_id),
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-09-02 00:29:49 +02:00
|
|
|
#define ONROTATE(id) OPCODE_ONROTATE,V(id),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2021-08-03 23:12:25 +02:00
|
|
|
#define ONTHROW(turnout_id) OPCODE_ONTHROW,V(turnout_id),
|
2022-12-30 00:46:42 +01:00
|
|
|
#define ONCHANGE(sensor_id) OPCODE_ONCHANGE,V(sensor_id),
|
2024-04-13 09:12:35 +02:00
|
|
|
#define ONSENSOR(sensor_id) OPCODE_ONSENSOR,V(sensor_id),
|
|
|
|
#define ONBUTTON(sensor_id) OPCODE_ONBUTTON,V(sensor_id),
|
2021-11-22 12:10:26 +01:00
|
|
|
#define PAUSE OPCODE_PAUSE,0,0,
|
2023-11-23 11:41:35 +01:00
|
|
|
#define PICKUP_STASH(id) OPCODE_PICKUP_STASH,V(id),
|
2023-04-19 23:08:11 +02:00
|
|
|
#define PIN_TURNOUT(id,pin,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(pin),
|
2023-04-20 00:16:32 +02:00
|
|
|
#ifndef DISABLE_PROG
|
2021-08-03 23:12:25 +02:00
|
|
|
#define POM(cv,value) OPCODE_POM,V(cv),OPCODE_PAD,V(value),
|
2023-04-20 00:16:32 +02:00
|
|
|
#endif
|
2021-11-22 12:10:26 +01:00
|
|
|
#define POWEROFF OPCODE_POWEROFF,0,0,
|
2022-02-28 11:38:26 +01:00
|
|
|
#define POWERON OPCODE_POWERON,0,0,
|
2021-08-12 09:53:52 +02:00
|
|
|
#define PRINT(msg) OPCODE_PRINT,V(__COUNTER__ - StringMacroTracker2),
|
2022-03-31 23:04:40 +02:00
|
|
|
#define PARSE(msg) PRINT(msg)
|
2021-11-22 12:10:26 +01:00
|
|
|
#define READ_LOCO OPCODE_READ_LOCO1,0,0,OPCODE_READ_LOCO2,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define RED(signal_id) OPCODE_RED,V(signal_id),
|
|
|
|
#define RESERVE(blockid) OPCODE_RESERVE,V(blockid),
|
2024-11-05 13:23:06 +01:00
|
|
|
#define RESET(pin,count...) OPCODE_RESET,V(pin),OPCODE_PAD,V(#count[0] ? count+0: 1),
|
2021-11-22 12:10:26 +01:00
|
|
|
#define RESUME OPCODE_RESUME,0,0,
|
|
|
|
#define RETURN OPCODE_RETURN,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define REV(speed) OPCODE_REV,V(speed),
|
2021-12-26 19:24:04 +01:00
|
|
|
#define ROSTER(cabid,name,funcmap...)
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-09-08 23:22:10 +02:00
|
|
|
#define ROTATE(id,position,activity) OPCODE_ROTATE,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(EXTurntable::activity),
|
|
|
|
#define ROTATE_DCC(id,position) OPCODE_ROTATE,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(0),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2021-11-27 12:29:26 +01:00
|
|
|
#define ROUTE(id, description) OPCODE_ROUTE, V(id),
|
2023-11-07 17:27:26 +01:00
|
|
|
#define ROUTE_ACTIVE(id) OPCODE_ROUTE_ACTIVE,V(id),
|
|
|
|
#define ROUTE_INACTIVE(id) OPCODE_ROUTE_INACTIVE,V(id),
|
|
|
|
#define ROUTE_HIDDEN(id) OPCODE_ROUTE_HIDDEN,V(id),
|
2023-11-17 11:45:36 +01:00
|
|
|
#define ROUTE_DISABLED(id) OPCODE_ROUTE_DISABLED,V(id),
|
2023-11-07 17:27:26 +01:00
|
|
|
#define ROUTE_CAPTION(id,caption) PRINT(caption)
|
2021-08-16 17:30:30 +02:00
|
|
|
#define SENDLOCO(cab,route) OPCODE_SENDLOCO,V(cab),OPCODE_PAD,V(route),
|
2021-11-27 12:29:26 +01:00
|
|
|
#define SEQUENCE(id) OPCODE_SEQUENCE, V(id),
|
2021-09-08 17:29:58 +02:00
|
|
|
#define SERIAL(msg) PRINT(msg)
|
2021-09-08 17:21:04 +02:00
|
|
|
#define SERIAL1(msg) PRINT(msg)
|
|
|
|
#define SERIAL2(msg) PRINT(msg)
|
|
|
|
#define SERIAL3(msg) PRINT(msg)
|
2022-12-16 14:14:48 +01:00
|
|
|
#define SERIAL4(msg) PRINT(msg)
|
|
|
|
#define SERIAL5(msg) PRINT(msg)
|
|
|
|
#define SERIAL6(msg) PRINT(msg)
|
2021-08-28 18:39:48 +02:00
|
|
|
#define SERVO(id,position,profile) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::profile),OPCODE_PAD,V(0),
|
|
|
|
#define SERVO2(id,position,ms) OPCODE_SERVO,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(PCA9685::Instant),OPCODE_PAD,V(ms/100L),
|
2022-02-06 14:56:51 +01:00
|
|
|
#define SERVO_SIGNAL(vpin,redpos,amberpos,greenpos)
|
2021-11-27 12:29:26 +01:00
|
|
|
#define SERVO_TURNOUT(id,pin,activeAngle,inactiveAngle,profile,description...) OPCODE_SERVOTURNOUT,V(id),OPCODE_PAD,V(pin),OPCODE_PAD,V(activeAngle),OPCODE_PAD,V(inactiveAngle),OPCODE_PAD,V(PCA9685::ProfileType::profile),
|
2024-11-05 13:23:06 +01:00
|
|
|
#define SET(pin,count...) OPCODE_SET,V(pin),OPCODE_PAD,V(#count[0] ? count+0: 1),
|
2022-03-19 17:26:29 +01:00
|
|
|
#define SET_TRACK(track,mode) OPCODE_SET_TRACK,V(TRACK_MODE_##mode <<8 | TRACK_NUMBER_##track),
|
2023-09-25 10:59:17 +02:00
|
|
|
#define SET_POWER(track,onoff) OPCODE_SET_POWER,V(TRACK_POWER_##onoff),OPCODE_PAD, V(TRACK_NUMBER_##track),
|
2021-11-27 12:29:26 +01:00
|
|
|
#define SETLOCO(loco) OPCODE_SETLOCO,V(loco),
|
2024-07-10 10:57:03 +02:00
|
|
|
#define SETFREQ(freq) OPCODE_SETFREQ,V(freq),
|
2022-01-03 13:43:06 +01:00
|
|
|
#define SIGNAL(redpin,amberpin,greenpin)
|
2022-03-18 14:46:07 +01:00
|
|
|
#define SIGNALH(redpin,amberpin,greenpin)
|
2021-08-03 23:12:25 +02:00
|
|
|
#define SPEED(speed) OPCODE_SPEED,V(speed),
|
2023-09-24 16:40:42 +02:00
|
|
|
#define START(route) OPCODE_START,V(route),
|
2023-11-23 11:41:35 +01:00
|
|
|
#define STASH(id) OPCODE_STASH,V(id),
|
2021-08-03 23:12:25 +02:00
|
|
|
#define STOP OPCODE_SPEED,V(0),
|
|
|
|
#define THROW(id) OPCODE_THROW,V(id),
|
2024-04-09 21:45:28 +02:00
|
|
|
#define TOGGLE_TURNOUT(id) OPCODE_TOGGLE_TURNOUT,V(id),
|
2023-09-02 10:45:59 +02:00
|
|
|
#ifndef IO_NO_HAL
|
2023-09-08 23:22:10 +02:00
|
|
|
#define TT_ADDPOSITION(id,position,value,angle,description...) OPCODE_TTADDPOSITION,V(id),OPCODE_PAD,V(position),OPCODE_PAD,V(value),OPCODE_PAD,V(angle),
|
2023-09-02 10:45:59 +02:00
|
|
|
#endif
|
2021-11-27 12:29:26 +01:00
|
|
|
#define TURNOUT(id,addr,subaddr,description...) OPCODE_TURNOUT,V(id),OPCODE_PAD,V(addr),OPCODE_PAD,V(subaddr),
|
2023-04-08 18:22:39 +02:00
|
|
|
#define TURNOUTL(id,addr,description...) TURNOUT(id,(addr-1)/4+1,(addr-1)%4, description)
|
2021-11-22 12:10:26 +01:00
|
|
|
#define UNJOIN OPCODE_UNJOIN,0,0,
|
2021-08-03 23:12:25 +02:00
|
|
|
#define UNLATCH(sensor_id) OPCODE_UNLATCH,V(sensor_id),
|
2022-06-18 13:31:54 +02:00
|
|
|
#define VIRTUAL_SIGNAL(id)
|
2022-03-24 12:56:06 +01:00
|
|
|
#define VIRTUAL_TURNOUT(id,description...) OPCODE_PINTURNOUT,V(id),OPCODE_PAD,V(0),
|
2023-05-01 15:25:45 +02:00
|
|
|
#define WITHROTTLE(msg) PRINT(msg)
|
2021-08-28 18:39:48 +02:00
|
|
|
#define WAITFOR(pin) OPCODE_WAITFOR,V(pin),
|
2023-09-06 23:58:19 +02:00
|
|
|
#ifndef IO_NO_HAL
|
|
|
|
#define WAITFORTT(turntable_id) OPCODE_WAITFORTT,V(turntable_id),
|
|
|
|
#endif
|
2021-09-06 13:27:21 +02:00
|
|
|
#define XFOFF(cab,func) OPCODE_XFOFF,V(cab),OPCODE_PAD,V(func),
|
|
|
|
#define XFON(cab,func) OPCODE_XFON,V(cab),OPCODE_PAD,V(func),
|
2024-04-09 21:45:28 +02:00
|
|
|
#define XFTOGGLE(cab,func) OPCODE_XFTOGGLE,V(cab),OPCODE_PAD,V(func),
|
2021-08-03 23:12:25 +02:00
|
|
|
|
2021-11-27 12:29:26 +01:00
|
|
|
// Build RouteCode
|
2021-08-12 09:53:52 +02:00
|
|
|
const int StringMacroTracker2=__COUNTER__;
|
2023-11-21 22:14:54 +01:00
|
|
|
const HIGHFLASH3 byte RMFT2::RouteCode[] = {
|
2021-11-27 12:29:26 +01:00
|
|
|
#include "myAutomation.h"
|
|
|
|
OPCODE_ENDTASK,0,0,OPCODE_ENDEXRAIL,0,0 };
|
2021-08-03 23:12:25 +02:00
|
|
|
|
2021-09-09 11:12:27 +02:00
|
|
|
// Restore normal code LCD & SERIAL macro
|
2021-08-12 09:53:52 +02:00
|
|
|
#undef LCD
|
|
|
|
#define LCD StringFormatter::lcd
|
2023-02-12 00:37:09 +01:00
|
|
|
#undef SCREEN
|
|
|
|
#define SCREEN StringFormatter::lcd2
|
2021-09-09 11:12:27 +02:00
|
|
|
#undef SERIAL
|
|
|
|
#define SERIAL 0x0
|
2021-08-03 23:12:25 +02:00
|
|
|
#endif
|