Skip to content

Commit

Permalink
[examples] Encoder output examle for STM32F4_Discovery
Browse files Browse the repository at this point in the history
  • Loading branch information
rleh committed Jun 14, 2020
1 parent 7755151 commit 21af57b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/stm32f4_discovery/encoder_output/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2020, Raphael Lehmann
*
* This file is part of the modm project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
// ----------------------------------------------------------------------------

#include <modm/board.hpp>
#include <modm/driver/encoder/encoder_output.hpp>

using namespace Board;

// ----------------------------------------------------------------------------
int
main()
{

initialize();

LedBlue::set();
LedGreen::set();

// period=100000 // 100000us => 10Hz (visible)
using TestEncoder = modm::EncoderOutput<LedBlue, LedGreen, int32_t, modm::PrecisePeriodicTimer, 100'000>;
TestEncoder testEncoder{0};

testEncoder.setPosition(1 << 31);
while (1)
{
testEncoder.update();
LedRed::toggle();
}

return 0;
}
10 changes: 10 additions & 0 deletions examples/stm32f4_discovery/encoder_output/project.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<library>
<extends>modm:disco-f407vg</extends>
<options>
<option name="modm:build:build.path">../../../build/stm32f4_discovery/encoder_output</option>
</options>
<modules>
<module>modm:driver:encoder.output</module>
<module>modm:build:scons</module>
</modules>
</library>

0 comments on commit 21af57b

Please sign in to comment.