CaryCoders / Mbed 2 deprecated SX1276_GPS

Dependencies:   SX1276Lib AdaFruit_RGBLCD MCP23017 mbed

Fork of AdaFruit_RGBLCD by Justin Howard

Revision:
21:c44cfd3259c0
Parent:
20:93c70a1869ee
--- a/Modules/TempModule.cpp	Sat Aug 30 16:30:27 2014 +0000
+++ b/Modules/TempModule.cpp	Tue Sep 02 07:12:23 2014 +0000
@@ -3,7 +3,7 @@
 
 #include "extra_chars.h"
 
-#define MCP9808_I2CADDR_DEFAULT        0x30
+#define MCP9808_I2CADDR_DEFAULT        (0x18 << 1)
 #define MCP9808_REG_CONFIG             0x01
 
 #define MCP9808_REG_CONFIG_SHUTDOWN    0x0100
@@ -23,26 +23,29 @@
 #define MCP9808_REG_MANUF_ID           0x06
 #define MCP9808_REG_DEVICE_ID          0x07
 
-TempModule::TempModule(Serial & in_cDisplay)
+TempModule::TempModule(Serial & in_cDisplay,I2C & in_nI2C,uint8_t in_nAddress)
     : Module(in_cDisplay)
-    , m_cI2C(D3, D6) //I2C_SDA, I2C_SCL)    
-    , m_nAddress(MCP9808_I2CADDR_DEFAULT)
+    , m_cI2C(in_nI2C)
+    , m_nAddress(in_nAddress)
+    , m_bValid(false)
 {
     uint16_t nManufacturer = read16(MCP9808_REG_MANUF_ID);// != 0x0054) return false;
     uint16_t nDeviceId = read16(MCP9808_REG_DEVICE_ID);//
     
     // Check to see if we need to autoscan for our device
-    bool bAutoScan = (0x0054 != nManufacturer || 0x0400 != nDeviceId);
-    if (bAutoScan) m_nAddress = 0;
-    
-    while (bAutoScan && m_nAddress < 0x80)
-    {
-        nManufacturer = read16(MCP9808_REG_MANUF_ID);// != 0x0054) return false;
-        nDeviceId = read16(MCP9808_REG_DEVICE_ID);//
-        
-        bAutoScan = (0x0054 != nManufacturer || 0x0400 != nDeviceId);
-        m_nAddress++;
-    }
+    m_bValid = (0x0054 == nManufacturer || 0x0400 == nDeviceId);
+
+//    bool bAutoScan = true;
+//    m_nAddress = 0;
+//    
+//    while (bAutoScan && m_nAddress < 0x80)
+//    {
+//        nManufacturer = read16(MCP9808_REG_MANUF_ID);// != 0x0054) return false;
+//        nDeviceId = read16(MCP9808_REG_DEVICE_ID);//
+//        
+//        bAutoScan = (0x0054 != nManufacturer || 0x0400 != nDeviceId);
+//        m_nAddress++;
+//    }
 }
 
 TempModule::~TempModule()