Relatively Simple Project, But Complex Interface

I built a circuit for work to address a test suite that the lab techs here have to perform as part of a product evaluation.

The current design uses 5 DPDT switches and 1 4-position rotary switch. I want to replace all of these switches with DPDT relays and give the techs a nice LCD screen with a touchscreen on top so that they can navigate through a menu system to select the test they want to perform. Once they select the proper test, the Arduino will pull the correct relays and set the circuit up for that test sequence.

So, here is the menu I want to create:

PAGE 1:

Select:

2-Wire 4-Wire

If they select the "2-Wire" option, then:

PAGE 2a:

Select:

Tip Ring Tip/Ring

If they selected the "4-Wire" option, then:

PAGE 2b:

Select:

Tip Ring Tip1 Ring1 Tip/Ring Tip1/Ring1

I'm pretty sure I can do this with a switch structure, but I have a couple of questions regarding the LCD and Touchscreen combination.

I bought these:

http://www.sparkfun.com/commerce/product_info.php?products_id=710

http://www.sparkfun.com/commerce/product_info.php?products_id=8977

http://www.sparkfun.com/commerce/product_info.php?products_id=9170

And, I read this information:

http://www.arduino.cc/playground/Code/GLCDks0108

and this topic regarding this LCD and the above mentioned code found here:

http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1210427907

From what I gathered, it seems that the LCD Library should work with this LCD.

I have not worked with LCDs or Touchscreens, but I think I have the basic idea here.

This is what I want to do:

The touchscreen is basically a set of invisible buttons that are laid over the LCD. When a person touches a particular location of the touchscreen, the program interprets that as a button press and it executes the routine associated with that button press. To the user, it appears that they are actually pushing the pseudobutton on the LCD.

So, as the user navigates through the various submenus, the information displayed on the LCD will obviously change, and if they need the ability to select options on those submenu screens, then the touchscreen "buttons" will have to change position accordingly, right?

So, here are my questions:

  1. Will all anticipated softbuttons on the touchscreen have to be defined seperately, or can you reuse certain button definitions in more than one routine?

  2. Can the code for the touchscreen and the LCD be contained in the same routine, or would it be better to separate them into two different functions so that the touchscreen inputs change the LCD outputs and relocates the touchscreen softbuttons?

  3. I will be prototyping with a Mega, and then converting it over to a smaller Arduino once I have it working (possibly a Nano, or similar). Is there any issues with doing this?

NOTE: This will be a permanent install, so it does not matter if I use all of the pins or not. I would, however, like to utilize as many pins as possible to justify the expense.

So, here are my questions:

  1. Will all anticipated softbuttons on the touchscreen have to be defined seperately, or can you reuse certain button definitions in more than one routine?

This is really a gui design question; since the display you are going to use is a dot-addressable display, what you would want to most likely do is set up a function like "drawButton(int x, int y, char *label, boolean state)" - so that you can pass the position of the button, the label on the button, and the state (true/false == down/up respectively). This will allow you to control where and how a button looks, and keep all the buttons looking the same (you will need code in that section to allow buttons to size based on label size, etc).

Other custom code will be needed (graphics primitives - line, circle, box, filled box, clear screen, print text, etc) - start with those low-level functions first (there should be enough code on the net done by others to get you started), then expand from there.

  1. Can the code for the touchscreen and the LCD be contained in the same routine, or would it be better to separate them into two different functions so that the touchscreen inputs change the LCD outputs and relocates the touchscreen softbuttons?

Separate the display logic from the control logic - this is standard software design process; doing so will make debugging now (and in the future) much easier. Use tons of comments, document everything as you go - you will thank me later.

  1. I will be prototyping with a Mega, and then converting it over to a smaller Arduino once I have it working (possibly a Nano, or similar). Is there any issues with doing this?

Hmm - this I don't know (don't have any experience with the Mega) - there may be pin-relocation issues (ie, pins on the Mega may/may not match up with a standard 168/328 Arduino)?

Your best bet is to set up defined (#define) constants at the top of your program for pin assignments, perhaps with compiler directives to control compilation process based on the target platform (I think this is possible); if compiler directives for targeting platforms are not possible, then at least set up the defined constants - then if you need to change something, rather than go thru all the code changing a pin assignment or whatnot, you just change the constants and recompile.

Make the constants human-readable, so that someone in the future (ie, your future self or another - who has either forgotten how the code works or has never seen it!) can easily change it for whatever reason (different LCD, different Arduino platform, who knows).

Hope this helps! Good luck...

:)

Thank you very much for the advice and help.

Welp, the items have arrived from Sparkfun. It looks like I have some work to do.