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.
main.cpp
- Committer:
- jack1930
- Date:
- 2020-04-28
- Revision:
- 0:f5694e6b4092
- Child:
- 1:eff878d1c631
File content as of revision 0:f5694e6b4092:
/* 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);
}
}