Skip to content

Commit

Permalink
[examples] Add STM32F4 disco board example with encoder output
Browse files Browse the repository at this point in the history
  • Loading branch information
rleh committed Jan 27, 2019
1 parent 3033e30 commit 2585e8d
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
42 changes: 42 additions & 0 deletions examples/stm32f4_discovery/encoder_output/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2011, Georgi Grinshpun
* Copyright (c) 2011-2012, Fabian Greif
* Copyright (c) 2012, 2014, Sascha Schade
* Copyright (c) 2013, Kevin Läufer
* Copyright (c) 2013, 2015-2017, Niklas Hauser
*
* 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();

using TestEncoder = modm::EncoderOutput<LedBlue, LedGreen, int32_t, modm::LongPrecisionPeriodicTimer, 500'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:board: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 2585e8d

Please sign in to comment.