temperature sensor with uOLED 96 g1 & GSM Support

Dependencies:   OLED160G1 mbed uOLED

Fork of DS18B20 by Renato Loureiro

Files at this revision

API Documentation at this revision

Comitter:
Renato
Date:
Wed Oct 31 12:26:00 2012 +0000
Parent:
0:03ec282c2908
Child:
2:fe0f893513d4
Commit message:
Test v1

Changed in this revision

DS18B20.cpp Show annotated file Show diff for this revision Revisions of this file
DS18B20.h Show annotated file Show diff for this revision Revisions of this file
OLED160G1.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
uOLED.lib Show annotated file Show diff for this revision Revisions of this file
--- a/DS18B20.cpp	Fri Jan 29 19:01:56 2010 +0000
+++ b/DS18B20.cpp	Wed Oct 31 12:26:00 2012 +0000
@@ -6,6 +6,7 @@
 // Device byte commands over 1-wire serial
 enum COMMANDS { READ_ROM = 0x33, CONVERT = 0x44, READ_SCRATCHPAD = 0xBE,  SKIP_ROM = 0xCC };
 
+
 // device onboard register layout
 typedef struct {
     uint8_t    LSB;
@@ -76,11 +77,12 @@
 }
 
 // temperature is store as 7.4 fixed point format (assuming 12 bit conversion)
-void displayTemperature(Serial& s) {
+void showTemperature(float *f) {
     DoConversion();
     uint32_t temp = GetTemperature();
-    float f = (temp & 0x0F) * 0.0625;    // calculate .4 part
-    f += (temp >> 4);    // add 7.0 part to it
-    s.printf("Temp is %2.1fC\n\r", f);    // display in 2.1 format
+    *f = (temp & 0x0F) * 0.0625;    // calculate .4 part
+    *f += (temp >> 4);    // add 7.0 part to it
+    //return(f);
+    //s.printf("Temp is %2.1fC\n\r", f);    // display in 2.1 format
 }
 
--- a/DS18B20.h	Fri Jan 29 19:01:56 2010 +0000
+++ b/DS18B20.h	Wed Oct 31 12:26:00 2012 +0000
@@ -1,22 +1,23 @@
-#ifndef _DS18B20_
-#define _DS18B20_
-
-#include <stdint.h>
-#include "mbed.h"
-
-// Device Faimly ID and Setial number information
-typedef union {
-    uint8_t rom[8];
-    struct {
-        uint8_t    familyCode;
-        uint8_t    serialNo[6];
-        uint8_t    CRC;
-    } BYTES;
-} ROM_Code_t;
-
-ROM_Code_t ReadROM() ;
-
-// temperature is store as 7.4 fixed point format (assuming 12 bit conversion)
-void displayTemperature(Serial& s) ;
-
+#ifndef _DS18B20_
+#define _DS18B20_
+
+#include <stdint.h>
+#include "mbed.h"
+
+// Device Faimly ID and Setial number information
+typedef union {
+    uint8_t rom[8];
+    struct {
+        uint8_t    familyCode;
+        uint8_t    serialNo[6];
+        uint8_t    CRC;
+    } BYTES;
+} ROM_Code_t;
+
+ROM_Code_t ReadROM() ;
+
+// temperature is store as 7.4 fixed point format (assuming 12 bit conversion)
+void displayTemperature(Serial& s) ;
+void showTemperature(float *f);
+
 #endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/OLED160G1.lib	Wed Oct 31 12:26:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Renato/code/OLED160G1/#c22a582f62c0
--- a/main.cpp	Fri Jan 29 19:01:56 2010 +0000
+++ b/main.cpp	Wed Oct 31 12:26:00 2012 +0000
@@ -1,28 +1,51 @@
 #include "mbed.h"
-#include <stdint.h>
+#include "stdint.h"
 #include "DS18B20.h"
+#include "OLED160G1.h"
+#include "uOLED.h"
 
-DigitalInOut sensor(p5);     // sensor connected to pin 5
+
+DigitalInOut sensor(p23);     // sensor connected to pin 23
+
+OLED160G1 oled(p9, p10, p8);
+uOLED uoled(p9, p10, p8);
 
 Ticker timer;                // used for our microsec timing
 Serial pc(USBTX, USBRX);     // serial comms over usb back to console
+float temp=0;
+
+
 
 int main() {
-    pc.printf("\n\r=====================================================\n\r");
-    pc.printf("DS18B20 Configuration\n\r");
+
+    /*oled.init();
+    oled.eraseScreen();
+    oled.setTextBackgroundType(OLED_SET_TEXT_OPAQUE);
+    oled.setFontSize(0);
+      */                    //uOLED initialization...
+    uoled.init();
+    
+    
+    //oled.printf("===========\n");
+    //oled.printf("DS18B20 Config\n");
     sensor.mode(PullUp);
     
     ROM_Code_t ROM_Code = ReadROM();
-    pc.printf("Family code: 0x%X\n\r", ROM_Code.BYTES.familyCode);
-    pc.printf("Serial Number: ");
+    /*oled.printf("Family code: 0x%X\n", ROM_Code.BYTES.familyCode);
+    oled.printf("Serial Number: \n");
     for (uint32_t i = 6; i != 0; --i) {
-        pc.printf("%02X%s", ROM_Code.BYTES.serialNo[i-1], (i != 1)?":":"\r\n");
+        oled.printf("%02X%s", ROM_Code.BYTES.serialNo[i-1], (i != 1)?":":"\n");
     }
-    pc.printf("CRC: 0x%X\r\n", ROM_Code.BYTES.CRC);
-    
-    pc.printf("\n\rRunning temperature conversion...\n\r");
+    oled.printf("CRC: 0x%X\n", ROM_Code.BYTES.CRC);
+    */
+    oled.locate(0,1);
+    uoled.printf("Convertendo...\n");
+    //uoled.drawText(1, 3, 3, 200, 100, 40, "Convertendo...\n");
     while (1) {
-        displayTemperature(pc);
+    showTemperature(&temp);
+       oled.locate(2,3);
+       oled.setFontSize(2);
+        oled.printf("%.2f C",temp);
         wait(10);
     }
 }
--- a/mbed.bld	Fri Jan 29 19:01:56 2010 +0000
+++ b/mbed.bld	Wed Oct 31 12:26:00 2012 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/49a220cc26e0
+http://mbed.org/users/mbed_official/code/mbed/builds/e2ed12d17f06
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/uOLED.lib	Wed Oct 31 12:26:00 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Nakor/code/uOLED/#7ad5bf258a1e