example project to explain how to write a class library

Embed: (wiki syntax)

« Back to documentation index

test_LM75B Class Reference

test_LM75B Class Reference

test_LM75Bクラスライブラリ More...

#include <test_LM75B.h>

Public Member Functions

 test_LM75B (PinName sda, PinName scl, char address=ADDRESS_LM75B)
 I2Cピンとスレーブアドレスを指定し,インスタンスを作成します
 test_LM75B (I2C &i2c_obj, char address=ADDRESS_LM75B)
 I2Cオブジェクトとスレーブアドレスを指定し,インスタンスを作成します
 ~test_LM75B ()
 デストラクタ
void init (void)
 初期化
float read (void)
 温度の読み出し
 operator float (void)
 温度の読み出し

Detailed Description

test_LM75Bクラスライブラリ

クラスライブラリは非常にシンプルなインターフェースを提供します

コード例:

  #include "mbed.h"
  #include "test_LM75B.h"
  
  test_LM75B  temp0( p28, p27 );
  
  I2C         i2c( p28, p27 );
  test_LM75B  temp1( i2c );
  
  
  int main()
  {
      float   t0;
      float   t1;
  
      i2c.frequency( 400 * 1000 );
  
      while(1) {
          t0   = temp0;
          t1   = temp1;
          printf( "temp = %7.3f, %7.3f\r\n", t0, t1 );
          wait( 1 );
      }
  }

Definition at line 57 of file test_LM75B.h.


Constructor & Destructor Documentation

test_LM75B ( PinName  sda,
PinName  scl,
char  address = ADDRESS_LM75B 
)

I2Cピンとスレーブアドレスを指定し,インスタンスを作成します

Parameters:
sdaI2C-bus SDAピン
sclI2C-bus SCLピン
address(オプション) I2C-bus スレーブアドレス (デフォルト: 0x90)

Definition at line 3 of file test_LM75B.cpp.

test_LM75B ( I2C &  i2c_obj,
char  address = ADDRESS_LM75B 
)

I2Cオブジェクトとスレーブアドレスを指定し,インスタンスを作成します

Parameters:
i2c_objI2C オブジェクト (インスタンス)
address(オプション) I2C-bus スレーブアドレス (デフォルト: 0x90)

Definition at line 9 of file test_LM75B.cpp.

~test_LM75B (  )

デストラクタ

Definition at line 15 of file test_LM75B.cpp.


Member Function Documentation

void init ( void   )

初期化

Definition at line 21 of file test_LM75B.cpp.

operator float ( void   )

温度の読み出し

Returns:
オブジェクトが読みだした値を返すようにしています

Definition at line 43 of file test_LM75B.cpp.

float read ( void   )

温度の読み出し

Returns:
摂氏温度を返します(float型)

Definition at line 31 of file test_LM75B.cpp.