Click here to Skip to main content
15,851,711 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All,

I am designing a data log system for an engine control system.

summarised, you can draw a graph (injection and ignition timing in function of rpm and tps) containing up to 12 curves.
depending on the position of a sensor, the control system will choose one of these curves.

as feedback, the control system will continously (every rotation) send data.
With an UI you can open the the curves that are programmed in the control box.

A crosshair will show which curve is active and at what rpm we are running.

each rotation the screen needs to be updated, without delay, since it has to be a real-time logger.

I now use
parent->RedrawWindow(graph_rect,NULL);


the graph is shown in the parent dialog, the child dialog will enable the user to select some visual options.

graph_rect is the CRect in the main dialog containing the graph

This works, but since the rect is continuously updating, you get a flicker effect.
As not only the crosshair is updated, but the entire graph (curves, axes, legends, title, grid,...)

if I use
parent->invalidate();

it goes smooth, without flicker, but there is a delay, since everything will be updated.
And the crosshair will run far behind the real timing

how can I avoid this?

Thanks in advance
Posted

1 solution

My suggestion is to do the drawing of your entire diagram on bitmap in memory, i.e. with a memory DC. Then copy that bitmap over to the screen with a single BitBlt operation. This has several advantages:

- The flicker will go away
- Drawing onto a memory bitmap is way faster than drawing on the screen
- You could easily implement scaling if you need

To refine this scheme you could use two bitmaps, one for all static elements that do not change from one cycle to the next. You copy that one to a second bitmap in which you do the per-cycle drawing. The BitBlt that second bitmap to the screen.

For the details I would suggest to google a little; there are many articles and examples around which you can use as a template.
 
Share this answer
 
Comments
Blob_Dlg 30-Jul-13 4:20am    
Thanks!
That did the trick!
Blob
nv3 30-Jul-13 4:58am    
You are welcome.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900