From 8a7dc2643cd15a6d55dd1f257c4940d4167702fc Mon Sep 17 00:00:00 2001 From: Asbelos Date: Mon, 7 Oct 2024 10:54:05 +0100 Subject: [PATCH] comments --- IO_TM1638.cpp | 3 ++ Release - Architecture Doc/TM1638.md | 66 ++++++++++++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/IO_TM1638.cpp b/IO_TM1638.cpp index 79d8490..45614f6 100644 --- a/IO_TM1638.cpp +++ b/IO_TM1638.cpp @@ -17,6 +17,9 @@ * along with CommandStation. If not, see . */ +/* Credit to https://github.com/dvarrel/TM1638 for the basic formulae.*/ + + #include #include "IODevice.h" #include "DIAG.h" diff --git a/Release - Architecture Doc/TM1638.md b/Release - Architecture Doc/TM1638.md index e69de29..a9b1660 100644 --- a/Release - Architecture Doc/TM1638.md +++ b/Release - Architecture Doc/TM1638.md @@ -0,0 +1,66 @@ +## 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 ` 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 `` will cause the command station to issue `` and `` messages when the first button is pressed or released. + +Exrail `JMRI_SENSOR(500,8)` will create `