-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #143 from rtlopez/board-align
Board alignment
- Loading branch information
Showing
15 changed files
with
234 additions
and
86 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
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,70 @@ | ||
#include "BaseSensor.h" | ||
#include "ModelConfig.h" | ||
#include "Utils/MemoryHelper.h" | ||
|
||
namespace Espfc { | ||
|
||
namespace Sensor { | ||
|
||
void FAST_CODE_ATTR BaseSensor::align(VectorFloat& dest, uint8_t rotation) | ||
{ | ||
const float x = dest.x; | ||
const float y = dest.y; | ||
const float z = dest.z; | ||
|
||
switch(rotation) | ||
{ | ||
default: | ||
case ALIGN_CW0_DEG: | ||
dest.x = x; | ||
dest.y = y; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW90_DEG: | ||
dest.x = y; | ||
dest.y = -x; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW180_DEG: | ||
dest.x = -x; | ||
dest.y = -y; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW270_DEG: | ||
dest.x = -y; | ||
dest.y = x; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW0_DEG_FLIP: | ||
dest.x = -x; | ||
dest.y = y; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW90_DEG_FLIP: | ||
dest.x = y; | ||
dest.y = x; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW180_DEG_FLIP: | ||
dest.x = x; | ||
dest.y = -y; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW270_DEG_FLIP: | ||
dest.x = -y; | ||
dest.y = -x; | ||
dest.z = -z; | ||
break; | ||
} | ||
} | ||
|
||
void FAST_CODE_ATTR BaseSensor::toVector(VectorInt16& v, uint8_t * buf) | ||
{ | ||
v.x = (int16_t)(((uint16_t)buf[0] << 8) | (uint16_t)buf[1]); | ||
v.y = (int16_t)(((uint16_t)buf[2] << 8) | (uint16_t)buf[3]); | ||
v.z = (int16_t)(((uint16_t)buf[4] << 8) | (uint16_t)buf[5]); | ||
} | ||
|
||
} | ||
|
||
} |
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 |
---|---|---|
@@ -1,79 +1,19 @@ | ||
#ifndef _ESPFC_SENSOR_BASE_SENSOR_H_ | ||
#define _ESPFC_SENSOR_BASE_SENSOR_H_ | ||
#pragma once | ||
|
||
#include <cmath> | ||
#include "Model.h" | ||
#include "Hardware.h" | ||
#include <helper_3dmath.h> | ||
#include <cstdint> | ||
|
||
namespace Espfc { | ||
|
||
namespace Sensor { | ||
|
||
class BaseSensor | ||
{ | ||
public: | ||
void FAST_CODE_ATTR align(VectorInt16& dest, uint8_t rotation) | ||
{ | ||
const int16_t x = dest.x; | ||
const int16_t y = dest.y; | ||
const int16_t z = dest.z; | ||
|
||
switch(rotation) | ||
{ | ||
default: | ||
case ALIGN_CW0_DEG: | ||
dest.x = x; | ||
dest.y = y; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW90_DEG: | ||
dest.x = y; | ||
dest.y = -x; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW180_DEG: | ||
dest.x = -x; | ||
dest.y = -y; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW270_DEG: | ||
dest.x = -y; | ||
dest.y = x; | ||
dest.z = z; | ||
break; | ||
case ALIGN_CW0_DEG_FLIP: | ||
dest.x = -x; | ||
dest.y = y; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW90_DEG_FLIP: | ||
dest.x = y; | ||
dest.y = x; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW180_DEG_FLIP: | ||
dest.x = x; | ||
dest.y = -y; | ||
dest.z = -z; | ||
break; | ||
case ALIGN_CW270_DEG_FLIP: | ||
dest.x = -y; | ||
dest.y = -x; | ||
dest.z = -z; | ||
break; | ||
} | ||
} | ||
|
||
void toVector(VectorInt16& v, uint8_t * buf) | ||
{ | ||
v.x = (int16_t)(((uint16_t)buf[0] << 8) | (uint16_t)buf[1]); | ||
v.y = (int16_t)(((uint16_t)buf[2] << 8) | (uint16_t)buf[3]); | ||
v.z = (int16_t)(((uint16_t)buf[4] << 8) | (uint16_t)buf[5]); | ||
} | ||
public: | ||
void align(VectorFloat& dest, uint8_t rotation); | ||
void toVector(VectorInt16& v, uint8_t * buf); | ||
}; | ||
|
||
} | ||
|
||
} | ||
|
||
#endif |
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
Oops, something went wrong.