LCD Manager – part 1: the beginning

Lets start from scratch. We need do some thinking, some planing and some assumptions. Some requirements are also necessary. Lots of ‘some’ but lets forge it to some ideas and latter to code.

Basic structure

We will go with structure similar to CharLCD, so project directory lcdmanager, package lcdmanager directly in root and in it two packages: demos and abstract. And of course tests directory.

In root dir add .gitignore with:



First thoughts

So our manager need to know about few things and keep information about few other things 🙂

First it need to know where to display content, so lcd. Question is buffered and direct ? Maybe only buffered ?
What will happen when we display label on lcd. In direct mode it should be displayed instantly, buffered should wait for flush.
But what when we have few widgets and we want to hide one. We need to rewrite each widget to lcd in direct mode. In buffered change buffer and wait for flush. Seems direct mode is slow, very slow. Direct mode works as follow: send instantly command to lcd and write. But witch few widgets first we need to calculate visibility, position and then display. So it is impossible to use direct mode with manager. For speed its necessary to use buffer to stack all widgets and then display.

  • So we are going with only buffered mode.

Next we need to keep dictionary of widgets. But how to make an access to them ? Maybe with name? So each widget may have a name. And widgets without name won’t be available to user via manager, we have to keep reference to it.
So we will go with two arrays, one for widgets and second for name-to-id reference.

  • dictionary with widgets

What about  lcd functions like write, pos? Will we allow them? Or only widgets? I think if we are using manager we want only widgets.

  • only manager function

Time for widgets.

We will keep each widget in its own file.
We need some common interface for it. I’m thinking functions to control size, visibility and render are required. We will try to implement autowidth and manual width.

What else? We will see.

Rendering output to screen will require a loop over each widget, get its view and write to buffer. Seems we will need some kind of z-index on each item. And menu should always be on top when visible.


Each widget will hold information about its position and visibility. What widgets will we implement?

Label should have a label 🙂 and functions to set and get it.

Panel is more complicated, we should have ability to add other widgets to it, something similar to manager.

Menu this is a challenge 🙂 We should have ability to add submenu to menu. I’m not sure about depth, we will see what comes out. But most important, menu will have events and functions to call when activating.
One thing more, it will render differently on different height. One liner lcd should work slight different than multiliner.

Text another not-so-simple widget. First we will use numbers only type.

Almost every widget should have a render function. This will return an array with look.

Controls and events

This is another mater to analyze. Manager will have a event handler but how to send events to proper widget? Seems we need to keep another information:

  • what widget we are focused into

And when no focus send event to all.

We will use named events, so event dispatcher will use names and not some codes.

But what about event dispatcher?

Seems we need demo code with loop and put all this in it.


We know what to do:

  • lcd manager will support only buffered mode lcd
  • add/remove widgets from manager
  • dictionary with widgets
  • names for widget reference
  • hide lcd function from user like write, stream
  • event queue
  • event handlers
  • label widget
  • panel widget
  • menu widget
  • visible menu always on top
  • event handler for menu
  • actions for menu
  • numeric input widget
  • event handler for text
  • shared widget functions for position, render, visibility, size

Another mater is what will come out 🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s