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:
- 1:73315e249185
- Parent:
- 0:763fd05f2a27
- Child:
- 2:ce1e2d72919d
diff -r 763fd05f2a27 -r 73315e249185 main.cpp
--- a/main.cpp Wed Jun 30 12:54:13 2021 +0000
+++ b/main.cpp Thu Jul 01 10:11:10 2021 +0000
@@ -13,7 +13,7 @@
#define BLINKING_RATE_MS 500
#define Init 0
-#define Zu 1
+#define Geschlossen 1
#define Oeffnen 2
#define Offen 3
#define Schliessen 4
@@ -29,8 +29,8 @@
AnalogIn Poti(PA_0);
DigitalOut Leuchte(PC_0);
-int Zustand=Init;
-
+int zustand=Init;
+float tastgrad;
string meldung[]={"Tor-auf","Tor-zu","Tor-stop","Tor-faehrt"};
void blinkenEin()
@@ -64,19 +64,19 @@
__enable_irq();
}
-void ADC_PWMCW()
+void torAufCW()
{
CCW=0;
CW=Poti;
}
-void ADC_PWMCCW()
+void torZuCCW()
{
CW=0;
CCW=Poti;
}
-void LCDout(int nr)
+void lcdOut(int nr)
{
mylcd.clear();
mylcd.cursorpos(0);
@@ -100,13 +100,12 @@
TIM6->ARR=249; //250ms
}
-void ISR_EXT_IR()
+void schnellstop()
{
- if (Zustand==Schliessen || Zustand==Oeffnen)
+ if (zustand==Schliessen || zustand==Oeffnen)
{
- Zustand=Gestoppt;
- motorstop();
- LCDout(2);
+ zustand=Gestoppt;
+ lcdOut(2);
doppelteFrequenz();
}
}
@@ -118,75 +117,76 @@
Stop.mode(PullDown);
EndschalterOffen.mode(PullDown);
EndschalterZu.mode(PullDown);
- Stop.fall(&ISR_EXT_IR);
+ Stop.fall(&schnellstop);
Stop.enable_irq();
CW.period_us(100);
CCW.period_us(100);
- CW=0;
- CCW=0;
Timer_init();
- Zustand=Zu;
+
}
int main()
{
-
init();
+ zustand=Geschlossen;
+ motorstop();
+ lcdOut(1);
while (true) {
- switch(Zustand)
+ switch(zustand)
{
- case Zu: if (TorAuf==1)
- {
-
- Zustand=Oeffnen;
+ case Geschlossen: if (TorAuf==1)
+ {
+ zustand=Oeffnen;
blinkenEin();
- LCDout(3);
+ lcdOut(3);
}
break;
case Oeffnen:
- ADC_PWMCCW();
+ torAufCW();
if (EndschalterOffen==1)
{
blinkenAus();
- Zustand=Offen;
+ zustand=Offen;
motorstop();
- LCDout(0);
+ lcdOut(0);
}
break;
case Offen: if (TorZu==1)
{
- Zustand=Schliessen;
+ zustand=Schliessen;
blinkenEin();
- LCDout(3);
+ lcdOut(3);
}
break;
case Schliessen:
- ADC_PWMCW();
+ torZuCCW();
if (EndschalterZu==1)
{
- Zustand=Zu;
- LCDout(1);
+ zustand=Geschlossen;
+ lcdOut(1);
motorstop();
blinkenAus();
}
break;
case Gestoppt:
+ motorstop();
if (TorAuf==1)
{
- LCDout(3);
- Zustand=Oeffnen;
+ lcdOut(3);
+ zustand=Oeffnen;
blinkenEin();
normaleFrequenz();
}
if (TorZu==1)
{
- LCDout(3);
- Zustand=Schliessen;
+ lcdOut(3);
+ zustand=Schliessen;
blinkenEin();
normaleFrequenz();
}
break;
}
+ HAL_Delay(20);
}
}