Simple cpp wrapper of a ds18b20, onewire 'c' library. Supports multiple sensors.

Dependencies:   mbed

Dependents:   LPC11U68_DS18B20Sensor

Fork of DS18B20Sensor by Steve Spence

Revision:
1:ea35ad346f25
Parent:
0:1449f126b241
Child:
3:9fd95d590149
--- a/DS18B20Sensor.h	Sun Mar 03 01:41:51 2013 +0000
+++ b/DS18B20Sensor.h	Sun Mar 03 01:59:15 2013 +0000
@@ -6,38 +6,38 @@
 #include "onewire.h"
  
 /** DS18B20Sensor class.
- *  A wrapper class for the DS18X20 and onewire 'c' library.
- *  Many thanks to Frederic Blanc (among others) for making this code available.
- *
+ *  A wrapper class for the DS18B20 (temperature sensor) and onewire 'c' library.
+ *  Based on the OneWireDrv Library by Frederic Blanc. Many thanks to him for making this code available.
+ *  
  * Simple Example:
  * @code
  #include "mbed.h"
  #include "DS18B20Sensor.h"
- 
+
  DS18B20Sensor sensor(p30);
- 
- int main() 
+
+ int main()
  {
     char sensorBuf[25];
-    
+
     // count will search for sensors, if not already called
-    printf("Found %d sensor/s\r", sensor.count());  
-    
+    printf("Found %d sensor/s\r", sensor.count());
+
     uint8_t result = sensor.startReading(true);     // start sensor readings and wait
-    
+
     for (uint8_t i = 0; i < sensor.count(); i++) {
        sensor.getReadingText(sensorBuf, i);         // get result into buf
        printf("Sensor %d : %s\r", i+1, sensorBuf);  // display it to the world
     }
- 
+
  }
  * @endcode
  */
 class DS18B20Sensor
 {
 public:
-    /** Create Sensor instance
-    * @param pin pin number for the onewire bus
+    /** Create DS18B20Sensor instance
+    * @param pin The pin number used by the onewire bus.
     */
     DS18B20Sensor(PinName pin);
 
@@ -45,7 +45,7 @@
     * @param text The target text buffer.
     * @param index The sensor number.
     */
-    void getReadingText(char * text, uint8_t index);
+    void getReading(char * text, uint8_t index);
 
     /** Copies the sensor results into the parameter text.
     * @param text The target text buffer.
@@ -53,7 +53,15 @@
     * @param cel Degrees Cel
     * @param cel Degrees fraction
     */
-    void getReadingText(char * text, uint8_t subzero, uint8_t cel, uint8_t cel_frac_bits);
+    void getReading(char * text, uint8_t subzero, uint8_t cel, uint8_t cel_frac_bits);
+
+    /** Gets the sensors reading results.
+    * @param index The sensor number.
+    * @param subzero Returns 1 if less than zero.
+    * @param cel Returns degrees Cel
+    * @param cel Returns degrees fraction
+    */
+    void getReading(uint8_t index, uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
 
     /** This searches for sensors on the onewire bus.
     *   It can also invoked by just using count()
@@ -69,14 +77,6 @@
     */
     uint8_t startReading(bool includeWait = true);
 
-    /** Gets the sensors reading results.
-    * @param index The sensor number.
-    * @param subzero Returns 1 if less than zero.
-    * @param cel Returns degrees Cel
-    * @param cel Returns degrees fraction
-    */
-    void getReading(uint8_t index, uint8_t *subzero, uint8_t *cel, uint8_t *cel_frac_bits);
-
     /** If search() was not called before this, then search() is invoked.
     *   @returns The number of sensors found on the bus.
     */