Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of CRAC-Strat_2017_homologation_gros_rob by
AnalogIn.h
00001 /* mbed Microcontroller Library - AnalogIn 00002 * Copyright (c) 2006-2011 ARM Limited. All rights reserved. 00003 */ 00004 00005 #ifndef MBED_ANALOGIN_H 00006 #define MBED_ANALOGIN_H 00007 00008 #include "device.h" 00009 00010 #if DEVICE_ANALOGIN 00011 00012 #include "platform.h" 00013 #include "PinNames.h" 00014 #include "PeripheralNames.h" 00015 #include "Base.h" 00016 00017 namespace mbed { 00018 00019 /* Class: AnalogIn 00020 * An analog input, used for reading the voltage on a pin 00021 * 00022 * Example: 00023 * > // Print messages when the AnalogIn is greater than 50% 00024 * > 00025 * > #include "mbed.h" 00026 * > 00027 * > AnalogIn temperature(p20); 00028 * > 00029 * > int main() { 00030 * > while(1) { 00031 * > if(temperature > 0.5) { 00032 * > printf("Too hot! (%f)", temperature.read()); 00033 * > } 00034 * > } 00035 * > } 00036 */ 00037 class AnalogIn : public Base { 00038 00039 public: 00040 00041 /* Constructor: AnalogIn 00042 * Create an AnalogIn, connected to the specified pin 00043 * 00044 * Variables: 00045 * pin - AnalogIn pin to connect to 00046 * name - (optional) A string to identify the object 00047 */ 00048 AnalogIn(PinName pin, const char *name = NULL); 00049 00050 /* Function: read 00051 * Read the input voltage, represented as a float in the range [0.0, 1.0] 00052 * 00053 * Variables: 00054 * returns - A floating-point value representing the current input voltage, 00055 * measured as a percentage 00056 */ 00057 float read(); 00058 00059 /* Function: read_u16 00060 * Read the input voltage, represented as an unsigned short in the range [0x0, 0xFFFF] 00061 * 00062 * Variables: 00063 * returns - 16-bit unsigned short representing the current input voltage, 00064 * normalised to a 16-bit value 00065 */ 00066 unsigned short read_u16(); 00067 00068 #ifdef MBED_OPERATORS 00069 /* Function: operator float 00070 * An operator shorthand for <read()> 00071 * 00072 * The float() operator can be used as a shorthand for <read()> to simplify common code sequences 00073 * 00074 * Example: 00075 * > float x = volume.read(); 00076 * > float x = volume; 00077 * > 00078 * > if(volume.read() > 0.25) { ... } 00079 * > if(volume > 0.25) { ... } 00080 */ 00081 operator float(); 00082 #endif 00083 00084 #ifdef MBED_RPC 00085 virtual const struct rpc_method *get_rpc_methods(); 00086 static struct rpc_class *get_rpc_class(); 00087 #endif 00088 00089 protected: 00090 00091 ADCName _adc; 00092 00093 }; 00094 00095 } // namespace mbed 00096 00097 #endif 00098 00099 #endif
Generated on Tue Jul 12 2022 19:28:47 by
