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.
ble.h
00001 //state used to remember previous characters read in a button message 00002 //global variables for main and interrupt routine 00003 #include "mbed.h" 00004 volatile bool button_ready = 0; 00005 volatile int bnum = 0; 00006 volatile int bhit ; 00007 Serial Blue(p28,p27); 00008 enum statetype {start = 0, got_exclm, got_B, got_num, got_hit}; 00009 statetype state = start; 00010 void parse_message() 00011 { 00012 switch (state) { 00013 case start: 00014 if (Blue.getc()=='!') state = got_exclm; 00015 else state = start; 00016 break; 00017 case got_exclm: 00018 if (Blue.getc() == 'B') state = got_B; 00019 else state = start; 00020 break; 00021 case got_B: 00022 bnum = Blue.getc(); 00023 state = got_num; 00024 break; 00025 case got_num: 00026 bhit = Blue.getc(); 00027 state = got_hit; 00028 break; 00029 case got_hit: 00030 if (Blue.getc() == char(~('!' + ' B' + bnum + bhit))) button_ready = 1; 00031 state = start; 00032 break; 00033 default: 00034 Blue.getc(); 00035 state = start; 00036 } 00037 }
Generated on Sat Jul 23 2022 04:16:47 by
1.7.2