Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: IZU2020_AVIONICS IZU2020_AVIONICS
Diff: PQINA226.h
- Revision:
- 4:9e7136efda5c
- Parent:
- 3:252d161776cc
- Child:
- 5:7f4ebd11d751
--- a/PQINA226.h Wed Dec 04 09:37:02 2019 +0000
+++ b/PQINA226.h Tue Dec 17 10:56:04 2019 +0000
@@ -9,20 +9,6 @@
#define VOLTAGE_LSB 1.25
#define POWER_LSB 25
-typedef enum A0 {
- A0_GND = 0b00,
- A0_VS = 0b01,
- A0_SDA = 0b10,
- A0_SCL = 0b11
-} A0_t;
-
-typedef enum A1 {
- A1_GND = 0b00,
- A1_VS = 0b01,
- A1_SDA = 0b10,
- A1_SCL = 0b11
-} A1_t;
-
/** 電圧電流センサINA226のライブラリ
* @code
#include "mbed.h"
@@ -48,11 +34,27 @@
*/
class INA226
{
+public:
+ typedef enum A0 {
+ A0_GND = 0b00,
+ A0_VS = 0b01,
+ A0_SDA = 0b10,
+ A0_SCL = 0b11
+ } A0_t;
+
+ typedef enum A1 {
+ A1_GND = 0b00,
+ A1_VS = 0b01,
+ A1_SDA = 0b10,
+ A1_SCL = 0b11
+ } A1_t;
+
private:
I2C *_i2c;
int _addr;
char cmd[3];
char buff[2];
+
public:
/**
* @param i2c I2Cのインスタンスへの参照
@@ -60,19 +62,19 @@
* @param A1 A1のジャンパ
*/
INA226(I2C &i2c, A0_t A0, A1_t A1);
-
+
/**
* センサ動作開始
*/
void begin();
-
+
/**
* センサ通信テスト
* @retval true 通信成功
* @retval false 通信失敗
*/
bool test();
-
+
/**
* 測定値読み取り
* @param voltage 電圧を格納する変数へのポインタ
@@ -80,19 +82,19 @@
* @param power 電力を格納する変数へのポインタ
*/
void read(float *voltage, float *current, float *power);
-
+
/**
* 電圧測定値読み取り
* @param voltage 電圧を格納する変数へのポインタ
*/
void read_voltage(float *voltage);
-
+
/**
* 電流測定値読み取り
* @param current 電流を格納する変数へのポインタ
*/
void read_current(float *current);
-
+
/**
* 電力測定値読み取り
* @param power 電力を格納する変数へのポインタ