LALALA

Dependencies:   mbed

Committer:
DoTTi
Date:
Thu Jan 18 11:05:42 2018 +0000
Revision:
1:3a95f280192d
Parent:
0:425c87a33e63
LALALALA

Who changed what in which revision?

UserRevisionLine numberNew contents of line
martinale 0:425c87a33e63 1 #include "mbed.h"
martinale 0:425c87a33e63 2 #include "BtnEventM0.h"
martinale 0:425c87a33e63 3
martinale 0:425c87a33e63 4 Serial pc(USBTX, USBRX);
martinale 0:425c87a33e63 5 // LSB MSB
DoTTi 1:3a95f280192d 6 BusOut lb(/*P1_13,P1_12,*/P1_7,P1_6,P1_4,P1_3,P1_1,P1_0,LED4,LED3,LED2,LED1);
martinale 0:425c87a33e63 7
martinale 0:425c87a33e63 8 BtnEventM0 sw4(P1_16), sw3(P0_23), sw1(P0_10), sw2(P0_15);
martinale 0:425c87a33e63 9
DoTTi 1:3a95f280192d 10
DoTTi 1:3a95f280192d 11 // Zustandsangebe
DoTTi 1:3a95f280192d 12 BusOut stLED(P1_13,P1_12);
DoTTi 1:3a95f280192d 13
DoTTi 1:3a95f280192d 14
martinale 0:425c87a33e63 15 int blinkIdx = 0;
martinale 0:425c87a33e63 16 int hh=0, mm=0;
martinale 0:425c87a33e63 17
martinale 0:425c87a33e63 18 void ShowMode();
martinale 0:425c87a33e63 19 void ShowTime();
martinale 0:425c87a33e63 20
martinale 0:425c87a33e63 21 int main()
martinale 0:425c87a33e63 22 {
martinale 0:425c87a33e63 23 pc.baud(500000);
martinale 0:425c87a33e63 24 sw4.Init(); sw3.Init(); sw1.Init(); sw2.Init();
martinale 0:425c87a33e63 25 ShowMode();
martinale 0:425c87a33e63 26 ShowTime();
martinale 0:425c87a33e63 27
martinale 0:425c87a33e63 28 Timer t1; t1.start();
martinale 0:425c87a33e63 29 while(1)
martinale 0:425c87a33e63 30 {
martinale 0:425c87a33e63 31 if( sw4.CheckFlag() ) {
martinale 0:425c87a33e63 32 if( blinkIdx==-1 )
martinale 0:425c87a33e63 33 blinkIdx=0;
martinale 0:425c87a33e63 34 else if( blinkIdx==0 )
martinale 0:425c87a33e63 35 blinkIdx=3;
martinale 0:425c87a33e63 36 else if( blinkIdx==3 )
martinale 0:425c87a33e63 37 blinkIdx=-1;
martinale 0:425c87a33e63 38 ShowMode();
martinale 0:425c87a33e63 39 }
DoTTi 1:3a95f280192d 40
DoTTi 1:3a95f280192d 41
DoTTi 1:3a95f280192d 42 if( t1.read_ms()>50 ) { // Ausgabe (20Hz)
martinale 0:425c87a33e63 43 t1.reset();
martinale 0:425c87a33e63 44 if( blinkIdx==-1 ) {
martinale 0:425c87a33e63 45 mm++;
DoTTi 1:3a95f280192d 46 if( mm>59 )
martinale 0:425c87a33e63 47 { mm=0; hh++; }
DoTTi 1:3a95f280192d 48 if( hh>23 )
DoTTi 1:3a95f280192d 49 { hh=0; }
martinale 0:425c87a33e63 50 ShowTime();
martinale 0:425c87a33e63 51 }
martinale 0:425c87a33e63 52 }
DoTTi 1:3a95f280192d 53
DoTTi 1:3a95f280192d 54
DoTTi 1:3a95f280192d 55 if( blinkIdx==0 ) { //EditH
martinale 0:425c87a33e63 56 if( sw3.CheckFlag() ) {
martinale 0:425c87a33e63 57 hh++;
DoTTi 1:3a95f280192d 58 if( hh>23 ) hh=0;
martinale 0:425c87a33e63 59 ShowTime();
martinale 0:425c87a33e63 60 }
martinale 0:425c87a33e63 61 }
DoTTi 1:3a95f280192d 62
DoTTi 1:3a95f280192d 63
DoTTi 1:3a95f280192d 64 if( blinkIdx==3 ) { // EditM
martinale 0:425c87a33e63 65 if( sw3.CheckFlag() ) {
martinale 0:425c87a33e63 66 mm++;
DoTTi 1:3a95f280192d 67 if( mm>59 ) mm=0;
martinale 0:425c87a33e63 68 ShowTime();
martinale 0:425c87a33e63 69 }
martinale 0:425c87a33e63 70 }
martinale 0:425c87a33e63 71 }
martinale 0:425c87a33e63 72 }
martinale 0:425c87a33e63 73
martinale 0:425c87a33e63 74 void ShowMode()
martinale 0:425c87a33e63 75 {
DoTTi 1:3a95f280192d 76 if( blinkIdx==-1 ){
martinale 0:425c87a33e63 77 // 1..in die erste Zeile schreiben
martinale 0:425c87a33e63 78 pc.printf("1 Clock running\n");
DoTTi 1:3a95f280192d 79 stLED = 1;
DoTTi 1:3a95f280192d 80 }
DoTTi 1:3a95f280192d 81
DoTTi 1:3a95f280192d 82 if( blinkIdx==0 ){
martinale 0:425c87a33e63 83 pc.printf("1 Edit hh\n");
DoTTi 1:3a95f280192d 84 stLED = 2;
DoTTi 1:3a95f280192d 85 }
DoTTi 1:3a95f280192d 86
DoTTi 1:3a95f280192d 87 if( blinkIdx==3 ){
martinale 0:425c87a33e63 88 pc.printf("1 Edit mm\n");
DoTTi 1:3a95f280192d 89 stLED = 3;
DoTTi 1:3a95f280192d 90 }
DoTTi 1:3a95f280192d 91
martinale 0:425c87a33e63 92 // 3..BlinkIndex setzen
martinale 0:425c87a33e63 93 // es blinken immer 2 Zeichen ( Spalten ) beginnend mit blinkIdx
martinale 0:425c87a33e63 94 pc.printf("3 %d\n", blinkIdx);
martinale 0:425c87a33e63 95 }
martinale 0:425c87a33e63 96
martinale 0:425c87a33e63 97 void ShowTime()
martinale 0:425c87a33e63 98 {
martinale 0:425c87a33e63 99 // 2..in die 2te Zeile schreiben
martinale 0:425c87a33e63 100 pc.printf("2 %02d:%02d\n",hh,mm);
martinale 0:425c87a33e63 101 }