6
\$\begingroup\$

This question: Standard text LCD menu system has generated some confusion.

Standard text LCD menu system

Is there a pattern out there for a simple menu system in C for a text LCD. I find myself re-writing code a lot for handling simple text LCD menus.

I find most systems have a main menu and some sub-menus that when selected allow you to set a parameter with within some minimum and maximum value.

Ideally this menu system could be navigated with 4 simple keys such as enter, cancel, up, and down.

In my application I'm using a 2 line x 16 character text LCD though an ideal solution should be able to be applied to any NxM display.

It's a question about programming specifically for embedded systems, but it's also a question about programming patterns. Is it on-topic here?

\$\endgroup\$
5
\$\begingroup\$

Essentially we are a hardware site. Sure we have many questions that aren't about hardware, but pretty much everything we answer has some direct connection to the hardware.

Firmware/software can have a direct connection to the hardware when it comes to things like "why is my pin doing X" or "how do I setup the module in my PIC to be able to do Y". It can even be related to LCDs when it is things like "When I send command Z over my SPI line to my LCD controller I have whatever bad happen"

However, when it comes to questions that can be answered with out talking a single bit about the hardware, then it should be on SO. This specific question even takes it a step further and talks about designing the User Interface which falls more into the scope of UX.stackexchange. The specific coding structure to support the interface would be an SO question though.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ I agree, if the question was "how can I read values from a rotary encoder" or "how can I draw to this LCD" or "how can I debounce my buttons" it would be a good fit here. But, the core of the question, as I understand it, is about how to build a text based menu system in C. If this is done properly, it should be hardware independent. \$\endgroup\$ – Toby Jaffey Oct 14 '11 at 16:09
  • \$\begingroup\$ Yes the question is independent of hardware, but it is useful question for people who are working with any text LCD hardware. Some questions on this site apply to different hardware platforms like PIC and AVR and those are still good questions. \$\endgroup\$ – mjh2007 Oct 14 '11 at 18:24
  • \$\begingroup\$ P.S. I've found other examples of menus that use structures like you describe in your answer leading me to believe that it is a good way to solve the menu problem that not everyone knows about. \$\endgroup\$ – mjh2007 Oct 14 '11 at 18:26
  • \$\begingroup\$ @kellenjb, is it possible that the reason that this was asked here is that he cannot use standard libraries and such as an affect of limited microcontroller resources? \$\endgroup\$ – Kortuk Oct 18 '11 at 14:44
5
\$\begingroup\$

I answered this question today re an addressing mode of MIPS and noticed it had one close vote, so I made the comment:

Why the vote to close? In general, microcontroller programming questions have been allowed in this forum. Note under RELATED in the right sidebar the number of MIPS questions.

Although in the past MIPS might have been more associated with workstations, it is now the core of Microchip's PIC32 microcontrollers.

This question, although not about specific peripheral hardware (like SPI or LCD), was still specific to the MIPS/PIC32 hardware and only relevant to someone writing assembly language for the chip. Therefore I believe it belongs more here than on SO, as there are a lot of embedded systems programmers who use PIC microcontrollers hanging out on this site.

As I mentioned in my comment, there are a number of other general MIPS questions that have been allowed here.

\$\endgroup\$
1
  • 3
    \$\begingroup\$ I can't think of a reason the MIPS addressing question should be closed either. \$\endgroup\$ – Olin Lathrop Oct 16 '11 at 13:41
4
\$\begingroup\$

I thought this question was off topic because it was more of a application problem than actual programming issue. It was closer to gimme the code than why does this pin change after a unrelated BSF PORTB,2 ?. It may have been on a system without a OS, but that doesn't seem all that relevant to this particular question.

I think it's hard to make a clear rule what's on topic and what's not. There will always be some gray area and therefore require judgement calls. In other words, maybe I can't clearly explain it, but I'll know it when I see it.

This is why we have a voting system. It's good that my vote only counts 1/5 of the way to closing. Let it be worked out by consensus.

\$\endgroup\$
1
  • \$\begingroup\$ is it possible that the reason that this was asked here is that he cannot use standard libraries and such as an affect of limited microcontroller resources? I agree on the grey area and I myself will only act as a 5th vote when I have an opinion, but not a moderator close. \$\endgroup\$ – Kortuk Oct 18 '11 at 14:45
2
\$\begingroup\$

I think any programming question that is at the operating system level or lower should be accepted. This question is asking about creating a menu system in C for a text based LCD. The text based LCD is connected to an embedded device without the assistance of an operating system.

Stack Overflow covers a very large range of programming topics and a very small portion of them are related to writing embedded software or writing operating system software. Therefore questions like this tend to get lost on a larger forum like Stack Overflow.

This forum (electronics.stackexchange.com) has a user base that is more familiar with low level software of this type. Therefore this forum is more likely to generate answers to the question and the users of this forum are more likely to benefit from the answers supplied than the users at other forums.

\$\endgroup\$
2
  • 2
    \$\begingroup\$ It is great that you think that, but it would be helpful to explain why you think that. \$\endgroup\$ – Kellenjb Oct 14 '11 at 15:55
  • 2
    \$\begingroup\$ I will note, any questions that I have regarding writing an application that resides on a PC (mac, linux, windows box) or uses a virtual machine to run (I.E. java for android) I ask at SO, electronics.stackexchange (for me) is the level that I look to for any hardware level programming, so even if I asked a purely programming question, if it was so I could run it on a microchip, I would ask it here..just my .02 \$\endgroup\$ – onaclov2000 Oct 16 '11 at 19:37
2
\$\begingroup\$

It's concerned with the user interface, and is a relatively high-level software question. It has nothing to do with electronic design.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ agreed - even in embedded code, that which decides what should be displayed (OP's question) should be separable from that which does the displaying (e.g. 'how do i operate this LCD'). There's simply no need to have I/O registers visible at the menu system level, and I/O regs are about as far as we should go. \$\endgroup\$ – JustJeff Oct 15 '11 at 3:38
  • \$\begingroup\$ @JustJeff, is it possible that the reason that this was asked here is that he cannot use standard libraries and such as an affect of limited microcontroller resources? \$\endgroup\$ – Kortuk Oct 18 '11 at 14:44
  • \$\begingroup\$ @Kortuk -- well, I almost never, never ever like to generalize but in this case, I can imagine almost no excuse to intertwine hardware manipulation details with what's arguably user interface code. \$\endgroup\$ – JustJeff Oct 18 '11 at 22:52
  • \$\begingroup\$ @JustJeff - embedded hardware's capabilities often imposes limits on software even in areas where the hardware interaction itself is abstracted away. Embedded engineers who participate here are generally better prepared to deal with those than desktop developers on SO, since PC's outgrew many of those constraints 20 years ago. \$\endgroup\$ – Chris Stratton Dec 3 '11 at 5:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .