I2C 接続の温度センサ ADT7410 用のライブラリの使用例. Demo program of the library for temperature sensor ADT7410 connected using I2C interface.

Dependencies:   mbed UIT_ADT7410

main.cpp

Committer:
MikamiUitOpen
Date:
2017-08-08
Revision:
9:eabefe7e52be
Parent:
8:8851e1dcb109
Child:
10:dc41d13e64cb

File content as of revision 9:eabefe7e52be:

//--------------------------------------------------------------
//  ADT7410 and LCD display using I2C interface
//      mbed revision: 148
//  2017/08/08, Copyright (c) 2017 MIKAMI, Naoki
//--------------------------------------------------------------

#include "ADT7410.hpp"
using namespace Mikami;

// If you want to display the temperature on AQM1602,
// enable following #define statement
#define USING_AQM1602

#ifdef USING_AQM1602
#include "AQM1602.hpp"
Aqm1602 lcd_;       // using default I2C port
#endif

ADT7410 tempr_;     // using default I2C port

int main()
{
    printf("\r\nStart ADT7410\r\n");
#ifdef USING_AQM1602
    bool on = true;
    lcd_.WriteStringXY("ADT7410", 0, 0);
#endif

    // Confirmation of setting
    uint8_t cReg = tempr_.GetConfig();
    printf("Mode: 0x%02x\r\n", cReg);
 
    while (true)
    {
        // Member function version
//        float value = tempr_.Read();
        // Operator version
        float value = tempr_;

#ifdef USING_AQM1602
        lcd_.WriteValueXY("%5.1f \xDF""C", value, 0, 1);
        if (on) lcd_.WriteStringXY(".", 15, 0);
        else    lcd_.WriteStringXY(" ", 15, 0);
        on = !on;
#endif
        printf("%5.1f deg. Celsius\r\n", value);
        wait(1);
    }
}