ladsidfs

Dependencies:   BMP280 LGLCDv2

Fork of 0NicksCoursework_copywithserialtime by Liam Grazier

Committer:
liam_grazier
Date:
Wed Jan 10 14:10:05 2018 +0000
Revision:
10:c9c1522957b2
Parent:
8:582ac4c5a524
workin;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
liam_grazier 8:582ac4c5a524 1 #include "mbed.h"
liam_grazier 8:582ac4c5a524 2 #include "stx.hpp"
liam_grazier 8:582ac4c5a524 3 #include "components.hpp"
liam_grazier 8:582ac4c5a524 4 Mutex Sx;
liam_grazier 8:582ac4c5a524 5 char buffer[255];
liam_grazier 8:582ac4c5a524 6 int empty = 0;
liam_grazier 8:582ac4c5a524 7 void welcomemsg(void){
liam_grazier 8:582ac4c5a524 8 printf("WELCOME TO ELEC351 ENVIRONMENTAL SERIAL INTERFACE\n\rFOR ASSISTANCE TYPE HELP\n\r");
liam_grazier 8:582ac4c5a524 9 }
liam_grazier 8:582ac4c5a524 10 void datain(void){
liam_grazier 8:582ac4c5a524 11 if(empty == 0){
liam_grazier 8:582ac4c5a524 12 Sx.lock();
liam_grazier 8:582ac4c5a524 13 scanf("%s", &buffer);
liam_grazier 8:582ac4c5a524 14 Sx.unlock();
liam_grazier 8:582ac4c5a524 15 }
liam_grazier 8:582ac4c5a524 16 }
liam_grazier 8:582ac4c5a524 17 void printcommandlist(){
liam_grazier 8:582ac4c5a524 18 Sx.lock();
liam_grazier 8:582ac4c5a524 19 printf("Command List:\n\r READALL\n\r DELETEALL\n\r SETDATE\n\r DISPLAYTIME\n\r SETTIME\n\r SETT\n\r STATEON(Sampling State)\n\r STATEOFF(Sampling State)\n\r LOGGINGON\n\r LOGGINGOFF\n\r COMMANDLIST\n\r" );
liam_grazier 8:582ac4c5a524 20 Sx.unlock();
liam_grazier 8:582ac4c5a524 21 }
liam_grazier 8:582ac4c5a524 22 void readdata(){
liam_grazier 8:582ac4c5a524 23 if (buffer != ""){
liam_grazier 8:582ac4c5a524 24 if (strstr(buffer, "READALL")){
liam_grazier 8:582ac4c5a524 25 readalldata();
liam_grazier 8:582ac4c5a524 26 }
liam_grazier 8:582ac4c5a524 27 else if(strstr(buffer, "COMMANDLIST")){
liam_grazier 8:582ac4c5a524 28 printcommandlist();
liam_grazier 8:582ac4c5a524 29 }
liam_grazier 8:582ac4c5a524 30 else if(strstr(buffer, "DISPLAYTIME")){
liam_grazier 8:582ac4c5a524 31 printcommandlist();
liam_grazier 8:582ac4c5a524 32 }
liam_grazier 8:582ac4c5a524 33 else if(strstr(buffer, "HELP")){
liam_grazier 8:582ac4c5a524 34 help();
liam_grazier 8:582ac4c5a524 35 }
liam_grazier 8:582ac4c5a524 36 else if(strstr(buffer, "DELETEALL")){
liam_grazier 8:582ac4c5a524 37 deletealldata();
liam_grazier 8:582ac4c5a524 38 }
liam_grazier 8:582ac4c5a524 39 else if(strstr(buffer, "SETDATE")){////////COME BACK HERE LATE
liam_grazier 8:582ac4c5a524 40 rundate();
liam_grazier 8:582ac4c5a524 41 }
liam_grazier 8:582ac4c5a524 42 else if(strstr(buffer, "SETTIME")){////////COME BACK HERE LATE
liam_grazier 8:582ac4c5a524 43 runtime();
liam_grazier 8:582ac4c5a524 44 }
liam_grazier 8:582ac4c5a524 45 else if(strstr(buffer, "SETT")){////////COME BACK HERE LATE
liam_grazier 8:582ac4c5a524 46 setT();
liam_grazier 8:582ac4c5a524 47 }
liam_grazier 8:582ac4c5a524 48 else if(strstr(buffer, "STATEON")){
liam_grazier 8:582ac4c5a524 49 stateon();
liam_grazier 8:582ac4c5a524 50 }
liam_grazier 8:582ac4c5a524 51 else if(strstr(buffer, "STATEOFF")){
liam_grazier 8:582ac4c5a524 52 stateoff();
liam_grazier 8:582ac4c5a524 53 }
liam_grazier 8:582ac4c5a524 54 else if(strstr(buffer, "LOGGINGON")){
liam_grazier 8:582ac4c5a524 55 loggingon();
liam_grazier 8:582ac4c5a524 56 }
liam_grazier 8:582ac4c5a524 57 else if(strstr(buffer, "LOGGINGOFF")){
liam_grazier 8:582ac4c5a524 58 loggingoff();
liam_grazier 8:582ac4c5a524 59 }
liam_grazier 8:582ac4c5a524 60 else
liam_grazier 8:582ac4c5a524 61 {
liam_grazier 8:582ac4c5a524 62 printf("UNRECOGNISED\n\r");
liam_grazier 8:582ac4c5a524 63 }
liam_grazier 8:582ac4c5a524 64 }
liam_grazier 8:582ac4c5a524 65 }
liam_grazier 8:582ac4c5a524 66 void help(){
liam_grazier 8:582ac4c5a524 67 printf("HELP: \n\rFOR COMMAND LIST, type COMMANDLIST\n\r");
liam_grazier 8:582ac4c5a524 68 }
liam_grazier 8:582ac4c5a524 69 void readalldata(){
liam_grazier 8:582ac4c5a524 70 printf("read all data\n\r");
liam_grazier 8:582ac4c5a524 71 } //displays date, tim, temperature, presure, ligt
liam_grazier 8:582ac4c5a524 72 void deletealldata(){
liam_grazier 8:582ac4c5a524 73 printf("delete all data \n\r");
liam_grazier 8:582ac4c5a524 74 } //deletes all memory from th iternal memory
liam_grazier 8:582ac4c5a524 75 void setdate(){
liam_grazier 8:582ac4c5a524 76 printf("Set Date\n\r");
liam_grazier 8:582ac4c5a524 77 } //sets the day month and year
liam_grazier 8:582ac4c5a524 78 void settime(){
liam_grazier 8:582ac4c5a524 79 printf("Set Time\n\r");
liam_grazier 8:582ac4c5a524 80 } //sets the clock hours, minutes, seconds
liam_grazier 8:582ac4c5a524 81 void setT()
liam_grazier 8:582ac4c5a524 82 {
liam_grazier 8:582ac4c5a524 83 printf("Set Sampling Period 'T'\n\r");
liam_grazier 8:582ac4c5a524 84 } //sets the sampling period to <T> seconds
liam_grazier 8:582ac4c5a524 85 void stateon(){
liam_grazier 8:582ac4c5a524 86 printf("Set Sampling ON\n\r");
liam_grazier 8:582ac4c5a524 87 } //turns ampling ON and OFF
liam_grazier 8:582ac4c5a524 88 void stateoff(){
liam_grazier 8:582ac4c5a524 89 printf("Set Sampling OFF\n\r");
liam_grazier 8:582ac4c5a524 90 }
liam_grazier 8:582ac4c5a524 91 void loggingon(){
liam_grazier 8:582ac4c5a524 92
liam_grazier 8:582ac4c5a524 93 printf("Logging On\n\r");
liam_grazier 8:582ac4c5a524 94 }
liam_grazier 8:582ac4c5a524 95 void loggingoff(){
liam_grazier 8:582ac4c5a524 96
liam_grazier 8:582ac4c5a524 97 printf("Logging Off\n\r");
liam_grazier 8:582ac4c5a524 98 }
liam_grazier 8:582ac4c5a524 99 //turns diagnostic logging ON and OFF
liam_grazier 8:582ac4c5a524 100 void useseriel(){
liam_grazier 8:582ac4c5a524 101
liam_grazier 8:582ac4c5a524 102 help();
liam_grazier 8:582ac4c5a524 103 while(true){
liam_grazier 8:582ac4c5a524 104 Thread::signal_wait(SIG_SX);
liam_grazier 8:582ac4c5a524 105 datain();
liam_grazier 8:582ac4c5a524 106 readdata();
liam_grazier 8:582ac4c5a524 107 }
liam_grazier 8:582ac4c5a524 108 }
liam_grazier 8:582ac4c5a524 109