Lehrer Busch
/
xxx_Uhr_I2C_LCD_Delay_Bua
xxx_Uhr_I2C_LCD_Delay_Bua
main.cpp@0:c1a408e17600, 2022-02-23 (annotated)
- Committer:
- itbusch
- Date:
- Wed Feb 23 19:23:05 2022 +0000
- Revision:
- 0:c1a408e17600
xxx_Uhr_I2C_LCD_Delay_Bua
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
itbusch | 0:c1a408e17600 | 1 | /* mbed BuschA, */ |
itbusch | 0:c1a408e17600 | 2 | #include "mbed.h" |
itbusch | 0:c1a408e17600 | 3 | #include "UP_Uhr.c" |
itbusch | 0:c1a408e17600 | 4 | #include "LCD.h" |
itbusch | 0:c1a408e17600 | 5 | #include "I2C_LCD_Ausgabe.h" |
itbusch | 0:c1a408e17600 | 6 | |
itbusch | 0:c1a408e17600 | 7 | |
itbusch | 0:c1a408e17600 | 8 | // Set the LCD address to 0x27 for a 16 chars and 2 line display |
itbusch | 0:c1a408e17600 | 9 | |
itbusch | 0:c1a408e17600 | 10 | lcd mylcd; |
itbusch | 0:c1a408e17600 | 11 | |
itbusch | 0:c1a408e17600 | 12 | int sec, minu, stud; |
itbusch | 0:c1a408e17600 | 13 | |
itbusch | 0:c1a408e17600 | 14 | void Ausgabe_LCD (void) |
itbusch | 0:c1a408e17600 | 15 | { |
itbusch | 0:c1a408e17600 | 16 | mylcd.cursorpos(0x00); |
itbusch | 0:c1a408e17600 | 17 | mylcd.printf(" Uhrzeit:"); |
itbusch | 0:c1a408e17600 | 18 | mylcd.cursorpos(0x40); |
itbusch | 0:c1a408e17600 | 19 | mylcd.printf(" %2d h: m:%2d s:%2d ",stud, minu, sec); |
itbusch | 0:c1a408e17600 | 20 | } |
itbusch | 0:c1a408e17600 | 21 | |
itbusch | 0:c1a408e17600 | 22 | |
itbusch | 0:c1a408e17600 | 23 | void Uhr (void) |
itbusch | 0:c1a408e17600 | 24 | { |
itbusch | 0:c1a408e17600 | 25 | sec = sec + 1; |
itbusch | 0:c1a408e17600 | 26 | if (sec == 60) |
itbusch | 0:c1a408e17600 | 27 | { |
itbusch | 0:c1a408e17600 | 28 | minu ++; |
itbusch | 0:c1a408e17600 | 29 | sec = 0; |
itbusch | 0:c1a408e17600 | 30 | |
itbusch | 0:c1a408e17600 | 31 | if (minu == 60) |
itbusch | 0:c1a408e17600 | 32 | { |
itbusch | 0:c1a408e17600 | 33 | stud ++; |
itbusch | 0:c1a408e17600 | 34 | minu = 0; |
itbusch | 0:c1a408e17600 | 35 | |
itbusch | 0:c1a408e17600 | 36 | if (stud == 24) |
itbusch | 0:c1a408e17600 | 37 | { |
itbusch | 0:c1a408e17600 | 38 | stud = 0; |
itbusch | 0:c1a408e17600 | 39 | } |
itbusch | 0:c1a408e17600 | 40 | } |
itbusch | 0:c1a408e17600 | 41 | } |
itbusch | 0:c1a408e17600 | 42 | } |
itbusch | 0:c1a408e17600 | 43 | |
itbusch | 0:c1a408e17600 | 44 | int main() |
itbusch | 0:c1a408e17600 | 45 | { |
itbusch | 0:c1a408e17600 | 46 | mylcd.clear(); |
itbusch | 0:c1a408e17600 | 47 | |
itbusch | 0:c1a408e17600 | 48 | |
itbusch | 0:c1a408e17600 | 49 | while (true) |
itbusch | 0:c1a408e17600 | 50 | { |
itbusch | 0:c1a408e17600 | 51 | |
itbusch | 0:c1a408e17600 | 52 | { |
itbusch | 0:c1a408e17600 | 53 | Uhr(); |
itbusch | 0:c1a408e17600 | 54 | Ausgabe_LCD(); |
itbusch | 0:c1a408e17600 | 55 | thread_sleep_for(1000); //Sleep = Warten... |
itbusch | 0:c1a408e17600 | 56 | } |
itbusch | 0:c1a408e17600 | 57 | } |
itbusch | 0:c1a408e17600 | 58 | } |
itbusch | 0:c1a408e17600 | 59 | |
itbusch | 0:c1a408e17600 | 60 |