VirtualPeripheral for PWM Input?
Wiry
Posts: 1
I'm considering using the Javelin for reading two PWM signals of an X-Y-acceleration-sensor and controlling 2 servos. It seems easy to control the servos by instantiating 2 PWMs as PWMs are VirtualPeripherals and run in teh background. Unfortunately I didn't find a subclass of VirtualPeripheral for reading PWM.
Is it possible to extend VirtualPeripheral and implement a standard-method which is run in the background?
The API docs don't say how to build custom VirtualPeripherals.
cheers
Gunther
Is it possible to extend VirtualPeripheral and implement a standard-method which is run in the background?
The API docs don't say how to build custom VirtualPeripherals.
cheers
Gunther
Comments
All you can do is use the existent ones. You can however write
your code as state machines, that are called frequently from the mainloop.
If a state machine must wait for some event, it tests for that·event and returns
immediately if that event has not occured. To a certain level that gives you the
same behaviour as background tasks.
Pwm input could be done by testing for edges and counting the time between
those edges.·Would work only for·a low frequency pwm signal though.
regards peter