I wrote a program using Lazarus and it checks for GPIO2 pin's status every 3 seconds using TProcess component to run a terminal command for retrieving GPIO pin status as follows...
procedure TForm1.Timer1Timer(Sender: TObject);
begin
...
Process1.CommandLine:='gpio -g read 2';
Process1.Execute;
Memo1.Lines.LoadFromStream(Process1.Output);
...
end;
This works great with no issue. However, when I let my program run for several hours or all day, my program starts to freeze or become unresponsive. Probably due to repeatedly calling TProcess over and over again every 3 seconds. I have looked up on the Internet about this and found many options available but a lot of them are too complicated or the libraries just won't work or outdated. So, what is the simplest and not over complicated ways of reading GPIO pin status? fpSystem seems promising but I can't find any code where you capture the return values for the terminal command.