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
|
//callback that will run at datarate
//data - array of spatial event data structures that holds the spatial data packets that were sent in this event
//count - the number of spatial data event packets included in this event
function SpatialDataHandler(spatial: CPhidgetSpatialHandle; userptr: Pointer;
data : pCPhidgetSpatial_SpatialEventDataHandle ;
count: CInteger): CInteger; stdcall;
var
i: Integer;
DT: CPhidgetSpatial_SpatialEventData;
begin
if (count = 0) then Exit(0);
try
for i := 0 to count - 1 do
begin
DT := CPhidgetSpatial_SpatialEventData(data^^); // double déréférencement
if (SameValue(DT.magneticField[0], PUNK_DBL)) then exit(0);
Form1.Memo2.Lines.Add(Format('=== Data Set: %d of %d ===', [i, Count - 1]));
Form1.Memo2.Lines.Add(Format('Acceleration> x: %.6f y: %.6f z: %.6f', [DT.acceleration[0], DT.acceleration[1], DT.acceleration[2]]));
Form1.Memo2.Lines.Add(Format('Angular Rate> x: %.6f y: %.6f z: %.6f', [DT.angularRate[0], DT.angularRate[1], DT.angularRate[2]]));
Form1.Memo2.Lines.Add(Format('Magnetic Field> x: %.6f y: %.6f z: %.6f', [DT.magneticField[0], DT.magneticField[1], DT.magneticField[2]]));
Form1.Memo2.Lines.Add(Format('Timestamp> seconds: %d -- microseconds: %d', [DT.timestamp.seconds, DT.timestamp.microseconds]));
//*)
end;
except
;
end;
Result := 0;
end; |
Partager