final
Dependencies: BSP_DISCO_F746NG LCD_DISCO_F746NG TS_DISCO_F746NG
main.cpp@0:af94a5725e48, 2018-10-25 (annotated)
- Committer:
- abp123
- Date:
- Thu Oct 25 12:32:13 2018 +0000
- Revision:
- 0:af94a5725e48
final version;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
abp123 | 0:af94a5725e48 | 1 | //Include filer |
abp123 | 0:af94a5725e48 | 2 | #include "mbed.h" |
abp123 | 0:af94a5725e48 | 3 | #include "TS_DISCO_F746NG.h" |
abp123 | 0:af94a5725e48 | 4 | #include "LCD_DISCO_F746NG.h" |
abp123 | 0:af94a5725e48 | 5 | #include "head.h" |
abp123 | 0:af94a5725e48 | 6 | |
abp123 | 0:af94a5725e48 | 7 | int main() |
abp123 | 0:af94a5725e48 | 8 | { |
abp123 | 0:af94a5725e48 | 9 | //for loop der itererer data fra user input |
abp123 | 0:af94a5725e48 | 10 | for (i = 0; i < antal; i++) { |
abp123 | 0:af94a5725e48 | 11 | printf("\nIndtast Bygning nummer:"); |
abp123 | 0:af94a5725e48 | 12 | //Num void |
abp123 | 0:af94a5725e48 | 13 | Num(cAntal, 4); |
abp123 | 0:af94a5725e48 | 14 | // atoi = konverter string til int(ASCII to integer) |
abp123 | 0:af94a5725e48 | 15 | Bnr = atoi(cAntal); |
abp123 | 0:af94a5725e48 | 16 | printf("Indtast Lokale nummer:"); |
abp123 | 0:af94a5725e48 | 17 | Num(cAntal, 5); |
abp123 | 0:af94a5725e48 | 18 | Lnr = atoi(cAntal); |
abp123 | 0:af94a5725e48 | 19 | } |
abp123 | 0:af94a5725e48 | 20 | //Udskriver den indtastede information |
abp123 | 0:af94a5725e48 | 21 | printf("Info:\n"); |
abp123 | 0:af94a5725e48 | 22 | printf("Bygning %d\n", Bnr); |
abp123 | 0:af94a5725e48 | 23 | printf("Lokale %d\n", Lnr); |
abp123 | 0:af94a5725e48 | 24 | printf("Tast 1 for temperatur(hex), 2 for lyd, 3 for lys: "); |
abp123 | 0:af94a5725e48 | 25 | //Her starter jeg min thread i baggrunden |
abp123 | 0:af94a5725e48 | 26 | thread.start(InputThread); |
abp123 | 0:af94a5725e48 | 27 | wait(0.1); |
abp123 | 0:af94a5725e48 | 28 | //Hvis der ikke er fundet resultater fra user input, udløser displayet en fejlbesked |
abp123 | 0:af94a5725e48 | 29 | if (Bnr == NULL || Lnr == NULL) { |
abp123 | 0:af94a5725e48 | 30 | lcd.Clear(LCD_COLOR_RED); |
abp123 | 0:af94a5725e48 | 31 | lcd.SetBackColor(LCD_COLOR_RED); |
abp123 | 0:af94a5725e48 | 32 | lcd.SetTextColor(LCD_COLOR_WHITE); |
abp123 | 0:af94a5725e48 | 33 | lcd.DisplayStringAt(0, LINE(5), (uint8_t *)"Fejl, ingen input", CENTER_MODE); |
abp123 | 0:af94a5725e48 | 34 | wait(1); |
abp123 | 0:af94a5725e48 | 35 | } else |
abp123 | 0:af94a5725e48 | 36 | //Hvis der ikke er fejl, aktiveres Display void |
abp123 | 0:af94a5725e48 | 37 | DisplayVoid(Bnr, Lnr); |
abp123 | 0:af94a5725e48 | 38 | //User button med bool variabel, aktiverer temperatur, lyd og lys voids |
abp123 | 0:af94a5725e48 | 39 | label: |
abp123 | 0:af94a5725e48 | 40 | while(btnPress == true) { |
abp123 | 0:af94a5725e48 | 41 | //bool til false |
abp123 | 0:af94a5725e48 | 42 | button.fall(&pressed); |
abp123 | 0:af94a5725e48 | 43 | wait(0.1); |
abp123 | 0:af94a5725e48 | 44 | TempVoid(); |
abp123 | 0:af94a5725e48 | 45 | wait(0.1); |
abp123 | 0:af94a5725e48 | 46 | LydVoid(); |
abp123 | 0:af94a5725e48 | 47 | wait(0.1); |
abp123 | 0:af94a5725e48 | 48 | LysVoid(); |
abp123 | 0:af94a5725e48 | 49 | wait(0.1); |
abp123 | 0:af94a5725e48 | 50 | } |
abp123 | 0:af94a5725e48 | 51 | label2: |
abp123 | 0:af94a5725e48 | 52 | while(btnPress == false) { |
abp123 | 0:af94a5725e48 | 53 | //bool til true |
abp123 | 0:af94a5725e48 | 54 | button.fall(&pressed2); |
abp123 | 0:af94a5725e48 | 55 | wait(0.1); |
abp123 | 0:af94a5725e48 | 56 | TempVoid(); |
abp123 | 0:af94a5725e48 | 57 | wait(0.1); |
abp123 | 0:af94a5725e48 | 58 | LydVoid(); |
abp123 | 0:af94a5725e48 | 59 | wait(0.1); |
abp123 | 0:af94a5725e48 | 60 | LysVoid(); |
abp123 | 0:af94a5725e48 | 61 | wait(0.1); |
abp123 | 0:af94a5725e48 | 62 | } |
abp123 | 0:af94a5725e48 | 63 | //Bool variablen styrer hvilket sted i programmet vi er |
abp123 | 0:af94a5725e48 | 64 | if(btnPress == true) |
abp123 | 0:af94a5725e48 | 65 | goto label; |
abp123 | 0:af94a5725e48 | 66 | else if (btnPress == false) |
abp123 | 0:af94a5725e48 | 67 | goto label2; |
abp123 | 0:af94a5725e48 | 68 | } |
abp123 | 0:af94a5725e48 | 69 | |
abp123 | 0:af94a5725e48 | 70 | |
abp123 | 0:af94a5725e48 | 71 |