Skip to content
This repository was archived by the owner on May 11, 2025. It is now read-only.

Commit fb53b4e

Browse files
authored
💚 fixes ci and repo structure (#5)
1 parent e2a7a87 commit fb53b4e

21 files changed

Lines changed: 711 additions & 5917 deletions

.github/workflows/ci.yml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ name: ✅ CI
1717
on:
1818
workflow_dispatch:
1919
pull_request:
20+
release:
21+
types:
22+
- published
23+
- deleted
2024
push:
2125
branches:
2226
- main
@@ -25,26 +29,24 @@ on:
2529

2630
jobs:
2731
ci:
28-
uses: libhal/ci/.github/workflows/library.yml@3.0.3
29-
with:
30-
coverage: true
32+
uses: libhal/ci/.github/workflows/library.yml@4.x.y
3133
secrets: inherit
3234
deploy:
33-
uses: libhal/ci/.github/workflows/deploy.yml@3.0.3
35+
uses: libhal/ci/.github/workflows/deploy.yml@4.x.y
3436
secrets: inherit
3537
build_lpc4074:
36-
uses: libhal/ci/.github/workflows/demo_builder.yml@3.0.3
38+
uses: libhal/ci/.github/workflows/demo_builder.yml@4.x.y
3739
with:
3840
profile: lpc4074
3941
processor_profile: https://github.com/libhal/libhal-armcortex.git
4042
platform_profile: https://github.com/libhal/libhal-lpc40.git
4143
secrets: inherit
4244
build_lpc4078:
43-
uses: libhal/ci/.github/workflows/demo_builder.yml@3.0.3
45+
uses: libhal/ci/.github/workflows/demo_builder.yml@4.x.y
4446
with:
4547
profile: lpc4078
4648
processor_profile: https://github.com/libhal/libhal-armcortex.git
4749
platform_profile: https://github.com/libhal/libhal-lpc40.git
4850
secrets: inherit
4951

50-
# Add more build_<platform> blocks below for each platform you support
52+
# Add more build_<platform> blocks below for each platform you support

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,4 @@ archives/
4141
# Artifacts
4242
build/
4343
CMakeUserPresets.json
44+
*.DS_Store

README.md

Lines changed: 77 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
[![GitHub stars](https://img.shields.io/github/stars/libhal/libhal-icm.svg)](https://github.com/libhal/libhal-icm/stargazers)
77
[![GitHub forks](https://img.shields.io/github/forks/libhal/libhal-icm.svg)](https://github.com/libhal/libhal-icm/network)
88
[![GitHub issues](https://img.shields.io/github/issues/libhal/libhal-icm.svg)](https://github.com/libhal/libhal-icm/issues)
9-
[![Latest Version](https://libhal.github.io/libhal-icm/latest_version.svg)](https://github.com/libhal/libhal-icm/blob/main/conanfile.py)
10-
[![ConanCenter Version](https://repology.org/badge/version-for-repo/conancenter/libhal-icm.svg)](https://conan.io/center/libhal-icm)
119

1210
libhal compatible device library for the icm device.
1311

@@ -24,3 +22,80 @@ Apache 2.0; see [`LICENSE`](LICENSE) for details.
2422
This project is not an official Google project. It is not supported by
2523
Google and Google specifically disclaims all warranties as to its quality,
2624
merchantability, or fitness for a particular purpose.
25+
26+
## About the libhal-device template
27+
28+
The libhal-__device__ repository is a template for creating device libraries in
29+
the libhal ecosystem. It provides a structured layout and a set of files to help
30+
you get started with creating your own device library.
31+
32+
## .github/workflows
33+
34+
This directory contains GitHub Actions workflow files for continuous integration
35+
(CI) and other automated tasks. The workflows currently included are:
36+
37+
- `ci.yml`: This workflow runs the CI pipeline, which includes
38+
building the project, running tests, and deploying the library to the
39+
`libhal-trunk` package repository.
40+
- `take.yml`: This workflow is responsible for the "take" action, which assigns
41+
commits to
42+
- `update_name.yml`: This workflow updates the name of the repository when it's
43+
used as a template for a new repository.
44+
45+
## conanfile.py
46+
47+
This is a [Conan](https://conan.io/) recipe file. Conan is a package manager for
48+
C and C++ that helps manage dependencies in your project. This file defines how
49+
Conan should build your project and its dependencies.
50+
51+
## datasheets
52+
53+
This directory is intended for storing datasheets related to the device that the
54+
library is being built for. It currently contains a placeholder file,
55+
`put_datasheets_here.md`.
56+
57+
Many datasheets are subject to copyright and that must be considered when adding
58+
the datasheet to a libhal repo. If the datasheet cannot be redistributed on the
59+
repo for copyright and/or license reasons, then a markdown file with a link to
60+
the datasheet (and potentially mirrors of it) is an acceptable alternative.
61+
62+
## demos
63+
64+
This directory contains demonstration applications showing how to use the device
65+
library. It includes:
66+
67+
- `applications/icm20948.cpp`: A sample application demonstrating usage of the
68+
device library.
69+
- `hardware_map.hpp`: A header file defining the hardware map for the demo
70+
applications.
71+
- `main.cpp`: The main entry point for the demo applications.
72+
- `platforms/lpc4074.cpp` and `platforms/lpc4078.cpp`: Platform-specific
73+
implementations for the demo applications.
74+
75+
## include/libhal-mpl
76+
77+
This directory contains the header files for the device library. It currently
78+
includes `icm.hpp`, which is a placeholder for the main header file of
79+
your device library.
80+
81+
## src
82+
83+
This directory contains the source files for the device library. It currently
84+
includes `icm.cpp`, which is a placeholder for the main source file of
85+
your device library.
86+
87+
## test_package
88+
89+
This directory contains a test package for the Conan recipe. It includes a
90+
simple application that uses the device library, which helps verify that the
91+
Conan recipe is working correctly.
92+
93+
## tests
94+
95+
This directory contains tests for the device library. It includes:
96+
97+
- `icm.test.cpp`: A placeholder for tests for the device library.
98+
- `main.test.cpp`: The main entry point for the tests.
99+
100+
Remember to replace all instances of `icm` with the actual name of the
101+
device that your library is being built for.

conanfile.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import os
2121

2222

23-
required_conan_version = ">=1.50.0"
23+
required_conan_version = ">=2.0.6"
2424

2525

2626
class libhal_icm_conan(ConanFile):
@@ -29,7 +29,7 @@ class libhal_icm_conan(ConanFile):
2929
license = "Apache-2.0"
3030
url = "https://github.com/conan-io/conan-center-index"
3131
homepage = "https://github.com/libhal/libhal-icm"
32-
description = ("A collection of drivers for the icm")
32+
description = ("A collection of drivers for the icm series IMU devices")
3333
topics = ("icm", "libhal", "driver")
3434
settings = "compiler", "build_type", "os", "arch"
3535
exports_sources = ("include/*", "tests/*", "LICENSE", "CMakeLists.txt",
@@ -58,7 +58,7 @@ def validate(self):
5858

5959
def build_requirements(self):
6060
self.tool_requires("cmake/3.27.1")
61-
self.tool_requires("libhal-cmake-util/1.0.0")
61+
self.tool_requires("libhal-cmake-util/3.0.0")
6262
self.test_requires("libhal-mock/[^2.0.0]")
6363
self.test_requires("boost-ext-ut/1.1.9")
6464

1.09 MB
Binary file not shown.

datasheets/put_datasheets_here.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

demos/applications/icm20948.cpp

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,26 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "../hardware_map.hpp"
15+
#include <cmath>
16+
1617
#include <libhal-icm/icm20948.hpp>
1718
#include <libhal-util/serial.hpp>
1819
#include <libhal-util/steady_clock.hpp>
1920

21+
#include "../hardware_map.hpp"
22+
23+
float compute_heading(float x, float y, float offset = 0.0)
24+
{
25+
float angle = 360 - (atan2(y, x) * (180.0 / std::numbers::pi));
26+
angle += offset; // Apply offset
27+
if (angle < 0) {
28+
angle += 360;
29+
} else if (angle >= 360) {
30+
angle -= 360;
31+
}
32+
return angle;
33+
}
34+
2035
hal::status application(hardware_map& p_map)
2136
{
2237
using namespace std::chrono_literals;
@@ -27,32 +42,33 @@ hal::status application(hardware_map& p_map)
2742
auto& i2c = *p_map.i2c;
2843

2944
hal::print(console, "icm Application Starting...\n\n");
30-
(void)hal::delay(clock, 200ms);
31-
auto icm_device = HAL_CHECK(hal::icm::icm20948::create(i2c, 0x69));
32-
(void)hal::delay(clock, 200ms);
33-
icm_device.auto_offsets();
34-
(void)hal::delay(clock, 100ms);
45+
hal::delay(clock, 200ms);
46+
auto icm_device = HAL_CHECK(hal::icm::icm20948::create(i2c));
3547

48+
hal::delay(clock, 200ms);
49+
icm_device.init_mag();
50+
hal::delay(clock, 100ms);
51+
52+
icm_device.auto_offsets();
3653

3754
while (true) {
38-
hal::print(console, "\n\n================Reading IMU================\n");
3955

40-
(void)hal::delay(clock, 500ms);
4156
auto accel = HAL_CHECK(icm_device.read_acceleration());
42-
(void)hal::delay(clock, 10ms);
57+
hal::delay(clock, 10ms);
4358
auto gyro = HAL_CHECK(icm_device.read_gyroscope());
44-
(void)hal::delay(clock, 10ms);
59+
hal::delay(clock, 10ms);
4560
auto temp = HAL_CHECK(icm_device.read_temperature());
46-
(void)hal::delay(clock, 10ms);
47-
61+
hal::delay(clock, 10ms);
62+
auto mag = HAL_CHECK(icm_device.read_magnetometer());
63+
hal::delay(clock, 10ms);
64+
hal::print(console, "\n\n================Reading IMU================\n");
4865

4966
hal::print<128>(console,
5067
"\n\nG-Accel Values: x = %fg, y = %fg, z = %fg",
5168
accel.x,
5269
accel.y,
5370
accel.z);
5471

55-
5672
hal::print<128>(console,
5773
"\n\nGyro Values: x = %f, y = %f, z = %f",
5874
gyro.x,
@@ -61,6 +77,15 @@ hal::status application(hardware_map& p_map)
6177

6278
hal::print<128>(console, "\n\nCurrent Temperature: %f°C", temp.temp);
6379

80+
hal::print<128>(console,
81+
"\n\nMagnetometer Values: x = %f, y = %f, z = %f",
82+
mag.x,
83+
mag.y,
84+
mag.z);
85+
86+
float heading = compute_heading(mag.x, mag.y, 0.0);
87+
hal::print<128>(console, "\n\nHeading: %f°", heading);
88+
6489
hal::print(console, "\n\n===========================================\n");
6590
}
6691
return hal::success();

demos/conanfile.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class demos(ConanFile):
2424

2525
def build_requirements(self):
2626
self.tool_requires("cmake/3.27.1")
27-
self.tool_requires("libhal-cmake-util/1.0.0")
27+
self.tool_requires("libhal-cmake-util/3.0.0")
2828

2929
def requirements(self):
3030
if str(self.options.platform).startswith("lpc40"):

0 commit comments

Comments
 (0)