Smart watch for ECE4180 final design project. Walter Ley, Srinivas Ravindran, Nathan Weiss

Dependencies:   4DGL-uLCD-SE LSM9DS1_Library_cal_smart_watch MPL3115A2 PinDetect RTC SDFileSystem mbed-rtos mbed

Committer:
nsloth
Date:
Thu Apr 28 17:05:52 2016 +0000
Revision:
1:65e1d74a137c
Parent:
0:1dae141d9533
This is the final code for the smart watch application for the ECE 4180 final design project

Who changed what in which revision?

UserRevisionLine numberNew contents of line
nsloth 0:1dae141d9533 1 /*Final Design Project Main File || ECE 4180 Section B
nsloth 0:1dae141d9533 2 Team members:
nsloth 0:1dae141d9533 3 Nathan Weiss
nsloth 0:1dae141d9533 4 Walter Ley
nsloth 0:1dae141d9533 5 Srinivas Ravindran
nsloth 0:1dae141d9533 6 */
nsloth 0:1dae141d9533 7
nsloth 0:1dae141d9533 8 #include "mbed.h"
nsloth 0:1dae141d9533 9 #include "rtos.h"
nsloth 0:1dae141d9533 10 #include "PinDetect.h"
nsloth 0:1dae141d9533 11 #include "MPL3115A2.h"
nsloth 0:1dae141d9533 12 #include "LSM9DS1.h"
nsloth 0:1dae141d9533 13 #include "uLCD_4DGL.h"
nsloth 0:1dae141d9533 14 #include "SDFileSystem.h"
nsloth 0:1dae141d9533 15 #include "RTC.h"
nsloth 0:1dae141d9533 16 #include <stdlib.h>
nsloth 0:1dae141d9533 17 #include <iostream>
nsloth 0:1dae141d9533 18
nsloth 0:1dae141d9533 19 uLCD_4DGL uLCD(p13,p14,p17); // serial tx, serial rx, reset pin;
nsloth 0:1dae141d9533 20 I2C altI2C(p28,p27);
nsloth 0:1dae141d9533 21 Serial pc(USBTX, USBRX);
nsloth 0:1dae141d9533 22 MPL3115A2 sensor(&altI2C, NULL);
nsloth 0:1dae141d9533 23 RawSerial dev(p9,p10);
nsloth 0:1dae141d9533 24 LSM9DS1 lol(p28, p27, 0xD6, 0x3C);
nsloth 0:1dae141d9533 25 SDFileSystem sd(p5,p6,p7,p8,"sd");
nsloth 0:1dae141d9533 26 Altitude alt;
nsloth 0:1dae141d9533 27 Temperature therm;
nsloth 0:1dae141d9533 28 Mutex mut;
nsloth 0:1dae141d9533 29 DigitalOut myled(LED1);
nsloth 0:1dae141d9533 30 PwmOut red(p21); // Red led
nsloth 0:1dae141d9533 31 PwmOut blue(p22); //blue led
nsloth 0:1dae141d9533 32 PwmOut green(p23); // green LED
nsloth 0:1dae141d9533 33
nsloth 0:1dae141d9533 34 //Global variable declarations
nsloth 0:1dae141d9533 35 volatile int stepCount = 0;
nsloth 0:1dae141d9533 36 volatile bool yPassedMarker = true; //True if y passed 6000, false if y passed -6000
nsloth 0:1dae141d9533 37 volatile float thermf = 0.0;
nsloth 0:1dae141d9533 38 volatile float oldthermf = 0.0;
nsloth 0:1dae141d9533 39 volatile float altf = 0.0;
nsloth 0:1dae141d9533 40 volatile float minAltitude = 5000.0;
nsloth 0:1dae141d9533 41 volatile float maxAltitude = 0.0;
nsloth 0:1dae141d9533 42 volatile float minTemp = 1000.0;
nsloth 0:1dae141d9533 43 volatile float maxTemp = 0.0;
nsloth 0:1dae141d9533 44 char currDate[9];
nsloth 0:1dae141d9533 45
nsloth 0:1dae141d9533 46 void altSensor(void const *args){
nsloth 0:1dae141d9533 47 while(1){
nsloth 0:1dae141d9533 48 mut.lock();
nsloth 0:1dae141d9533 49 sensor.readAltitude(&alt);
nsloth 0:1dae141d9533 50 sensor.readTemperature(&therm);
nsloth 0:1dae141d9533 51 //pc.printf("Altitude: %sft, Temp: %sºF\r\n", alt.print(), therm.print());
nsloth 0:1dae141d9533 52 //pc.printf("OFF_H: 0x%X, OFF_T: 0x%X\r\n", sensor.offsetAltitude(), sensor.offsetTemperature());
nsloth 0:1dae141d9533 53 thermf = atof(therm.print());
nsloth 0:1dae141d9533 54 altf = atof(alt.print());
nsloth 0:1dae141d9533 55 if(thermf > maxTemp) {maxTemp=thermf;}
nsloth 0:1dae141d9533 56 if(thermf < minTemp) {minTemp=thermf;}
nsloth 0:1dae141d9533 57 if(altf > maxAltitude) {maxAltitude=altf;}
nsloth 0:1dae141d9533 58 if(altf < minAltitude) {minAltitude=altf;}
nsloth 0:1dae141d9533 59
nsloth 0:1dae141d9533 60 //pc.printf("Max alt: %f, min alt: %f, max temp: %f, min temp: %f\n\r", maxAltitude, minAltitude, maxTemp, minTemp);
nsloth 0:1dae141d9533 61 mut.unlock();
nsloth 0:1dae141d9533 62 Thread::wait(2000);
nsloth 0:1dae141d9533 63 }
nsloth 0:1dae141d9533 64 }
nsloth 0:1dae141d9533 65
nsloth 0:1dae141d9533 66 void stepCounter(void const *args){
nsloth 0:1dae141d9533 67 while(1){
nsloth 0:1dae141d9533 68 mut.lock();
nsloth 0:1dae141d9533 69 if(lol.accelAvailable()) {
nsloth 0:1dae141d9533 70 lol.readAccel();
nsloth 0:1dae141d9533 71
nsloth 0:1dae141d9533 72 //Step if y alternates between +/-6000 while x < -3000
nsloth 0:1dae141d9533 73 if(lol.ax < -3000) {
nsloth 0:1dae141d9533 74 //pc.printf("accel: %d %d %d\n\r", lol.ax, lol.ay, lol.az);
nsloth 0:1dae141d9533 75 if(yPassedMarker && lol.ay < -600) {
nsloth 0:1dae141d9533 76 stepCount++;
nsloth 0:1dae141d9533 77 //pc.printf("Step!\n\r");
nsloth 0:1dae141d9533 78 yPassedMarker = false;
nsloth 0:1dae141d9533 79 } else if (!yPassedMarker && lol.ay > 600) {
nsloth 0:1dae141d9533 80 stepCount++;
nsloth 0:1dae141d9533 81 //pc.printf("Step!\n\r");
nsloth 0:1dae141d9533 82 yPassedMarker = true;
nsloth 0:1dae141d9533 83 }
nsloth 0:1dae141d9533 84 }
nsloth 0:1dae141d9533 85 }
nsloth 0:1dae141d9533 86 mut.unlock();
nsloth 0:1dae141d9533 87 Thread::wait(250);
nsloth 0:1dae141d9533 88 }
nsloth 0:1dae141d9533 89 }
nsloth 0:1dae141d9533 90
nsloth 0:1dae141d9533 91 void readSD(char testDate[], bool isBluetooth){
nsloth 0:1dae141d9533 92 //Writes out the relevant data to the device
nsloth 0:1dae141d9533 93 //led4 = !led4;
nsloth 0:1dae141d9533 94 char data1[100];
nsloth 0:1dae141d9533 95 char data2[100];
nsloth 0:1dae141d9533 96 bool datePassed = false;
nsloth 0:1dae141d9533 97 bool data1Active = true;
nsloth 0:1dae141d9533 98 bool keepLooping = true;
nsloth 0:1dae141d9533 99 FILE *fp = fopen("/sd/mydir/info.txt", "r"); //Open file to append
nsloth 0:1dae141d9533 100 if(fp == NULL) {
nsloth 0:1dae141d9533 101 //uLCD.cls();
nsloth 0:1dae141d9533 102 pc.printf("Could not open file for read\n");
nsloth 0:1dae141d9533 103 return;
nsloth 0:1dae141d9533 104 }
nsloth 0:1dae141d9533 105
nsloth 0:1dae141d9533 106 while(keepLooping) {
nsloth 0:1dae141d9533 107 //save the last string
nsloth 0:1dae141d9533 108 //read in string
nsloth 0:1dae141d9533 109 //if end of file, keep looping should be false
nsloth 0:1dae141d9533 110 if(data1Active) {
nsloth 0:1dae141d9533 111 data1Active = false;
nsloth 0:1dae141d9533 112 memset(data2, 0, sizeof(data2));
nsloth 0:1dae141d9533 113 if (fgets (data2 , 100, fp) == NULL )
nsloth 0:1dae141d9533 114 keepLooping = false;
nsloth 0:1dae141d9533 115 } else {
nsloth 0:1dae141d9533 116 data1Active = true;
nsloth 0:1dae141d9533 117 memset(data1, 0, sizeof(data1));
nsloth 0:1dae141d9533 118 if (fgets (data1 , 100, fp) == NULL )
nsloth 0:1dae141d9533 119 keepLooping = false;
nsloth 0:1dae141d9533 120 }
nsloth 0:1dae141d9533 121
nsloth 0:1dae141d9533 122 if(keepLooping) {
nsloth 0:1dae141d9533 123 //if the string contains the date and the date hasn't yet been found, mark the date as found
nsloth 0:1dae141d9533 124 if(data1Active) {
nsloth 0:1dae141d9533 125 if(!datePassed && (strstr(data1,testDate) != NULL)) {
nsloth 0:1dae141d9533 126 datePassed = true;
nsloth 0:1dae141d9533 127 } else if(datePassed && strstr(data1, testDate) == NULL) { //if we have already found the date but now we've passed it, stop looping
nsloth 0:1dae141d9533 128 keepLooping = false;
nsloth 0:1dae141d9533 129 }
nsloth 0:1dae141d9533 130 } else {
nsloth 0:1dae141d9533 131 if(!datePassed && (strstr(data2,testDate) != NULL)) {
nsloth 0:1dae141d9533 132 datePassed = true;
nsloth 0:1dae141d9533 133 } else if(datePassed && strstr(data2, testDate) == NULL) { //if we have already found the date but now we've passed it, stop looping
nsloth 0:1dae141d9533 134 keepLooping = false;
nsloth 0:1dae141d9533 135 }
nsloth 0:1dae141d9533 136 }
nsloth 0:1dae141d9533 137 }
nsloth 0:1dae141d9533 138 }
nsloth 0:1dae141d9533 139 fclose (fp);
nsloth 0:1dae141d9533 140
nsloth 0:1dae141d9533 141 //At the end of the loop, the relevant data is in the pastData string
nsloth 0:1dae141d9533 142 if(datePassed) {
nsloth 0:1dae141d9533 143 //Parse the data in pastData and store it in the variables
nsloth 0:1dae141d9533 144 if(isBluetooth) {
nsloth 0:1dae141d9533 145 int pastStepCount = 0;
nsloth 0:1dae141d9533 146 float pastMinAlt = 0;
nsloth 0:1dae141d9533 147 float pastMaxAlt = 0;
nsloth 0:1dae141d9533 148 float pastMinTemp = 0;
nsloth 0:1dae141d9533 149 float pastMaxTemp = 0;
nsloth 0:1dae141d9533 150 char output[100];
nsloth 0:1dae141d9533 151 if(data1Active) {
nsloth 0:1dae141d9533 152 sscanf(data2, "%*s %*s %*s %i %*s %f %*s %f %*s %f %*s %f", &pastStepCount, &pastMinAlt, &pastMaxAlt, &pastMinTemp, &pastMaxTemp);
nsloth 0:1dae141d9533 153 pc.printf("Data Exists! And is %s", data2);
nsloth 0:1dae141d9533 154 } else {
nsloth 0:1dae141d9533 155 sscanf(data1, "%*s %*s %*s %i %*s %f %*s %f %*s %f %*s %f", &pastStepCount, &pastMinAlt, &pastMaxAlt, &pastMinTemp, &pastMaxTemp);
nsloth 0:1dae141d9533 156 pc.printf("Data Exists! And is %s", data1);
nsloth 0:1dae141d9533 157 }
nsloth 0:1dae141d9533 158 sprintf(output, "\n\rFor %s:\n\rStep count - %i\n\rMinimum altitude - %5.2f\n\rMaximum altitude - %5.2f\n\rMinimum temp - %5.2f\n\rMaximum temp - %5.2f\n\r", testDate, pastStepCount, pastMinAlt, pastMaxAlt, pastMinTemp, pastMaxTemp);
nsloth 0:1dae141d9533 159 pc.printf("Bluetooth output:%s", output);
nsloth 0:1dae141d9533 160 dev.puts(output);
nsloth 0:1dae141d9533 161 } else {
nsloth 0:1dae141d9533 162 if(data1Active) {
nsloth 0:1dae141d9533 163 //pc.printf("Data Exists! And is %s", data2);
nsloth 0:1dae141d9533 164 sscanf(data2, "%*s %*s %*s %i %*s %f %*s %f %*s %f %*s %f", &stepCount, &minAltitude, &maxAltitude, &minTemp, &maxTemp);
nsloth 0:1dae141d9533 165 } else {
nsloth 0:1dae141d9533 166 //pc.printf("Data Exists! And is %s", data1);
nsloth 0:1dae141d9533 167 sscanf(data1, "%*s %*s %*s %i %*s %f %*s %f %*s %f %*s %f", &stepCount, &minAltitude, &maxAltitude, &minTemp, &maxTemp);
nsloth 0:1dae141d9533 168 }
nsloth 0:1dae141d9533 169 /*minAltitude = 5000.0;
nsloth 0:1dae141d9533 170 maxAltitude = 0.0;
nsloth 0:1dae141d9533 171 minTemp = 5000.0;
nsloth 0:1dae141d9533 172 maxTemp = 0.0;*/
nsloth 0:1dae141d9533 173 }
nsloth 0:1dae141d9533 174 } else {
nsloth 0:1dae141d9533 175 //No prexisting data for that day, so load null data into the variables
nsloth 0:1dae141d9533 176 if(isBluetooth) {
nsloth 0:1dae141d9533 177 //No data for that day
nsloth 0:1dae141d9533 178 char output[80];
nsloth 0:1dae141d9533 179 sprintf(output, "\n\rNo data available for %s.\n\r", testDate);
nsloth 0:1dae141d9533 180 pc.printf("Bluetooth output:%s", output);
nsloth 0:1dae141d9533 181 dev.puts(output);
nsloth 0:1dae141d9533 182 } else {
nsloth 0:1dae141d9533 183 pc.printf("Data does not exist!\n\r");
nsloth 0:1dae141d9533 184 stepCount = 0;
nsloth 0:1dae141d9533 185 }
nsloth 0:1dae141d9533 186 }
nsloth 0:1dae141d9533 187 pc.printf("\n\rWatch stepcount = %i\n\r", stepCount);
nsloth 0:1dae141d9533 188 }
nsloth 0:1dae141d9533 189 void dev_recv(void const *args)
nsloth 0:1dae141d9533 190 {
nsloth 0:1dae141d9533 191 char inputString[9];
nsloth 0:1dae141d9533 192 memset(inputString, 0, sizeof(inputString));
nsloth 0:1dae141d9533 193 int inputIndex = 0;
nsloth 0:1dae141d9533 194 while(1) {
nsloth 0:1dae141d9533 195 if(dev.readable()) {
nsloth 0:1dae141d9533 196 while(dev.readable()) {
nsloth 0:1dae141d9533 197 inputString[inputIndex] = dev.getc();
nsloth 0:1dae141d9533 198 inputIndex++;
nsloth 0:1dae141d9533 199 Thread::wait(100);
nsloth 0:1dae141d9533 200 }
nsloth 0:1dae141d9533 201 pc.printf("search for date:\n\r%s\n\r", inputString);
nsloth 0:1dae141d9533 202 readSD(inputString, true);
nsloth 0:1dae141d9533 203 memset(inputString, 0, sizeof(inputString));
nsloth 0:1dae141d9533 204 inputIndex = 0;
nsloth 0:1dae141d9533 205 }
nsloth 0:1dae141d9533 206 }
nsloth 0:1dae141d9533 207 }
nsloth 0:1dae141d9533 208
nsloth 0:1dae141d9533 209 void updateSD(){
nsloth 0:1dae141d9533 210 mut.lock();
nsloth 0:1dae141d9533 211 FILE *fp = fopen("/sd/mydir/info.txt", "a"); //Open file to append
nsloth 0:1dae141d9533 212 if(fp == NULL) {
nsloth 0:1dae141d9533 213 //pc.cls();
nsloth 0:1dae141d9533 214 pc.printf("Could not open file for write\n");
nsloth 0:1dae141d9533 215 }
nsloth 0:1dae141d9533 216 fprintf(fp,"date: %s steps: %i min_alt: %5.2f max_alt: %5.2f min_temp: %5.2f max_temp: %5.2f\n\r", currDate, stepCount, minAltitude, maxAltitude, minTemp, maxTemp);
nsloth 0:1dae141d9533 217 fclose(fp);
nsloth 0:1dae141d9533 218 mut.unlock();
nsloth 0:1dae141d9533 219 }
nsloth 0:1dae141d9533 220
nsloth 0:1dae141d9533 221 void temperatureRGB(void const *args){
nsloth 0:1dae141d9533 222 while(1){
nsloth 0:1dae141d9533 223 mut.lock();
nsloth 0:1dae141d9533 224 if (thermf > oldthermf && ((thermf-oldthermf)>0.5)) {
nsloth 0:1dae141d9533 225 red = 1.0;
nsloth 0:1dae141d9533 226 green = 0.0;
nsloth 0:1dae141d9533 227 blue = 0.0;
nsloth 0:1dae141d9533 228 }
nsloth 0:1dae141d9533 229 else if (thermf < oldthermf && ((oldthermf-thermf)>0.5)) {
nsloth 0:1dae141d9533 230 red= 0.0;
nsloth 0:1dae141d9533 231 green = 0.0;
nsloth 0:1dae141d9533 232 blue =1.0;
nsloth 0:1dae141d9533 233 }
nsloth 0:1dae141d9533 234 else if (thermf < oldthermf && ((oldthermf-thermf)<=0.5) && ((oldthermf-thermf)>=0.15)) {
nsloth 0:1dae141d9533 235 red= 0.0;
nsloth 0:1dae141d9533 236 green =0.8;
nsloth 0:1dae141d9533 237 blue =0.6;
nsloth 0:1dae141d9533 238 }
nsloth 0:1dae141d9533 239
nsloth 0:1dae141d9533 240 else if (thermf > oldthermf && ((thermf-oldthermf)<=0.5) && ((thermf-oldthermf)>=0.15)) {
nsloth 0:1dae141d9533 241 red = 0.6;
nsloth 0:1dae141d9533 242 green=0.8;
nsloth 0:1dae141d9533 243 blue = 0.0;
nsloth 0:1dae141d9533 244 }
nsloth 0:1dae141d9533 245 else {
nsloth 0:1dae141d9533 246 red=0.0;
nsloth 0:1dae141d9533 247 green=1.0;
nsloth 0:1dae141d9533 248 blue=0.0;
nsloth 0:1dae141d9533 249 }
nsloth 0:1dae141d9533 250 oldthermf = thermf;
nsloth 0:1dae141d9533 251 mut.unlock();
nsloth 0:1dae141d9533 252 Thread::wait(1500);
nsloth 0:1dae141d9533 253 }
nsloth 0:1dae141d9533 254 }
nsloth 0:1dae141d9533 255
nsloth 0:1dae141d9533 256 void lcdDisplay(void const *args){
nsloth 0:1dae141d9533 257 while(1) {
nsloth 0:1dae141d9533 258 mut.lock();
nsloth 0:1dae141d9533 259 uLCD.locate(0,0);
nsloth 0:1dae141d9533 260 uLCD.filled_rectangle(50,66,128,128,BLACK);
nsloth 0:1dae141d9533 261 uLCD.filled_rectangle(0,0,128,64,WHITE);
nsloth 0:1dae141d9533 262 time_t seconds = time(NULL);
nsloth 0:1dae141d9533 263
nsloth 0:1dae141d9533 264 //uLCD.locate(19,19);
nsloth 0:1dae141d9533 265 //time_t seconds = time(NULL);
nsloth 0:1dae141d9533 266 // uLCD.printf("%s", ctime(&seconds));
nsloth 0:1dae141d9533 267 //uLCD.printf("%s", time_buffer);
nsloth 0:1dae141d9533 268 //Print data
nsloth 0:1dae141d9533 269 uLCD.text_width(1);
nsloth 0:1dae141d9533 270 uLCD.text_height(1);
nsloth 0:1dae141d9533 271 uLCD.textbackground_color(BLACK);
nsloth 0:1dae141d9533 272 //uLCD.set_font(FONT_8X12);
nsloth 0:1dae141d9533 273 uLCD.color(BLUE);
nsloth 0:1dae141d9533 274 uLCD.locate(0,9);
nsloth 0:1dae141d9533 275 uLCD.printf("Steps: %*d", 5, stepCount);
nsloth 0:1dae141d9533 276 uLCD.color(GREEN);
nsloth 0:1dae141d9533 277 uLCD.locate(0,11);
nsloth 0:1dae141d9533 278 uLCD.printf("Alt: %*sft", 7, alt.print());
nsloth 0:1dae141d9533 279 uLCD.color(RED);
nsloth 0:1dae141d9533 280 uLCD.locate(0,13);
nsloth 0:1dae141d9533 281 uLCD.printf("Temp: %*sF", 6, therm.print());
nsloth 0:1dae141d9533 282
nsloth 0:1dae141d9533 283 //Print time
nsloth 0:1dae141d9533 284 uLCD.locate(1,2);
nsloth 0:1dae141d9533 285 uLCD.textbackground_color(WHITE);
nsloth 0:1dae141d9533 286 uLCD.color(BLACK);
nsloth 0:1dae141d9533 287 //uLCD.set_font(FONT_8X12);
nsloth 0:1dae141d9533 288 uLCD.text_width(2);
nsloth 0:1dae141d9533 289 uLCD.text_height(2);
nsloth 0:1dae141d9533 290 //uLCD.text_bold(ON);
nsloth 0:1dae141d9533 291 //uLCD.printf("%s", ctime(&seconds));
nsloth 0:1dae141d9533 292 char buffer[32];
nsloth 0:1dae141d9533 293 strftime(buffer, 32, "%I:%M %p", localtime(&seconds));
nsloth 0:1dae141d9533 294 uLCD.printf("%s", buffer);
nsloth 0:1dae141d9533 295
nsloth 0:1dae141d9533 296 mut.unlock();
nsloth 0:1dae141d9533 297 Thread::wait(1000);
nsloth 0:1dae141d9533 298 }
nsloth 0:1dae141d9533 299 }
nsloth 0:1dae141d9533 300
nsloth 0:1dae141d9533 301 int main(){
nsloth 0:1dae141d9533 302 pc.printf("Program starting!\n\r");
nsloth 0:1dae141d9533 303 myled = 0;
nsloth 0:1dae141d9533 304 uLCD.baudrate(3000000);
nsloth 0:1dae141d9533 305 sensor.init();
nsloth 0:1dae141d9533 306 wait_ms(300);
nsloth 0:1dae141d9533 307 sensor.setOffsetAltitude(113);
nsloth 0:1dae141d9533 308 sensor.setOffsetTemperature(20);
nsloth 0:1dae141d9533 309
nsloth 0:1dae141d9533 310 //set_time(1460806560);
nsloth 0:1dae141d9533 311
nsloth 0:1dae141d9533 312 //mkdir("/sd/mydir", 0777);
nsloth 0:1dae141d9533 313 time_t seconds = time(NULL);
nsloth 0:1dae141d9533 314 strftime(currDate, 9, "%m-%d-%y", localtime(&seconds));
nsloth 0:1dae141d9533 315 pc.printf("Today's date: %s\n\r", currDate);
nsloth 0:1dae141d9533 316 readSD(currDate, false);
nsloth 0:1dae141d9533 317
nsloth 0:1dae141d9533 318 lol.begin();
nsloth 0:1dae141d9533 319 if (!lol.begin()) {
nsloth 0:1dae141d9533 320 pc.printf("Failed to communicate with LSM9DS1.\n");
nsloth 0:1dae141d9533 321 }
nsloth 0:1dae141d9533 322 lol.calibrate();
nsloth 0:1dae141d9533 323
nsloth 0:1dae141d9533 324 uLCD.cls();
nsloth 0:1dae141d9533 325 uLCD.background_color(BLACK);
nsloth 0:1dae141d9533 326
nsloth 0:1dae141d9533 327 red=0;//red=0;
nsloth 0:1dae141d9533 328 green=0; //green=0;
nsloth 0:1dae141d9533 329 blue=0; //blue=0;
nsloth 0:1dae141d9533 330
nsloth 0:1dae141d9533 331 Thread th1(altSensor);
nsloth 0:1dae141d9533 332 Thread th2(stepCounter);
nsloth 0:1dae141d9533 333 Thread th3(lcdDisplay);
nsloth 0:1dae141d9533 334 Thread th4(temperatureRGB);
nsloth 0:1dae141d9533 335 Thread th5(dev_recv);
nsloth 0:1dae141d9533 336
nsloth 0:1dae141d9533 337 while(1){
nsloth 0:1dae141d9533 338 pc.printf("Saving data!\n\r");
nsloth 0:1dae141d9533 339 myled != myled;
nsloth 0:1dae141d9533 340 Thread::wait(30000);
nsloth 0:1dae141d9533 341 updateSD();
nsloth 0:1dae141d9533 342 }
nsloth 0:1dae141d9533 343 }