[Lazarus] how to modify or add component after Application.Run method?

2016-01-24 Thread Mr Bee
Hi,
Common Lazarus project source code contains this snippet:
begin  Application.Initialize;
  Application.CreateForm(TForm, Form1);  Application.Run;end. 

Adding code to modify or add components of/into Form1 after the Application.Run 
method will be ignored because it's out of the application's main thread. So, 
is there a correct and safe way to do it?
begin  Application.Initialize;
  Application.CreateForm(TForm, Form1);  Application.Run;  // how to make below 
code be executed?  Form1.Caption := 'My caption';  Form1.Edit1.Text := 'My text 
input';  MyLabel := TMyLabel.Create(Form1);  MyLabel.Parent := Form1;  
MyLabel.Caption := 'My runtime label';  // or one could add any arbitraty code 
hereend. 
 Thank you. :)
Regards,
–Mr Bee
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Bls: how to modify or add component after Application.Run method?

2016-01-24 Thread Mr Bee
No, I can't put them in the Form1's OnCreate event. Because the additional code 
wouldn't be just from me, but the could be from others as well. I'd like to 
make the main application into a unit. So, the form should be established on 
the unit call. The other would simply use the unit and add or modify any 
components of the existing Form1.
Do you understand what I'm trying to achieve? I think it should be possible to 
do, I just don't know how to do it properly. I've looked at the PostMessage 
method, but I don't think it suits my need. CMIIW.
Regards,
–Mr Bee
 

Pada Minggu, 24 Januari 2016 15:48, Sven Barth 
 menulis:
 

 Am 24.01.2016 09:46 schrieb "Mr Bee" :
>
> Hi,
>
> Common Lazarus project source code contains this snippet:
>
> begin
>   Application.Initialize;
>   Application.CreateForm(TForm, Form1);
>   Application.Run;
> end. 
>
> Adding code to modify or add components of/into Form1 after the 
> Application.Run method will be ignored because it's out of the application's 
> main thread. So, is there a correct and safe way to do it?
>
> begin
>   Application.Initialize;
>   Application.CreateForm(TForm, Form1);
>   Application.Run;
>   // how to make below code be executed?
>   Form1.Caption := 'My caption';
>   Form1.Edit1.Text := 'My text input';
>   MyLabel := TMyLabel.Create(Form1);
>   MyLabel.Parent := Form1;
>   MyLabel.Caption := 'My runtime label';
>   // or one could add any arbitraty code here
> end. Put it into the form's OnCreate event handler. This kind of code does 
> not belong into the main project file anyway.Regards,
Sven

  --
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] how to modify or add component after Application.Run method?

2016-01-24 Thread Sven Barth
Am 24.01.2016 09:46 schrieb "Mr Bee" :
>
> Hi,
>
> Common Lazarus project source code contains this snippet:
>
> begin
>   Application.Initialize;
>   Application.CreateForm(TForm, Form1);
>   Application.Run;
> end.
>
> Adding code to modify or add components of/into Form1 after the
Application.Run method will be ignored because it's out of the
application's main thread. So, is there a correct and safe way to do it?
>
> begin
>   Application.Initialize;
>   Application.CreateForm(TForm, Form1);
>   Application.Run;
>   // how to make below code be executed?
>   Form1.Caption := 'My caption';
>   Form1.Edit1.Text := 'My text input';
>   MyLabel := TMyLabel.Create(Form1);
>   MyLabel.Parent := Form1;
>   MyLabel.Caption := 'My runtime label';
>   // or one could add any arbitraty code here
> end.

Put it into the form's OnCreate event handler. This kind of code does not
belong into the main project file anyway.

Regards,
Sven
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Bo Berglund
On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig 
wrote:

>The application itself must run as root to do digital I/O.  If you don't 
>want to debug using the IDE, you don't have to make the IDE run as root, 
>though, just the app.

I do not think this is necessary!

I am NOT running my RPi2B as any other user than pi and it works just
fine to access the GPIO pins. Both FPC and Lazarus run just fine as pi
user.

The trick is to make sure that pi belongs to the proper groups dealing
with the hardware. You can check this using the command:
cat /etc/group | grep pi

It will list the groups pi belongs to and you will find out if there
are missing groups here. This is what my Pi says:

pi@rpi2-jessie2:~/dev $ cat /etc/group | grep pi
adm:x:4:pi
dialout:x:20:pi
cdrom:x:24:pi
sudo:x:27:pi
audio:x:29:pi
video:x:44:pi
plugdev:x:46:pi
games:x:60:pi
users:x:100:pi
input:x:101:pi
netdev:x:108:pi
spi:x:999:pi
i2c:x:998:pi
gpio:x:997:pi  <== This for GPIO

I never use the NOOBS disk, I always create the start image from the
offiocial Raspbian Jessie image, currently I am on the Nov 2015
release. And the groups above were set from the start on that distro.

-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Donald Ziesig

On 01/24/2016 05:47 AM, Bo Berglund wrote:

On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig 
wrote:


The application itself must run as root to do digital I/O.  If you don't
want to debug using the IDE, you don't have to make the IDE run as root,
though, just the app.

I do not think this is necessary!

I am NOT running my RPi2B as any other user than pi and it works just
fine to access the GPIO pins. Both FPC and Lazarus run just fine as pi
user.

The trick is to make sure that pi belongs to the proper groups dealing
with the hardware. You can check this using the command:
cat /etc/group | grep pi

It will list the groups pi belongs to and you will find out if there
are missing groups here. This is what my Pi says:

pi@rpi2-jessie2:~/dev $ cat /etc/group | grep pi
adm:x:4:pi
dialout:x:20:pi
cdrom:x:24:pi
sudo:x:27:pi
audio:x:29:pi
video:x:44:pi
plugdev:x:46:pi
games:x:60:pi
users:x:100:pi
input:x:101:pi
netdev:x:108:pi
spi:x:999:pi
i2c:x:998:pi
gpio:x:997:pi  <== This for GPIO

Hi Bo,

I get exactly this on my pi except there is a line:

pi:x:1000:

immediately following the netdev line..


I never use the NOOBS disk, I always create the start image from the
offiocial Raspbian Jessie image, currently I am on the Nov 2015
release. And the groups above were set from the start on that distro.


I updated the copy of NOOBS to use jessie as soon as jessie was available.
I updated FPC and Lazarus from Anthony's download (as he corrected it 
for the problem with installing custom components) as soon as it was 
available.


When I run my program unprivileged from the command line I get:

wiringPiSetup:  Must be root.  (did you forget sudo?).

Using the same executable but prefacing the command with sudo, it runs 
and does digital I/O.


When I try to run my program using unprivileged Lazarus it compiles but 
the Debugger crashes.


When I run my program using root-mode Lazarus it compiles, runs and does 
digital I/O.


The comments in h2WiringPi state that the programs that use it must run 
as root, which is how I got to this position in the first place.


Don




--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] [PATCH] components/turbopower_ipro: added the Iphttpbroker and its example

2016-01-24 Thread silvioprog
On Sat, Jan 23, 2016 at 8:37 AM, Jy V  wrote:

> Hello Silvio,
>
> Are you considering to use TurboPower HTTP components to implements HPACK
> and HTTP/2 ?
>

Hello Jy,

Yes, it can be easily implemented in TP comps. ASA nghttp2 get a pascal
header, BTW with a ng header in hands, you can use this one with any pascal
code. :-)

I took a look at the IpHtmlPanel comp. on Windows, it's a nice component...
it prints some basic HTML/CSS, but it needs patches to fix some bugs (eg: I
can't see a HTML form on it), so I'm going to send that ASAP.

-- 
Silvio Clécio
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] technical knobs components

2016-01-24 Thread Michael Van Canneyt



On Sun, 24 Jan 2016, Marc Santhoff wrote:


Hi,

can someone give me a hint, if there is a free or cheap component
library for lazarus implementing operational controls like switches,
potentiometers and the like for makin a GUI lok like a physical device?


Maybe this can be of use ?

http://wiki.freepascal.org/uE_Controls

Michael.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] technical knobs components

2016-01-24 Thread Marc Santhoff
On So, 2016-01-24 at 15:29 +0100, Michael Van Canneyt wrote:
> 
> On Sun, 24 Jan 2016, Marc Santhoff wrote:
> 
> > Hi,
> >
> > can someone give me a hint, if there is a free or cheap component
> > library for lazarus implementing operational controls like switches,
> > potentiometers and the like for makin a GUI lok like a physical device?
> 
> Maybe this can be of use ?
> 
> http://wiki.freepascal.org/uE_Controls

Yes, found it while browsing, and TDigitLed there, too:

http://breakoutbox.de/pascal/pascal.html

What is missing now are some linear sliders, because round knobs are not
so easy to handle using mouse or fingers on a touch screen.

Ah, since we're at it:
Last time I searched for a Star Trek gui lib I found nothing freely
avaliable. I don't ask for pascal, this could be done if necessary (and
not written in C++ ..) but does an open source variant exist?

Thanks,
Marc

-- 
Marc Santhoff 


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] technical knobs components

2016-01-24 Thread Marc Santhoff
Hi,

can someone give me a hint, if there is a free or cheap component
library for lazarus implementing operational controls like switches,
potentiometers and the like for makin a GUI lok like a physical device?


TIA,
Marc

-- 
Marc Santhoff 


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Bls: how to modify or add component after Application.Run method?

2016-01-24 Thread Sven Barth
Am 24.01.2016 10:01 schrieb "Mr Bee" :
>
> No, I can't put them in the Form1's OnCreate event. Because the
additional code wouldn't be just from me, but the could be from others as
well. I'd like to make the main application into a unit. So, the form
should be established on the unit call. The other would simply use the unit
and add or modify any components of the existing Form1.

That's not how things are supposed to be done AND bad style.
But if you really need to do this you must do it before the call of Run.

Regards,
Sven
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Bo Berglund
On Sun, 24 Jan 2016 22:02:49 -0500, Donald Ziesig 
wrote:

>
>I get exactly this on my pi except there is a line:
>
>pi:x:1000:
>
>immediately following the netdev line..

I edited out that because the grep found pi in the wrong place...

>wiringPiSetup:  Must be root.  (did you forget sudo?).
>
>Using the same executable but prefacing the command with sudo, it runs 
>and does digital I/O.
>
>When I try to run my program using unprivileged Lazarus it compiles but 
>the Debugger crashes.
>
>When I run my program using root-mode Lazarus it compiles, runs and does 
>digital I/O.
>
>The comments in h2WiringPi state that the programs that use it must run 
>as root, which is how I got to this position in the first place.

I solved my root/pi problem back in Oct 2015.
You can read about it here:
http://lists.lazarus.freepascal.org/pipermail/lazarus/2015-October/094438.html

Specifically see how the change from using /dev/mem to /dev/gpiomem
made it possible to run as user pi.

I personally totally detest having to be root in a development system
and having my programs require root to run.
I don't have to anymore.


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Bo Berglund
On Mon, 25 Jan 2016 00:18:50 +0100, Marc Santhoff 
wrote:

>> For me it is like this:
>> pi@rpi2-jessie2:~/dev $ cat /etc/group | grep gpio
>> gpio:x:997:pi
>
>Thje last one wrong, should have been
>
>$ ls -lL /sys/class/gpio/gpiochip0

New test:

pi@rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio/gpiochip0
total 0
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 base
drwxr-xr-x 3 root root0 Jan 17 16:47 device
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 label
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 ngpio
drwxrwx--- 2 root gpio0 Jan 17 16:47 subsystem
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 uevent

>and
>
>$ ls -lL ../../devices/platform/soc/3f20.gpio/gpio/

This is a relative path and you did not specify where one should be
located in order to execute it. Cannot perform this command.
Please supply an absolute path instead.


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] technical knobs components

2016-01-24 Thread hfiandor
Dear Mr. Santhoff:

One day, some time ago, I was working in an application to re-edit a fly
from the "black box" data, and I have to create a form trying to "copy" the
control panel of an IL18. I am sending a copy.

Yours,

Saludos,
Ing. Héctor Fiandor
hfian...@ceniai.inf.cu
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Koenraad Lelong

Op 24-01-16 om 11:47 schreef Bo Berglund:

On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig 
wrote:


The application itself must run as root to do digital I/O.  If you don't
want to debug using the IDE, you don't have to make the IDE run as root,
though, just the app.


I do not think this is necessary!


Strange,

I tried this with my test-application and it does not work as user 'pi'.
I investigated a little bit further.
No application running :
root@raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l 
/sys/class/gpio

totaal 0
-rwxrwx--- 1 root gpio 4096 jan 22 22:03 export
lrwxrwxrwx 1 root gpio0 jan 22 22:03 gpiochip0 -> 
../../devices/platform/soc/3f20.gpio/gpio/gpiochip0

-rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport

When I run the application as 'pi', I get this :

root@raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l 
/sys/class/gpio

totaal 0
-rwxrwx--- 1 root gpio 4096 jan 22 22:03 export
lrwxrwxrwx 1 root gpio0 jan 24 19:43 gpio17 -> 
../../devices/platform/soc/3f20.gpio/gpio/gpio17
lrwxrwxrwx 1 root gpio0 jan 24 19:43 gpio18 -> 
../../devices/platform/soc/3f20.gpio/gpio/gpio18
lrwxrwxrwx 1 root gpio0 jan 22 22:03 gpiochip0 -> 
../../devices/platform/soc/3f20.gpio/gpio/gpiochip0

-rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport
root@raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test#

But the IO does not work. When I do
echo 1 > /sys/class/gpio/gpio17/value
from the command-line, the IO does not work, even when I do this as root.

When I run the application as root, everything works as expected.

B.T.W. what 'library' are you using for the GPIO's ?

Koenraad


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O - PiGpio.zip (1/1)

2016-01-24 Thread Bo Berglund

begin 644 PiGpio.zip
M4$L#!!0``@`(`..:*DBT1R3E"@L``%\E```*4'<+G!A<\U:;4_;
MRA+^W$K]#U,)Z22G*;&=0(&<'IU`$AH52)2$(MT/C9QX#;YU;,MVH+3BO]]G
M=NVU"8'"%>7>B`9[9W;>=W9FZ#+P4AIZAY$7MMZ\_OGF->T?'%L[C2TZ'/8'
M-!+G7I+]2)O4L1U\CVDY#F=D#+1%`:TL(.O@>;2D,+T0,<7Y+CL6
M=O+F-:A.+KR$YJ$C"+]3D:3"H3#PKVD_#FUG'BYH-E](OB!3(\=S71&+(`6)
M!2\EX'1-@<`V#0/9<\A-CI2-O$7DBP76[=0+`\G5,LP&'=JS,*;QC]#WP\1[
M\_H&>FXL6)1P]F\WFM_\W/CT[H;QO2`5L6O/!;_4ZQ!:D,O;KKS@G,*(Z4*)
M((U#/Z"R?6C'$6W@](Z8+GR$ZBF8AAB&&?K$U)L^TX@$*PK?>F@1^:
MP08A[8OXW%\&3HG?E9B1[5QZW9=:H$A\4NQ'<0,ID08B]A-U\C

Re: [Lazarus] Raspberry Pi Debug Digital I/O - PiGpio.zip (0/1)

2016-01-24 Thread Bo Berglund
On Sun, 24 Jan 2016 20:59:40 +0100, Koenraad Lelong
 wrote:

>Op 24-01-16 om 11:47 schreef Bo Berglund:
>> On Fri, 22 Jan 2016 20:55:59 -0500, Donald Ziesig 
>> wrote:
>>
>>> The application itself must run as root to do digital I/O.  If you don't
>>> want to debug using the IDE, you don't have to make the IDE run as root,
>>> though, just the app.
>>
>> I do not think this is necessary!
>>
>Strange,
>
>I tried this with my test-application and it does not work as user 'pi'.

On your Pi, what groups are user pi member of?
...

>B.T.W. what 'library' are you using for the GPIO's ?

I have used PiGpio.pas, I will try to attach it - don't really know
how one does thios in a newsreader...


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Marc Santhoff
On So, 2016-01-24 at 20:59 +0100, Koenraad Lelong wrote:

> When I run the application as 'pi', I get this :
> 
> root@raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test# ls -l 
> /sys/class/gpio
> totaal 0
> -rwxrwx--- 1 root gpio 4096 jan 22 22:03 export
> lrwxrwxrwx 1 root gpio0 jan 24 19:43 gpio17 -> 
> ../../devices/platform/soc/3f20.gpio/gpio/gpio17
> lrwxrwxrwx 1 root gpio0 jan 24 19:43 gpio18 -> 
> ../../devices/platform/soc/3f20.gpio/gpio/gpio18
> lrwxrwxrwx 1 root gpio0 jan 22 22:03 gpiochip0 -> 
> ../../devices/platform/soc/3f20.gpio/gpio/gpiochip0
> -rwxrwx--- 1 root gpio 4096 jan 22 22:03 unexport
> root@raspberrypi:/home/pi/Documents/lazarus/pascalio/koen-test#
> 
> But the IO does not work. When I do
> echo 1 > /sys/class/gpio/gpio17/value
> from the command-line, the IO does not work, even when I do this as root.
> 
> When I run the application as root, everything works as expected.

What do

$ cat /etc/group | grep gpio

and

$ ls -lL /sys/class/gpio

show?

-- 
Marc Santhoff 


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Bo Berglund
On Sun, 24 Jan 2016 21:42:06 +0100, Marc Santhoff 
wrote:

>What do
>
>$ cat /etc/group | grep gpio
>
>and
>
>$ ls -lL /sys/class/gpio
>
>show?

For me it is like this:
pi@rpi2-jessie2:~/dev $ cat /etc/group | grep gpio
gpio:x:997:pi
pi@rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 export
drwxrwx--- 2 root gpio0 Jan 17 16:47 gpiochip0
-rwxrwx--- 1 root gpio 4096 Jan 17 16:47 unexport


-- 
Bo Berglund
Developer in Sweden


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Raspberry Pi Debug Digital I/O

2016-01-24 Thread Marc Santhoff
On Mo, 2016-01-25 at 00:11 +0100, Bo Berglund wrote:
> On Sun, 24 Jan 2016 21:42:06 +0100, Marc Santhoff 
> wrote:
> 
> >What do
> >
> >$ cat /etc/group | grep gpio
> >
> >and
> >
> >$ ls -lL /sys/class/gpio
> >
> >show?
> 
> For me it is like this:
> pi@rpi2-jessie2:~/dev $ cat /etc/group | grep gpio
> gpio:x:997:pi

Thje last one wrong, should have been

$ ls -lL /sys/class/gpio/gpiochip0

and

$ ls -lL ../../devices/platform/soc/3f20.gpio/gpio/

to see the the targets of the links (correct permissions there, too?)
and content of the directory, sorry.

> pi@rpi2-jessie2:~/dev $ ls -lL /sys/class/gpio
> total 0
> -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 export
> drwxrwx--- 2 root gpio0 Jan 17 16:47 gpiochip0
> -rwxrwx--- 1 root gpio 4096 Jan 17 16:47 unexport
> 
> 

-- 
Marc Santhoff 


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus