-
-
Notifications
You must be signed in to change notification settings - Fork 959
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'p8-acc-hfble' into p8b
- Loading branch information
Showing
16 changed files
with
689 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#include "AccelerationSensor.h" | ||
|
||
namespace Pinetime { | ||
namespace Drivers { | ||
|
||
AccelerationSensor::AccelerationSensor(TwiMaster& twiMaster, uint8_t twiAddress) : twiMaster(twiMaster), deviceAddress(twiAddress) { | ||
} | ||
|
||
void AccelerationSensor::SoftReset() { | ||
} | ||
|
||
void AccelerationSensor::Init() { | ||
} | ||
|
||
AccelerationValues AccelerationSensor::Process() { | ||
return {0}; | ||
} | ||
|
||
void AccelerationSensor::ResetStepCounter() { | ||
} | ||
|
||
void AccelerationSensor::Read(uint8_t registerAddress, uint8_t* buffer, size_t size) { | ||
twiMaster.Read(deviceAddress, registerAddress, buffer, size); | ||
} | ||
|
||
void AccelerationSensor::Write(uint8_t registerAddress, const uint8_t* data, size_t size) { | ||
twiMaster.Write(deviceAddress, registerAddress, data, size); | ||
} | ||
|
||
AccelerationDeviceTypes AccelerationSensor::DeviceType() const { | ||
return deviceType; | ||
} | ||
|
||
bool AccelerationSensor::IsInitialized() const { | ||
return isInitialized; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#pragma once | ||
|
||
#include "drivers/TwiMaster.h" | ||
|
||
namespace Pinetime { | ||
namespace Drivers { | ||
|
||
enum class AccelerationDeviceTypes : uint8_t { Unknown, BMA421, BMA425, SC7A20 }; | ||
|
||
struct AccelerationValues { | ||
uint32_t steps; | ||
int16_t x; | ||
int16_t y; | ||
int16_t z; | ||
int16_t* samples = nullptr; | ||
uint16_t samples_length = 0; | ||
}; | ||
|
||
class AccelerationSensor { | ||
public: | ||
AccelerationSensor(TwiMaster& twiMaster, uint8_t twiAddress); | ||
AccelerationSensor(const AccelerationSensor&) = delete; | ||
AccelerationSensor& operator=(const AccelerationSensor&) = delete; | ||
AccelerationSensor(AccelerationSensor&&) = delete; | ||
AccelerationSensor& operator=(AccelerationSensor&&) = delete; | ||
|
||
virtual void SoftReset(); | ||
virtual void Init(); | ||
virtual AccelerationValues Process(); | ||
virtual void ResetStepCounter(); | ||
|
||
void Read(uint8_t registerAddress, uint8_t* buffer, size_t size); | ||
void Write(uint8_t registerAddress, const uint8_t* data, size_t size); | ||
|
||
bool IsInitialized() const; | ||
AccelerationDeviceTypes DeviceType() const; | ||
|
||
protected: | ||
TwiMaster& twiMaster; | ||
uint8_t deviceAddress; | ||
bool isInitialized = false; | ||
AccelerationDeviceTypes deviceType = AccelerationDeviceTypes::Unknown; | ||
int16_t fifo[32][3] = {0}; | ||
}; | ||
|
||
} | ||
} |
Oops, something went wrong.