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.
Dependents: DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_PingPong DISCO-L072CZ-LRWAN1_LoRa_USB_Rx ... more
Fork of SX1276Lib by
Revision 72:2a6c776b5e92, committed 2017-07-23
- Comitter:
- Helmut Tschemernjak
- Date:
- Sun Jul 23 16:30:11 2017 +0200
- Parent:
- 71:7067e67902a8
- Child:
- 73:23cc8ba412e0
- Commit message:
- Added Timer Test App.
Changed in this revision
| Arduino-mbed-APIs/examples/TimerTest/TimerTest.ino | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Arduino-mbed-APIs/examples/TimerTest/TimerTest.ino Sun Jul 23 16:30:11 2017 +0200
@@ -0,0 +1,70 @@
+
+#include "arduino-mbed.h"
+
+void TestTimeoutFunc(void);
+void TestTimeoutFunc55(void);
+void TestTimeoutFunc10(void);
+void TestTimeoutFunc1m(void);
+void SwitchInput(void);
+
+#define SW0 3 // switch needs pullup
+
+DigitalOut led(LED_BUILTIN);
+InterruptIn intr(SW0);
+Timeout tp;
+Timeout tp2;
+Timeout tp3;
+Timeout tp4;
+
+void setup() {
+ Serial.begin(230400);
+
+ Serial.println("TimerTest");
+
+ tp.attach(callback(&TestTimeoutFunc), 1000);
+ tp2.attach(callback(&TestTimeoutFunc55), 5500);
+ tp3.attach(callback(&TestTimeoutFunc10), 10000);
+ // tp4.attach(callback(&TestTimeoutFunc1m), 1);
+
+ intr.mode(PullUp);
+ intr.fall(callback(&SwitchInput));
+}
+
+void loop() {
+ led = !led;
+
+ sleep(); // or deepsleep()
+}
+
+
+
+void TestTimeoutFunc(void) {
+ tp.attach(callback(&TestTimeoutFunc), 1000);
+ led = !led;
+ Serial.print(ms_getTicker(), DEC);
+ Serial.println(" TestTimeoutFunc 1 sec");
+}
+
+void TestTimeoutFunc55(void) {
+ tp2.attach(callback(&TestTimeoutFunc55), 5500);
+ Serial.print(ms_getTicker(), DEC);
+ Serial.println(" TestTimeoutFunc 5.5 sec");
+}
+
+
+void TestTimeoutFunc10(void) {
+ tp3.attach(callback(&TestTimeoutFunc10), 10000);
+ Serial.print(ms_getTicker(), DEC);
+ Serial.println(" TestTimeoutFunc 10 sec");
+}
+
+
+void TestTimeoutFunc1m(void) {
+ tp4.attach(callback(&TestTimeoutFunc1m), 1);
+}
+
+void SwitchInput(void) {
+ Serial.print(ms_getTicker(), DEC);
+ Serial.println(" SwitchInput");
+ led = !led;
+}

