java: changed some C types to C++ types

Signed-off-by: Andrei Vasiliu <andrei.vasiliu@intel.com>
Signed-off-by: Mihai Tudor Panu <mihai.tudor.panu@intel.com>

Conflicts:
	src/mma7455/mma7455.cxx
	src/mma7455/mma7455.h
	src/sm130/sm130.cxx
	src/sm130/sm130.h
This commit is contained in:
Andrei Vasiliu
2015-09-02 14:56:13 +03:00
committed by Mihai Tudor Panu
parent b8835958e2
commit ab730038fd
46 changed files with 731 additions and 996 deletions

View File

@ -31,47 +31,37 @@
using namespace upm;
MLX90614::MLX90614 (int bus, int devAddr) {
MLX90614::MLX90614 (int bus, int devAddr) : m_i2Ctx(bus) {
m_name = "MLX90614";
m_i2cAddr = devAddr;
m_bus = bus;
if (!(m_i2Ctx = mraa_i2c_init(m_bus)))
{
mraa::Result ret = m_i2Ctx.address(m_i2cAddr);
if (ret != mraa::SUCCESS) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_i2c_init() failed");
}
mraa_result_t ret = mraa_i2c_address(m_i2Ctx, m_i2cAddr);
if (ret != MRAA_SUCCESS) {
throw std::invalid_argument(std::string(__FUNCTION__) +
": mraa_i2c_address() failed");
": address() failed");
}
}
MLX90614::~MLX90614() {
mraa_i2c_stop(m_i2Ctx);
}
float
MLX90614::readObjectTempF(void) {
return (readTemperature (MLX90614_TOBJ1) * 9 / 5) + 32;
return (readTemperature(MLX90614_TOBJ1) * 9 / 5) + 32;
}
float
MLX90614::readAmbientTempF(void) {
return (readTemperature (MLX90614_TA) * 9 / 5) + 32;
return (readTemperature(MLX90614_TA) * 9 / 5) + 32;
}
float
MLX90614::readObjectTempC(void) {
return readTemperature (MLX90614_TOBJ1);
return readTemperature(MLX90614_TOBJ1);
}
float
MLX90614::readAmbientTempC(void) {
return readTemperature (MLX90614_TA);
return readTemperature(MLX90614_TA);
}
/*
@ -83,19 +73,19 @@ uint16_t
MLX90614::i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer) {
int readByte = 0;
mraa_i2c_address(m_i2Ctx, m_i2cAddr);
mraa_i2c_write_byte(m_i2Ctx, reg);
m_i2Ctx.address(m_i2cAddr);
m_i2Ctx.writeByte(reg);
readByte = mraa_i2c_read(m_i2Ctx, buffer, len);
readByte = m_i2Ctx.read(buffer, len);
return readByte;
}
mraa_result_t
mraa::Result
MLX90614::i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer) {
mraa_result_t error = MRAA_SUCCESS;
mraa::Result error = mraa::SUCCESS;
error = mraa_i2c_address (m_i2Ctx, m_i2cAddr);
error = mraa_i2c_write (m_i2Ctx, buffer, len);
error = m_i2Ctx.address(m_i2cAddr);
error = m_i2Ctx.write(buffer, len);
return error;
}
@ -108,7 +98,7 @@ MLX90614::readTemperature (uint8_t address) {
/* Reading temperature from sensor.
Answer contained of 3 bytes (TEMP_LSB | TEMP_MSB | PEC)
*/
if (i2cReadReg_N (address, 3, buffer) > 2) {
if (i2cReadReg_N(address, 3, buffer) > 2) {
temperature = buffer[0];
temperature = buffer[1] << 8;

View File

@ -24,7 +24,7 @@
#pragma once
#include <string>
#include <mraa/i2c.h>
#include <mraa/i2c.hpp>
#define DEVICE_ADDR 0x5A // device address
@ -83,11 +83,6 @@ class MLX90614 {
*/
MLX90614 (int bus=0, int devAddr=0x5A);
/**
* MLX90614 object destructor; basically, it closes the I2C connection.
*/
~MLX90614 ();
/**
* Reads the object temperature in Fahrenheit
*/
@ -119,10 +114,10 @@ class MLX90614 {
int m_i2cAddr;
int m_bus;
mraa_i2c_context m_i2Ctx;
mraa::I2c m_i2Ctx;
uint16_t i2cReadReg_N (int reg, unsigned int len, uint8_t * buffer);
mraa_result_t i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
mraa::Result i2cWriteReg_N (uint8_t reg, unsigned int len, uint8_t * buffer);
float readTemperature (uint8_t address);
};