Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed vcdLogger vcdSignal
Diff: main.cpp
- Revision:
- 0:9a59cffaafad
- Child:
- 1:446154224f92
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Fri Feb 12 21:38:04 2016 +0000
@@ -0,0 +1,131 @@
+/*!
+ @file main.cpp
+
+ The main vcdMaker demo file.
+
+ @par Full Description
+ The vcdMaker demo. See http://vcdmaker.org for details.
+
+ @if REVISION_HISTORY_INCLUDED
+ @par Edit History
+ @li [0] wojciech.rynczuk@wp.pl 20-JAN-2015 Initial file revision.
+ @endif
+
+ @ingroup vcdMakerDemo
+
+ @par Copyright (c) MMXV Wojciech Rynczuk
+
+ Permission is hereby granted, free of charge, to any person obtaining a
+ copy of this software and associated documentation files (the "Software"),
+ to deal in the Software without restriction, including without limitation
+ the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ and/or sell copies of the Software, and to permit persons to whom the
+ Software is furnished to do so, subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ IN THE SOFTWARE.
+
+*/
+
+
+#include <stdint.h>
+
+#include "mbed.h"
+#include "serialLogger.hpp"
+#include "button.hpp"
+#include "light.hpp"
+#include "slider.hpp"
+#include "magnetometer.hpp"
+#include "accelerometer.hpp"
+
+#define NO_OF_LINES ((uint32_t)75)
+#define NO_OF_CHARACTERS ((uint32_t)100)
+
+// Periodic timers
+Ticker timer1;
+Ticker timer2;
+
+// Button interrupts
+InterruptIn sw1_event(PTC3);
+InterruptIn sw3_event(PTC12);
+
+// Logger
+SerialLogger slogger(NO_OF_LINES,NO_OF_CHARACTERS);
+Logger* uniLogger;
+
+// Signals
+Button sw1("FRDM.Buttons.SW1",PTC3,slogger);
+Button sw3("FRDM.Buttons.SW3",PTC12,slogger);
+Light light("FRDM.Sensors.Light",PTE22,slogger);
+Slider slider("FRDM.Sensors.Slider", slogger);
+Magnetometer magnetometer("FRDM.Sensors.Magnetometer.", slogger);
+Accelerometer accelerometer("FRDM.Sensors.Accelerometer.", slogger);
+
+// Time reference
+uint32_t time_ref = 0;
+
+void log_slider_accelerometer()
+{
+ slider.PrintState();
+ accelerometer.PrintState();
+}
+
+void log_light_magnetometer()
+{
+ light.PrintState();
+ magnetometer.PrintState();
+}
+
+void sw1_irq()
+{
+ sw1.PrintState();
+ if (0 == sw1)
+ {
+ time_ref = uniLogger->GetTime();
+ }
+ else
+ {
+ if ((uniLogger->GetTime() - time_ref) > 3000000)
+ {
+ if (uniLogger->IsRecording())
+ {
+ uniLogger->StopRecording();
+ }
+ else
+ {
+ uniLogger->StartRecording();
+ }
+ }
+ }
+}
+
+void sw3_irq()
+{
+ sw3.PrintState();
+}
+
+
+int main()
+{
+ uniLogger = &slogger;
+
+ sw1_event.rise(&sw1_irq);
+ sw3_event.rise(&sw3_irq);
+ sw1_event.fall(&sw1_irq);
+ sw3_event.fall(&sw3_irq);
+ timer1.attach_us(&log_light_magnetometer, 50000);
+ timer2.attach_us(&log_slider_accelerometer, 40000);
+
+ while (true)
+ {
+ uniLogger->Print();
+ };
+}
\ No newline at end of file