Skip to content
Gionata edited this page Jan 25, 2015 · 1 revision

#DisplayGroup library


##UPDATES!!!

A new version of the scoreboard has been released, with wireless controller!! Since Google Code doesn't allow new download to be created any more, you can find all the source, documentation, schematics, drafts file and more in this public [https://www.dropbox.com/sh/2w9wfuafjlqs3h5/AAD1wwyYpn6WiD12J3mucF9Ga?dl=0 Dropbox folder].

This is just a bit of what's new!!!


This document describes a C++ library developed for the Arduino platform, with standard C++ functionality, which helps to manage any number of display connect to the Arduino digital outputs. The goal of this library is to ease down the representation of some process variables giving the user a simple interface and a way to update the current values shown. This library is especially designed for 7-segments display, which are commonly used in electronic projects to display data. The code has been developed with the user in mind, and it has been tested and used on a real application, to show the score of a basketball game for my local team!!

###What is this library for?

Let’s suppose you have many displays, each of them with its shift register connected, and you have to show different variables on different displays, but some of this variables have one digit, other have two or three digits and so on. You could make a program (sketch) for Arduino to manage this situation, but this library is a more convenient way. The design is based on the display group concept: this is a set of semantically linked displays, like two displays which represent the two digits of the same number. The library is able to keep the informations regarding each display group and update all the display group when some of the values has changed. In addition every group can pad the unused display with zeros automatically, depending of the number of digit currently used by the represented variable.

##Classes

The library classes are the following:

  • Display: this class represent a single 7-segments display and is a low level class that uses some Arduino primitives to change the state of hardware digital output, and update the shift register associated with the display;

  • DisplayGroup: this class represent the core of the library and manages many Display object to show the correct digit in every position. This is useful when a multi-digit number has to be shown: this class does the hard work of splitting every digits and send it to the correct display, together with zero padding when needed. Each of Display object correspond to a real 7-segments display;

  • DisplayManager: this class is the interface between the library and the main user code. It offers the API to create or remove one or many DisplayGroup, update all the display groups and some other useful functions.

The library has been tested with a small breadboard circuit, with all the required functionality. The test code creates two group with two displays each, and demonstrates how to link some variables and update all the displays, even with different digits encodings among groups!!

##Architecture

The library has been developed following a design patter similar to the Observer design patter from GoF. The patter I used is slightly different, with some simplification, to avoid too much code overhead. The main data structure, holding the information for all the displays, is made of standard C++ STL vectors, which provides fast iteration and preserve order. For this purpose a specialized STL version has been used, converted for Arduino (AVR CPU). More details on all these aspects can be found in the project documentation that comes with the sources.


##Real application

A real scoreboard has been realized, starting from scratch and using DIY materials. The library is currently used to control this scoreboard, along with other software components. Here are some pictures, you can see some other pictures and video of the whole building process at https://plus.google.com/photos/109652469005118520122/albums/5799213099932281809 :

The board is controlled by a small control panel, and everything is managed by Arduino:

The electronic boards needed to connect the display to the data bus and the panel to Arduino have been designed with Eagle and realized.

The code uses counter interrupt from the AVR integrated counters to manage the countdown timer, and a wear leveling algorithm to store the actual score and time to the integrated EEPROM memory, to prolong the EEPROM life. The data can be restored in case of power loss during a game!!

Most of these features are described in the documentation, that you can find in the each project Doc folder.

Clone this wiki locally