dcsimg
 

Static LED control

Thursday Feb 17th 2000 by Michel Wassink

Static LED control

Sample Image

Overview

This article presents a CStatic derived class for displaying numbers or text like a LED Display. This control does not use bitmaps. Everything is drawn with lines and Bezier curves. First I made some classes to draw a character, which consists of segments that can be any closed shape, by only giving some points. The points can be connected by lines or by Bezier curves to make nice smoothened characters. The theory of fitting Bezier curves can be found in bezdist.pdf, created by Jim Fitzsimmons, in my demo project cabinet. The CDigistring resizes itself automatically, which can be experienced with the demo app, wherefore I used the resizing dialog code from Hans Bühler.

To to design the characters I looked around for different styles. The most inspiration came out of my car. I used characters from the date/time/temperature display and from my RDS-radio. 14- And 7-segment displays in straight and smooth style are supported and one common character for displaying a decimal point or a colon. I changed the designs a lot to get aesthetically best results, but I didn't went crazy by changing all the points every time because I do some nifty mirrorring for most of the segments. For example i only specified 5 segments for the 14 segment display.

The Designs


You can modify these if you like, then you can take them over to the source the same way as I did. The height of every design is the same only the width may be different, necessary for easy scaling.

Changing styles


 BOOL ModifyDigiStyle(DWORD dwRemove, DWORD dwAdd);

With the MidifyDigiStyle function you can add or remove specific CDigistring styles. The styles, which can be combined by using the bitwise OR (|) operator, are:


CDigistring::DS_SMOOTH   // Smooth kind of characters
CDigistring::DS_STYLE14  // use always 14 segment display.
CDigistring::DS_SZ_PROP  // size proportional(default)

How to use (in a dialog):

  1. Add digistring.h, digistring.cpp, memdc.h, curvefit.h, curvefit.cpp and rgbcolor.h to your project environment.
  2. Add a static control to your dialog resource.
  3. Change its ID to something like IDC_LEDTEXT, open classwizard and assign a member variable, type control (CStatic) to it (m_LedText for example).
  4. Open your dialog class' header file.
    Add #include "digistring.h".
    Find the line CStatic m_LedText and replace the CStatic by CDigistring.
  5. In OnInitDialog() you can give it some text with SetText(),
    change the colors with SetColor() or for the background SetBackColor() or you can
    set the right style with ModifyDigistyle().
  6. Compile and run.

Acknowledgements

  • Hans Bühler - For using his resizing software for the demo application;
  • Keith Rule - For creating the memdc class for flickerfree drawing.

Downloads

Download demo project - 163 Kb
Download source - 13 Kb
Home
Mobile Site | Full Site
Copyright 2018 © QuinStreet Inc. All Rights Reserved