Recent

Author Topic: Help Raspberry PI Lazarus Is Slow  (Read 5724 times)

HarryCover

  • Newbie
  • Posts: 5
Help Raspberry PI Lazarus Is Slow
« on: May 22, 2018, 07:56:19 pm »
Hello everyone

I get closer to you to find a solution, I wrote a program that recovered a record via Socket with 700 character divided as follows

350 Char corresponding to my text
and 350 CharColor corresponding to the color of my Char
all in 2 tables MonChar and CharColor

each character must be written in a Label of 1 characters (so in total my sheet at 350 Label)

so in my timer here is my code
i use TidClient to recev Record and after i use BytesTo1Raw(RecvBuf, pMonRecord, Sizeof TMonRecord));

Label1.caption:= pMonRecord.MonChar
  • .text; Label1.font.Color:= MyColor (pMonRecord.CharColor
  • .text


This line is written 350 times implement up to 350 Label of course and according to the Char of my record also

So, the function code perfectly,

But the problem is that my timer is set to 15ms and the processing of this procedure takes 6 seconds before being displayed
for info I test in a same problem Thread

I have a Raspberry PI3 with a class 10 SD card and Debian

Do you have a solution so that the processing of this procedure can be faster

Sorry i'm a french and i use Google traduction

cordially

Harry
« Last Edit: May 22, 2018, 08:11:00 pm by HarryCover »

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Help Raspberry PI Lazarus Is Slow
« Reply #1 on: May 22, 2018, 08:43:47 pm »
You are using the wrong control (TLabel) for this application, because every time you change the Text or Font.Color of any TLabel a message is sent to repaint the underlying form parent control (usually the form). In your example that is 700 times.

Find a different approach.

Edit:
Try to lock the form.canvas before updating the labels and unlock it when done.
Code: Pascal  [Select][+][-]
  1.   form1.Canvas.LockCanvas;
  2. ....update lablels
  3.   form1.Canvas.UnlockCanvas;
« Last Edit: May 22, 2018, 08:50:11 pm by engkin »

HarryCover

  • Newbie
  • Posts: 5
Re: Help Raspberry PI Lazarus Is Slow
« Reply #2 on: May 22, 2018, 10:25:12 pm »
Thank you for your help, I will test your proposal tomorrow. I'll tell you if it worked

cordially

Harry

HarryCover

  • Newbie
  • Posts: 5
Re: Help Raspberry PI Lazarus Is Slow
« Reply #3 on: May 24, 2018, 08:13:56 pm »
Hello and thank you for your help

Actually now the display is a little faster, 2s but not enough yet, the ping on both sides is 5 to 14 ms, is that the thread writing is the same as Windows and Delphi for Arm processors

cordially

Harry

engkin

  • Hero Member
  • *****
  • Posts: 3112
Re: Help Raspberry PI Lazarus Is Slow
« Reply #4 on: May 25, 2018, 01:35:01 am »
The key is to find a better method. For instance, hide all the labels (Visible := False) and use them just for their location in the OnPaint event of the form:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormPaint(Sender: TObject);
  2. begin
  3.   Canvas.Brush.Style:=bsClear;
  4.  
  5.   Canvas.Font.Color := MyColor(pMonRecord.CharColor[0][0].text);
  6.   Canvas.TextOut(Label1.Left, Label1.Top, pMonRecord.MonChar[0][0].text);

HarryCover

  • Newbie
  • Posts: 5
Re: Help Raspberry PI Lazarus Is Slow
« Reply #5 on: May 25, 2018, 01:00:35 pm »
Thank you

I will test, but in your code it is wrong to consider that each label has its color it is each character can have a different color I have 5 color that is assigned by a color function that corresponds to the letter received via socket

Harry

Josh

  • Hero Member
  • *****
  • Posts: 1270
Re: Help Raspberry PI Lazarus Is Slow
« Reply #6 on: May 25, 2018, 02:44:24 pm »
Hi

Are the coloured characters being displayed in various location over the form, or are they in a row like in a string of coloured characters.

Just trying to get an idea of what the display looks like and is displaying.
The best way to get accurate information on the forum is to post something wrong and wait for corrections.

HarryCover

  • Newbie
  • Posts: 5
Re: Help Raspberry PI Lazarus Is Slow
« Reply #7 on: May 25, 2018, 04:27:42 pm »
Hello,

Actually it's complicated to explain, I propose to see the video of the Android version of my Software here

https://www.youtube.com/watch?v=u7tjZ--0ng4&feature=youtu.be

It is necessary to know that each character is in 1 label and each character with its color

Watch from 5 minutes you will understand better what I want

And Tonight i test with other SD CARD


Thanks again to everyone

Harry
« Last Edit: May 25, 2018, 04:49:16 pm by HarryCover »

 

TinyPortal © 2005-2018