my fork
Fork of mbed by
AnalogIn.h@0:82220227f4fa, 2008-04-08 (annotated)
- Committer:
- simon.ford@mbed.co.uk
- Date:
- Tue Apr 08 14:12:21 2008 +0000
- Revision:
- 0:82220227f4fa
- Child:
- 1:6b7f447ca868
A first develoment release of the mbed libraries
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
simon.ford@mbed.co.uk | 0:82220227f4fa | 1 | /* mbed Microcontroller Library - AnalogIn |
simon.ford@mbed.co.uk | 0:82220227f4fa | 2 | * Copyright (c) 2007-2008, sford |
simon.ford@mbed.co.uk | 0:82220227f4fa | 3 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 4 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 5 | #ifndef MBED_ANALOGIN_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 6 | #define MBED_ANALOGIN_H |
simon.ford@mbed.co.uk | 0:82220227f4fa | 7 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 8 | #include "Base.h" |
simon.ford@mbed.co.uk | 0:82220227f4fa | 9 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 10 | namespace mbed { |
simon.ford@mbed.co.uk | 0:82220227f4fa | 11 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 12 | /* Class: AnalogIn |
simon.ford@mbed.co.uk | 0:82220227f4fa | 13 | * An analog input, used for reading the voltage on a pin |
simon.ford@mbed.co.uk | 0:82220227f4fa | 14 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 15 | class AnalogIn : public Base { |
simon.ford@mbed.co.uk | 0:82220227f4fa | 16 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 17 | public: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 18 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 19 | /* Group: Configuration Methods */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 20 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 21 | /* Constructor: AnalogIn |
simon.ford@mbed.co.uk | 0:82220227f4fa | 22 | * Create an AnalogIn connected to the specified pin |
simon.ford@mbed.co.uk | 0:82220227f4fa | 23 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 24 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 25 | * pin - AnalogIn pin to connect to (15-20) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 26 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 27 | AnalogIn(int pin); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 28 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 29 | /* Group: Access Methods */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 30 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 31 | /* Function: read |
simon.ford@mbed.co.uk | 0:82220227f4fa | 32 | * Read the input, measured as a percentage (float) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 33 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 34 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 35 | * returns - A floating-point value representing the current input voltage, |
simon.ford@mbed.co.uk | 0:82220227f4fa | 36 | * measured as a percentage. The returned value will lie between |
simon.ford@mbed.co.uk | 0:82220227f4fa | 37 | * 0.0f (representing 0v / 0%) and 1.0f (representing 3.3v / 100%). |
simon.ford@mbed.co.uk | 0:82220227f4fa | 38 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 39 | float read(); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 40 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 41 | /* Function: read_v |
simon.ford@mbed.co.uk | 0:82220227f4fa | 42 | * Read the input, measured in volts (float) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 43 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 44 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 45 | * returns - A floating-point value representing the current input voltage, |
simon.ford@mbed.co.uk | 0:82220227f4fa | 46 | * measured in volts. The returned value will lie between |
simon.ford@mbed.co.uk | 0:82220227f4fa | 47 | * 0.0f (representing 0v / 0%) and 3.3f (representing 3.3v / 100%). |
simon.ford@mbed.co.uk | 0:82220227f4fa | 48 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 49 | float read_v(); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 50 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 51 | /* Function: read_mv |
simon.ford@mbed.co.uk | 0:82220227f4fa | 52 | * Read the input, measured in milli-volts (int) |
simon.ford@mbed.co.uk | 0:82220227f4fa | 53 | * |
simon.ford@mbed.co.uk | 0:82220227f4fa | 54 | * Variables: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 55 | * returns - An integer value representing the current input voltage, |
simon.ford@mbed.co.uk | 0:82220227f4fa | 56 | * measured in milli-volts. The returned value will lie between |
simon.ford@mbed.co.uk | 0:82220227f4fa | 57 | * 0 (representing 0v / 0%) and 3300 (representing 3.3v / 100%). |
simon.ford@mbed.co.uk | 0:82220227f4fa | 58 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 59 | int read_mv(); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 60 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 61 | /* Group: Access Methods Shorthand */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 62 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 63 | /* Function: operator float |
simon.ford@mbed.co.uk | 0:82220227f4fa | 64 | * A shorthand for <read> |
simon.ford@mbed.co.uk | 0:82220227f4fa | 65 | */ |
simon.ford@mbed.co.uk | 0:82220227f4fa | 66 | operator float(); |
simon.ford@mbed.co.uk | 0:82220227f4fa | 67 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 68 | protected: |
simon.ford@mbed.co.uk | 0:82220227f4fa | 69 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 70 | int _id; |
simon.ford@mbed.co.uk | 0:82220227f4fa | 71 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 72 | }; |
simon.ford@mbed.co.uk | 0:82220227f4fa | 73 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 74 | } |
simon.ford@mbed.co.uk | 0:82220227f4fa | 75 | |
simon.ford@mbed.co.uk | 0:82220227f4fa | 76 | #endif |