forked from libhal-google/libhal-util
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
1,283 additions
and
118 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 was deleted.
Oops, something went wrong.
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,45 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <libhal/accelerometer.hpp> | ||
|
||
namespace hal { | ||
/** | ||
* @brief Inert implementation of acceleration sensing hardware | ||
* | ||
*/ | ||
class inert_accelerometer : public hal::accelerometer | ||
{ | ||
public: | ||
/** | ||
* @brief Create inert_accelerometer object | ||
* | ||
* @param p_values - what will be returned from the read function. | ||
*/ | ||
constexpr inert_accelerometer(read_t p_values) | ||
: m_values(p_values) | ||
{ | ||
} | ||
|
||
private: | ||
read_t driver_read() | ||
{ | ||
return m_values; | ||
} | ||
|
||
read_t m_values; | ||
}; | ||
} // namespace hal |
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,48 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <libhal/adc.hpp> | ||
|
||
#include <algorithm> | ||
|
||
namespace hal { | ||
/** | ||
* @brief Inert implementation of Analog to Digital Converter (ADC) hardware | ||
* | ||
*/ | ||
class inert_adc : public hal::adc | ||
{ | ||
public: | ||
/** | ||
* @brief Create inert_adc object | ||
* | ||
* @param p_result - What will be returned from inert_adc's read function, | ||
* clamped to -1.0f to 1.0f. | ||
*/ | ||
constexpr inert_adc(float p_result) | ||
: m_result(std::clamp(p_result, -1.0f, 1.0f)) | ||
{ | ||
} | ||
|
||
private: | ||
float driver_read() | ||
{ | ||
return m_result; | ||
} | ||
|
||
float m_result; | ||
}; | ||
} // namespace hal |
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 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <libhal/dac.hpp> | ||
|
||
namespace hal { | ||
/** | ||
* @brief Inert implementation of Digital to Analog Converter (DAC) hardware | ||
* | ||
*/ | ||
class inert_dac : public hal::dac | ||
{ | ||
public: | ||
/** | ||
* @brief Create inert_dac object | ||
*/ | ||
constexpr inert_dac() | ||
{ | ||
} | ||
|
||
private: | ||
void driver_write(float) | ||
{ | ||
} | ||
}; | ||
} // namespace hal |
45 changes: 45 additions & 0 deletions
45
include/libhal-util/inert_drivers/inert_distance_sensor.hpp
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,45 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <libhal/distance_sensor.hpp> | ||
|
||
namespace hal { | ||
/** | ||
* @brief Inert implementation of linear distance hardware | ||
* | ||
*/ | ||
class inert_distance_sensor : public hal::distance_sensor | ||
{ | ||
public: | ||
/** | ||
* @brief Create inert_distance_sensor object | ||
* | ||
* @param p_result - what will be returned from the read function. | ||
*/ | ||
constexpr inert_distance_sensor(hal::meters p_result) | ||
: m_result(p_result) | ||
{ | ||
} | ||
|
||
private: | ||
hal::meters driver_read() | ||
{ | ||
return m_result; | ||
} | ||
|
||
hal::meters m_result; | ||
}; | ||
} // namespace hal |
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,45 @@ | ||
// Copyright 2024 Khalil Estell | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#pragma once | ||
|
||
#include <libhal/gyroscope.hpp> | ||
|
||
namespace hal { | ||
/** | ||
* @brief Inert implementation of angular velocity sensing hardware | ||
* | ||
*/ | ||
class inert_gyroscope : public hal::gyroscope | ||
{ | ||
public: | ||
/** | ||
* @brief Create inert_gyroscope object | ||
* | ||
* @param p_result - what will be returned from the read function. | ||
*/ | ||
constexpr inert_gyroscope(read_t p_result) | ||
: m_result(p_result) | ||
{ | ||
} | ||
|
||
private: | ||
read_t driver_read() | ||
{ | ||
return m_result; | ||
} | ||
|
||
read_t m_result; | ||
}; | ||
} // namespace hal |
Oops, something went wrong.