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-10-28
Revision:
11:632e038543e3
Parent:
10:dc41d13e64cb
Child:
12:9a71c11c8e92

File content as of revision 11:632e038543e3:

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

#pragma diag_suppress 870   // マルチバイト文字使用の警告を抑制
#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  // #ifdef USING_AQM1602

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  // #ifdef USING_AQM1602

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

#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  // #ifdef USING_AQM1602
        printf("%5.1f [℃]\r\n", value);
        wait(1);
    }
}