1 | uint8_t TasterDimmenAufAb (struct inputDesc* pInput)
|
2 | {
|
3 |
|
4 |
|
5 | //Steigende Flanke abfragen
|
6 | pInput->bR_TRIG = Eingang[pInput->EingangArr] && !pInput->Hilfsmerker;
|
7 | //Fallende Flanke abfragen
|
8 | pInput->bF_TRIG = !Eingang[pInput->EingangArr] && pInput->Hilfsmerker;
|
9 | pInput->Hilfsmerker = Eingang[pInput->EingangArr];
|
10 |
|
11 | // Ausschalten wenn nur kurz gedrückt wurd, damit nicht ausgeschaltet
|
12 | // wird wenn hochgedimmt wurde!
|
13 | if (pInput->bF_TRIG && pInput->pressedCycles < 50 && (!pInput->TasteIstGedrueckt) && licht_status[pInput->bitStatus])
|
14 | {
|
15 | licht_schalten[pInput->bitStatus] = 1;
|
16 | }
|
17 |
|
18 | //Einschalten wenn noch nicht an ist
|
19 | if (pInput->bR_TRIG && (!licht_status[pInput->bitStatus]))
|
20 | {
|
21 | licht_schalten[pInput->bitStatus] = 1;
|
22 | pInput->TasteIstGedrueckt = 1;
|
23 | }
|
24 |
|
25 | //Beim Loslassen des Tasters Speicher "TasteGedrückt" löschen
|
26 | if (pInput->bF_TRIG)
|
27 | {
|
28 | pInput->TasteIstGedrueckt = 0;
|
29 | }
|
30 | //Länge des Tastendruckes aufzeichnen
|
31 | if (Eingang[pInput->EingangArr])
|
32 | pInput->pressedCycles++;
|
33 | else
|
34 | pInput->pressedCycles = 0;
|
35 |
|
36 | //#######################################################################
|
37 | //Dimmen
|
38 | //#######################################################################
|
39 |
|
40 | // Wenn Taste länger gedrückt wird
|
41 | if (pInput->pressedCycles >50)
|
42 | {
|
43 | //Nach Zeit Dimmwert erhöhen
|
44 | pInput->takt++;
|
45 |
|
46 | if (pInput->takt == 5)
|
47 | {
|
48 |
|
49 | if (u8SpeicherDimmwert[pInput->bitStatus] == 100)
|
50 | pInput->aufab = 1;
|
51 | if (u8SpeicherDimmwert[pInput->bitStatus] == 5)
|
52 | pInput->aufab = 0;
|
53 |
|
54 | //Wenn unter 100%, dann plus
|
55 | if (u8SpeicherDimmwert[pInput->bitStatus] <100 && !pInput->aufab)
|
56 | u8SpeicherDimmwert[pInput->bitStatus]++;
|
57 |
|
58 | else if (u8SpeicherDimmwert[pInput->bitStatus] >5 && pInput->aufab)
|
59 | u8SpeicherDimmwert[pInput->bitStatus]--;
|
60 |
|
61 | pInput->takt = 0;
|
62 |
|
63 | }
|
64 |
|
65 |
|
66 | return u8SpeicherDimmwert[pInput->bitStatus];
|
67 | }
|
68 |
|
69 | }
|