Skip to content

Commit a3edeaf

Browse files
committed
[examples] Deduplicate external examples
1 parent 864f523 commit a3edeaf

File tree

6 files changed

+53
-42
lines changed

6 files changed

+53
-42
lines changed

examples/nucleo_f031k6/sk6812/main.cpp renamed to examples/driver/sk6812/main.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
using namespace Board;
1818

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

2323
int
2424
main()
2525
{
2626
Board::initialize();
27-
LedD13::setOutput();
27+
Leds::setOutput();
2828
leds.initialize<Board::SystemClock>();
2929

3030
constexpr uint8_t max = 62;
@@ -45,7 +45,7 @@ main()
4545
leds.write();
4646

4747
while(not tmr.execute()) ;
48-
LedD13::toggle();
48+
Leds::toggle();
4949
}
5050

5151
return 0;

examples/driver/sk6812/project.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<library>
2+
<!-- All boards must be able to produce SPI at exactly 3 MHz!!! -->
3+
<extends>modm:nucleo-f031k6</extends>
4+
<!-- <extends>modm:nucleo-f042k6</extends> -->
5+
<!-- <extends>modm:nucleo-f072rb</extends> -->
6+
<!-- <extends>modm:nucleo-f091rc</extends> -->
7+
<!-- <extends>modm:nucleo-f411re</extends> -->
8+
<!-- <extends>modm:nucleo-l476rg</extends> -->
9+
<modules>
10+
<module>modm:build:scons</module>
11+
<module>modm:driver:sk6812</module>
12+
<module>modm:ui:led</module>
13+
</modules>
14+
</library>

examples/nucleo_f042k6/lis3mdl/main.cpp renamed to examples/generic/lis3mdl/main.cpp

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -14,48 +14,35 @@
1414
using namespace Board;
1515
using namespace std::chrono_literals;
1616

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

2020
int
2121
main()
2222
{
2323
Board::initialize();
24-
LedD13::setOutput();
24+
Board::initializeI2c();
2525

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

28-
I2cMaster1::connect<I2cSda::Sda, I2cScl::Scl>();
29-
I2cMaster1::initialize<SystemClock, 400_kBd>();
30-
31-
// Create a sensor object with the adress of the sensor built onto the Pololu AltIMU-10 v5
32-
modm::Lis3mdl<I2cMaster1> sensor(0x1E);
33-
3428
// Turn on and configure the magnetometer
35-
bool success = RF_CALL_BLOCKING(sensor.configure(modm::lis3mdl::DataRate::Rate_5_Hz,
36-
modm::lis3mdl::Scale::Scale_8_gauss));
37-
38-
39-
if(!success)
29+
if(!RF_CALL_BLOCKING(sensor.configure(modm::lis3mdl::DataRate::Rate_5_Hz,
30+
modm::lis3mdl::Scale::Scale_8_gauss)))
4031
{
4132
MODM_LOG_INFO << "Sensor could not be configured!" << modm::endl;
4233
}
4334

4435
// Set the sensor to continous acquistion and turn on the temperature sensing
45-
success = RF_CALL_BLOCKING(sensor.setMode(modm::lis3mdl::OperationMode::Continous));
46-
if(!success)
36+
if(!RF_CALL_BLOCKING(sensor.setMode(modm::lis3mdl::OperationMode::Continous)))
4737
{
4838
MODM_LOG_INFO << "Sensor could not be started!" << modm::endl;
4939
}
5040

5141
modm::Vector3f magVector;
52-
5342
while (true)
5443
{
55-
//Read the sensor data and print it out
56-
success = RF_CALL_BLOCKING(sensor.readMagnetometer(magVector));
57-
58-
if(success)
44+
// Read the sensor data and print it out
45+
if(RF_CALL_BLOCKING(sensor.readMagnetometer(magVector)))
5946
{
6047
MODM_LOG_INFO << "Magnetic Vector:" << modm::endl;
6148
MODM_LOG_INFO << "X: "<< magVector.x << " gauss" << modm::endl;

examples/generic/lis3mdl/project.xml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<library>
2+
<extends>modm:nucleo-f031k6</extends>
3+
<!-- <extends>modm:nucleo-f042k6</extends> -->
4+
<!-- <extends>modm:nucleo-f072rb</extends> -->
5+
<!-- <extends>modm:nucleo-f091rc</extends> -->
6+
<!-- <extends>modm:nucleo-f103rb</extends> -->
7+
<!-- <extends>modm:nucleo-f303k8</extends> -->
8+
<!-- <extends>modm:nucleo-f303re</extends> -->
9+
<!-- <extends>modm:nucleo-f334r8</extends> -->
10+
<!-- <extends>modm:nucleo-f401re</extends> -->
11+
<!-- <extends>modm:nucleo-f411re</extends> -->
12+
<!-- <extends>modm:nucleo-f446re</extends> -->
13+
<!-- <extends>modm:nucleo-g071rb</extends> -->
14+
<!-- <extends>modm:nucleo-g431kb</extends> -->
15+
<!-- <extends>modm:nucleo-g431rb</extends> -->
16+
<!-- <extends>modm:nucleo-g474re</extends> -->
17+
<!-- <extends>modm:nucleo-l031k6</extends> -->
18+
<!-- <extends>modm:nucleo-l053r8</extends> -->
19+
<!-- <extends>modm:nucleo-l152re</extends> -->
20+
<!-- <extends>modm:nucleo-l432kc</extends> -->
21+
<!-- <extends>modm:nucleo-l452re</extends> -->
22+
<!-- <extends>modm:nucleo-l476rg</extends> -->
23+
<modules>
24+
<module>modm:build:scons</module>
25+
<module>modm:driver:lis3mdl</module>
26+
</modules>
27+
</library>

examples/nucleo_f031k6/sk6812/project.xml

Lines changed: 0 additions & 9 deletions
This file was deleted.

examples/nucleo_f042k6/lis3mdl/project.xml

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)