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.
Diff: main.cpp
- Revision:
- 0:f5694e6b4092
- Child:
- 1:eff878d1c631
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Tue Apr 28 15:52:47 2020 +0000
@@ -0,0 +1,59 @@
+/* mbed Microcontroller Library
+ * Copyright (c) 2019 ARM Limited
+ * SPDX-License-Identifier: Apache-2.0
+ */
+
+#include "mbed.h"
+#include "platform/mbed_thread.h"
+#include "LCD.h"
+
+#define dg drehgeber>>9
+
+InterruptIn dt(PA_9);
+InterruptIn clk(PA_10);
+PortIn drehgeber(PortA,0b11000000000);
+PortOut diag(PortC,0b11111111);
+int x=1,z=0,alt,neu,lsb[4]={3,0,2,1};
+
+
+void drehgeberISR(void)
+{
+ neu=lsb[dg];
+ diag=x;
+ if (alt==3 && neu==0) z=z+1;
+ if (alt==0 && neu==3) z=z-1;
+ x=(z<<2)+neu;
+ alt=neu;
+}
+
+void resetPos(void)
+{
+ x=1;
+ z=0;
+ //__disable_irq();
+ diag=0;
+}
+
+int main()
+{
+
+ InterruptIn sw(PA_8);
+ sw.fall(&resetPos);
+ sw.mode(PullUp);
+ dt.rise(&drehgeberISR);
+ dt.fall(&drehgeberISR);
+ clk.rise(&drehgeberISR);
+ clk.fall(&drehgeberISR);
+ //__disable_irq();
+ lcd mylcd;
+ mylcd.clear();
+ mylcd.cursorpos(0);
+ while (true) {
+
+
+ mylcd.cursorpos(0);
+ mylcd.printf("Position %d ",x);
+
+
+ }
+}