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 1:eff878d1c631, committed 2022-03-09
- Comitter:
- jack1930
- Date:
- Wed Mar 09 10:36:43 2022 +0000
- Parent:
- 0:f5694e6b4092
- Commit message:
- v1
Changed in this revision
| LCD_i2c_GSOE.lib | Show annotated file Show diff for this revision Revisions of this file |
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LCD_i2c_GSOE.lib Tue Apr 28 15:52:47 2020 +0000 +++ b/LCD_i2c_GSOE.lib Wed Mar 09 10:36:43 2022 +0000 @@ -1,1 +1,1 @@ -https://os.mbed.com/users/jack1930/code/LCD_i2c_GSOE/#013cfc9dedd3 +https://os.mbed.com/users/jack1930/code/LCD_i2c_GSOE/#e02aaac1b3cf
--- a/main.cpp Tue Apr 28 15:52:47 2020 +0000
+++ b/main.cpp Wed Mar 09 10:36:43 2022 +0000
@@ -7,47 +7,82 @@
#include "platform/mbed_thread.h"
#include "LCD.h"
-#define dg drehgeber>>9
+lcd mylcd;
+
+int Zustand=0;
+int x=0;
+
+InterruptIn A(PB_1); //DT
+InterruptIn B(PB_0); //CLJ
+PortIn drehgeber(PortB,0b11);
+
+void Arise()
+{
+ switch(Zustand)
+ {
+ case 0: Zustand=1;
+ x++;
+ break;
+ case 3: Zustand=2;
+ x--;
+ break;
+ }
+}
-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 Afall()
+{
+ switch(Zustand)
+ {
+ case 1: Zustand=0;
+ x--;
+ break;
+ case 2: Zustand=3;
+ x++;
+ break;
+ }
+}
+
+void Brise()
+{
+ switch(Zustand)
+ {
+ case 1: Zustand=2;
+ x++;
+ break;
+ case 0: Zustand=3;
+ x--;
+ break;
+ }
+}
+
+void Bfall()
+{
+ switch(Zustand)
+ {
+ case 2: Zustand=1;
+ x--;
+ break;
+ case 3: Zustand=0;
+ x++;
+ break;
+ }
+}
-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()
{
+ A.rise(&Arise);
+ A.fall(&Afall);
+ A.enable_irq();
+ B.rise(&Brise);
+ B.fall(&Bfall);
+ B.enable_irq();
+ Zustand=drehgeber;
- 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) {