English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1424) 
<== | ==>
Ugrás a végére | Összes megjelenítése | Utolsó oldal
OpenOpera patches | Opera-SSL patches | Opera 12.15 source (Git repository) | Opera 12.15 source (Torrent) | Opera internal pages | Otter Browser Linux x64 - Qt5.15.2/QtWebKit5.602.1 (2024.04.27. 20:05)
OS for MC680x0 | OS for PPC | OS for Sparc64 | besztofbégéaefcé | CSÉNDZSLOG | WebToolz | DDG Shit Filter | Google Shit Filter | Progz | Fast CSS Box | Browser | OS | Agent | Statisztika | BBCode
Monospace font-family: Courier New | Browser default monospace
Email értesítő / Email notification ===> 
Keresés
Σ: 1 post

TCH  (statz) Főfasz
#1, Főfasz (10443)
2713 | #4697 | ^ | Idézet | Mon, 23 Oct 2017 16:53:41 +02
94.21.*.* Linux x86 Opera Classic Hungary *.pool.digikabel.hu
Írtam Pascalban egy GPIO interface-t:
unit gpio_sysfs;

{$mode objfpc}{$H+}

interface

function open_gpio(pin: string): boolean;
function close_gpio(pin: string): boolean;
function set_gpio_dir(pin: string; d_out: boolean): boolean;
function set_gpio_val(pin: string; state: boolean): boolean;
function get_gpio_val(pin: string; out state: boolean): boolean;

implementation

uses linehnd, sysutils;

const sysfs = '/sys/class/gpio/';

function open_gpio(pin: string): boolean;
var
	tc: integer;
	gpio: string;
begin
	if (not put_line(sysfs + 'export', pin)) then
	begin
		result := false;
		exit;
	end;

	gpio := sysfs + 'gpio' + pin + '/';
	tc := 0;
	repeat
		sleep(10);
		inc(tc);
		result := directoryexists(gpio);
	until (result) or (tc = 100);
end;

function close_gpio(pin: string): boolean;
begin
	if (not put_line(sysfs + 'unexport', pin)) then
	begin
		result := false;
		exit;
	end;
end;

function set_gpio_dir(pin: string; d_out: boolean): boolean;
var
	gpio: string;
	dir: string;
begin
	gpio := sysfs + 'gpio' + pin + '/';
	result := directoryexists(gpio);
	if (not result) then
	begin
		exit;
	end;

	if (d_out) then dir := 'out' else dir := 'in';
	result := put_line(gpio + 'direction', dir);
end;

function set_gpio_val(pin: string; state: boolean): boolean;
var
	gpio: string;
	val: string;
begin
	gpio := sysfs + 'gpio' + pin + '/';
	result := directoryexists(gpio);
	if (not result) then
	begin
		exit;
	end;

	if (state) then val := '1' else val := '0';
	result := put_line(gpio + 'value', val);
end;

function get_gpio_val(pin: string; out state: boolean): boolean;
var
	gpio: string;
	val: string;
begin
	gpio := sysfs + 'gpio' + pin + '/';
	result := directoryexists(gpio);
	if (not result) then
	begin
		exit;
	end;

	result := get_line(gpio + 'value', val);
	state := val <> '0';
end;

end.
A linehnd unit meg itt van hozzá:
unit linehnd;

{$mode objfpc}{$H+}

interface

function put_line(filename: string; line: string): boolean;
function get_line(filename: string; out line: string): boolean;

implementation

function put_line(filename: string; line: string): boolean;
var tf: textfile;
begin
	result := false;
	assignfile(tf, filename);
	try
		rewrite(tf);
	except
		exit;
	end;
	writeln(tf, line);
	closefile(tf);
	result := true;
end;

function get_line(filename: string; out line: string): boolean;
var tf: textfile;
begin
	result := false;
	assignfile(tf, filename);
	try
		reset(tf);
	except
		exit;
	end;
	readln(tf, line);
	closefile(tf);
	result := true;
end;

end.


English | Magyar
JS ki | CSS ki | Ékezetek ki | HiContrast
Lapozó:  (0 - 1424) 
<== | ==>
Ugrás a végére | Összes megjelenítése | Utolsó oldal
OpenOpera patches | Opera-SSL patches | Opera 12.15 source (Git repository) | Opera 12.15 source (Torrent) | Opera internal pages | Otter Browser Linux x64 - Qt5.15.2/QtWebKit5.602.1 (2024.04.27. 20:05)
OS for MC680x0 | OS for PPC | OS for Sparc64 | besztofbégéaefcé | CSÉNDZSLOG | WebToolz | DDG Shit Filter | Google Shit Filter | Progz | Fast CSS Box | Browser | OS | Agent | Statisztika | BBCode
Monospace font-family: Courier New | Browser default monospace
Email értesítő / Email notification ===> 
Keresés

Név: (max 255 byte)

Email: (max 255 byte) Nem kötelező!

Üzenet: (max 65536 kar.) 65536-0=65536




crap_vkn v4.34.0 by TCH
Thx to saxus for the escaped string decoder function (PHP), the realIP function (PHP) & the SQL handle layer (PHP), to thookerov for the int_divide function (PHP), to Jeff Anderson for the getSelText function (JS), to Alex King for the insertAtCursor function (JS), Flood3r for the new CSS styles, Pety for the spamprotection idea and some design and comfort ideas, MaxMind for the IP2Country database, famfamfam for the flags of countries and an unknown PHP programmer for the removeAccents function.



Kecskebaszók ide!