Pinscape Controller version 1 fork. This is a fork to allow for ongoing bug fixes to the original controller version, from before the major changes for the expansion board project.
Dependencies: FastIO FastPWM SimpleDMA mbed
Fork of Pinscape_Controller by
potSensor.h@17:ab3cec0c8bf4, 2015-02-27 (annotated)
- Committer:
- mjr
- Date:
- Fri Feb 27 04:14:04 2015 +0000
- Revision:
- 17:ab3cec0c8bf4
- Child:
- 23:14f8c5004cd0
FastIO and FastAnalogIn; better firing event sensing; potentiometer plunger sensor option; new key debouncing; ZB Launch Ball feature
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mjr | 17:ab3cec0c8bf4 | 1 | // Potentiometer plunger sensor |
mjr | 17:ab3cec0c8bf4 | 2 | // |
mjr | 17:ab3cec0c8bf4 | 3 | // This file implements our generic plunger sensor interface for a |
mjr | 17:ab3cec0c8bf4 | 4 | // potentiometer. |
mjr | 17:ab3cec0c8bf4 | 5 | |
mjr | 17:ab3cec0c8bf4 | 6 | #include "FastAnalogIn.h" |
mjr | 17:ab3cec0c8bf4 | 7 | |
mjr | 17:ab3cec0c8bf4 | 8 | // The potentiometer doesn't have pixels, but we still need an |
mjr | 17:ab3cec0c8bf4 | 9 | // integer range for normalizing our digitized voltage level values. |
mjr | 17:ab3cec0c8bf4 | 10 | // The number here is fairly arbitrary; the higher it is, the finer |
mjr | 17:ab3cec0c8bf4 | 11 | // the digitized steps. A 40" 1080p HDTV has about 55 pixels per inch |
mjr | 17:ab3cec0c8bf4 | 12 | // on its physical display, so if the on-screen plunger is displayed |
mjr | 17:ab3cec0c8bf4 | 13 | // at roughly the true physical size, it's about 3" on screen or about |
mjr | 17:ab3cec0c8bf4 | 14 | // 165 pixels. So the minimum quantization size here should be about |
mjr | 17:ab3cec0c8bf4 | 15 | // the same. For the pot sensor, this is just a scaling factor, |
mjr | 17:ab3cec0c8bf4 | 16 | // so higher values don't cost us anything (unlike the CCD, where the |
mjr | 17:ab3cec0c8bf4 | 17 | // read time is proportional to the number of pixels we sample). |
mjr | 17:ab3cec0c8bf4 | 18 | const int npix = 4096; |
mjr | 17:ab3cec0c8bf4 | 19 | |
mjr | 17:ab3cec0c8bf4 | 20 | class PlungerSensor |
mjr | 17:ab3cec0c8bf4 | 21 | { |
mjr | 17:ab3cec0c8bf4 | 22 | public: |
mjr | 17:ab3cec0c8bf4 | 23 | PlungerSensor() : pot(POT_PIN) |
mjr | 17:ab3cec0c8bf4 | 24 | { |
mjr | 17:ab3cec0c8bf4 | 25 | pot.enable(); |
mjr | 17:ab3cec0c8bf4 | 26 | } |
mjr | 17:ab3cec0c8bf4 | 27 | |
mjr | 17:ab3cec0c8bf4 | 28 | void init() |
mjr | 17:ab3cec0c8bf4 | 29 | { |
mjr | 17:ab3cec0c8bf4 | 30 | } |
mjr | 17:ab3cec0c8bf4 | 31 | |
mjr | 17:ab3cec0c8bf4 | 32 | int lowResScan() |
mjr | 17:ab3cec0c8bf4 | 33 | { |
mjr | 17:ab3cec0c8bf4 | 34 | return int(pot.read() * npix); |
mjr | 17:ab3cec0c8bf4 | 35 | } |
mjr | 17:ab3cec0c8bf4 | 36 | |
mjr | 17:ab3cec0c8bf4 | 37 | bool highResScan(int &pos) |
mjr | 17:ab3cec0c8bf4 | 38 | { |
mjr | 17:ab3cec0c8bf4 | 39 | pos = int(pot.read() * npix); |
mjr | 17:ab3cec0c8bf4 | 40 | return true; |
mjr | 17:ab3cec0c8bf4 | 41 | } |
mjr | 17:ab3cec0c8bf4 | 42 | |
mjr | 17:ab3cec0c8bf4 | 43 | void sendExposureReport(USBJoystick &) |
mjr | 17:ab3cec0c8bf4 | 44 | { |
mjr | 17:ab3cec0c8bf4 | 45 | } |
mjr | 17:ab3cec0c8bf4 | 46 | |
mjr | 17:ab3cec0c8bf4 | 47 | private: |
mjr | 17:ab3cec0c8bf4 | 48 | FastAnalogIn pot; |
mjr | 17:ab3cec0c8bf4 | 49 | }; |