-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathpwmtest.pas
75 lines (55 loc) · 1.04 KB
/
pwmtest.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
unit pwmtest;
{$mode objfpc}{$H+}
// from original Ultibo PWM example
interface
procedure pwmtest1;
implementation
uses
Threads,
Classes,
simpleaudio,
retromalina;
type tpwmthread=class(TThread)
private
protected
procedure Execute; override;
public
Constructor Create(CreateSuspended : boolean);
end;
{Declare a window handle, a counter and a couple of PWM devices}
var
Handle:THandle;
Count:Integer;
pwmthread:TPwmthread;
procedure pwmtest1;
begin
pwmthread:=tpwmthread.create(true);
pwmthread.start;
end;
constructor Tpwmthread.create(CreateSuspended : boolean);
begin
FreeOnTerminate := True;
inherited Create(CreateSuspended);
end;
procedure tpwmthread.execute;
begin
// First locate the PWM devices
initpwm(1000,1024);
while keypressed do readkey;
while not keypressed do
begin
for Count:=0 to 1024 do
begin
setpwm(0,count);
setpwm(1,1024-count);
threadsleep(1);
end;
for Count:=0 to 1024 do
begin
setpwm(1,count);
setpwm(0,1024-count);
threadsleep(1);
end;
end;
end;
end.