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.
Revision 0:8f7f050af5a8, committed 2019-03-21
- Comitter:
- ThunderSoft
- Date:
- Thu Mar 21 10:01:07 2019 +0000
- Child:
- 1:0b1a84ce037f
- Commit message:
- Add PriSenor code for TT_Mxx
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PirSensor/PirSensor.cpp Thu Mar 21 10:01:07 2019 +0000
@@ -0,0 +1,28 @@
+#include "PirSensor.h"
+
+
+
+#if defined(__TT_M4G9__)
+#define DEFAULT_DOR_PIN PL0
+#endif
+
+
+#if defined(__TT_M3HQ__)
+#define DEFAULT_DOR_PIN PK7
+#endif
+
+
+PirSensor::PirSensor()
+{
+ interruptPin = new InterruptIn(DEFAULT_DOR_PIN);
+}
+
+PirSensor::PirSensor(PinName pin)
+{
+ interruptPin = new InterruptIn(pin);
+}
+
+void PirSensor::handleCallback(Callback<void()> func)
+{
+ interruptPin->fall(func);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/PirSensor/PirSensor.h Thu Mar 21 10:01:07 2019 +0000
@@ -0,0 +1,34 @@
+#ifndef PIRSENSOR_H
+#define PIRSENSOR_H
+
+#include "mbed.h"
+
+
+
+class PirSensor {
+
+
+public:
+ /**
+ * @brief
+ */
+ PirSensor(PinName pin);
+
+ PirSensor();
+
+ /**
+ * @brief Handle the event about door status.
+ * @param func handle of function.
+ */
+ void handleCallback(Callback<void()> func);
+private:
+ InterruptIn *interruptPin;
+
+};
+
+
+
+
+
+
+#endif
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Thu Mar 21 10:01:07 2019 +0000
@@ -0,0 +1,37 @@
+#include "mbed.h"
+#include "PirSensor.h"
+
+
+
+
+
+
+#if __TT_M3HQ__
+#define DISPLAY_TMPM_STRING "Welcome to Thundersoft TT_M3HQ"
+#endif
+
+
+#if __TT_M4G9__
+#define DISPLAY_TMPM_STRING "Welcome to Thundersoft TT_M4G9"
+#endif
+
+DigitalOut testLed(LED1);
+
+static void pirHandle()
+{
+ testLed = 1;
+ wait_ms(5000);
+ testLed = 0;
+}
+
+int main()
+{
+ printf("%s\r\n",DISPLAY_TMPM_STRING);
+ PirSensor pir;
+ testLed = 1;
+ pir.handleCallback(&pirHandle);
+ while(1)
+ {
+
+ }
+}
\ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Mar 21 10:01:07 2019 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#51d55508e8400b60af467005646c4e2164738d48