Skip to content

Commit

Permalink
[examples] Deduplicate sensor examples
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Jan 12, 2024
1 parent e81de4f commit 79e7e22
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 50 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ jobs:
- name: Examples STM32F0 Series
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f031k6 nucleo_f072rb nucleo_f042k6 stm32f030f4p6_demo_board)
(cd examples && ../tools/scripts/examples_compile.py stm32f0_discovery stm32f072_discovery nucleo_f072rb nucleo_f042k6 stm32f030f4p6_demo_board)
- name: Examples STM32F1 Series
if: always()
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ jobs:
if: always()
run: |
(cd examples && ../tools/scripts/examples_compile.py nucleo_f031k6 nucleo_f103rb nucleo_f303re nucleo_f411re)
(cd examples && ../tools/scripts/examples_compile.py nucleo_g071rb nucleo_l031k6 nucleo_l152re nucleo_l476rg nucleo_g474re)
(cd examples && ../tools/scripts/examples_compile.py nucleo_g071rb nucleo_l152re nucleo_l476rg nucleo_g474re)
- name: Compile AVR Examples
if: always()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,35 @@
using namespace Board;
using namespace std::chrono_literals;

using I2cSda = GpioA10;
using I2cScl = GpioA9;
// Create a sensor object with the address of the sensor built onto the Pololu AltIMU-10 v5
modm::Lis3mdl<Board::i2c::Controller> sensor(0x1E);

int
main()
{
Board::initialize();
LedD13::setOutput();
Board::initializeI2c();

MODM_LOG_INFO << "LIS3MDL demo" << modm::endl;

I2cMaster1::connect<I2cSda::Sda, I2cScl::Scl>();
I2cMaster1::initialize<SystemClock, 400_kBd>();

// Create a sensor object with the adress of the sensor built onto the Pololu AltIMU-10 v5
modm::Lis3mdl<I2cMaster1> sensor(0x1E);

// Turn on and configure the magnetometer
bool success = RF_CALL_BLOCKING(sensor.configure(modm::lis3mdl::DataRate::Rate_5_Hz,
modm::lis3mdl::Scale::Scale_8_gauss));


if(!success)
if(!RF_CALL_BLOCKING(sensor.configure(modm::lis3mdl::DataRate::Rate_5_Hz,
modm::lis3mdl::Scale::Scale_8_gauss)))
{
MODM_LOG_INFO << "Sensor could not be configured!" << modm::endl;
}

// Set the sensor to continous acquistion and turn on the temperature sensing
success = RF_CALL_BLOCKING(sensor.setMode(modm::lis3mdl::OperationMode::Continous));
if(!success)
if(!RF_CALL_BLOCKING(sensor.setMode(modm::lis3mdl::OperationMode::Continous)))
{
MODM_LOG_INFO << "Sensor could not be started!" << modm::endl;
}

modm::Vector3f magVector;

while (true)
{
//Read the sensor data and print it out
success = RF_CALL_BLOCKING(sensor.readMagnetometer(magVector));

if(success)
// Read the sensor data and print it out
if(RF_CALL_BLOCKING(sensor.readMagnetometer(magVector)))
{
MODM_LOG_INFO << "Magnetic Vector:" << modm::endl;
MODM_LOG_INFO << "X: "<< magVector.x << " gauss" << modm::endl;
Expand Down
30 changes: 30 additions & 0 deletions examples/generic/lis3mdl/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<library>
<extends>modm:nucleo-f031k6</extends>
<!-- <extends>modm:nucleo-f042k6</extends> -->
<!-- <extends>modm:nucleo-f072rb</extends> -->
<!-- <extends>modm:nucleo-f091rc</extends> -->
<!-- <extends>modm:nucleo-f103rb</extends> -->
<!-- <extends>modm:nucleo-f303k8</extends> -->
<!-- <extends>modm:nucleo-f303re</extends> -->
<!-- <extends>modm:nucleo-f334r8</extends> -->
<!-- <extends>modm:nucleo-f401re</extends> -->
<!-- <extends>modm:nucleo-f411re</extends> -->
<!-- <extends>modm:nucleo-f446re</extends> -->
<!-- <extends>modm:nucleo-g071rb</extends> -->
<!-- <extends>modm:nucleo-g431kb</extends> -->
<!-- <extends>modm:nucleo-g431rb</extends> -->
<!-- <extends>modm:nucleo-g474re</extends> -->
<!-- <extends>modm:nucleo-l031k6</extends> -->
<!-- <extends>modm:nucleo-l053r8</extends> -->
<!-- <extends>modm:nucleo-l152re</extends> -->
<!-- <extends>modm:nucleo-l432kc</extends> -->
<!-- <extends>modm:nucleo-l452re</extends> -->
<!-- <extends>modm:nucleo-l476rg</extends> -->
<options>
<option name="modm:build:build.path">../../../build/generic/lis3mdl</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:driver:lis3mdl</module>
</modules>
</library>
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

using namespace Board;

using Output = Board::D11;
modm::Sk6812w<SpiMaster1, Output, 8*8> leds;
using Output = Board::spi::Sdo;
modm::Sk6812w<Board::spi::Controller, Output, 8*8> leds;
modm::ShortPeriodicTimer tmr{33ms};

int
main()
{
Board::initialize();
LedD13::setOutput();
Leds::setOutput();
leds.initialize<Board::SystemClock>();

constexpr uint8_t max = 62;
Expand All @@ -45,7 +45,7 @@ main()
leds.write();

while(not tmr.execute()) ;
LedD13::toggle();
Leds::toggle();
}

return 0;
Expand Down
17 changes: 17 additions & 0 deletions examples/generic/sk6812/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<library>
<!-- All boards must be able to produce SPI at exactly 3 MHz!!! -->
<extends>modm:nucleo-f031k6</extends>
<!-- <extends>modm:nucleo-f042k6</extends> -->
<!-- <extends>modm:nucleo-f072rb</extends> -->
<!-- <extends>modm:nucleo-f091rc</extends> -->
<!-- <extends>modm:nucleo-f411re</extends> -->
<!-- <extends>modm:nucleo-l476rg</extends> -->
<options>
<option name="modm:build:build.path">../../../build/generic/sk6812</option>
</options>
<modules>
<module>modm:build:scons</module>
<module>modm:driver:sk6812</module>
<module>modm:ui:led</module>
</modules>
</library>
12 changes: 0 additions & 12 deletions examples/nucleo_f031k6/sk6812/project.xml

This file was deleted.

11 changes: 0 additions & 11 deletions examples/nucleo_f042k6/lis3mdl/project.xml

This file was deleted.

0 comments on commit 79e7e22

Please sign in to comment.