![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Display zeigt merkwürdige Zeichen
Dependencies: mbed PinDetect TextLCD
Fork of FWFSU_Start_28102013 by
Revision 35:1fcb3101c2f9, committed 2016-08-24
- Comitter:
- fox46
- Date:
- Wed Aug 24 13:12:18 2016 +0000
- Branch:
- oldschool
- Parent:
- 34:71b726a58856
- Commit message:
- Display zeigt merkw?rdige zeichen;
Changed in this revision
diff -r 71b726a58856 -r 1fcb3101c2f9 EventBus.lib --- a/EventBus.lib Fri Aug 12 09:59:19 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/KX-ONE/code/EventBus/#02b9f6ad14df
diff -r 71b726a58856 -r 1fcb3101c2f9 MsgSerial_v1_0.lib --- a/MsgSerial_v1_0.lib Fri Aug 12 09:59:19 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/KX-ONE/code/MsgSerial_v1_0/#f42e1ff6c331
diff -r 71b726a58856 -r 1fcb3101c2f9 common.lib --- a/common.lib Fri Aug 12 09:59:19 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/KX-ONE/code/common/#684a4951d1e4
diff -r 71b726a58856 -r 1fcb3101c2f9 linked_list.lib --- a/linked_list.lib Fri Aug 12 09:59:19 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -https://developer.mbed.org/teams/KX-ONE/code/linked_list/#306fe28933a5
diff -r 71b726a58856 -r 1fcb3101c2f9 main.cpp --- a/main.cpp Fri Aug 12 09:59:19 2016 +0000 +++ b/main.cpp Wed Aug 24 13:12:18 2016 +0000 @@ -1,452 +1,590 @@ -#include "main.h" +#include "mbed.h" +#include "PinDetect.h" +#include "stdlib.h" +#include "TextLCD.h" -using namespace evtbus; -using namespace evt; -using namespace msg; - -EventBus ebus; - -time_100us ping_flag = 0; +#define ulow 3.3 //definiere Symbolische Konstante für ulow mit dem Wert xx +#define u_shutdown 3.1 //Konstante für shutdown bei zu geringer Akkuspannung muss immer kleiner als charge4 sein!!! +#define charge1 4 +#define charge2 3.7 +#define charge3 3.4 +#define charge4 3.2 -/** - * Synchronize with the slave - */ -void resync( void ) { - Message *m = new Message(MSG_CODE_TOTAL_RESET, ""); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - comm_flags = 0; - buzzer_state = 0; - button_state = 0; - D = MIN_ROUND_CNT; -} - -/******************************************************************************************** - INTERRUPT SERVICE ROUTINES (those raise all events!) - ********************************************************************************************/ +Timer timer1; +Timer t; +TextLCD lcd(p34, p23, p36, p15, p16, p35); // rs, e, d0-d3 für 130110-1P1 +PinDetect pb1(p18); //Buzzer +PinDetect pb2(p19); //LED-Button +DigitalIn dip0(p26); //Hex-Schalter Pin 1 LSB +DigitalIn dip1(p27); //Hex-schalter Pin 2 +DigitalIn dip2(p28); //Hex-schalter Pin 3 +DigitalIn dip3(p29); //Hex-Schalter Pin 4 MSB +//Serial hm(p13, p14); // definiere UART fuer HM-TPR433 Modul LPC1768 +Serial hm(p9, p10); // definiere UART fr HM-TPR433 Modul LPC11U24 +DigitalOut config(p22); +DigitalOut enable(p21); +DigitalOut stoppled(p25); //LED-Button +DigitalOut kill(p8); +DigitalOut suspend_charge(p7); //enables LION Charger suspend mode +DigitalOut highpower_charge(p6); // high- 100% charge current, low- 20% charge current +DigitalOut ChargeLed1(LED1); +DigitalOut ChargeLed2(LED2); +DigitalOut ChargeLed3(LED3); +DigitalOut ChargeLed4(LED4); +AnalogIn ubat(p17); +AnalogIn charge_current(p20); -void bzr_pressed( void ) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(1, 0, ts, NULL); -} +Ticker time1; +Ticker timelong; -void bzr_held_pressed( void ) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(2, 0, ts, NULL); -} +int volatile count=0; +int volatile resetcnt=0; +int volatile zz1=0; +int volatile zz2=0; +int volatile sblock=0; +int volatile reset=0; +int volatile D=1; +int volatile j=0; -void btn_pressed( void ) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(3, 0, ts, NULL); -} +int ms; +int sec; +int min; +int ms1; -void btn_held_released( void ) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(4, 0, ts, NULL); -} +int firsthit=1; + +int empfangi=0; + +int debug=0; +int timerwert=0; + +float u_akku=0; + -void beam_pressed(void) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(5, 0, ts, NULL); -} + +char buffer[9]; +char buffer1[9]; +char temp[20]; -void hdl_rec( void ) { - time_100us ts = systime; - ebus.setInterruptContext(); - ebus.raiseEvent(6, 0, ts, NULL); -} +char zwischenzeit[9]; +char zwischenzeit1[9]; + +char transmit=0; -/******************************************************************************************** - EVENT BUS FUNCTIONS - ********************************************************************************************/ +/*Funktions Dekleration*/ -char handleEvent_01_BuzzerPressed(Event *e) { - if ((comm_flags & FLAG_START) == 0) - ebus.raiseEvent(7, 0, e->timestamp, NULL); - else if ((comm_flags & FLAG_STOP) == 0 && (comm_flags & FLAG_SNAP_0) == 0) //only when stop has not been pressed - ebus.raiseEvent(8, 0, e->timestamp, NULL); - else if ((comm_flags & FLAG_STOP) == 0 && (comm_flags & FLAG_SNAP_1) == 0) - ebus.raiseEvent(9, 0, e->timestamp, NULL); - else if ((comm_flags & FLAG_STOP) == 0) - ebus.raiseEvent(10, 0, e->timestamp, NULL); - - delete e; - return 0; -} +void konfiguration(void) +{ + config = 0; + enable = 0; + wait(0.1); + +/*******Standardkonfiguration laden*******/ + hm.putc(0xAA); /******/ + hm.putc(0xFA); /******/ + hm.putc(0xF0); /******/ +/*****************************************/ + +wait(0.1); -char handleEvent_02_StartNextRun(Event *e) { - reset(); - - ebus.raiseEvent(11, 0, e->timestamp, NULL); - - delete e; - return 0; -} +if((dip0 == 1) && (dip1 == 1) && (dip2 == 1) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xCF); hm.putc(0xD1); hm.putc(0x90); //HEX-Schalter 0 + } + else if((dip0 == 0) && (dip1 == 1) && (dip2 == 1) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD1); hm.putc(0x58); hm.putc(0x30); //HEX-Schalter 1 + } + else if((dip0 == 1) && (dip1 == 0) && (dip2 == 1) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD2); hm.putc(0xDE); hm.putc(0xD0); //HEX-Schalter 2 + } + else if((dip0 == 0) && (dip1 == 0) && (dip2 == 1) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD4); hm.putc(0x65); hm.putc(0x70); //HEX-Schalter 3 + } + else if((dip0 == 1) && (dip1 == 1) && (dip2 == 0) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD5); hm.putc(0xEC); hm.putc(0x10); //HEX-Schalter 4 + } + else if((dip0 == 0) && (dip1 == 1) && (dip2 == 0) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD7); hm.putc(0x72); hm.putc(0xB0); //HEX-Schalter 5 + } + else if((dip0 == 1) && (dip1 == 0) && (dip2 == 0) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xD8); hm.putc(0xF9); hm.putc(0x50); //HEX-Schalter 6 + } + else if((dip0 == 0) && (dip1 == 0) && (dip2 == 0) && (dip3 == 1)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xDA); hm.putc(0x7F); hm.putc(0xF0); //HEX-Schalter 7 + } + else if((dip0 == 1) && (dip1 == 1) && (dip2 == 1) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xDC); hm.putc(0x06); hm.putc(0x90); //HEX-Schalter 8 + } + else if((dip0 == 0) && (dip1 == 1) && (dip2 == 1) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xDD); hm.putc(0x8D); hm.putc(0x30); //HEX-Schalter 9 + } + else if((dip0 == 1) && (dip1 == 0) && (dip2 == 1) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xDF); hm.putc(0x13); hm.putc(0xD0); //HEX-Schalter A + } + else if((dip0 == 0) && (dip1 == 0) && (dip2 == 1) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xE0); hm.putc(0x9A); hm.putc(0x70); //HEX-Schalter B + } + else if((dip0 == 1) && (dip1 == 1) && (dip2 == 0) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xE2); hm.putc(0x21); hm.putc(0x10); //HEX-Schalter C + } + else if((dip0 == 0) && (dip1 == 1) && (dip2 == 0) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xE3); hm.putc(0xA7); hm.putc(0xB0); //HEX-Schalter D + } + else if((dip0 == 1) && (dip1 == 0) && (dip2 == 0) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xE5); hm.putc(0x2E); hm.putc(0x50); //HEX-Schalter E + } + else if((dip0 == 0) && (dip1 == 0) && (dip2 == 0) && (dip3 == 0)) + { + hm.putc(0xAA);hm.putc(0xFA);hm.putc(0xD2);hm.putc(0x19); hm.putc(0xE6); hm.putc(0xB4); hm.putc(0xF0); //HEX-Schalter F + } + else + { +stoppled=1; + } + wait(0.1); -char handleEvent_03_Resync(Event *e) { - resync(); - - delete e; - return 0; -} - -char handleEvent_04_Shutdown(Event *e) { - shutdown_seq(); - - delete e; - return 0; +/*******Reading the current Config parameter*******/ +/*hm.putc(0xAA); + hm.putc(0xFA); + hm.putc(0xE1); +*/ +// wait(0.1); + config = 1; + enable = 0; + return; } -char handleEvent_05_BeamPressed(Event *e) { - ebus.raiseEvent(7, 0, e->timestamp, NULL); - - delete e; - return 0; +void stoppuhr(void) +{ + ms = t.read_ms(); //hole mir den TimerWert in ms + sec = (ms/1000); //erzeuge mir durch division eine sekunde - aktueller Timerwert/1000 - z.b: 2548/1000=2sec + ms = ms - (sec*1000); //stelle meine ms richtig + min = (sec/60); //erzeuge mir Minuten + sec = sec - (min*60); //stelle Sekunden richtig + ms = (ms/10); + ms1 = (ms/10); + //erzeuge mir zwei Stellen nach komma + sprintf(buffer, "%02d:%02d:%02d", min, sec, ms); //schreibe in den buffer + return; } -char handleEvent_06_Receive(Event *e) { - Message *m; - char e_b[EVENT_DATA_LENGTH] = { 0 }; - - /* - if (ser.available() == 0) { - delete e; - return 0; +void starten(void) // Callback routine is interrupt activated by a debounced pb1 hit +{ + + if ((resetcnt==0) && (sblock==0)) { + t.reset(); //restiere Timer + t.start(); //starte Timer + resetcnt=1; + enable = 0; //schalte das RF-Modul ein + firsthit=0; //verhindert ein erhöhen der Variable sblock durch wiederholtes drücken des Buzzers. + } else if ((resetcnt==1) && (sblock==0)) { + zz1=1; + sprintf(zwischenzeit,"%01d:%02d:%1d", min, sec, ms1); + lcd.locate(0, 1); + lcd.printf("A%s", zwischenzeit); + resetcnt=2; + } else if ((resetcnt==2) && (sblock==0)) { + zz2=1; + sprintf(zwischenzeit1,"%01d:%02d:%1d", min, sec, ms1); + lcd.locate(8, 1); + lcd.printf("B%s", zwischenzeit1); + resetcnt=3; + } else { //nach hundert mal drueken wieder auf restcnt auf 3 setzen - SIcherheitsmechanismus um Integerüberlauf zu vermeiden + resetcnt=resetcnt++; + if(resetcnt==100) { + resetcnt=3; + } } - */ - - /* - switch (ser.messageAvailable()) { - case MSG_AV_FLAG_NONE: - delete e; - return 2; - case MSG_AV_FLAG_MSG: - //cprintf("MSG!!!!"); - //display(); - //wait(1); - goto PROCESS_MSG; - case MSG_AV_FLAG_RESEND: - ser.resendMsg(); - ser.flush(); - delete e; - return 1; - } - */ - -PROCESS_MSG: - m = ser.getMessage(); - if (m == NULL) { - delete e; - return 2; - } - int_to_str(m->code, e_b); - strcat(e_b, m->data); - ebus.raiseEvent(12, 0, e->timestamp, e_b); - delete m; - delete e; - return 0; + resetcnt=resetcnt++; } -char handleEvent_07_Start(Event *e) { - char b[9]; - Message *m; - - if ((comm_flags & FLAG_START) == 0) { - start_tm = e->timestamp; - comm_flags |= FLAG_START; - - int_to_str(start_tm, b); - m = new Message(MSG_CODE_TMS, b); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - #ifdef DEBUG - DPRINT("start"); - #endif - } - - delete e; - return 0; +void sendkill (void) +{ + enable=0; + wait(0.1); + hm.putc(0); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('q'); + wait(0.1); + hm.putc(0); } -char handleEvent_08_Snap0(Event *e) { - char b[9]; - Message *m; - - if ((comm_flags & FLAG_SNAP_0) == 0) { - snapshot0 = e->timestamp; - comm_flags |= FLAG_SNAP_0; - - int_to_str(snapshot0, b); - m = new Message(MSG_CODE_TML0, b); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - #ifdef DEBUG - DPRINT("snap0"); - #endif - } - - delete e; - return 0; +void sendreset(){ + enable=0; + wait(0.1); + hm.putc(0); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('x'); + wait(0.1); + hm.putc(0); + enable=0; + return; } -char handleEvent_09_Snap1(Event *e) { - char b[9]; - Message *m; - - if ((comm_flags & FLAG_SNAP_1) == 0) { - snapshot1 = e->timestamp; - comm_flags |= FLAG_SNAP_1; - - int_to_str(snapshot1, b); - m = new Message(MSG_CODE_TML1, b); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - #ifdef DEBUG - DPRINT("snap1"); - #endif - } - - delete e; - return 0; +void sendstart(){ + starten(); + transmit=1; + enable=0; + wait(0.1); + hm.putc(0); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('g'); + wait(0.1); + hm.putc(0); + enable=0; + transmit=0; + return; } -char handleEvent_10_Stop(Event *e) { - char b[9]; - Message *m; - - if ((comm_flags & FLAG_STOP) == 0) { - end_tm = e->timestamp; - comm_flags |= FLAG_STOP; - - int_to_str(end_tm, b); - m = new Message(MSG_CODE_TMP, b); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - #ifdef DEBUG - DPRINT("stop"); - #endif - } - - delete e; - return 0; -} +void sendstop(){ + enable=0; + wait(0.1); + hm.putc(0); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc('s'); + wait(0.1); + hm.putc(0); + enable=0; + return; +} -char handleEvent_11_SendReset(Event *e) { - char b[9]; - Message *m; - - int_to_str(D, b); - - #ifdef DEBUG - DPRINT("D (int)=%d\n(str)=%s", D, b); - #endif +void kill_modul(void) +{ + lcd.cls(); + lcd.printf(" shut down"); - m = new Message(MSG_CODE_RESET, b); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); + sendkill(); - //that here for not delaying the msg transfere - #ifdef DEBUG - DPRINT("reset"); - #endif - - delete e; - return 0; -} + wait(3); + kill=0; + wait (0.1); + return; +} -char handleEvent_12_MessageReceived(Event *e) { - tcode c = str_to_int(e->data); - char *msg = &e->data[8]; - - #ifdef DEBUG - //cprintf("%08x %s", c, msg); - //display(); - //wait(3); - #endif - - switch(c) { - case MSG_CODE_KILL: - ebus.raiseEvent(4, 0, e->timestamp, NULL); - break; - case MSG_CODE_RESET: - ebus.raiseEvent(2, 0, e->timestamp, NULL); - break; - case MSG_CODE_STOP: - ebus.raiseEvent(10, 0, e->timestamp, NULL); - break; - case MSG_CODE_REQ_RES: - ebus.raiseEvent(2, 0, e->timestamp, NULL); - break; - case MSG_CODE_PING: - ebus.raiseEvent(14, 0, e->timestamp, NULL); - break; - case MSG_CODE_TOTAL_RESET: - ebus.raiseEvent(3, 0, e->timestamp, NULL); - break; +void reset_startbutton( void ) +{ + if(sblock==1) { // Reset für Durchgang erhöhen + t.stop(); + t.reset(); + memset(buffer1,0,19); + stoppuhr(); + //sprintf(zwischenzeit,"%01d:%02d:%1d", min, sec, ms1); + //sprintf(zwischenzeit1,"%01d:%02d:%1d", min, sec, ms1); + resetcnt=0; + zz1=0; + zz2=0; + sblock=0; + D++; + firsthit=1; + lcd.cls(); + + sendreset(); + + if(D>99) { + D=1; + } } - - delete e; - return 0; -} + } + +void totalreset_local (void) +{ + t.stop(); + t.reset(); + stoppuhr(); + memset(buffer1,0,19); + //sprintf(zwischenzeit,"%01d:%02d:%1d", min, sec, ms1); + //sprintf(zwischenzeit1,"%01d:%02d:%1d", min, sec, ms1); + resetcnt=0; + zz1=0; + zz2=0; + sblock=0; + D=1; + firsthit=1; + time1.detach(); + lcd.cls(); +} -char handleEvent_13_YouThere(Event *e) { - Message *m; - ping_flag = systime; - - m = new Message(MSG_CODE_PING, ""); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); - - delete e; - return 0; +void stoppen (void) //Stoppen des Timers ohne Funk +{ + t.stop(); + if (firsthit==0){ + sblock=1; + } } -char handleEvent_14_Hello(Event *e) { - Message *m; - if (ping_flag) { - if ((comm_flags & FLAG_BROTHER_HERE) == 0) { - cprintf("reconnected"); - display(); - wait(0.5); - comm_flags |= FLAG_BROTHER_HERE; +void stoppled_blink() { + stoppled=!stoppled; + return; +} + +void akkucheck() +{ + if (transmit==0){ + float i=0; + + for(int t=0; t<100; t++) { + i=i+ubat.read(); + } + // 100x ubat ADC Wert abfragen und in i aufsummieren um mittels Mittelwertbildung genaueres Ergebnis zu erziehlen + + u_akku=((i/100)*4.364); + + //lcd.locate(0, 1); //debug Ausgabe + //lcd.printf("Akkucheck %3.2fV", u_akku); //debug Ausgabe + //wait(0.1); //debug Ausgabe + + if(u_akku<=ulow) { //wenn Batteriespannung kleiner als ulow dann Akku laden am LCD ausgeben + lcd.cls(); + + lcd.locate(6,0); + lcd.printf("%3.2fV", u_akku); + lcd.locate(3,1); + lcd.printf("Akku laden!"); + wait(3); + lcd.cls(); } - ping_flag = 0; - } else { - m = new Message(MSG_CODE_PING, ""); - ser.putMsg(m); - ser.flush(); - wait(FLUSH_DELAY); + /*if(u_akku>ulow) { + time1.attach(&stoppled_blink,2); + + + } + if(u_akku<=ulow) { + time1.attach(&stoppled_blink,0.5); + + }*/ + if(u_akku>=charge1) { + ChargeLed1=1; + ChargeLed2=1; + ChargeLed3=1; + ChargeLed4=1; + time1.attach(&stoppled_blink,2); + } + + else if(u_akku>=charge2) { + ChargeLed1=1; + ChargeLed2=1; + ChargeLed3=1; + ChargeLed4=0; + time1.attach(&stoppled_blink,2); + } + else if(u_akku>=charge3) { + ChargeLed1=1; + ChargeLed2=1; + ChargeLed3=0; + ChargeLed4=0; + time1.attach(&stoppled_blink,2); + } + else if(u_akku>=charge4) { + ChargeLed1=1; + ChargeLed2=0; + ChargeLed3=0; + ChargeLed4=0; + time1.attach(&stoppled_blink,0.5); + } + else if (u_akku<=u_shutdown) { + time1.detach(); + stoppled=0; + wait(3); + kill_modul(); + } + + } + + + return; + // } +} + +void empfangen() +{ + //Funktion wird aufgerufen sobald das RF-Modul Daten an TX hat - über die Interruptroutine hm.attach(&empfangen) springe ich in die Funktion + //Beim konfigurieren des Funkmoduls werden Uart Interrupts ausgelöst, diese werden durch die folgende while schleife abgefangen + //Funkmodul schickt anscheinend 4 char nach der Konfiguration + + /* while (j<4) { + j=j+1; + hm.getc(); + return; + }*/ + int i=0; + + if (hm.readable()) { + temp[empfangi] = hm.getc(); + empfangi++; + + if (temp[empfangi-1]==0) { + temp[empfangi]=0; + empfangi=0; + i=0; + + if (temp[0]=='s' && temp[1]=='s' && temp[2]=='q') { //Kommandos werden mit zwei 's' characters eingeleitet der dritte character definiert das Kommando + kill_modul(); + } else if (temp[0]=='s' && temp[1]=='s' && temp[2]=='s') { + stoppen(); + } else if (temp[0]=='s' && temp[1]=='s' && temp[2]=='x') { + reset_startbutton(); + } else if (temp[0]=='s' && temp[1]=='s' && temp[2]=='t') { + totalreset_local(); + } else if (temp[0]=='s' && temp[1]=='s' && temp[2]=='e') { //mit Kommando 'e' kann Text übertragen werden + + + for (int z=3; temp[z]!=0; z++) + // lcd.printf("%c", temp[z]); + {buffer1[i]=temp[z]; + i++; + } + buffer1[i]=0; + + //lcd.locate(4,1); + //lcd.printf("Z1:%s",buffer1); + memset(temp,0,19); + //lcd.locate(4,0); + //lcd.printf("Zx:%s",buffer1); + } + } + } - - delete e; - return 0; + return; } -int main() { - //| Element 0 | Element 1 | Element 2 | Element 3 | - //|-----------|-----------|-----------|-----------| - //| Akkucheck | LED blink | Disp-Rate | Ping | - time_100us prev[5]; +/*Funktion zur Anzeige der Batteriespannung am LCD.****** +**Unterhalb der Spannung "ulow" wird eine Aufforderung*** +** zum Batterietausch ausgegeben.************************/ +void lowbatt() +{ + float i=0; + + for(int t=0; t<100; t++) { + i=i+ubat.read(); + } // 100x ubat ADC Wert abfragen und in i aufsummieren um mittels Mittelwertbildung genaueres Ergebnis zu erziehlen + + u_akku=((i/100)*4.364); + if(u_akku>=ulow) { + lcd.cls(); + + //lcd.setUDC(unsigned char udc_Bat_Hi[],{0x0E, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x1F, 0x00}); + + lcd.printf(" Akkuspannung"); + lcd.locate(5,1); + lcd.printf("%3.2fV",u_akku); // Ausgabe der Akkuspannung + wait(2); + lcd.cls(); + + } + if(u_akku<=ulow) { //wenn Batteriespannung kleiner als ulow dann Akku laden am LCD ausgeben + lcd.cls(); + + lcd.locate(6,0); + lcd.printf("%3.2fV", u_akku); + lcd.locate(3,1); + lcd.printf("Akku laden!"); + wait(3); + lcd.cls(); - //init - init_io(); - init_values(); - tick.attach_us(&handle_systime, 100); //every 100 us - pb1.attach_asserted(&bzr_pressed); - pb1.attach_asserted_held(&bzr_held_pressed); - pb1.setSamplesTillHeld(1000); //1000 samples ---> 1ms ---> 1 second - pb1.setSampleFrequency(1000); //1ms + } + if (u_akku<=u_shutdown) { + kill_modul(); + } + return; +} + +int main() +{ + kill=1; + suspend_charge=0; + highpower_charge=1; + + + pb1.mode(PullDown); // Use internal pulldown for pushbutton + pb2.mode(PullNone); // keinen Modus verwenden + dip0.mode(PullUp); // Use internal pullup for heX-switch - on LPC1768 you need also hardware pull up resistor + dip1.mode(PullUp); // Use internal pullup for heX-switch - on LPC1768 you need also hardware pull up resistor + dip2.mode(PullUp); // Use internal pullup for heX-switch - on LPC1768 you need also hardware pull up resistor + dip3.mode(PullUp); // Use internal pullup for pushbutton - on LPC1768 you need also hardware pull up resistor - pb2.attach_deasserted(&btn_pressed); - pb2.attach_deasserted_held(&btn_held_released); - pb2.setSamplesTillHeld(200); + wait(0.01); // Delay for initial pullup to take effect + + konfiguration(); //RF Modul konfigurieren + + lowbatt(); //Batteriespannung beim Start abfragen + + pb1.attach_asserted(&sendstart); + pb1.attach_asserted_held(&reset_startbutton); + + pb2.attach_asserted(&sendstop); + pb2.attach_deasserted_held(&kill_modul); // Setup Interrupt callback functions for a pb hit + + pb1.setSampleFrequency(); + pb2.setSampleFrequency(); - beam.attach_asserted(&beam_pressed); - beam.setSampleFrequency(1000); + pb2.setSamplesTillHeld( 200 ); - //register event handlers - ebus.registerEvent(1, &handleEvent_01_BuzzerPressed); - ebus.registerEvent(2, &handleEvent_02_StartNextRun); - ebus.registerEvent(3, &handleEvent_03_Resync); - ebus.registerEvent(4, &handleEvent_04_Shutdown); - ebus.registerEvent(5, &handleEvent_05_BeamPressed); - ebus.registerEvent(6, &handleEvent_06_Receive); - ebus.registerEvent(7, &handleEvent_07_Start); - ebus.registerEvent(8, &handleEvent_08_Snap0); - ebus.registerEvent(9, &handleEvent_09_Snap1); - ebus.registerEvent(10, &handleEvent_10_Stop); - ebus.registerEvent(11, &handleEvent_11_SendReset); - ebus.registerEvent(12, &handleEvent_12_MessageReceived); - ebus.registerEvent(13, &handleEvent_13_YouThere); - ebus.registerEvent(14, &handleEvent_14_Hello); + hm.attach(&empfangen,Serial::RxIrq); // Setup Interrupt callback functions for Datareceive + timelong.attach(&akkucheck,60); //Akkutest wird alle 60sec. gestartet - //info - cprintf(RUNMODE_SERVER); - display(); - wait(WAIT_INFO_TM); - - //config - config_buttons(); - config_rf_mod(); + lcd.cls(); //debug Ausgabe + lcd.printf(" Starttaster"); //debug Ausgabe + wait(2); - //start - lowbatt(); - ser.registerRcFc(&hdl_rec); - - prev[0] = prev[1] = prev[2] = prev[3] = prev[4] = systime; - - memset(bl0, 0, LCD_BUFFERLEN); - memset(bl1, 0, LCD_BUFFERLEN); - memset(bl0_, 0, LCD_BUFFERLEN); - memset(bl1_, 0, LCD_BUFFERLEN); - - //ebus.raiseEvent(3, 0, systime, NULL); + time1.attach(&stoppled_blink,2); + timer1.start(); + lcd.cls(); - while(1) { - if (systime - prev[2] >= RATE_DISPLAY) { - prev[2] = systime; - render_time(); - display(); - } - if (systime - prev[1] >= ((akku_state >= AKKU_1)? RATE_LED_NOK : RATE_LED_OK)) { - prev[1] = systime; - stoppled.write(!stoppled.read()); - } - if (systime - prev[3] >= 50000) { //every 5 secs ping - prev[3] = systime; - //ebus.raiseEvent(13, 0, systime, NULL); - } - if (comm_flags & FLAG_INFO_LOCK && systime - info_tm >= RATE_SHOW_INFO) { - //if the flag is set it means, that we wanna show something and the time has been set --> if the difference bigger than the rate, then clear the flag - //the flag gets checked in the render_time function, to prevent that from overwriting the info text - comm_flags &= ~FLAG_INFO_LOCK; - } - if (systime - prev[0] >= RATE_CHECK_AKKU) { - prev[0] = systime; - akkucheck(); + memset (buffer,0,19); + memset (buffer1,0,19); + while (1) { + wait(.1); + //lcd.cls(); + stoppuhr(); //rufe Funktion stoppuhr auf + lcd.locate(0, 0); //setze den Cursor auf Zeichen 0 Reihe 1 + lcd.printf("D%02d", D); // Ausgabe der Durchgänge, Formatiere mein LCD-Ausgabe nach D00 (zwei stellen) + lcd.locate(4, 0); + if (buffer1[1]!=0) { + // if (strlen(buffer1)>0) { + //lcd.printf("ZE:%c%c%c%c%c%c%c%c",buffer1[0],buffer1[1],buffer1[2],buffer1[3],buffer1[4],buffer1[5],buffer1[6],buffer1[7]); + lcd.printf("ZE:%s",buffer1); + //} else { + // lcd.printf("pussy %d ",debug); + // } + } else if (buffer[1]!=0){ + lcd.printf("ZE:%s",buffer); + } - if (akku_state == AKKU_CRITICAL) { - shutdown_seq(); - } - } - if (ping_flag != 0 && systime - ping_flag >= 30000) { //3 secs - if (comm_flags & FLAG_BROTHER_HERE) { - cprintf("connection lost"); - display(); - wait(0.5); - } - comm_flags &= ~FLAG_BROTHER_HERE; - ping_flag = 0; - } - - /* - if (ser.available_()) { - ser.read(); - } - */ - - //if (systime - prev[4] > 100) { - // prev[4] = systime; - ebus.run(); - //} - } -} \ No newline at end of file + //lcd.locate(4, 1); + //lcd.printf("ZE:%s", temp); + + } + +}
diff -r 71b726a58856 -r 1fcb3101c2f9 main.h --- a/main.h Fri Aug 12 09:59:19 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -#include "dbg.h" -#include "common.h" -#include "EventBus.hpp" -#include "linked_list.h" - -#define FLUSH_DELAY 0.3f - -struct run_time { - time_100us start; - time_100us snap0; - time_100us snap1; - time_100us end; -}; - -extern evtbus::EventBus ebus; \ No newline at end of file
diff -r 71b726a58856 -r 1fcb3101c2f9 mbed.bld --- a/mbed.bld Fri Aug 12 09:59:19 2016 +0000 +++ b/mbed.bld Wed Aug 24 13:12:18 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/2241e3a39974 \ No newline at end of file