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.
Dependencies: mbed
main.cpp@18:6f0897438c03, 2022-12-05 (annotated)
- Committer:
- alexander0707
- Date:
- Mon Dec 05 09:51:36 2022 +0000
- Revision:
- 18:6f0897438c03
- Parent:
- 17:c34f14ec2beb
- Child:
- 19:8fdd91276de8
v2.7
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
prof_al | 0:5ac32d240694 | 1 | /*************************************************************************** |
alexander0707 | 5:5c9b508670cf | 2 | * Titel : main.cpp |
prof_al | 0:5ac32d240694 | 3 | * |
alexander0707 | 5:5c9b508670cf | 4 | * Description : Labormodul "HAPOA" |
prof_al | 0:5ac32d240694 | 5 | * |
prof_al | 0:5ac32d240694 | 6 | * Revision List: |
prof_al | 0:5ac32d240694 | 7 | -------------------------------------------------------------------------- |
prof_al | 0:5ac32d240694 | 8 | Date | Author | Change |
prof_al | 0:5ac32d240694 | 9 | -------------------------------------------------------------------------- |
prof_al | 0:5ac32d240694 | 10 | 24.10.22 | J. Altenburg | Ersterstellung |
prof_al | 0:5ac32d240694 | 11 | -------------------------------------------------------------------------- |
prof_al | 0:5ac32d240694 | 12 | | | |
alexander0707 | 5:5c9b508670cf | 13 | --------------------------------------------------------------------------- |
alexander0707 | 5:5c9b508670cf | 14 | |
alexander0707 | 5:5c9b508670cf | 15 | Editor List: |
alexander0707 | 5:5c9b508670cf | 16 | -------------------------------------------------------------------------- |
alexander0707 | 5:5c9b508670cf | 17 | Date | Author | Change |
alexander0707 | 5:5c9b508670cf | 18 | -------------------------------------------------------------------------- |
alexander0707 | 5:5c9b508670cf | 19 | 30.11.22 |Tobias Zinke | Labor03 |
alexander0707 | 5:5c9b508670cf | 20 | -------------------------------------------------------------------------- |
alexander0707 | 5:5c9b508670cf | 21 | 30.11.22 |Alexander Pitthan| Labor03 |
alexander0707 | 5:5c9b508670cf | 22 | --------------------------------------------------------------------------- |
prof_al | 0:5ac32d240694 | 23 | ****************************************************************************/ |
prof_al | 0:5ac32d240694 | 24 | #include "mbed.h" |
prof_al | 0:5ac32d240694 | 25 | #include "cdef.h" |
prof_al | 0:5ac32d240694 | 26 | |
alexander0707 | 5:5c9b508670cf | 27 | AnalogIn pinPoti (A0); |
alexander0707 | 5:5c9b508670cf | 28 | |
prof_al | 0:5ac32d240694 | 29 | /* Vereinbarungen zu den Tasteneingängen */ |
prof_al | 0:5ac32d240694 | 30 | DigitalIn pinS1(A1); |
prof_al | 0:5ac32d240694 | 31 | DigitalIn pinS2(A2); |
prof_al | 0:5ac32d240694 | 32 | DigitalIn pinS3(A3); |
prof_al | 0:5ac32d240694 | 33 | |
alexander0707 | 12:bd1417475c5f | 34 | //BusOut bLedShield(D10, D11, D12, D13); |
prof_al | 0:5ac32d240694 | 35 | |
prof_al | 0:5ac32d240694 | 36 | /* Anschlüsse der Schieberegister */ |
prof_al | 0:5ac32d240694 | 37 | DigitalOut pinSdo(PA_9); |
prof_al | 0:5ac32d240694 | 38 | DigitalOut pinSck(PA_8); |
prof_al | 0:5ac32d240694 | 39 | DigitalOut pinLoad(PB_5); |
alexander0707 | 6:4e55101c65f4 | 40 | DigitalOut pinBeep(PB_3); |
prof_al | 0:5ac32d240694 | 41 | |
prof_al | 0:5ac32d240694 | 42 | /* ISR */ |
prof_al | 0:5ac32d240694 | 43 | Ticker stTimer; |
prof_al | 0:5ac32d240694 | 44 | |
prof_al | 0:5ac32d240694 | 45 | /*************************************************************************** |
prof_al | 0:5ac32d240694 | 46 | * Defines und Makros * |
prof_al | 0:5ac32d240694 | 47 | ***************************************************************************/ |
alexander0707 | 5:5c9b508670cf | 48 | #define nTastShort 20 /* Taste 50 Millisekunden gedrückt */ |
alexander0707 | 12:bd1417475c5f | 49 | #define nTastLong 240 /* Taste 0.6 Sekunden gedrückt */ |
alexander0707 | 5:5c9b508670cf | 50 | #define nCircleTime 2500 /* Laufzeit der Main in us */ |
prof_al | 0:5ac32d240694 | 51 | |
prof_al | 0:5ac32d240694 | 52 | #define nSegA 0x01 |
prof_al | 0:5ac32d240694 | 53 | #define nSegB 0x02 |
prof_al | 0:5ac32d240694 | 54 | #define nSegC 0x04 |
prof_al | 0:5ac32d240694 | 55 | #define nSegD 0x08 |
prof_al | 0:5ac32d240694 | 56 | #define nSegE 0x10 |
prof_al | 0:5ac32d240694 | 57 | #define nSegF 0x20 |
prof_al | 0:5ac32d240694 | 58 | #define nSegG 0x40 |
prof_al | 0:5ac32d240694 | 59 | #define nSegH 0x80 |
prof_al | 0:5ac32d240694 | 60 | |
prof_al | 0:5ac32d240694 | 61 | #define nZiffer0 ~(nSegA | nSegB | nSegC | nSegD | nSegE | nSegF) |
prof_al | 0:5ac32d240694 | 62 | #define nZiffer1 ~(nSegB | nSegC) |
prof_al | 0:5ac32d240694 | 63 | #define nZiffer2 ~(nSegA | nSegB | nSegD | nSegE | nSegG) |
prof_al | 0:5ac32d240694 | 64 | #define nZiffer3 ~(nSegA | nSegB | nSegC | nSegD | nSegG) |
prof_al | 0:5ac32d240694 | 65 | #define nZiffer4 ~(nSegB | nSegC | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 66 | #define nZiffer5 ~(nSegA | nSegC | nSegD | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 67 | #define nZiffer6 ~(nSegA | nSegC | nSegD | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 68 | #define nZiffer7 ~(nSegA | nSegB | nSegC) |
prof_al | 0:5ac32d240694 | 69 | #define nZiffer8 ~(nSegA | nSegB | nSegC | nSegD | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 70 | #define nZiffer9 ~(nSegA | nSegB | nSegC | nSegD | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 71 | #define nZifferA ~(nSegA | nSegB | nSegC | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 72 | #define nZifferB ~(nSegC | nSegD | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 73 | #define nZifferC ~(nSegA | nSegD | nSegE | nSegF) |
prof_al | 0:5ac32d240694 | 74 | #define nZifferD ~(nSegB | nSegC | nSegD | nSegE | nSegG) |
prof_al | 0:5ac32d240694 | 75 | #define nZifferE ~(nSegA | nSegD | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 76 | #define nZifferF ~(nSegA | nSegE | nSegF | nSegG) |
prof_al | 0:5ac32d240694 | 77 | #define nZifferOff (nSegA | nSegB | nSegC | nSegD | nSegE | nSegF | nSegG | nSegH) |
prof_al | 0:5ac32d240694 | 78 | |
prof_al | 0:5ac32d240694 | 79 | byte bIdx; /* |
prof_al | 0:5ac32d240694 | 80 | * Description : Index auf Ausgabe |
prof_al | 0:5ac32d240694 | 81 | */ |
prof_al | 0:5ac32d240694 | 82 | |
prof_al | 0:5ac32d240694 | 83 | byte bDigit; /* |
prof_al | 0:5ac32d240694 | 84 | * Description : aktives Digit |
prof_al | 0:5ac32d240694 | 85 | */ |
prof_al | 0:5ac32d240694 | 86 | |
prof_al | 0:5ac32d240694 | 87 | byte bBargraph; /* |
prof_al | 0:5ac32d240694 | 88 | * Description : Bargraph durchschalten |
prof_al | 0:5ac32d240694 | 89 | */ |
prof_al | 0:5ac32d240694 | 90 | |
prof_al | 0:5ac32d240694 | 91 | byte bS1Timer; /* |
prof_al | 0:5ac32d240694 | 92 | * Description : Timer für Taste S1 |
prof_al | 0:5ac32d240694 | 93 | */ |
prof_al | 0:5ac32d240694 | 94 | |
prof_al | 0:5ac32d240694 | 95 | byte bS2Timer; /* |
prof_al | 0:5ac32d240694 | 96 | * Description : Timer für Taste S2 |
prof_al | 0:5ac32d240694 | 97 | */ |
prof_al | 0:5ac32d240694 | 98 | |
prof_al | 0:5ac32d240694 | 99 | byte bS3Timer; /* |
prof_al | 0:5ac32d240694 | 100 | * Description : Timer für Taste S3 |
prof_al | 0:5ac32d240694 | 101 | */ |
prof_al | 0:5ac32d240694 | 102 | |
alexander0707 | 14:88379565eac6 | 103 | byte bSCounter; /* |
alexander0707 | 14:88379565eac6 | 104 | * Description : Zähler UART-Auslese für Tasterersatz |
alexander0707 | 14:88379565eac6 | 105 | */ |
alexander0707 | 14:88379565eac6 | 106 | |
alexander0707 | 5:5c9b508670cf | 107 | byte bDisplayState; /* |
alexander0707 | 5:5c9b508670cf | 108 | * Description : |
alexander0707 | 5:5c9b508670cf | 109 | */ |
alexander0707 | 5:5c9b508670cf | 110 | const byte enSchwellenwert=0x00; |
alexander0707 | 5:5c9b508670cf | 111 | const byte enPotiAnzeige = 0x01; |
alexander0707 | 5:5c9b508670cf | 112 | const byte enVergleich = 0x02; |
alexander0707 | 5:5c9b508670cf | 113 | |
alexander0707 | 5:5c9b508670cf | 114 | |
alexander0707 | 5:5c9b508670cf | 115 | byte bState; /* |
alexander0707 | 5:5c9b508670cf | 116 | * Description : |
alexander0707 | 5:5c9b508670cf | 117 | */ |
alexander0707 | 5:5c9b508670cf | 118 | |
alexander0707 | 5:5c9b508670cf | 119 | byte bTimerDot; /* |
alexander0707 | 5:5c9b508670cf | 120 | * Description : Zähler für Dots |
alexander0707 | 5:5c9b508670cf | 121 | */ |
alexander0707 | 5:5c9b508670cf | 122 | |
alexander0707 | 5:5c9b508670cf | 123 | byte bHotKey; /* |
alexander0707 | 5:5c9b508670cf | 124 | * Description : Auswahl der Taste |
alexander0707 | 5:5c9b508670cf | 125 | */ |
alexander0707 | 5:5c9b508670cf | 126 | |
alexander0707 | 5:5c9b508670cf | 127 | byte bDisplayDot; /* |
alexander0707 | 5:5c9b508670cf | 128 | * Description : |
alexander0707 | 5:5c9b508670cf | 129 | */ |
alexander0707 | 5:5c9b508670cf | 130 | |
alexander0707 | 5:5c9b508670cf | 131 | byte bMainState; /* |
alexander0707 | 5:5c9b508670cf | 132 | * Description : Hauptzustand |
alexander0707 | 5:5c9b508670cf | 133 | */ |
alexander0707 | 5:5c9b508670cf | 134 | |
alexander0707 | 5:5c9b508670cf | 135 | byte bBeepTime; /* |
alexander0707 | 5:5c9b508670cf | 136 | * Description : Tondauer |
alexander0707 | 5:5c9b508670cf | 137 | */ |
alexander0707 | 5:5c9b508670cf | 138 | |
alexander0707 | 5:5c9b508670cf | 139 | byte bEinstellungsModus;/* |
alexander0707 | 5:5c9b508670cf | 140 | * Description : Einstellungszustand |
alexander0707 | 5:5c9b508670cf | 141 | */ |
alexander0707 | 5:5c9b508670cf | 142 | |
alexander0707 | 5:5c9b508670cf | 143 | byte bSchwellenwertVergleich;/* |
alexander0707 | 5:5c9b508670cf | 144 | * Description : Einstellungszustand |
alexander0707 | 5:5c9b508670cf | 145 | */ |
alexander0707 | 5:5c9b508670cf | 146 | |
alexander0707 | 6:4e55101c65f4 | 147 | byte bTimeLong;/* |
alexander0707 | 6:4e55101c65f4 | 148 | * Description : Ob Taste bereits lange gedrückt war |
alexander0707 | 6:4e55101c65f4 | 149 | */ |
alexander0707 | 6:4e55101c65f4 | 150 | |
alexander0707 | 13:b1d6b2285b13 | 151 | byte bSizeData;/* |
alexander0707 | 13:b1d6b2285b13 | 152 | * Description : Größe der Daten |
alexander0707 | 13:b1d6b2285b13 | 153 | */ |
alexander0707 | 13:b1d6b2285b13 | 154 | byte *pUartData; /* |
alexander0707 | 13:b1d6b2285b13 | 155 | * Description : pointer to data |
alexander0707 | 13:b1d6b2285b13 | 156 | */ |
alexander0707 | 13:b1d6b2285b13 | 157 | |
alexander0707 | 5:5c9b508670cf | 158 | |
prof_al | 0:5ac32d240694 | 159 | word wSerial; /* |
prof_al | 0:5ac32d240694 | 160 | * Description : serielles Ausgaberegister |
prof_al | 0:5ac32d240694 | 161 | */ |
prof_al | 0:5ac32d240694 | 162 | |
alexander0707 | 5:5c9b508670cf | 163 | word wClockTime; /* |
alexander0707 | 5:5c9b508670cf | 164 | *Description : Timer für verstrichene Zeit |
alexander0707 | 5:5c9b508670cf | 165 | */ |
alexander0707 | 5:5c9b508670cf | 166 | |
alexander0707 | 5:5c9b508670cf | 167 | word wClockShow; /* |
alexander0707 | 5:5c9b508670cf | 168 | *Description : Timer für verstrichene Zeit |
alexander0707 | 5:5c9b508670cf | 169 | */ |
alexander0707 | 5:5c9b508670cf | 170 | |
alexander0707 | 5:5c9b508670cf | 171 | word wDelayGame; /* |
alexander0707 | 5:5c9b508670cf | 172 | * Description : Verzögerungstimer |
alexander0707 | 5:5c9b508670cf | 173 | */ |
alexander0707 | 5:5c9b508670cf | 174 | |
alexander0707 | 5:5c9b508670cf | 175 | word wPotiWert; /* |
alexander0707 | 5:5c9b508670cf | 176 | * Description : Wert des Potis |
alexander0707 | 5:5c9b508670cf | 177 | */ |
alexander0707 | 5:5c9b508670cf | 178 | |
alexander0707 | 5:5c9b508670cf | 179 | word wVorgabeWert; /* |
alexander0707 | 14:88379565eac6 | 180 | * Description : eingestellter Vorgabewert |
alexander0707 | 5:5c9b508670cf | 181 | */ |
alexander0707 | 5:5c9b508670cf | 182 | |
alexander0707 | 10:fdd52c601fcc | 183 | int nDiffWert; /* |
alexander0707 | 6:4e55101c65f4 | 184 | * Description : Differenz zwischen Vorgabe und Eingang |
alexander0707 | 6:4e55101c65f4 | 185 | */ |
alexander0707 | 6:4e55101c65f4 | 186 | |
alexander0707 | 14:88379565eac6 | 187 | word wSizeData; /* |
alexander0707 | 14:88379565eac6 | 188 | * Description : Größe der empfangenen Daten |
alexander0707 | 14:88379565eac6 | 189 | */ |
alexander0707 | 14:88379565eac6 | 190 | |
alexander0707 | 15:bbcf8c3f91c5 | 191 | int zaehler; |
alexander0707 | 14:88379565eac6 | 192 | |
prof_al | 0:5ac32d240694 | 193 | /* Bitmuster */ |
prof_al | 0:5ac32d240694 | 194 | const byte abZiffer[] = {nZiffer0, nZiffer1, nZiffer2, nZiffer3, nZiffer4, nZiffer5, nZiffer6, nZiffer7, nZiffer8, nZiffer9, nZifferA, nZifferB, nZifferC, nZifferD, nZifferE, nZifferF, nZifferOff}; |
alexander0707 | 12:bd1417475c5f | 195 | //const byte abBargraph[] = {~Bit0, ~(Bit0|Bit1), ~(Bit0|Bit1|Bit2), ~(Bit0|Bit1|Bit2|Bit3), 0x0f}; |
alexander0707 | 14:88379565eac6 | 196 | byte abTxBuffer[256]; |
alexander0707 | 13:b1d6b2285b13 | 197 | |
prof_al | 0:5ac32d240694 | 198 | |
prof_al | 0:5ac32d240694 | 199 | |
prof_al | 0:5ac32d240694 | 200 | void vShiftLoad(word wLoad){ |
prof_al | 0:5ac32d240694 | 201 | word wMask = Bit15; |
prof_al | 0:5ac32d240694 | 202 | pinLoad = 0; |
prof_al | 0:5ac32d240694 | 203 | while(wMask){ |
prof_al | 0:5ac32d240694 | 204 | if(wMask & wLoad) pinSdo = 1; |
prof_al | 0:5ac32d240694 | 205 | else pinSdo = 0; |
prof_al | 0:5ac32d240694 | 206 | pinSck = 1; |
prof_al | 0:5ac32d240694 | 207 | wMask >>= 1; |
prof_al | 0:5ac32d240694 | 208 | pinSck = 0; |
prof_al | 0:5ac32d240694 | 209 | } |
prof_al | 0:5ac32d240694 | 210 | pinLoad = 1; |
prof_al | 0:5ac32d240694 | 211 | } |
prof_al | 0:5ac32d240694 | 212 | |
alexander0707 | 5:5c9b508670cf | 213 | |
alexander0707 | 5:5c9b508670cf | 214 | byte abDisplayMemory[] = {16,16,16,16}; /* alle Segmente aus */ |
alexander0707 | 5:5c9b508670cf | 215 | |
alexander0707 | 6:4e55101c65f4 | 216 | void vDisplayVolt( word w ) |
alexander0707 | 5:5c9b508670cf | 217 | { |
alexander0707 | 5:5c9b508670cf | 218 | int16 v; |
alexander0707 | 5:5c9b508670cf | 219 | abDisplayMemory[0] = 16; /* Aus */ |
alexander0707 | 8:6f91c39dbabc | 220 | v = (byte)(w / 1000); |
alexander0707 | 8:6f91c39dbabc | 221 | abDisplayMemory[1] = v; /* Hunderter */ |
alexander0707 | 8:6f91c39dbabc | 222 | w = w - (v * 1000); |
alexander0707 | 5:5c9b508670cf | 223 | v = (byte)(w / 100); |
alexander0707 | 8:6f91c39dbabc | 224 | abDisplayMemory[2] = v; /* Zehner */ |
alexander0707 | 5:5c9b508670cf | 225 | w = w - (v * 100); |
alexander0707 | 5:5c9b508670cf | 226 | v = (byte)(w / 10); |
alexander0707 | 8:6f91c39dbabc | 227 | abDisplayMemory[3] = v; /* Einer */ |
alexander0707 | 5:5c9b508670cf | 228 | } |
alexander0707 | 6:4e55101c65f4 | 229 | |
alexander0707 | 6:4e55101c65f4 | 230 | void vDisplayDiff( word w ) |
alexander0707 | 5:5c9b508670cf | 231 | { |
alexander0707 | 6:4e55101c65f4 | 232 | int16 v; |
alexander0707 | 6:4e55101c65f4 | 233 | abDisplayMemory[0] = 12; /* "C" */ |
alexander0707 | 8:6f91c39dbabc | 234 | v = (byte)(w / 1000); |
alexander0707 | 8:6f91c39dbabc | 235 | abDisplayMemory[1] = v; /* Hunderter */ |
alexander0707 | 8:6f91c39dbabc | 236 | w = w - (v * 1000); |
alexander0707 | 6:4e55101c65f4 | 237 | v = (byte)(w / 100); |
alexander0707 | 8:6f91c39dbabc | 238 | abDisplayMemory[2] = v; /* Zehner */ |
alexander0707 | 6:4e55101c65f4 | 239 | w = w - (v * 100); |
alexander0707 | 6:4e55101c65f4 | 240 | v = (byte)(w / 10); |
alexander0707 | 8:6f91c39dbabc | 241 | abDisplayMemory[3] = v; /* Einer */ |
alexander0707 | 6:4e55101c65f4 | 242 | } |
alexander0707 | 6:4e55101c65f4 | 243 | |
alexander0707 | 6:4e55101c65f4 | 244 | void vSetForStart( void ) |
alexander0707 | 6:4e55101c65f4 | 245 | { |
alexander0707 | 6:4e55101c65f4 | 246 | abDisplayMemory[0] = 16; /* 7-Segment-Display ausschalten */ |
alexander0707 | 5:5c9b508670cf | 247 | abDisplayMemory[1] = 16; |
alexander0707 | 5:5c9b508670cf | 248 | abDisplayMemory[2] = 16; |
alexander0707 | 5:5c9b508670cf | 249 | abDisplayMemory[3] = 16; |
alexander0707 | 5:5c9b508670cf | 250 | bTimerDot = 0; |
alexander0707 | 5:5c9b508670cf | 251 | bDigit = 0; |
alexander0707 | 6:4e55101c65f4 | 252 | bMainState = enSchwellenwert; |
alexander0707 | 6:4e55101c65f4 | 253 | bDisplayState = enSchwellenwert; |
alexander0707 | 6:4e55101c65f4 | 254 | pinBeep = 1; |
alexander0707 | 6:4e55101c65f4 | 255 | wVorgabeWert = 0; |
alexander0707 | 5:5c9b508670cf | 256 | } |
alexander0707 | 14:88379565eac6 | 257 | |
alexander0707 | 5:5c9b508670cf | 258 | /* Tastenabfrage */ |
alexander0707 | 5:5c9b508670cf | 259 | void vTasteS1( void ){ |
alexander0707 | 16:404bcdd9c518 | 260 | if(pinS1 == 0){ /* User-Taste gedrückt */ |
alexander0707 | 16:404bcdd9c518 | 261 | if(bS1Timer < nTastLong+1){ /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 5:5c9b508670cf | 262 | if(bS1Timer == nTastShort){ /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 5:5c9b508670cf | 263 | //... |
alexander0707 | 5:5c9b508670cf | 264 | } |
alexander0707 | 16:404bcdd9c518 | 265 | if(bS1Timer == nTastLong){ /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 16:404bcdd9c518 | 266 | if(bDisplayState == enSchwellenwert){ |
alexander0707 | 6:4e55101c65f4 | 267 | bDisplayState = enVergleich; |
alexander0707 | 6:4e55101c65f4 | 268 | bMainState = enVergleich; |
alexander0707 | 6:4e55101c65f4 | 269 | } |
alexander0707 | 6:4e55101c65f4 | 270 | else{ |
alexander0707 | 6:4e55101c65f4 | 271 | bDisplayState = enSchwellenwert; |
alexander0707 | 6:4e55101c65f4 | 272 | bMainState = enSchwellenwert; |
alexander0707 | 6:4e55101c65f4 | 273 | } |
alexander0707 | 6:4e55101c65f4 | 274 | } |
alexander0707 | 6:4e55101c65f4 | 275 | bS1Timer++; |
alexander0707 | 6:4e55101c65f4 | 276 | } |
alexander0707 | 6:4e55101c65f4 | 277 | } |
alexander0707 | 6:4e55101c65f4 | 278 | else{ /* Taste nicht gedrückt */ |
alexander0707 | 16:404bcdd9c518 | 279 | if(((bS1Timer >= nTastShort) && (bS1Timer <= nTastLong))){ /* Taste wurde bereits erkannt */ |
alexander0707 | 7:94c73e4168d8 | 280 | if(bDisplayState == enSchwellenwert){ |
alexander0707 | 5:5c9b508670cf | 281 | bDisplayState = enPotiAnzeige; |
alexander0707 | 5:5c9b508670cf | 282 | bMainState = enPotiAnzeige; |
alexander0707 | 5:5c9b508670cf | 283 | } |
alexander0707 | 5:5c9b508670cf | 284 | else{ |
alexander0707 | 5:5c9b508670cf | 285 | bDisplayState = enSchwellenwert; |
alexander0707 | 5:5c9b508670cf | 286 | bMainState= enSchwellenwert; |
alexander0707 | 5:5c9b508670cf | 287 | } |
alexander0707 | 5:5c9b508670cf | 288 | } |
alexander0707 | 5:5c9b508670cf | 289 | bS1Timer = 0; |
alexander0707 | 5:5c9b508670cf | 290 | } |
alexander0707 | 16:404bcdd9c518 | 291 | |
alexander0707 | 16:404bcdd9c518 | 292 | if(abTxBuffer[0] == 'b') { /* User-Taste gedrückt */ |
alexander0707 | 16:404bcdd9c518 | 293 | |
alexander0707 | 16:404bcdd9c518 | 294 | for(zaehler=0; zaehler<=250; zaehler++) { /*Zaehlen der Tastatur-Eingabe*/ |
alexander0707 | 16:404bcdd9c518 | 295 | while(abTxBuffer[zaehler] == abTxBuffer[zaehler+1]) if(abTxBuffer[zaehler] == 'b') bSCounter++; |
alexander0707 | 16:404bcdd9c518 | 296 | } |
alexander0707 | 16:404bcdd9c518 | 297 | |
alexander0707 | 16:404bcdd9c518 | 298 | if(bSCounter < nTastLong+1) { /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 16:404bcdd9c518 | 299 | if(bS1Timer == nTastShort) { /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 16:404bcdd9c518 | 300 | //... |
alexander0707 | 16:404bcdd9c518 | 301 | } |
alexander0707 | 16:404bcdd9c518 | 302 | if(bSCounter == nTastLong) { /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 16:404bcdd9c518 | 303 | if(bDisplayState == enPotiAnzeige) { |
alexander0707 | 16:404bcdd9c518 | 304 | bDisplayState = enVergleich; |
alexander0707 | 16:404bcdd9c518 | 305 | bMainState = enVergleich; |
alexander0707 | 16:404bcdd9c518 | 306 | } else { |
alexander0707 | 16:404bcdd9c518 | 307 | bDisplayState = enSchwellenwert; |
alexander0707 | 16:404bcdd9c518 | 308 | bMainState = enSchwellenwert; |
alexander0707 | 16:404bcdd9c518 | 309 | } |
alexander0707 | 16:404bcdd9c518 | 310 | } |
alexander0707 | 16:404bcdd9c518 | 311 | } |
alexander0707 | 16:404bcdd9c518 | 312 | } else { /* Taste nicht gedrückt */ |
alexander0707 | 16:404bcdd9c518 | 313 | if(((bSCounter >= nTastShort) && (bSCounter <= nTastLong))) { /* Taste wurde bereits erkannt */ |
alexander0707 | 16:404bcdd9c518 | 314 | if(bDisplayState == enSchwellenwert) { |
alexander0707 | 16:404bcdd9c518 | 315 | bDisplayState = enPotiAnzeige; |
alexander0707 | 16:404bcdd9c518 | 316 | bMainState = enPotiAnzeige; |
alexander0707 | 16:404bcdd9c518 | 317 | } else { |
alexander0707 | 16:404bcdd9c518 | 318 | bDisplayState = enSchwellenwert; |
alexander0707 | 16:404bcdd9c518 | 319 | bMainState= enSchwellenwert; |
alexander0707 | 16:404bcdd9c518 | 320 | } |
alexander0707 | 16:404bcdd9c518 | 321 | } |
alexander0707 | 16:404bcdd9c518 | 322 | bSCounter = 0; |
alexander0707 | 16:404bcdd9c518 | 323 | } |
alexander0707 | 5:5c9b508670cf | 324 | } |
alexander0707 | 5:5c9b508670cf | 325 | |
alexander0707 | 5:5c9b508670cf | 326 | void vTasteS2( void ){ |
alexander0707 | 17:c34f14ec2beb | 327 | if((pinS2 == 0) && bMainState == enSchwellenwert){ /* User-Taste gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 328 | if(bS2Timer < nTastLong+1){ /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 5:5c9b508670cf | 329 | if(bS2Timer == nTastShort){ /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 5:5c9b508670cf | 330 | //... |
alexander0707 | 5:5c9b508670cf | 331 | } |
alexander0707 | 17:c34f14ec2beb | 332 | if(bS2Timer == nTastLong){ /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 6:4e55101c65f4 | 333 | bTimeLong = 1; |
alexander0707 | 10:fdd52c601fcc | 334 | if(wVorgabeWert >=3200) wVorgabeWert = 3300; |
alexander0707 | 10:fdd52c601fcc | 335 | else wVorgabeWert = wVorgabeWert + 100; |
alexander0707 | 9:b30caa6d008f | 336 | bS2Timer = bS2Timer - 40; |
alexander0707 | 5:5c9b508670cf | 337 | } |
alexander0707 | 5:5c9b508670cf | 338 | bS2Timer++; |
alexander0707 | 5:5c9b508670cf | 339 | } |
alexander0707 | 5:5c9b508670cf | 340 | } |
alexander0707 | 5:5c9b508670cf | 341 | else{ /* Taste nicht gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 342 | if(((bS2Timer >= nTastShort) && (bS2Timer <= nTastLong))){ /* Taste wurde bereits erkannt */ |
alexander0707 | 10:fdd52c601fcc | 343 | if(bTimeLong==0){ |
alexander0707 | 10:fdd52c601fcc | 344 | if(wVorgabeWert >=3290) wVorgabeWert = 3300; |
alexander0707 | 10:fdd52c601fcc | 345 | else wVorgabeWert = wVorgabeWert + 10; |
alexander0707 | 10:fdd52c601fcc | 346 | } |
alexander0707 | 5:5c9b508670cf | 347 | } |
alexander0707 | 5:5c9b508670cf | 348 | bS2Timer = 0; |
alexander0707 | 14:88379565eac6 | 349 | bTimeLong = 0; |
alexander0707 | 17:c34f14ec2beb | 350 | } |
alexander0707 | 17:c34f14ec2beb | 351 | |
alexander0707 | 17:c34f14ec2beb | 352 | if(abTxBuffer[0] == ',' && bMainState == enSchwellenwert){ /* User-Taste gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 353 | |
alexander0707 | 17:c34f14ec2beb | 354 | for(zaehler=0; zaehler<=250; zaehler++){ /*Zaehlen der Tastatur-Eingabe*/ |
alexander0707 | 17:c34f14ec2beb | 355 | while(abTxBuffer[zaehler] == abTxBuffer[zaehler+1]) if(abTxBuffer[zaehler] == ',') bSCounter++; |
alexander0707 | 17:c34f14ec2beb | 356 | } |
alexander0707 | 17:c34f14ec2beb | 357 | |
alexander0707 | 17:c34f14ec2beb | 358 | if(bSCounter < nTastLong+1){ /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 359 | if(bS2Timer == nTastShort){ /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 17:c34f14ec2beb | 360 | //... |
alexander0707 | 17:c34f14ec2beb | 361 | } |
alexander0707 | 17:c34f14ec2beb | 362 | if(bSCounter == nTastLong){ /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 17:c34f14ec2beb | 363 | bTimeLong = 1; |
alexander0707 | 17:c34f14ec2beb | 364 | if(wVorgabeWert >=3200) wVorgabeWert = 3300; |
alexander0707 | 17:c34f14ec2beb | 365 | else wVorgabeWert = wVorgabeWert + 100; |
alexander0707 | 17:c34f14ec2beb | 366 | bS2Timer = bS2Timer - 40; |
alexander0707 | 17:c34f14ec2beb | 367 | } |
alexander0707 | 17:c34f14ec2beb | 368 | } |
alexander0707 | 17:c34f14ec2beb | 369 | } |
alexander0707 | 17:c34f14ec2beb | 370 | else{ /* Taste nicht gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 371 | if((bSCounter >= nTastShort) && (bSCounter <= nTastLong)){ /* Taste wurde bereits erkannt */ |
alexander0707 | 17:c34f14ec2beb | 372 | if(bTimeLong==0){ |
alexander0707 | 17:c34f14ec2beb | 373 | if(wVorgabeWert >=3290) wVorgabeWert = 3300; |
alexander0707 | 17:c34f14ec2beb | 374 | else wVorgabeWert = wVorgabeWert + 10; |
alexander0707 | 17:c34f14ec2beb | 375 | } |
alexander0707 | 17:c34f14ec2beb | 376 | } |
alexander0707 | 17:c34f14ec2beb | 377 | bTimeLong = 0; |
alexander0707 | 14:88379565eac6 | 378 | bSCounter = 0; |
alexander0707 | 5:5c9b508670cf | 379 | } |
alexander0707 | 5:5c9b508670cf | 380 | } |
alexander0707 | 5:5c9b508670cf | 381 | |
alexander0707 | 5:5c9b508670cf | 382 | void vTasteS3( void ){ |
alexander0707 | 17:c34f14ec2beb | 383 | if(pinS3 == 0 && bMainState == enSchwellenwert){ /* User-Taste gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 384 | if(bS3Timer < nTastLong+1){ /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 5:5c9b508670cf | 385 | if(bS3Timer == nTastShort){ /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 5:5c9b508670cf | 386 | //... |
alexander0707 | 5:5c9b508670cf | 387 | } |
alexander0707 | 17:c34f14ec2beb | 388 | if(bS3Timer == nTastLong){ /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 6:4e55101c65f4 | 389 | bTimeLong = 1; |
alexander0707 | 10:fdd52c601fcc | 390 | if(wVorgabeWert <=100) wVorgabeWert = 0; |
alexander0707 | 10:fdd52c601fcc | 391 | else wVorgabeWert = wVorgabeWert - 100; |
alexander0707 | 12:bd1417475c5f | 392 | bS3Timer = bS3Timer - 40; |
alexander0707 | 5:5c9b508670cf | 393 | } |
alexander0707 | 5:5c9b508670cf | 394 | bS3Timer++; |
alexander0707 | 5:5c9b508670cf | 395 | } |
alexander0707 | 5:5c9b508670cf | 396 | } |
alexander0707 | 5:5c9b508670cf | 397 | else{ /* Taste nicht gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 398 | if((bS3Timer >= nTastShort) && (bS3Timer <= nTastLong)){ /* Taste wurde bereits erkannt */ |
alexander0707 | 10:fdd52c601fcc | 399 | if(bTimeLong==0){ |
alexander0707 | 10:fdd52c601fcc | 400 | if(wVorgabeWert <=10) wVorgabeWert = 0; |
alexander0707 | 10:fdd52c601fcc | 401 | else wVorgabeWert = wVorgabeWert - 10; |
alexander0707 | 10:fdd52c601fcc | 402 | } |
alexander0707 | 5:5c9b508670cf | 403 | } |
alexander0707 | 5:5c9b508670cf | 404 | bS3Timer = 0; |
alexander0707 | 14:88379565eac6 | 405 | bTimeLong = 0; |
alexander0707 | 17:c34f14ec2beb | 406 | } |
alexander0707 | 17:c34f14ec2beb | 407 | |
alexander0707 | 17:c34f14ec2beb | 408 | if(abTxBuffer[0] == '.' && bMainState == enSchwellenwert){ /* User-Taste gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 409 | |
alexander0707 | 17:c34f14ec2beb | 410 | for(zaehler=0; zaehler<=250; zaehler++){ /*Zaehlen der Tastatur-Eingabe*/ |
alexander0707 | 17:c34f14ec2beb | 411 | while(abTxBuffer[zaehler] == abTxBuffer[zaehler+1]) if(abTxBuffer[zaehler] == '.') bSCounter++; |
alexander0707 | 17:c34f14ec2beb | 412 | } |
alexander0707 | 17:c34f14ec2beb | 413 | |
alexander0707 | 17:c34f14ec2beb | 414 | if(bSCounter < nTastLong+1){ /* Abfrage max. bis Taste lange gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 415 | if(bS3Timer == nTastShort){ /* Taste "kurz gedrückt" erkannt */ |
alexander0707 | 17:c34f14ec2beb | 416 | //... |
alexander0707 | 17:c34f14ec2beb | 417 | } |
alexander0707 | 17:c34f14ec2beb | 418 | if(bSCounter == nTastLong){ /* Taste "lange gedrückt" erkannt */ |
alexander0707 | 17:c34f14ec2beb | 419 | bTimeLong = 1; |
alexander0707 | 17:c34f14ec2beb | 420 | if(wVorgabeWert <=100) wVorgabeWert = 0; |
alexander0707 | 17:c34f14ec2beb | 421 | else wVorgabeWert = wVorgabeWert - 100; |
alexander0707 | 17:c34f14ec2beb | 422 | bS3Timer = bS3Timer - 40; |
alexander0707 | 17:c34f14ec2beb | 423 | } |
alexander0707 | 17:c34f14ec2beb | 424 | } |
alexander0707 | 17:c34f14ec2beb | 425 | } |
alexander0707 | 17:c34f14ec2beb | 426 | else{ /* Taste nicht gedrückt */ |
alexander0707 | 17:c34f14ec2beb | 427 | if((bSCounter >= nTastShort) && (bSCounter <= nTastLong)){ /* Taste wurde bereits erkannt */ |
alexander0707 | 17:c34f14ec2beb | 428 | if(bTimeLong==0){ |
alexander0707 | 17:c34f14ec2beb | 429 | if(wVorgabeWert <=10) wVorgabeWert = 0; |
alexander0707 | 17:c34f14ec2beb | 430 | else wVorgabeWert = wVorgabeWert - 10; |
alexander0707 | 17:c34f14ec2beb | 431 | } |
alexander0707 | 17:c34f14ec2beb | 432 | } |
alexander0707 | 17:c34f14ec2beb | 433 | bTimeLong = 0; |
alexander0707 | 14:88379565eac6 | 434 | bSCounter = 0; |
alexander0707 | 5:5c9b508670cf | 435 | } |
alexander0707 | 5:5c9b508670cf | 436 | } |
alexander0707 | 5:5c9b508670cf | 437 | |
alexander0707 | 5:5c9b508670cf | 438 | |
alexander0707 | 5:5c9b508670cf | 439 | |
alexander0707 | 5:5c9b508670cf | 440 | void vCheckTasten( void ){ |
alexander0707 | 5:5c9b508670cf | 441 | vTasteS1(); |
alexander0707 | 5:5c9b508670cf | 442 | vTasteS2(); |
alexander0707 | 5:5c9b508670cf | 443 | vTasteS3(); |
alexander0707 | 5:5c9b508670cf | 444 | } |
alexander0707 | 5:5c9b508670cf | 445 | void vSegmentDigit( void ) //wichtig!! |
alexander0707 | 5:5c9b508670cf | 446 | { |
alexander0707 | 5:5c9b508670cf | 447 | bDigit++; |
alexander0707 | 5:5c9b508670cf | 448 | wSerial = abZiffer[abDisplayMemory[bDigit&0x03]]; |
alexander0707 | 5:5c9b508670cf | 449 | switch(bDisplayState) { |
alexander0707 | 5:5c9b508670cf | 450 | case enSchwellenwert: |
alexander0707 | 5:5c9b508670cf | 451 | bTimerDot++; /* Zähler für Punktwechsel */ |
alexander0707 | 6:4e55101c65f4 | 452 | vDisplayVolt(wVorgabeWert); |
alexander0707 | 6:4e55101c65f4 | 453 | if(bTimerDot == 400) { |
alexander0707 | 18:6f0897438c03 | 454 | wDelayGame=2*nTastShort; |
alexander0707 | 18:6f0897438c03 | 455 | bTimerDot = 0; |
alexander0707 | 18:6f0897438c03 | 456 | } |
alexander0707 | 18:6f0897438c03 | 457 | if(wDelayGame!=0){ |
alexander0707 | 7:94c73e4168d8 | 458 | if((bDigit&0x03) == 0x01) { |
alexander0707 | 7:94c73e4168d8 | 459 | wSerial = wSerial & ~nSegH; /* Punktanzeigen */ |
alexander0707 | 18:6f0897438c03 | 460 | } |
alexander0707 | 18:6f0897438c03 | 461 | wDelayGame--; |
alexander0707 | 5:5c9b508670cf | 462 | } |
alexander0707 | 5:5c9b508670cf | 463 | break; |
alexander0707 | 5:5c9b508670cf | 464 | case enPotiAnzeige: |
alexander0707 | 6:4e55101c65f4 | 465 | vDisplayVolt(wPotiWert); |
alexander0707 | 5:5c9b508670cf | 466 | if((bDigit&0x03) == 0x01) { /* Dezimalpunkt setzen */ |
alexander0707 | 5:5c9b508670cf | 467 | wSerial = wSerial & ~nSegH; |
alexander0707 | 5:5c9b508670cf | 468 | } |
alexander0707 | 5:5c9b508670cf | 469 | break; |
alexander0707 | 5:5c9b508670cf | 470 | case enVergleich: |
alexander0707 | 10:fdd52c601fcc | 471 | vDisplayDiff(nDiffWert); |
alexander0707 | 5:5c9b508670cf | 472 | if((bDigit&0x03) == 0x01) { /* Dezimalpunkt setzen */ |
alexander0707 | 5:5c9b508670cf | 473 | wSerial = wSerial & ~nSegH; |
alexander0707 | 5:5c9b508670cf | 474 | } |
alexander0707 | 5:5c9b508670cf | 475 | break; |
alexander0707 | 5:5c9b508670cf | 476 | } |
alexander0707 | 5:5c9b508670cf | 477 | vShiftLoad(((wSerial << 8) & 0xfff0)| (1 << (bDigit&0x03))); |
alexander0707 | 5:5c9b508670cf | 478 | } |
alexander0707 | 5:5c9b508670cf | 479 | |
alexander0707 | 13:b1d6b2285b13 | 480 | |
alexander0707 | 13:b1d6b2285b13 | 481 | |
alexander0707 | 13:b1d6b2285b13 | 482 | |
alexander0707 | 13:b1d6b2285b13 | 483 | |
alexander0707 | 13:b1d6b2285b13 | 484 | |
alexander0707 | 13:b1d6b2285b13 | 485 | |
alexander0707 | 13:b1d6b2285b13 | 486 | |
alexander0707 | 13:b1d6b2285b13 | 487 | |
alexander0707 | 13:b1d6b2285b13 | 488 | |
alexander0707 | 13:b1d6b2285b13 | 489 | Serial stComX(D1,D0); /* UART-Kommunikation (Txd(D1)/Rxd(D0)) mit dem PC */ |
alexander0707 | 13:b1d6b2285b13 | 490 | |
alexander0707 | 14:88379565eac6 | 491 | |
alexander0707 | 14:88379565eac6 | 492 | byte SYS_vStartComX( word wSize, byte *pData ){ /* Start einer Übertragung */ |
alexander0707 | 14:88379565eac6 | 493 | byte i; |
alexander0707 | 14:88379565eac6 | 494 | if(wSizeData) i = False; |
alexander0707 | 14:88379565eac6 | 495 | else{ |
alexander0707 | 14:88379565eac6 | 496 | wSizeData = wSize; /* Anzahl der Sendedaten */ |
alexander0707 | 14:88379565eac6 | 497 | pUartData = pData; /* Zeiger auf diese Daten */ |
alexander0707 | 14:88379565eac6 | 498 | stComX.putc(*pUartData); /* erstes Zeichen senden */ |
alexander0707 | 14:88379565eac6 | 499 | pUartData++; |
alexander0707 | 14:88379565eac6 | 500 | wSizeData--; |
alexander0707 | 14:88379565eac6 | 501 | USART2->CR1 |= USART_CR1_TXEIE; /* TXE-Interrupt freigeben */ |
alexander0707 | 14:88379565eac6 | 502 | i = True; |
alexander0707 | 14:88379565eac6 | 503 | } |
alexander0707 | 14:88379565eac6 | 504 | return i; |
alexander0707 | 14:88379565eac6 | 505 | } |
alexander0707 | 13:b1d6b2285b13 | 506 | |
alexander0707 | 13:b1d6b2285b13 | 507 | |
alexander0707 | 14:88379565eac6 | 508 | /* Senderoutine zum COM-Port am PC */ |
alexander0707 | 14:88379565eac6 | 509 | void vIsrTxComX( void ){ /* Senderoutine */ |
alexander0707 | 14:88379565eac6 | 510 | if(stComX.writeable()){ /* Sende-ISR */ |
alexander0707 | 14:88379565eac6 | 511 | if(bSizeData){ /* sind Daten vorhanden ? */ |
alexander0707 | 14:88379565eac6 | 512 | stComX.putc(*pUartData); /* daten senden */ |
alexander0707 | 14:88379565eac6 | 513 | pUartData++; |
alexander0707 | 14:88379565eac6 | 514 | bSizeData--; |
alexander0707 | 14:88379565eac6 | 515 | } |
alexander0707 | 14:88379565eac6 | 516 | else{ |
alexander0707 | 14:88379565eac6 | 517 | USART2->CR1 &= ~USART_CR1_TXEIE; /* Interrupt sperren */ |
alexander0707 | 14:88379565eac6 | 518 | } |
alexander0707 | 14:88379565eac6 | 519 | } |
alexander0707 | 14:88379565eac6 | 520 | } |
alexander0707 | 14:88379565eac6 | 521 | |
alexander0707 | 14:88379565eac6 | 522 | |
alexander0707 | 14:88379565eac6 | 523 | /* Empfangsroutine vom COM-Port des PC */ |
alexander0707 | 14:88379565eac6 | 524 | void vIsrRxComX( void ){ /* Empfangsroutine */ |
alexander0707 | 14:88379565eac6 | 525 | if(stComX.readable()){ /* Empfangs-ISR */ |
alexander0707 | 14:88379565eac6 | 526 | abTxBuffer[0] = stComX.getc(); |
alexander0707 | 14:88379565eac6 | 527 | abTxBuffer[0] = abTxBuffer[0] + 1; |
alexander0707 | 14:88379565eac6 | 528 | SYS_vStartComX(1, &abTxBuffer[0]); |
alexander0707 | 14:88379565eac6 | 529 | } |
alexander0707 | 14:88379565eac6 | 530 | } |
alexander0707 | 14:88379565eac6 | 531 | |
alexander0707 | 13:b1d6b2285b13 | 532 | |
alexander0707 | 13:b1d6b2285b13 | 533 | |
alexander0707 | 13:b1d6b2285b13 | 534 | |
alexander0707 | 13:b1d6b2285b13 | 535 | |
alexander0707 | 13:b1d6b2285b13 | 536 | |
alexander0707 | 13:b1d6b2285b13 | 537 | |
alexander0707 | 13:b1d6b2285b13 | 538 | |
alexander0707 | 13:b1d6b2285b13 | 539 | |
prof_al | 0:5ac32d240694 | 540 | /*************************************************************************** |
prof_al | 0:5ac32d240694 | 541 | * main() |
prof_al | 0:5ac32d240694 | 542 | ***************************************************************************/ |
prof_al | 0:5ac32d240694 | 543 | int main() { |
prof_al | 0:5ac32d240694 | 544 | /* Variablen initialisieren */ |
alexander0707 | 6:4e55101c65f4 | 545 | vSetForStart(); |
alexander0707 | 13:b1d6b2285b13 | 546 | |
alexander0707 | 13:b1d6b2285b13 | 547 | |
alexander0707 | 14:88379565eac6 | 548 | //Seriel.begin(9600); |
alexander0707 | 5:5c9b508670cf | 549 | |
alexander0707 | 14:88379565eac6 | 550 | |
alexander0707 | 6:4e55101c65f4 | 551 | while(1) { |
alexander0707 | 10:fdd52c601fcc | 552 | wPotiWert = pinPoti*3300; |
alexander0707 | 6:4e55101c65f4 | 553 | vCheckTasten(); |
alexander0707 | 10:fdd52c601fcc | 554 | nDiffWert = wVorgabeWert - wPotiWert; |
alexander0707 | 14:88379565eac6 | 555 | |
alexander0707 | 14:88379565eac6 | 556 | |
alexander0707 | 14:88379565eac6 | 557 | stComX.attach(&vIsrRxComX, Serial::RxIrq); /* ISR zum Datemempfang vom PC */ |
alexander0707 | 14:88379565eac6 | 558 | stComX.attach(&vIsrTxComX, Serial::TxIrq); /* Sende-ISR */ |
alexander0707 | 14:88379565eac6 | 559 | |
alexander0707 | 14:88379565eac6 | 560 | |
alexander0707 | 5:5c9b508670cf | 561 | switch(bMainState) { |
alexander0707 | 6:4e55101c65f4 | 562 | case enSchwellenwert: |
alexander0707 | 12:bd1417475c5f | 563 | pinBeep = 1; |
alexander0707 | 5:5c9b508670cf | 564 | break; |
alexander0707 | 6:4e55101c65f4 | 565 | case enPotiAnzeige: |
alexander0707 | 12:bd1417475c5f | 566 | pinBeep = 1; |
alexander0707 | 5:5c9b508670cf | 567 | break; |
alexander0707 | 6:4e55101c65f4 | 568 | case enVergleich: |
alexander0707 | 10:fdd52c601fcc | 569 | if(nDiffWert<0) pinBeep=0; |
alexander0707 | 6:4e55101c65f4 | 570 | else pinBeep=1; |
alexander0707 | 5:5c9b508670cf | 571 | break; |
prof_al | 0:5ac32d240694 | 572 | } |
alexander0707 | 5:5c9b508670cf | 573 | vSegmentDigit(); |
alexander0707 | 6:4e55101c65f4 | 574 | wait_us(nCircleTime); |
prof_al | 0:5ac32d240694 | 575 | } |
alexander0707 | 5:5c9b508670cf | 576 | } |