SPI 接続の温度センサ ADT7310 用のライブラリの使用例. Demo program of the library for temperature sensor ADT7310 connected using SPI interface.
Dependencies: UIT_ADT7310 UIT_AQM1602 mbed
Revision 5:8da999cd764a, committed 2017-10-28
- Comitter:
- MikamiUitOpen
- Date:
- Sat Oct 28 14:52:24 2017 +0000
- Parent:
- 4:16a9eda5ef78
- Commit message:
- 6
Changed in this revision
diff -r 16a9eda5ef78 -r 8da999cd764a UIT_ADT7310.lib --- a/UIT_ADT7310.lib Sat Jun 03 12:08:36 2017 +0000 +++ b/UIT_ADT7310.lib Sat Oct 28 14:52:24 2017 +0000 @@ -1,1 +1,1 @@ -http://developer.mbed.org/users/MikamiUitOpen/code/UIT_ADT7310/#6890e1214ea6 +http://developer.mbed.org/users/MikamiUitOpen/code/UIT_ADT7310/#38a276440674
diff -r 16a9eda5ef78 -r 8da999cd764a UIT_AQM1602.lib --- a/UIT_AQM1602.lib Sat Jun 03 12:08:36 2017 +0000 +++ b/UIT_AQM1602.lib Sat Oct 28 14:52:24 2017 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/MikamiUitOpen/code/UIT_AQM1602/#6e6c0f24e81f +http://mbed.org/users/MikamiUitOpen/code/UIT_AQM1602/#21830002e12d
diff -r 16a9eda5ef78 -r 8da999cd764a main.cpp --- a/main.cpp Sat Jun 03 12:08:36 2017 +0000 +++ b/main.cpp Sat Oct 28 14:52:24 2017 +0000 @@ -1,17 +1,14 @@ //-------------------------------------------------------------- -// Dual ADT7310's using SPI interface -// このプログラムは printf() 文でマルチバイト文字“℃”を -// 使っているので,コンパイル時に警告が出る +// ADT7310 using SPI interface // -// このプログラムは温度センサを2個使うということを前提に -// しているプログラムなので,温度センサが1個でも動くが, -// その場合の対応は特に行っていない +// mbed revision: 154 // -// 2017/06/03, Copyright (c) 2017 MIKAMI, Naoki +// 2017/10/28, Copyright (c) 2017 MIKAMI, Naoki //-------------------------------------------------------------- -#define ADT7310_DEBUG // デバッグの場合 -#define USING_AQM1602 // LCD 表示装置を使う場合 +#pragma diag_suppress 870 // マルチバイト文字使用の警告を抑制 +#define ADT7310_DEBUG // デバッグの場合 +#define USING_AQM1602 // LCD 表示器を使う場合 #ifdef USING_AQM1602 #include "AQM1602.hpp" @@ -24,39 +21,31 @@ Aqm1602 lcd_; // using default port #endif -// Declarations of the objects for ADT7310 +// Declaration of the object for ADT7310 ADT7310 sensor1(D10); // Slave select for the sensor: D10 -ADT7310 sensor2(D9); // Slave select for the sensor: D9 int main() { - printf("\r\nStart dual ADT7310s\r\n"); + printf("\r\nStart ADT7310\r\n"); #ifdef USING_AQM1602 bool on = true; - lcd_.WriteStringXY("Dual ADT7310s", 0, 0); + lcd_.WriteStringXY("ADT7310", 0, 0); #endif -/* - sensor1.SetResolution16(); // Set 13-bit resolution mode - sensor2.SetResolution16(true); // Set 16-bit resolution mode -*/ + #ifdef ADT7310_DEBUG // print out content of configuration registers - uint8_t v1 = sensor1.GetConfigReg(); - uint8_t v2 = sensor2.GetConfigReg(); - printf("v1: 0x%02x, v2: 0x%02x\r\n", v1, v2); + uint8_t reg = sensor1.GetConfigReg(); + printf("Config reg.: 0x%02x\r\n", reg); #endif while (true) { float tempr1 = sensor1.Read(); - float tempr2 = sensor2.Read(); - printf("Sensor1: %5.1f [℃], Sensor2: %5.1f [℃]\r\n", - tempr1, tempr2); + printf("%5.1f [℃]\r\n", tempr1); #ifdef USING_AQM1602 lcd_.ClearLine(1); - lcd_.WriteValueXY("%5.1f, ", tempr1, 0, 1); - lcd_.WriteValue("%5.1f \xDF\x43", tempr2); + lcd_.WriteValueXY("%5.1f \xDF""C", tempr1, 0, 1); if (on) lcd_.WriteStringXY(".", 15, 0); else lcd_.WriteStringXY(" ", 15, 0);
diff -r 16a9eda5ef78 -r 8da999cd764a mbed.bld --- a/mbed.bld Sat Jun 03 12:08:36 2017 +0000 +++ b/mbed.bld Sat Oct 28 14:52:24 2017 +0000 @@ -1,1 +1,1 @@ -https://mbed.org/users/mbed_official/code/mbed/builds/86740a56073b \ No newline at end of file +https://os.mbed.com/users/mbed_official/code/mbed/builds/fb8e0ae1cceb \ No newline at end of file