Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: EFM32_SegmentLCD IOFuncLib mbed
Functions.h
00001 #include <string> 00002 genFunctions fnz; 00003 00004 00005 /* 00006 * Callback for 1 second timebase 00007 */ 00008 void tickerCallback(void) 00009 { 00010 seconds++; 00011 uint32_t clockValue = ((seconds / 60) % 60) * 100 + (seconds % 60); 00012 segmentDisplay.Number(clockValue); 00013 segmentDisplay.Symbol(LCD_SYMBOL_COL10, seconds & 0x1); 00014 } 00015 00016 void blink(void) 00017 { 00018 //sarebbe bene evitare questa funzione ma il notPin non funziona direttamente dentro blinker.attach(blink, TOGGLE_RATE); 00019 led.notPin(); 00020 } 00021 00022 00023 void serialCb(int events) 00024 { 00025 /* Something triggered the callback, either buffer is full or '\n' is received */ 00026 unsigned char i; 00027 string stringout; 00028 00029 if(events & SERIAL_EVENT_RX_CHARACTER_MATCH) { 00030 //Received 'S', check for buffer length 00031 for(i = 0; i < BUFF_LENGTH; i++) { 00032 //Found the length! 00033 stringout=stringout+fnz.char2string(rx_buf[i]); 00034 if ((rx_buf[i] == '\n') || (rx_buf[i] == 'X')) break; 00035 } 00036 00037 // Toggle blinking 00038 if(blinking) { 00039 blinker.detach(); 00040 blinking = false; 00041 } else { 00042 blinker.attach(blink, TOGGLE_RATE); 00043 blinking = true; 00044 } 00045 } else if (events & SERIAL_EVENT_RX_COMPLETE) { 00046 i = BUFF_LENGTH - 1; 00047 } else { 00048 rx_buf[0] = 'E'; 00049 rx_buf[1] = 'R'; 00050 rx_buf[2] = 'R'; 00051 rx_buf[3] = '!'; 00052 rx_buf[4] = 0; 00053 i = 3; 00054 } 00055 00056 segmentDisplay.Write((char *)rx_buf); 00057 //oppure 00058 // segmentDisplay.Write((char *) stringout.c_str()); 00059 00060 // Echo string, no callback 00061 test_connection.write(rx_buf, i+1, 0, 0); 00062 00063 00064 // Reset serial reception 00065 test_connection.read(rx_buf, BUFF_LENGTH, serialEventCb, SERIAL_EVENT_RX_ALL, 'X'); 00066 } 00067 00068 void tickerCallback(void);
Generated on Thu Jul 28 2022 14:05:51 by
1.7.2