LCD Display Throttle

TwinDad Jan 31, 2017

  1. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I'm planning a small shelf switching layout that I want to be able to take to shows and such. Layout-wise it's just an Inglenook puzzle. I'm going to power it with DCC++ so I can use a sound loco and stuff, but I didn't want to have a separate throttle to keep track of.

    So, I got a 16x2 LCD display kit with buttons (the Adafruit I2C version), and wrote some code to add a throttle to DCC++ ...



    Hardware here is an UNO with the Pololu MC33926 driver and the Adafruit I2C-enabled display. You can't use a regular "all pins" display because the pinouts interfere with the current feedback from the motor board. The I2C displays only use 2 pins (the I2C).

    A long-press on the Select button toggles track power. Short Select is emergency stop. Left/Right are speed (and direction in Switcher mode), and Up/Down toggle direction.

    I still need to add a way to choose which display mode (standard vs. switcher) and input the loco address, and also to adjust the max speed. I also want to figure out (from a human interface standpoint -- the code is easy) how to allow for a bell and horn and lights. I may simply add more buttons. Dunno yet.

    I also wrote code that will do the randomization for the Inglenook puzzle, and tell you what cars to put in the train. It's separate, but I'm going to integrate the two so you can toggle back and forth between the puzzle "stuff" and the throttle.
     
  2. esfeld

    esfeld TrainBoard Member

    442
    382
    17
    Mark
    Very interested to see the code, even now, to follow along. Curious to investigate why you say a standard 16x2 LCD is not applicable ..... although I do see why the Adafruit unit with built in buttons would simplify the coding.
    Steve F
     
    Scott Eric Catalano likes this.
  3. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I'll put the code up on GitHub soon as I get a chance.

    The problem with the "standard" LCD (without the I2C) is that some of the pins are used by the motor driver board for current sense. I'm sure one could swizzle the pin assignments around and make it work, but it's sooooo much easier to just get an I2C enabled display. There are I2C "backpack" boards available to update the standard kind.

    I actually wrote the code to handle both kinds of LCDs ... and of course if you want to have separate buttons wired to GPIO that's easily done as well.
     
    Scott Eric Catalano likes this.
  4. TwinDad

    TwinDad TrainBoard Member

    1,844
    551
    34
    I've pushed the code for this to my local github: https://github.com/msunderwd/BaseStation-Uno/tree/lcd_throttle

    That should be branch "lcd_throttle", and it should be (otherwise) up-to-date with the main "master" branch. Let me know if there are any problems using it. You will need the Adafruit I2C-based LCD library "Adafruit_RGBLCDShield" or the OSEPP library. If you have a different display, the changes required to LCD.cpp to support it should be fairly straightforward.

    The code is not done yet. There are some known bugs, and some capabilities that I haven't implemented yet. For example, if you do the Inglenook game, the descriptions of the cars are hard coded. This won't be a big deal for *my* intended use, but it would be nice to be able to configure this via the serial interface or something.

    One thing of note... I had to do a "swizzle" to the EEStore code to make sure LCDThrottle had some space "up front" to store its configuration... this is because the turnouts/sensors/outputs storage is dynamic in size, and I wasn't sure I could count on the LCDThrottle data being in the same (right) place every time. Plus, I didn't want to re-write the turnout/sensor/output data every time the user changed the display mode or the loco address.
     
    Scott Eric Catalano likes this.

Share This Page