mirror of
https://github.com/DCC-EX/CommandStation-EX.git
synced 2024-11-23 08:06:13 +01:00
myCMRI.h example added
This commit is contained in:
parent
aa1e53035f
commit
486e083c1d
41
myCMRI_h_example.txt
Normal file
41
myCMRI_h_example.txt
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
// myCMRI.h to be included in myAutomation.h
|
||||||
|
|
||||||
|
// see myHal.cpp_example.txt for explanation of parameters
|
||||||
|
|
||||||
|
#include "IO_CMRI.h" // CMRI nodes
|
||||||
|
// in config.h #define ARDUINOCMRI_COMPATIBLE
|
||||||
|
|
||||||
|
// define CMRI bus
|
||||||
|
HAL(CMRIbus, 0, Serial5, 9600, 500, 51)
|
||||||
|
|
||||||
|
// define CMRI nodes
|
||||||
|
HAL(CMRInode, 900, 72, 0, 4, 'M')
|
||||||
|
|
||||||
|
// define the pins - this is S-MINI emulation 24/48 I/O
|
||||||
|
// 16 of 24 input pins
|
||||||
|
//JMRI_SENSOR(900,16) // broadcast <Q/q sensor for state changes
|
||||||
|
// ... these pins do not need to be defined unless needed for JMRI
|
||||||
|
|
||||||
|
// 16 turnouts require definition with vPin, id
|
||||||
|
// define as PIN_TURNOUT in DCC-EX -- the servo parameters are done within the CMRI sketch
|
||||||
|
PIN_TURNOUT(924, 924, "Pin 0 on PCA module")
|
||||||
|
PIN_TURNOUT(925, 925, "Pin 1 on PCA module")
|
||||||
|
PIN_TURNOUT(931, 931, "Pin 7 on PCA module")
|
||||||
|
// ... thru 939
|
||||||
|
|
||||||
|
// define 16 or 32 pins for digital outputs
|
||||||
|
//PARSE("<Z 940 940 0>")
|
||||||
|
// ... these pins do not need to be defined unless needed for JMRI
|
||||||
|
|
||||||
|
// a testing sequence
|
||||||
|
// pin 941 is wired to pin 907. LED on pin 943
|
||||||
|
// pin 942 is wired to pin 911.
|
||||||
|
// use commands <z 941> <z -941> etc.
|
||||||
|
AUTOSTART
|
||||||
|
SEQUENCE(99)
|
||||||
|
AT(907) SET(943)
|
||||||
|
AT(911) RESET(943)
|
||||||
|
FOLLOW(99)
|
||||||
|
|
||||||
|
// CMRI sketch used for testing available here
|
||||||
|
// https://www.trainboard.com/highball/index.php?threads/24-in-48-out-card-for-jmri.116454/page-2#post-1141569
|
|
@ -16,6 +16,7 @@
|
||||||
#if !defined(IO_NO_HAL)
|
#if !defined(IO_NO_HAL)
|
||||||
|
|
||||||
// Include devices you need.
|
// Include devices you need.
|
||||||
|
//#include "DCC.h" // for the locoID in updateLocoScreen()
|
||||||
#include "IODevice.h"
|
#include "IODevice.h"
|
||||||
//#include "IO_HALDisplay.h" // Auxiliary display devices (LCD/OLED)
|
//#include "IO_HALDisplay.h" // Auxiliary display devices (LCD/OLED)
|
||||||
//#include "IO_HCSR04.h" // Ultrasonic range sensor
|
//#include "IO_HCSR04.h" // Ultrasonic range sensor
|
||||||
|
@ -56,6 +57,10 @@ void halSetup() {
|
||||||
//mySerial2.begin(9600, SERIAL_8N2, 16, 17); // ESP32 to define pins also check DCCTimerESP.cpp
|
//mySerial2.begin(9600, SERIAL_8N2, 16, 17); // ESP32 to define pins also check DCCTimerESP.cpp
|
||||||
//CMRIbus::create(0, mySerial2, 9600, 500, 4); // for ESP32
|
//CMRIbus::create(0, mySerial2, 9600, 500, 4); // for ESP32
|
||||||
|
|
||||||
|
// for F439ZI and others - already defined Serial5(PD2, PC12); // Rx=PD2, Tx=PC12 -- UART5
|
||||||
|
// D51 is PD7
|
||||||
|
//CMRIbus::create(0, Serial5, 9600, 500, 51);
|
||||||
|
|
||||||
// for Mega
|
// for Mega
|
||||||
//CMRIbus::create(0, Serial3, 9600, 500, 38); // for Mega - Serial3 already defined
|
//CMRIbus::create(0, Serial3, 9600, 500, 38); // for Mega - Serial3 already defined
|
||||||
// bus=0 always, unless multiple serial ports are used
|
// bus=0 always, unless multiple serial ports are used
|
||||||
|
@ -64,6 +69,9 @@ void halSetup() {
|
||||||
// pin.. DE/!RE pins tied together on TTL RS485 module.
|
// pin.. DE/!RE pins tied together on TTL RS485 module.
|
||||||
// pin 38 should work on Mega and F411RE (pin D38 aka PB12 on CN10_16)
|
// pin 38 should work on Mega and F411RE (pin D38 aka PB12 on CN10_16)
|
||||||
|
|
||||||
|
//CMRInode::create(500, 72, 0, 1, 'M');
|
||||||
|
//CMRInode::create(600, 72, 0, 2, 'M');
|
||||||
|
//
|
||||||
//CMRInode::create(900, 72, 0, 4, 'M');
|
//CMRInode::create(900, 72, 0, 4, 'M');
|
||||||
//CMRInode::create(1000, 72, 0, 5, 'M');
|
//CMRInode::create(1000, 72, 0, 5, 'M');
|
||||||
// bus=0 must agree with bus in CMRIbus
|
// bus=0 must agree with bus in CMRIbus
|
||||||
|
@ -108,6 +116,8 @@ void halSetup() {
|
||||||
// on screen #3, the first eight entries (assuming an 8-line display)
|
// on screen #3, the first eight entries (assuming an 8-line display)
|
||||||
// from the loco speed table.
|
// from the loco speed table.
|
||||||
|
|
||||||
|
// Uncomment the line #include "DCC.h" above
|
||||||
|
|
||||||
// Put the following block of code in myHal.cpp OUTSIDE of the
|
// Put the following block of code in myHal.cpp OUTSIDE of the
|
||||||
// halSetup() function:
|
// halSetup() function:
|
||||||
//
|
//
|
||||||
|
|
Loading…
Reference in New Issue
Block a user