Question: How do they code the logic of a user interface running on embedded hardware. Microwave ovens, flat screen televisions, portable DVD players and even a digital watches these days have complex user interfaces. Are there tools / frameworks available to remove all the dirty work or are the developers using IF ELSE kind of constructs.

I'm not asking for user interface toolkits in the sense of QT or WxWidgets. I am more interested in knowing if there are frameworks to handle the logic behind the controls.

```
if (mTemperature > maxTemperature)
    temperatureDialControl.Enabled = false;

```

Answer: 
I've used the [**Quantum Platform**](http://www.state-machine.com/products/) family of frameworks from Quantum Leaps for several embedded products with user interfaces (and those without UIs as well).

The QP is a framework for event-driven programming (which essentially all embedded systems are). User interfaces in particular are a good match, because most user interfaces consist of "widgets" which can be customized, and the widgets typically receive events (timeout, button press, movement, etc.) from an event dispatcher. This "inversion of control" is very typical with user interfaces. Most (embedded) user interfaces that I've come across in my career are either event-driven state machines, or they should have been implemented that way.

You asked specifically about handling the logic & controls. What's nice about the QP is that the active-object model of computing that it embraces lends itself to very natural & straightforward implementation of state machines (flat or hierarchical). So in your example above, you'd probably receive a "temperature update" event with a new temperature, and your state handler would perform the logic & decide what action is necessary. With a framework, you create the logic behind the controls, but the infrastructure handles almost everything else.

The Quantum Platform is pretty slick. It's also very easy to see the connection (traceability) between the design (statechart) and the implementation/code. Best of all, the framework implements all the infrastructure (event queueing & dispatching, state transitions, garbage collection, memory pools, etc..) so all you have to do is focus on your application.

I've used Nokia's Qt on non-embedded platforms, but your question seems to suggest you're already aware of it. I think there's a smaller "embeddedable" version of Qt but I've never used it.
*Are there tools/frameworks to remove all the dirty work ..* ? Yes, there are. They are called embedded OS'es and RTOS'es. As a rule, they help in handling interrupts generated by timers, buttons, and other controls, they contain hardware abstraction levels, they include various communication protocol stacks and etc. So, basically, they do all dirty work. All you need is to process what they provide using IF/ELSE or SWITCH or whatever you like. At least who knows better that **temperatureDialControl.Enabled** has to be **false** if **mTemperature** exceeds **maxTemperature**?