Board index » delphi » Non-flickering text display?

Non-flickering text display?

I'm writing an app in D3 which controls stage lighting. It controls 100
channels, each of which can have a value from 0 to 255. These levels are
updated every 10ms, and I need to show their levels on a screen which is
updated at the same frequency. Most of the routine is OK - level
processing takes about 0.9ms.
However, I'm displaying the levels in TLabels, 25 to a label. The code
to update the levels works OK, and I run Application.ProcessMessages at
the end of the routine to update the display. The processing time comes
in at about 4ms with this addition.

Problem is, the display flickers horribly over the TLabels while their
value is updated. Is there a different component, or different way of
doing it, that won't flicker the display? I would like a smooth count
up/down because it's easier to read and looks better. Also, if it were
quicker that would be no bad thing - it'll leave more processor headroom
for normal processing of keypresses, mouse etc.

Andrew

 

Re:Non-flickering text display?


Look up LockWindowUpdate in help. Call before and then after with handle=0.
You may need to experiment as to which component's handle you use on the
first call.

Neil

Re:Non-flickering text display?


Hello Andrew Coulton,
you may have a look to our Abakus VCL. Included are flicker-free Value
indicators, meters, bars and much more....

regards
Achim Baecker
http://www.abaecker.com

Andrew Coulton <Andrew_Coul...@proscenia.clara.net> schrieb in im
Newsbeitrag: 37487D50.EBA5F...@proscenia.clara.net...

Quote
> I'm writing an app in D3 which controls stage lighting. It controls 100
> channels, each of which can have a value from 0 to 255. These levels are
> updated every 10ms, and I need to show their levels on a screen which is
> updated at the same frequency. Most of the routine is OK - level
> processing takes about 0.9ms.
> However, I'm displaying the levels in TLabels, 25 to a label. The code
> to update the levels works OK, and I run Application.ProcessMessages at
> the end of the routine to update the display. The processing time comes
> in at about 4ms with this addition.

> Problem is, the display flickers horribly over the TLabels while their
> value is updated. Is there a different component, or different way of
> doing it, that won't flicker the display? I would like a smooth count
> up/down because it's easier to read and looks better. Also, if it were
> quicker that would be no bad thing - it'll leave more processor headroom
> for normal processing of keypresses, mouse etc.

> Andrew

Re:Non-flickering text display?


Hi!

You can try using a component that has the property "DoubleBuffered"
like TPanel. TLabel is a descendant of TGraphicControl and has no
implementation of this property. The Problem is this property makes
things slower. But you can try it out, perhaps it works.

Ingo

Quote
Andrew Coulton wrote:

> I'm writing an app in D3 which controls stage lighting. It controls 100
> channels, each of which can have a value from 0 to 255. These levels are
> updated every 10ms, and I need to show their levels on a screen which is
> updated at the same frequency. Most of the routine is OK - level
> processing takes about 0.9ms.
> However, I'm displaying the levels in TLabels, 25 to a label. The code
> to update the levels works OK, and I run Application.ProcessMessages at
> the end of the routine to update the display. The processing time comes
> in at about 4ms with this addition.

> Problem is, the display flickers horribly over the TLabels while their
> value is updated. Is there a different component, or different way of
> doing it, that won't flicker the display? I would like a smooth count
> up/down because it's easier to read and looks better. Also, if it were
> quicker that would be no bad thing - it'll leave more processor headroom
> for normal processing of keypresses, mouse etc.

> Andrew

Re:Non-flickering text display?


Quote
Ingo Schulz wrote:
> Hi!

> You can try using a component that has the property "DoubleBuffered"
> like TPanel. TLabel is a descendant of TGraphicControl and has no
> implementation of this property. The Problem is this property makes
> things slower. But you can try it out, perhaps it works.

I haven't found any details of this property in the help. Is it undocumented,
or not in D3?

Andrew

Quote

> Ingo

> Andrew Coulton wrote:

> > I'm writing an app in D3 which controls stage lighting. It controls 100
> > channels, each of which can have a value from 0 to 255. These levels are
> > updated every 10ms, and I need to show their levels on a screen which is
> > updated at the same frequency. Most of the routine is OK - level
> > processing takes about 0.9ms.
> > However, I'm displaying the levels in TLabels, 25 to a label. The code
> > to update the levels works OK, and I run Application.ProcessMessages at
> > the end of the routine to update the display. The processing time comes
> > in at about 4ms with this addition.

> > Problem is, the display flickers horribly over the TLabels while their
> > value is updated. Is there a different component, or different way of
> > doing it, that won't flicker the display? I would like a smooth count
> > up/down because it's easier to read and looks better. Also, if it were
> > quicker that would be no bad thing - it'll leave more processor headroom
> > for normal processing of keypresses, mouse etc.

> > Andrew

Re:Non-flickering text display?


I'm not sure if this will help - I need the display to update - just smoothly.
My understanding of LockWindowUpdate is that it prevents the window from
repainting - thus removing the flicker but also preventing the text change.

Or am I wrong?

Andrew

Quote
Neil Howie wrote:
> Look up LockWindowUpdate in help. Call before and then after with handle=0.
> You may need to experiment as to which component's handle you use on the
> first call.

> Neil

Re:Non-flickering text display?


Hi !

You could try to draw the text yourself on a control with a canvas, not by using TLabels. It is not
necessary to have flicker at all.
Make sure you draw the text with opaque background, then you won't have to erase anything. The
erasing is actually what creates flicker. At First a grey background is painted, then the black text
is painted on top.

- Are you sure you want to show all these values as black numbers on grey background (I've been into
lighting control programming, myself) ? So much funny things like use of color & light to show more
than just the DMX value...

--

Bjoerge

<<Andrew Coulton:
I'm not sure if this will help - I need the display to update - just smoothly.

Quote

Re:Non-flickering text display?


Quote
Andrew Coulton wrote:

> Ingo Schulz wrote:

> > Hi!

> > You can try using a component that has the property "DoubleBuffered"
> > like TPanel. TLabel is a descendant of TGraphicControl and has no
> > implementation of this property. The Problem is this property makes
> > things slower. But you can try it out, perhaps it works.

> I haven't found any details of this property in the help. Is it undocumented,
> or not in D3?

> Andrew

In the last two months I've been working with D4, and I can't tell you
if it is implemented in D3, but I thought it was. Did you take a look on
the properties of the TPanel or TCustomPanel component?

Ingo

Re:Non-flickering text display?


Quote
"Bj?rge S?ther" wrote:
> Hi !

> You could try to draw the text yourself on a control with a canvas, not by using TLabels. It is not
> necessary to have flicker at all.
> Make sure you draw the text with opaque background, then you won't have to erase anything. The
> erasing is actually what creates flicker. At First a grey background is painted, then the black text
> is painted on top.

Which is the correct pen type to use for opaque text? I've never really been into owner-drawing before.
I can see that this will be better. In theory it should also be about twice the speed, since it's only
painting the text, not painting the erase rectangle first.

Quote

> - Are you sure you want to show all these values as black numbers on grey background (I've been into
> lighting control programming, myself) ?

At the minute, they're actually yellow on black. However, drawing each on the Canvas would be better,
since then different channels can have different cols. That was an aim, but I had sort of sacrificed it
for development and runtime speed. This is kind of a back burner project that suddenly got put over a
small nuclear reactor core - eg I decided I needed it done for a show in four weeks time :-)

Thanks very much

Andrew

Quote
>So much funny things like use of color & light to show more
>than just the DMX value...

     --

     Bjoerge

     <<Andrew Coulton:
     I'm not sure if this will help - I need the display to update - just smoothly.
     >>

Re:Non-flickering text display?


Quote
Ingo Schulz wrote:
> Andrew Coulton wrote:

> > Ingo Schulz wrote:

> > > Hi!

> > > You can try using a component that has the property "DoubleBuffered"
> > > like TPanel. TLabel is a descendant of TGraphicControl and has no
> > > implementation of this property. The Problem is this property makes
> > > things slower. But you can try it out, perhaps it works.

> > I haven't found any details of this property in the help. Is it undocumented,
> > or not in D3?

> > Andrew

> In the last two months I've been working with D4, and I can't tell you
> if it is implemented in D3, but I thought it was. Did you take a look on
> the properties of the TPanel or TCustomPanel component?

Yes. Also not found in a full-text search. But I like the sound of owner-drawing
anyway.

Quote

> Ingo

Andrew

Re:Non-flickering text display?


<<Andrew:
Which is the correct pen type to use for opaque text? I've never really been into owner-drawing
before.
I can see that this will be better. In theory it should also be about twice the speed, since it's
only
painting the text, not painting the erase rectangle first.

Quote

As far as I know, this is the fastest drawing method:

    TextOut(Canvas.Handle, 20, 40, '  0', 3); // (WinAPI version)

.. but the trouble is you can't right-align. one solution would be to use a fixed pitch font, and
pad with spaces to fill 3 chars. Otherwise you'll have to do fill first.

If you want to try right-aligning, then DrawText does it:

    DrawText(Handle, '255', 3, R, DT_SINGLELINE or DT_NOCLIP or DT_NOPREFIX); // make sure you get
these parameters (saves some 30% time).

... but the trouble is it won't fill the whole rect (only the part needed for the passed text).

The OPAQUE style is default when painting and drawing on a DC. You would, in fact use TRANSPARENT if
you need to fill the rect first. It's about 25% faster than the opaque drawing.

To set it:

  SetBkMode(Canvas.handle, TRANSPARENT);

Are you writing LightingControl software for stage use ?

--

Bjoerge

Re:Non-flickering text display?


Quote
"Bj?rge S?ther" wrote:
> <<Andrew:
> Which is the correct pen type to use for opaque text? I've never really been into owner-drawing
> before.
> I can see that this will be better. In theory it should also be about twice the speed, since it's
> only
> painting the text, not painting the erase rectangle first.

> As far as I know, this is the fastest drawing method:

>     TextOut(Canvas.Handle, 20, 40, '  0', 3); // (WinAPI version)

> .. but the trouble is you can't right-align. one solution would be to use a fixed pitch font, and
> pad with spaces to fill 3 chars. Otherwise you'll have to do fill first.

> If you want to try right-aligning, then DrawText does it:

>     DrawText(Handle, '255', 3, R, DT_SINGLELINE or DT_NOCLIP or DT_NOPREFIX); // make sure you get
> these parameters (saves some 30% time).

> ... but the trouble is it won't fill the whole rect (only the part needed for the passed text).

> The OPAQUE style is default when painting and drawing on a DC. You would, in fact use TRANSPARENT if
> you need to fill the rect first. It's about 25% faster than the opaque drawing.

> To set it:

>   SetBkMode(Canvas.handle, TRANSPARENT);

I'll check all this out and let you know how it works.

Quote

> Are you writing LightingControl software for stage use ?

Yes. Building the hardware too. I'm producing a cut-down system doing most of it's processing (down to
the composition of DMX packets) on-board, with a minimum of hardware connected to the parallel port more
as a protocol converter than anything else. It's going to be aimed at schools and amateur co's who don't
need quite such high-end features as pro boards, but who want a board with good medium range
functionality for about 70 that runs off a PC. This is about 1/3 price of most of the much higher-end
competition, which uses microprocessors to do a large amount of the processing externally.

Mine will be the Windows Printing System of stage lighting :-). It'll still get better results than a
GSX on a 200Mhz K-6.

Andrew

- Show quoted text -

Quote

> --

> Bjoerge

Other Threads