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: mbed mbed-rtos 4DGL-uLCD-SE RPCInterface
main.cpp@16:f4749ef7baa7, 2019-12-06 (annotated)
- Committer:
- robo1340
- Date:
- Fri Dec 06 18:40:27 2019 +0000
- Revision:
- 16:f4749ef7baa7
- Parent:
- 15:5120c88a7a87
- Child:
- 17:8d33d5305d26
fixed a minor bug that made the date incorrect for part of the day
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| emilmont | 1:491820ee784d | 1 | #include "mbed.h" |
| mbed_official | 11:0309bef74ba8 | 2 | #include "rtos.h" |
| robo1340 | 12:f1856a0b8ced | 3 | |
| robo1340 | 12:f1856a0b8ced | 4 | #include "mbed_rpc.h" |
| robo1340 | 12:f1856a0b8ced | 5 | #include "uLCD_4DGL.h" |
| robo1340 | 14:5b3f49d7bf19 | 6 | #include <time.h> |
| robo1340 | 14:5b3f49d7bf19 | 7 | #include <math.h> |
| robo1340 | 15:5120c88a7a87 | 8 | #include "chime.h" |
| robo1340 | 12:f1856a0b8ced | 9 | |
| robo1340 | 13:f1649dc31b04 | 10 | /* Example RPC commands that have currently been implemented |
| robo1340 | 13:f1649dc31b04 | 11 | |
| robo1340 | 15:5120c88a7a87 | 12 | /notify/run This_is_a_notification_message_that_should_be_displayed_on_the_lcd |
| robo1340 | 14:5b3f49d7bf19 | 13 | /setTime/run <unix time> <UTC offset (-5 for Atlanta)> |
| robo1340 | 14:5b3f49d7bf19 | 14 | /setTime/run 1256729737 -5 |
| robo1340 | 13:f1649dc31b04 | 15 | |
| robo1340 | 13:f1649dc31b04 | 16 | */ |
| robo1340 | 13:f1649dc31b04 | 17 | |
| robo1340 | 14:5b3f49d7bf19 | 18 | volatile bool display_notification = false; |
| robo1340 | 14:5b3f49d7bf19 | 19 | volatile bool display_time = true; |
| robo1340 | 14:5b3f49d7bf19 | 20 | |
| robo1340 | 14:5b3f49d7bf19 | 21 | volatile int utc_offset; //keeps track of the current timezone of the watch |
| robo1340 | 14:5b3f49d7bf19 | 22 | |
| robo1340 | 12:f1856a0b8ced | 23 | uLCD_4DGL uLCD(p9,p10,p11); // serial tx, serial rx, reset pin; |
| robo1340 | 14:5b3f49d7bf19 | 24 | //Serial bluetooth(p13,p14); |
| robo1340 | 12:f1856a0b8ced | 25 | Serial pc(USBTX, USBRX); |
| robo1340 | 12:f1856a0b8ced | 26 | |
| robo1340 | 14:5b3f49d7bf19 | 27 | InterruptIn view_button(p12); |
| robo1340 | 14:5b3f49d7bf19 | 28 | |
| robo1340 | 13:f1649dc31b04 | 29 | Mutex stdio_mutex; //mutex used when accessing stdio functions |
| robo1340 | 14:5b3f49d7bf19 | 30 | Mutex lcd_mutex; //mutex used when accessing the lcd object |
| robo1340 | 12:f1856a0b8ced | 31 | |
| robo1340 | 13:f1649dc31b04 | 32 | Thread bluetooth_thread; //thread responsible for receiving rpc commands over bluetooth |
| robo1340 | 13:f1649dc31b04 | 33 | Thread time_thread; //thread responsible for updating the lcd with the current time |
| robo1340 | 12:f1856a0b8ced | 34 | |
| robo1340 | 13:f1649dc31b04 | 35 | //rpc function prototypes |
| robo1340 | 15:5120c88a7a87 | 36 | void display_notification_rpc_func(Arguments *in, Reply *out); |
| robo1340 | 15:5120c88a7a87 | 37 | void set_time_rpc_func (Arguments *in, Reply *out); |
| robo1340 | 15:5120c88a7a87 | 38 | RPCFunction rpcWriteLCD(&display_notification_rpc_func, "notify"); |
| robo1340 | 15:5120c88a7a87 | 39 | RPCFunction rpcset_time_rpc_func(&set_time_rpc_func, "setTime"); |
| robo1340 | 15:5120c88a7a87 | 40 | |
| robo1340 | 15:5120c88a7a87 | 41 | #define sample_freq 16000.0 |
| robo1340 | 15:5120c88a7a87 | 42 | AnalogOut speaker(p18); |
| robo1340 | 15:5120c88a7a87 | 43 | Ticker notification_chime_ticker; |
| robo1340 | 15:5120c88a7a87 | 44 | |
| robo1340 | 15:5120c88a7a87 | 45 | //interrupt routine to play next audio sample from array in flash |
| robo1340 | 15:5120c88a7a87 | 46 | void audio_sample () { |
| robo1340 | 15:5120c88a7a87 | 47 | static int i=0; |
| robo1340 | 15:5120c88a7a87 | 48 | speaker.write_u16(((uint16_t)data[i]<<7)); |
| robo1340 | 15:5120c88a7a87 | 49 | i++; |
| robo1340 | 15:5120c88a7a87 | 50 | if (i>= sizeof(data)) { |
| robo1340 | 15:5120c88a7a87 | 51 | i = 0; |
| robo1340 | 15:5120c88a7a87 | 52 | notification_chime_ticker.detach(); |
| robo1340 | 15:5120c88a7a87 | 53 | } |
| robo1340 | 15:5120c88a7a87 | 54 | } |
| robo1340 | 12:f1856a0b8ced | 55 | |
| robo1340 | 14:5b3f49d7bf19 | 56 | //interrupt routine for when the input button is pressed |
| robo1340 | 15:5120c88a7a87 | 57 | //when the view button is pressed, dismiss the currently shown notification and display the current time |
| robo1340 | 14:5b3f49d7bf19 | 58 | void view_button_pressed(void){ |
| robo1340 | 14:5b3f49d7bf19 | 59 | display_notification = false; |
| robo1340 | 14:5b3f49d7bf19 | 60 | display_time = true; |
| robo1340 | 14:5b3f49d7bf19 | 61 | } |
| robo1340 | 14:5b3f49d7bf19 | 62 | |
| robo1340 | 14:5b3f49d7bf19 | 63 | //flip the y coordinate around so that standard cartesian coordinates can be used |
| robo1340 | 14:5b3f49d7bf19 | 64 | int flipy(int y_coord){ |
| robo1340 | 14:5b3f49d7bf19 | 65 | return (128-y_coord); |
| robo1340 | 14:5b3f49d7bf19 | 66 | } |
| robo1340 | 14:5b3f49d7bf19 | 67 | |
| robo1340 | 14:5b3f49d7bf19 | 68 | #define C_X 64 |
| robo1340 | 14:5b3f49d7bf19 | 69 | #define C_Y 64 |
| robo1340 | 14:5b3f49d7bf19 | 70 | #define M_PI 3.141592 |
| robo1340 | 14:5b3f49d7bf19 | 71 | //create the tick marks for an analog clock on the lcd display |
| robo1340 | 14:5b3f49d7bf19 | 72 | void setup_analog_clock(uint32_t color){ |
| robo1340 | 14:5b3f49d7bf19 | 73 | |
| robo1340 | 14:5b3f49d7bf19 | 74 | lcd_mutex.lock(); |
| robo1340 | 14:5b3f49d7bf19 | 75 | uLCD.filled_circle(64, 64, 5, color); //centercircle |
| robo1340 | 14:5b3f49d7bf19 | 76 | double angle; |
| robo1340 | 14:5b3f49d7bf19 | 77 | //start from 3 oclock and draw all the clock tick marks counter-clockwise |
| robo1340 | 14:5b3f49d7bf19 | 78 | for(angle = 0; angle < (2*M_PI)-(M_PI/12); angle += M_PI/6){ |
| robo1340 | 14:5b3f49d7bf19 | 79 | uLCD.line(54*cos(angle)+C_X,flipy(54*sin(angle)+C_Y), 64*cos(angle)+C_X,flipy(64*sin(angle)+C_Y), color); //3 oclock tick mark |
| robo1340 | 14:5b3f49d7bf19 | 80 | } |
| robo1340 | 14:5b3f49d7bf19 | 81 | lcd_mutex.unlock(); |
| robo1340 | 14:5b3f49d7bf19 | 82 | |
| robo1340 | 14:5b3f49d7bf19 | 83 | } |
| robo1340 | 14:5b3f49d7bf19 | 84 | |
| robo1340 | 14:5b3f49d7bf19 | 85 | #define RAD_PER_SEC (2*M_PI)/60 |
| robo1340 | 14:5b3f49d7bf19 | 86 | #define RAD_PER_MIN (2*M_PI)/60 |
| robo1340 | 14:5b3f49d7bf19 | 87 | #define RAD_PER_HOUR (2*M_PI)/12 |
| robo1340 | 15:5120c88a7a87 | 88 | //function to handle the display of the time on the lcd screen |
| robo1340 | 14:5b3f49d7bf19 | 89 | void show_time_analog(int sec, int minute, int hour, int day, int month, int year, uint32_t sec_color, uint32_t min_color, uint32_t hour_color, uint32_t back_color) { |
| robo1340 | 14:5b3f49d7bf19 | 90 | static double angle; |
| robo1340 | 14:5b3f49d7bf19 | 91 | static int prev_sec; |
| robo1340 | 14:5b3f49d7bf19 | 92 | static int prev_minute; |
| robo1340 | 14:5b3f49d7bf19 | 93 | static int prev_hour; |
| robo1340 | 14:5b3f49d7bf19 | 94 | |
| robo1340 | 14:5b3f49d7bf19 | 95 | lcd_mutex.lock(); |
| robo1340 | 14:5b3f49d7bf19 | 96 | |
| robo1340 | 14:5b3f49d7bf19 | 97 | //tear down the previous hands that were drawn |
| robo1340 | 14:5b3f49d7bf19 | 98 | angle = -(RAD_PER_SEC*prev_sec) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 99 | uLCD.line(C_X,C_Y,64*cos(angle)+C_X, flipy(64*sin(angle)+C_Y),back_color); |
| robo1340 | 14:5b3f49d7bf19 | 100 | |
| robo1340 | 14:5b3f49d7bf19 | 101 | angle = -(RAD_PER_MIN*prev_minute) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 102 | uLCD.line(C_X,C_Y,52*cos(angle)+C_X, flipy(52*sin(angle)+C_Y),back_color); |
| robo1340 | 14:5b3f49d7bf19 | 103 | |
| robo1340 | 14:5b3f49d7bf19 | 104 | angle = -(RAD_PER_HOUR*prev_hour) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 105 | uLCD.line(C_X,C_Y,40*cos(angle)+C_X, flipy(40*sin(angle)+C_Y),back_color); |
| robo1340 | 14:5b3f49d7bf19 | 106 | |
| robo1340 | 14:5b3f49d7bf19 | 107 | //draw the new hands |
| robo1340 | 14:5b3f49d7bf19 | 108 | angle = -(RAD_PER_SEC*sec) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 109 | uLCD.line(C_X,C_Y,64*cos(angle)+C_X, flipy(64*sin(angle)+C_Y),sec_color); |
| robo1340 | 14:5b3f49d7bf19 | 110 | |
| robo1340 | 14:5b3f49d7bf19 | 111 | angle = -(RAD_PER_MIN*minute) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 112 | uLCD.line(C_X,C_Y,52*cos(angle)+C_X, flipy(52*sin(angle)+C_Y),min_color); |
| robo1340 | 14:5b3f49d7bf19 | 113 | |
| robo1340 | 14:5b3f49d7bf19 | 114 | angle = -(RAD_PER_HOUR*hour) + M_PI/2; |
| robo1340 | 14:5b3f49d7bf19 | 115 | uLCD.line(C_X,C_Y,40*cos(angle)+C_X, flipy(40*sin(angle)+C_Y),hour_color); |
| robo1340 | 14:5b3f49d7bf19 | 116 | |
| robo1340 | 14:5b3f49d7bf19 | 117 | stdio_mutex.lock(); |
| robo1340 | 14:5b3f49d7bf19 | 118 | |
| robo1340 | 14:5b3f49d7bf19 | 119 | //print the current date in a month/day/year format |
| robo1340 | 14:5b3f49d7bf19 | 120 | uLCD.locate(4,10); |
| robo1340 | 14:5b3f49d7bf19 | 121 | uLCD.printf("%2d/%2d/%4d",month, day, year); |
| robo1340 | 14:5b3f49d7bf19 | 122 | uLCD.locate(8,11); |
| robo1340 | 14:5b3f49d7bf19 | 123 | if (hour < 12) {uLCD.printf("AM");} |
| robo1340 | 14:5b3f49d7bf19 | 124 | else {uLCD.printf("PM");} |
| robo1340 | 14:5b3f49d7bf19 | 125 | |
| robo1340 | 14:5b3f49d7bf19 | 126 | stdio_mutex.unlock(); |
| robo1340 | 14:5b3f49d7bf19 | 127 | lcd_mutex.unlock(); |
| robo1340 | 14:5b3f49d7bf19 | 128 | |
| robo1340 | 14:5b3f49d7bf19 | 129 | //store the location of the current hands |
| robo1340 | 14:5b3f49d7bf19 | 130 | prev_sec = sec; |
| robo1340 | 14:5b3f49d7bf19 | 131 | prev_minute = minute; |
| robo1340 | 14:5b3f49d7bf19 | 132 | prev_hour = hour; |
| robo1340 | 14:5b3f49d7bf19 | 133 | } |
| robo1340 | 12:f1856a0b8ced | 134 | |
| robo1340 | 15:5120c88a7a87 | 135 | //function to update the time displayed on the lcd approximately every second |
| robo1340 | 12:f1856a0b8ced | 136 | void time_thread_func() { |
| robo1340 | 14:5b3f49d7bf19 | 137 | struct tm * t; //time struct defined in time.h |
| robo1340 | 15:5120c88a7a87 | 138 | static time_t unix_time; //the time in unix time |
| robo1340 | 15:5120c88a7a87 | 139 | static bool prev_display_time; //indicates whether time was being displayed the last time the thread ran |
| robo1340 | 14:5b3f49d7bf19 | 140 | |
| robo1340 | 12:f1856a0b8ced | 141 | while (true) { |
| robo1340 | 14:5b3f49d7bf19 | 142 | if (display_time == true) { |
| robo1340 | 14:5b3f49d7bf19 | 143 | if (prev_display_time == false){ //clear whatever was previously on the screen |
| robo1340 | 14:5b3f49d7bf19 | 144 | lcd_mutex.lock(); |
| robo1340 | 14:5b3f49d7bf19 | 145 | uLCD.cls(); |
| robo1340 | 14:5b3f49d7bf19 | 146 | lcd_mutex.unlock(); |
| robo1340 | 14:5b3f49d7bf19 | 147 | } |
| robo1340 | 14:5b3f49d7bf19 | 148 | unix_time = time(NULL); |
| robo1340 | 14:5b3f49d7bf19 | 149 | t = localtime(&unix_time); |
| robo1340 | 14:5b3f49d7bf19 | 150 | |
| robo1340 | 14:5b3f49d7bf19 | 151 | setup_analog_clock(WHITE); |
| robo1340 | 16:f4749ef7baa7 | 152 | show_time_analog(t->tm_sec,t->tm_min,t->tm_hour,t->tm_mday,t->tm_mon+1,t->tm_year+1900,RED+BLUE,WHITE,BLUE,BLACK); |
| robo1340 | 14:5b3f49d7bf19 | 153 | } |
| robo1340 | 14:5b3f49d7bf19 | 154 | prev_display_time = display_time; |
| robo1340 | 12:f1856a0b8ced | 155 | |
| robo1340 | 12:f1856a0b8ced | 156 | Thread::wait(1000); //only update every second |
| robo1340 | 12:f1856a0b8ced | 157 | } |
| robo1340 | 12:f1856a0b8ced | 158 | |
| robo1340 | 12:f1856a0b8ced | 159 | } |
| robo1340 | 12:f1856a0b8ced | 160 | |
| robo1340 | 15:5120c88a7a87 | 161 | //function to continuously take in characters over bluetooth serial and parse them as RPC commands |
| robo1340 | 12:f1856a0b8ced | 162 | void bluetooth_thread_func() { |
| robo1340 | 12:f1856a0b8ced | 163 | char buf[256], outbuf[256]; |
| robo1340 | 12:f1856a0b8ced | 164 | uint16_t buf_pos = 0; |
| robo1340 | 12:f1856a0b8ced | 165 | |
| robo1340 | 12:f1856a0b8ced | 166 | while(true) { |
| robo1340 | 12:f1856a0b8ced | 167 | |
| robo1340 | 13:f1649dc31b04 | 168 | if (pc.readable() == true) { //comment out when using bluetooth to receive rpc commands |
| robo1340 | 12:f1856a0b8ced | 169 | //if (bluetooth.readable() == true) { |
| robo1340 | 12:f1856a0b8ced | 170 | |
| robo1340 | 12:f1856a0b8ced | 171 | stdio_mutex.lock(); |
| robo1340 | 12:f1856a0b8ced | 172 | |
| robo1340 | 13:f1649dc31b04 | 173 | buf[buf_pos] = pc.getc(); //comment out when using bluetooth to receive rpc commands |
| robo1340 | 12:f1856a0b8ced | 174 | //buf[buf_pos] = bluetooth.getc(); |
| robo1340 | 12:f1856a0b8ced | 175 | |
| robo1340 | 12:f1856a0b8ced | 176 | stdio_mutex.unlock(); |
| robo1340 | 12:f1856a0b8ced | 177 | |
| robo1340 | 12:f1856a0b8ced | 178 | if (buf[buf_pos] == '\n') { //the end of the RPC command has been received |
| robo1340 | 15:5120c88a7a87 | 179 | buf[buf_pos] = '\0'; //replace the newline character with a null character |
| robo1340 | 12:f1856a0b8ced | 180 | buf_pos = 0; |
| robo1340 | 12:f1856a0b8ced | 181 | RPC::call(buf, outbuf); //make an RPC call |
| robo1340 | 12:f1856a0b8ced | 182 | |
| robo1340 | 12:f1856a0b8ced | 183 | stdio_mutex.lock(); |
| robo1340 | 12:f1856a0b8ced | 184 | pc.printf("%s\n", outbuf); //send the response |
| robo1340 | 12:f1856a0b8ced | 185 | stdio_mutex.unlock(); |
| robo1340 | 12:f1856a0b8ced | 186 | } |
| robo1340 | 12:f1856a0b8ced | 187 | else { |
| robo1340 | 12:f1856a0b8ced | 188 | buf_pos++; |
| robo1340 | 12:f1856a0b8ced | 189 | } |
| robo1340 | 12:f1856a0b8ced | 190 | |
| robo1340 | 12:f1856a0b8ced | 191 | } else { |
| robo1340 | 12:f1856a0b8ced | 192 | Thread::yield(); |
| robo1340 | 12:f1856a0b8ced | 193 | } |
| robo1340 | 12:f1856a0b8ced | 194 | |
| emilmont | 1:491820ee784d | 195 | } |
| emilmont | 1:491820ee784d | 196 | } |
| robo1340 | 12:f1856a0b8ced | 197 | |
| robo1340 | 15:5120c88a7a87 | 198 | //RPC function to receive the current time |
| robo1340 | 15:5120c88a7a87 | 199 | //the first argument is unix time and the second argument is the offset from UTC time |
| robo1340 | 15:5120c88a7a87 | 200 | void set_time_rpc_func (Arguments *in, Reply *out) { |
| robo1340 | 12:f1856a0b8ced | 201 | static const char * unix_time_str; |
| robo1340 | 12:f1856a0b8ced | 202 | uint32_t unix_time; |
| robo1340 | 14:5b3f49d7bf19 | 203 | int offset; |
| robo1340 | 12:f1856a0b8ced | 204 | unix_time_str = in->getArg<const char*>(); //get a pointer to the location where the argument string is stored |
| robo1340 | 15:5120c88a7a87 | 205 | offset = in->getArg<int>(); //get the second argument which indicates the offeset (in hours) from UTC time |
| robo1340 | 12:f1856a0b8ced | 206 | unix_time = atoll(unix_time_str); |
| robo1340 | 14:5b3f49d7bf19 | 207 | utc_offset = offset; |
| robo1340 | 12:f1856a0b8ced | 208 | |
| robo1340 | 16:f4749ef7baa7 | 209 | set_time(unix_time + utc_offset*(3600.0)); |
| emilmont | 1:491820ee784d | 210 | |
| emilmont | 1:491820ee784d | 211 | } |
| robo1340 | 12:f1856a0b8ced | 212 | |
| robo1340 | 12:f1856a0b8ced | 213 | |
| robo1340 | 15:5120c88a7a87 | 214 | //RPC function to receive notification strings |
| robo1340 | 15:5120c88a7a87 | 215 | //note notification strings should not contain the character ' ', in lieu |
| robo1340 | 15:5120c88a7a87 | 216 | //they should contain '_' to indicate spaces |
| robo1340 | 15:5120c88a7a87 | 217 | void display_notification_rpc_func (Arguments *in, Reply *out) { |
| robo1340 | 14:5b3f49d7bf19 | 218 | static char display_str[18]; |
| robo1340 | 12:f1856a0b8ced | 219 | static const char * msg_str; |
| robo1340 | 14:5b3f49d7bf19 | 220 | int i,j; |
| robo1340 | 14:5b3f49d7bf19 | 221 | bool break_out = false; |
| robo1340 | 14:5b3f49d7bf19 | 222 | |
| robo1340 | 14:5b3f49d7bf19 | 223 | display_notification = true; |
| robo1340 | 14:5b3f49d7bf19 | 224 | display_time = false; |
| robo1340 | 12:f1856a0b8ced | 225 | |
| robo1340 | 12:f1856a0b8ced | 226 | msg_str = in->getArg<const char*>(); //get a pointer to the location where the argument string is stored |
| robo1340 | 12:f1856a0b8ced | 227 | |
| robo1340 | 12:f1856a0b8ced | 228 | stdio_mutex.lock(); |
| robo1340 | 12:f1856a0b8ced | 229 | lcd_mutex.lock(); |
| robo1340 | 12:f1856a0b8ced | 230 | |
| robo1340 | 14:5b3f49d7bf19 | 231 | uLCD.cls(); |
| robo1340 | 14:5b3f49d7bf19 | 232 | uLCD.locate(0,0); |
| robo1340 | 14:5b3f49d7bf19 | 233 | i = 0; |
| robo1340 | 14:5b3f49d7bf19 | 234 | while(true){ |
| robo1340 | 14:5b3f49d7bf19 | 235 | for(j=0; j<18; j++){ |
| robo1340 | 14:5b3f49d7bf19 | 236 | if (msg_str[i+j] == '_'){ |
| robo1340 | 14:5b3f49d7bf19 | 237 | display_str[j] = ' '; |
| robo1340 | 14:5b3f49d7bf19 | 238 | } else { |
| robo1340 | 14:5b3f49d7bf19 | 239 | display_str[j] = msg_str[i+j]; |
| robo1340 | 14:5b3f49d7bf19 | 240 | } |
| robo1340 | 14:5b3f49d7bf19 | 241 | if (msg_str[i+j] == '\0') {break_out = true; break;} |
| robo1340 | 14:5b3f49d7bf19 | 242 | } |
| robo1340 | 14:5b3f49d7bf19 | 243 | i+= 18; |
| robo1340 | 14:5b3f49d7bf19 | 244 | uLCD.printf("%s\r\n",display_str); |
| robo1340 | 14:5b3f49d7bf19 | 245 | if (break_out){break;} |
| robo1340 | 14:5b3f49d7bf19 | 246 | } |
| robo1340 | 12:f1856a0b8ced | 247 | |
| robo1340 | 12:f1856a0b8ced | 248 | stdio_mutex.unlock(); |
| robo1340 | 12:f1856a0b8ced | 249 | lcd_mutex.unlock(); |
| robo1340 | 12:f1856a0b8ced | 250 | |
| robo1340 | 15:5120c88a7a87 | 251 | notification_chime_ticker.attach(&audio_sample, 1.0/sample_freq); |
| robo1340 | 15:5120c88a7a87 | 252 | |
| robo1340 | 12:f1856a0b8ced | 253 | } |
| robo1340 | 15:5120c88a7a87 | 254 | |
| robo1340 | 15:5120c88a7a87 | 255 | int main() { |
| robo1340 | 15:5120c88a7a87 | 256 | |
| robo1340 | 15:5120c88a7a87 | 257 | uLCD.baudrate(3000000); //increase the lcd baud rate |
| robo1340 | 15:5120c88a7a87 | 258 | |
| robo1340 | 15:5120c88a7a87 | 259 | //configure the input button and attach an interrupt routine to it |
| robo1340 | 15:5120c88a7a87 | 260 | view_button.mode(PullUp); |
| robo1340 | 15:5120c88a7a87 | 261 | view_button.fall(&view_button_pressed); |
| robo1340 | 15:5120c88a7a87 | 262 | |
| robo1340 | 15:5120c88a7a87 | 263 | |
| robo1340 | 15:5120c88a7a87 | 264 | bluetooth_thread.start(bluetooth_thread_func); //start the thread that takes in characters to construct RPC commands |
| robo1340 | 15:5120c88a7a87 | 265 | time_thread.start(time_thread_func); //start the thread that updates the displayed time |
| robo1340 | 15:5120c88a7a87 | 266 | |
| robo1340 | 15:5120c88a7a87 | 267 | } |