mirror of
https://gitlab.com/freepascal.org/fpc/pas2js.git
synced 2025-08-18 17:59:05 +02:00
* node onoff module for GPIO control on raspberry
This commit is contained in:
parent
8032ea166e
commit
c581dece39
55
packages/nodejs/nodejsonoff.pas
Normal file
55
packages/nodejs/nodejsonoff.pas
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
unit nodejsonoff;
|
||||||
|
|
||||||
|
{$mode objfpc}
|
||||||
|
{$modeswitch externalclass}
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
JS,nodejs;
|
||||||
|
|
||||||
|
Type
|
||||||
|
TGPIOReadCallBack = reference to procedure(err : TJSError; aValue : Byte);
|
||||||
|
TGPIOWriteCallBack = reference to procedure(err : TJSError);
|
||||||
|
|
||||||
|
TNJSGPIO = class external name 'Gpio' (TJSObject)
|
||||||
|
class var
|
||||||
|
FAccessible : boolean; external name 'accessible' ;
|
||||||
|
constructor new (agpio : byte; aDirection : string); overload;
|
||||||
|
constructor new (agpio : byte; aDirection,aEdge : String); overload;
|
||||||
|
constructor new (agpio : byte; aDirection,aEdge : string; aOptions : TJSObject); overload;
|
||||||
|
procedure read; overload;
|
||||||
|
procedure read(aCallBack : TGPIOReadCallBack); overload;
|
||||||
|
function readSync : Byte;
|
||||||
|
procedure write(aValue: Byte); overload;
|
||||||
|
procedure write(aCallBack : TGPIOWriteCallBack); overload;
|
||||||
|
procedure writeSync(aValue: Byte);
|
||||||
|
procedure watch(aCallback : TGPIOReadCallBack);
|
||||||
|
procedure unwatch(aCallback : TGPIOReadCallBack);
|
||||||
|
procedure unwatchAll;
|
||||||
|
function getdirection : string; external name 'direction';
|
||||||
|
procedure setDirection(aDirection : string);
|
||||||
|
function getEdge : string; external name 'edge';
|
||||||
|
procedure setEdge(aEdge : string);
|
||||||
|
function GetactiveLow : boolean; external name 'activeLow';
|
||||||
|
procedure setActiveLow(aInvert : Boolean);
|
||||||
|
procedure unexport;
|
||||||
|
property Direction : string read getdirection write setdirection;
|
||||||
|
property Edge : string read GetEdge write SetEdge;
|
||||||
|
property ActiveLow : Boolean Read getActiveLow write setActiveLow;
|
||||||
|
class property accessible: boolean Read Faccessible;
|
||||||
|
const
|
||||||
|
High = 1;
|
||||||
|
Low = 0;
|
||||||
|
end;
|
||||||
|
TNJSGPIOClass = class of TNJSGPIO;
|
||||||
|
|
||||||
|
var
|
||||||
|
GPIO : TNJSGPIOClass;
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
initialization
|
||||||
|
gpio:=TNJSGPIOClass(require('onoff'));
|
||||||
|
end.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user