An I/O controller for virtual pinball machines: accelerometer nudge sensing, analog plunger input, button input encoding, LedWiz compatible output controls, and more.

Dependencies:   mbed FastIO FastPWM USBDevice

Fork of Pinscape_Controller by Mike R

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers tsl14xxSensor.h Source File

tsl14xxSensor.h

00001 // Base class for TSL14xx-based plunger sensors.
00002 //
00003 // This provides a common base class for plunger sensors based on
00004 // AMS/TAOS TSL14xx sensors (TSL1410R, TSL1412S, TSL1401CL).  The sensors
00005 // in this series all work the same way, differing mostly in the number
00006 // of pixels.  However, we have two fundamentally different ways of using
00007 // these image sensors to detect position: sensing the position of the
00008 // shadow cast by the plunger on the sensor, and optically reading a bar
00009 // code telling us the location of the sensor along a scale.  This class
00010 // provides the low-level pixel-sensor interface; subclasses provide the
00011 // image analysis that figures the position from the captured image.
00012 
00013 
00014 #ifndef _TSL14XXSENSOR_H_
00015 #define _TSL14XXSENSOR_H_
00016 
00017 #include "plunger.h"
00018 #include "edgeSensor.h"
00019 #include "barCodeSensor.h"
00020 #include "TSL14xx.h"
00021 
00022 class PlungerSensorTSL14xx: public PlungerSensorImageInterface
00023 {
00024 public:
00025     PlungerSensorTSL14xx(int nativePix, PinName si, PinName clock, PinName ao)
00026         : PlungerSensorImageInterface(nativePix), sensor(nativePix, si, clock, ao)
00027     {
00028     }
00029         
00030     // is the sensor ready?
00031     virtual bool ready() { return sensor.ready(); }
00032     
00033     virtual void init() { }
00034     
00035     // get the average sensor scan time
00036     virtual uint32_t getAvgScanTime() { return sensor.getAvgScanTime(); }
00037     
00038     virtual void readPix(uint8_t* &pix, uint32_t &t)
00039     {        
00040         // get the image array from the last capture
00041         sensor.getPix(pix, t);        
00042     }
00043     
00044     virtual void releasePix() { sensor.releasePix(); }
00045     
00046     virtual void setMinIntTime(uint32_t us) { sensor.setMinIntTime(us); }
00047 
00048     // the low-level interface to the TSL14xx sensor
00049     TSL14xx sensor;
00050 };
00051 
00052 
00053 // -------------------------------------------------------------------------
00054 //
00055 // Concrete TSL14xx sensor types
00056 //
00057 
00058 
00059 // TSL1410R sensor - edge detection sensor
00060 class PlungerSensorTSL1410R: public PlungerSensorEdgePos
00061 {
00062 public:
00063     PlungerSensorTSL1410R(PinName si, PinName clock, PinName ao)
00064         : PlungerSensorEdgePos(sensor, 1280), sensor(1280, si, clock, ao)
00065     {
00066     }
00067     
00068 protected:
00069     PlungerSensorTSL14xx sensor;
00070 };
00071 
00072 // TSL1412R - edge detection sensor
00073 class PlungerSensorTSL1412R: public PlungerSensorEdgePos
00074 {
00075 public:
00076     PlungerSensorTSL1412R(PinName si, PinName clock, PinName ao)
00077         : PlungerSensorEdgePos(sensor, 1536), sensor(1536, si, clock, ao)
00078     {
00079     }
00080     
00081 protected:
00082     PlungerSensorTSL14xx sensor;
00083 };
00084 
00085 // TSL1401CL - bar code sensor
00086 class PlungerSensorTSL1401CL: public PlungerSensorBarCode<7, 0, 1, 16>
00087 {
00088 public:
00089     PlungerSensorTSL1401CL(PinName si, PinName clock, PinName ao)
00090         : PlungerSensorBarCode(sensor, 128), sensor(128, si, clock, ao)
00091     {
00092     }
00093     
00094 protected:
00095     PlungerSensorTSL14xx sensor;
00096 };
00097 
00098 #endif