version for testing OneWire library

Dependencies:   OneWire mbed

#include "mbed.h"
#include "OneWire.h"
 
OneWire owBus(p21);
 
int main()
{
    char _id[16];
    DeviceAddresses* devAddresses = owBus.getFoundDevAddresses();
    uint8_t foundNum = owBus.getFoundDevNum();
    printf("OneWire: found %d devices\r\n", foundNum);
 
    while(1) {
        OneWireDeviceTemperature::startConversationForAll(&owBus, OWTEMP_11_BIT);
        for (uint8_t i = 0; i < foundNum; i++) {
            OneWireDevice* owDevice = OneWireDeviceFactory::init(&owBus, (*devAddresses)[i]);
            
            if (owDevice->getFamily() != ONEWIRE_DS18B20_FAMILY)    // currently only DS18B20 supports
                continue;
 
            owDevice->generateId(_id);
            printf("OneWire: device #%s = %.4f*C\r\n", _id, (float) owDevice->sendGetCommand(GET_TEMPERATURE));
            delete owDevice;            
        }
        
        wait(5);
    }
 }

Files at this revision

API Documentation at this revision

Comitter:
ivank
Date:
Tue Dec 18 12:16:06 2012 +0000
Parent:
0:8446fa47e6dd
Commit message:
updated OneWire Lib

Changed in this revision

OneWire.lib Show annotated file Show diff for this revision Revisions of this file
diff -r 8446fa47e6dd -r 873cb457746e OneWire.lib
--- a/OneWire.lib	Tue Dec 18 12:03:48 2012 +0000
+++ b/OneWire.lib	Tue Dec 18 12:16:06 2012 +0000
@@ -1,1 +1,1 @@
-https://mbed.org/users/ivank/code/OneWire/#07da4deb7135
+https://mbed.org/users/ivank/code/OneWire/#7bd102cb73e0