Version FC
Dependencies: DmTftLibrary eeprom SX1280Lib filesystem mbed
Fork of MSNV2-Terminal_V1-5 by
Diff: COMPONENTS/lsm303d_component.hpp
- Revision:
- 32:3bef9b81f639
- Parent:
- 31:2b8b98f3feed
diff -r 2b8b98f3feed -r 3bef9b81f639 COMPONENTS/lsm303d_component.hpp --- a/COMPONENTS/lsm303d_component.hpp Wed Oct 03 17:22:58 2018 +0000 +++ b/COMPONENTS/lsm303d_component.hpp Thu Oct 04 07:24:28 2018 +0000 @@ -97,7 +97,7 @@ (*srvIt)->readValue(); } } - + private: void setScale(float x, float y, float z){ scale[0] = x; @@ -130,32 +130,25 @@ OUTPUT_MODE output_mode, string comment, LSM303DLHC_component* parent - ) + ) : + Service(type, misnet_code, state, access_type, request_mode, + up_mode, access_pins, subsample_rate, action, output_mode, comment) { this->parent = parent; - this->setDeviceType(type); - this->setMisnetCode(misnet_code); - this->setState(state); - this->setAccessType(access_type); - this->setRequestMode(request_mode); - this->setUpMode(up_mode); - this->setAction(action); - this->setOutputMode(output_mode); - this->setComment(comment); - this->setSubsampleRate(subsample_rate); } virtual ~LSM303DLHC_accelerometer() {} - int* readValue(void) { + bool readValue(void) { int a[3]; parent->_data[0] = OUT_X_L_A | (1<<7); parent->_device.write(ACC_ADDRESS, _data, 1); parent->_device.read(ACC_ADDRESS, _data, 6); - // 12-bit values a[0] = (short)(parent->_data[1]<<8 | parent->_data[0]) >> 4; a[1] = (short)(parent->_data[3]<<8 | parent->_data[2]) >> 4; a[2] = (short)(parent->_data[5]<<8 | parent->_data[4]) >> 4; - return a; + //this->getValueAddress().set) // triple int value + this->savePreviousValue(); + return false; } private: @@ -178,31 +171,24 @@ OUTPUT_MODE output_mode, string comment, LSM303DLHC_component* parent - ) + ) : + Service(type, misnet_code, state, access_type, request_mode, + up_mode, access_pins, subsample_rate, action, output_mode, comment) { this->parent = parent; - this->setDeviceType(type); - this->setMisnetCode(misnet_code); - this->setState(state); - this->setAccessType(access_type); - this->setRequestMode(request_mode); - this->setUpMode(up_mode); - this->setAction(action); - this->setOutputMode(output_mode); - this->setComment(comment); - this->setSubsampleRate(subsample_rate); } virtual ~LSM303DLHC_megnetometer() {} - int* readValue(void) { + bool readValue(void) { int a[3]; parent->_data[0] = OUT_X_H_M; parent->_device.write(MAG_ADDRESS, parent->_data, 1); parent->_device.read(MAG_ADDRESS, parent->_data, 6); - a[0] = (short) (parent->_data[0]<<8 | parent->_data[1]); // X a[1] = (short) (parent->_data[4]<<8 | parent->_data[5]); // Y a[2] = (short) (parent->_data[2]<<8 | parent->_data[3]); // Z - return a; + //this->getValueAddress().set) // triple int value + this->savePreviousValue(); + return false; } private: @@ -211,4 +197,3 @@ }; #endif /* COMPONENTS_LSM303D_COMPONENT_HPP_ */ -