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: HIDScope MODSERIAL mbed
Fork of Signal Filter by
Diff: main.cpp
- Revision:
- 1:f6110f80fa45
- Parent:
- 0:c8a6e00fbdc3
- Child:
- 2:e30dbfec6d1e
diff -r c8a6e00fbdc3 -r f6110f80fa45 main.cpp --- a/main.cpp Wed Sep 09 12:16:21 2015 +0000 +++ b/main.cpp Wed Sep 09 14:46:35 2015 +0000 @@ -1,29 +1,45 @@ #include "mbed.h" - - -DigitalOut gpo(D0); -DigitalOut led(LED_GREEN); +#include "MODSERIAL.h" +#include "HIDScope.h" + +DigitalOut r_led(LED_RED); +DigitalOut g_led(LED_GREEN); +DigitalOut b_led(LED_BLUE); + DigitalIn button(PTA4); +MODSERIAL pc(USBTX, USBRX); -const int led_on = 0; -const int led_off = 1; -const int button_pressed = 0; +const int baudrate = 115200; +//const int ms_wait = 100; +// Define the HIDScope and Ticker objects +HIDScope scope(2); +Ticker scopeTimer; +Ticker controllerTimer; + +const float period_led = 0.2; + // Two analog inputs to read from +AnalogIn a0(p2); +AnalogIn a1(p3); + +void controlAndMeasure() +{ + // Do some control + // ** control code here ** + + // Store values in the scope + scope.set(0,a0.read()); + scope.set(1,a1.read()); +} + int main() { - + // Attach the HIDScope::send method from the scope object to the timer at 50Hz + scopeTimer.attach_us(&scope, &HIDScope::send, 2e4); + + // Attach the controlAndMeasure method to the controller timer at 1kHz + controllerTimer.attach_us(&controlAndMeasure, 1e3); - while (true) { - if(button.read() == button_pressed) { - for (int n=0; n<5 ; n++) { - - led.write(led_on); - wait(0.5f); - - led.write(led_off); - - wait(0.5f); - } - } - } + while(1) { } + } \ No newline at end of file