Mike R / Mbed 2 deprecated Pinscape_Controller_V2

Dependencies:   mbed FastIO FastPWM USBDevice

Fork of Pinscape_Controller by Mike R

Committer:
mjr
Date:
Sun Feb 07 03:07:11 2016 +0000
Revision:
44:b5ac89b9cd5d
Parent:
43:7a6364d82a41
Child:
45:c42166b2878c
Work in progress on CCD speed-ups

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mjr 35:e959ffba78fd 1 // Plunger Sensor Interface
mjr 35:e959ffba78fd 2 //
mjr 35:e959ffba78fd 3 // This module defines the abstract interface to the plunger sensors.
mjr 35:e959ffba78fd 4 // We support several different physical sensor types, so we need a
mjr 35:e959ffba78fd 5 // common interface for use in the main code.
mjr 35:e959ffba78fd 6 //
mjr 35:e959ffba78fd 7
mjr 35:e959ffba78fd 8 #ifndef PLUNGER_H
mjr 35:e959ffba78fd 9 #define PLUNGER_H
mjr 35:e959ffba78fd 10
mjr 35:e959ffba78fd 11 class PlungerSensor
mjr 35:e959ffba78fd 12 {
mjr 35:e959ffba78fd 13 public:
mjr 35:e959ffba78fd 14
mjr 35:e959ffba78fd 15 PlungerSensor() { }
mjr 35:e959ffba78fd 16 virtual ~PlungerSensor() { }
mjr 35:e959ffba78fd 17
mjr 35:e959ffba78fd 18 // Initialize the physical sensor device. This is called at startup
mjr 35:e959ffba78fd 19 // to set up the device for first use.
mjr 35:e959ffba78fd 20 virtual void init() = 0;
mjr 35:e959ffba78fd 21
mjr 35:e959ffba78fd 22 // Take a high-resolution reading. Sets pos to the current position,
mjr 44:b5ac89b9cd5d 23 // on a scale from 0.0 to 1.0: 0.0 is the maximum forward plunger position,
mjr 44:b5ac89b9cd5d 24 // and 1.0 is the maximum retracted position, in terms of the sensor's
mjr 35:e959ffba78fd 25 // extremes. This is a raw reading in terms of the sensor range; the
mjr 35:e959ffba78fd 26 // caller is responsible for applying calibration data and scaling the
mjr 35:e959ffba78fd 27 // result to the the joystick report range.
mjr 35:e959ffba78fd 28 //
mjr 35:e959ffba78fd 29 // Returns true on success, false on failure. Return false if it wasn't
mjr 35:e959ffba78fd 30 // possible to take a good reading for any reason.
mjr 44:b5ac89b9cd5d 31 virtual bool highResScan(float &pos) = 0;
mjr 35:e959ffba78fd 32
mjr 35:e959ffba78fd 33 // Take a low-resolution reading. This reports the result on the same
mjr 44:b5ac89b9cd5d 34 // 0.0 to 1.0 scale as highResScan(). Returns true on success, false on
mjr 35:e959ffba78fd 35 // failure.
mjr 35:e959ffba78fd 36 //
mjr 35:e959ffba78fd 37 // The difference between the high-res and low-res scans is the amount
mjr 35:e959ffba78fd 38 // of time it takes to complete the reading. The high-res scan is allowed
mjr 35:e959ffba78fd 39 // to take about 10ms; a low-res scan take less than 1ms. For many
mjr 35:e959ffba78fd 40 // sensors, either of these time scales would yield identical resolution;
mjr 35:e959ffba78fd 41 // if that's the case, simply take a reading the same way in both functions.
mjr 35:e959ffba78fd 42 // The distinction is for the benefit of sensors that need significantly
mjr 35:e959ffba78fd 43 // longer to read at higher resolutions, such as image sensors that have
mjr 35:e959ffba78fd 44 // to sample pixels serially.
mjr 44:b5ac89b9cd5d 45 virtual bool lowResScan(float &pos) = 0;
mjr 35:e959ffba78fd 46
mjr 35:e959ffba78fd 47 // Send an exposure report to the joystick interface. This is specifically
mjr 35:e959ffba78fd 48 // for image sensors, and should be omitted by other sensor types. For
mjr 35:e959ffba78fd 49 // image sensors, this takes one exposure and sends all pixels to the host
mjr 35:e959ffba78fd 50 // through special joystick reports. This is used for PC-side testing tools
mjr 35:e959ffba78fd 51 // to let the user check the sensor installation by directly viewing its
mjr 35:e959ffba78fd 52 // pixel output.
mjr 35:e959ffba78fd 53 virtual void sendExposureReport(class USBJoystick &js) { }
mjr 35:e959ffba78fd 54 };
mjr 35:e959ffba78fd 55
mjr 35:e959ffba78fd 56 #endif /* PLUNGER_H */