Network, SD, Readall. comments added

Dependencies:   Peripherals Buffer_lib_v2 SD_Lib_EffedUP_ERP Time_Lib_v2 Year3_Version5 BMP280 Network_Lib TextLCD BME280

Committer:
erolleyparnell
Date:
Fri Nov 23 20:12:19 2018 +0000
Revision:
8:dde5976445b4
Parent:
7:981670f59caf
Child:
11:799025124e87
Rearrange source code;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
noutram 0:90e393878517 1 #include "mbed.h"
emilytrembeth 4:da63962bc0f1 2 #include "TextLCD.h"
emilytrembeth 4:da63962bc0f1 3 #include "SDBlockDevice.h"
emilytrembeth 4:da63962bc0f1 4 #include "FATFileSystem.h"
emilytrembeth 4:da63962bc0f1 5 #include "sample_hardware.hpp"
erolleyparnell 8:dde5976445b4 6 #include "thread_functions.hpp"
noutram 0:90e393878517 7
erolleyparnell 8:dde5976445b4 8
emilytrembeth 5:60e116a1e913 9
noutram 0:90e393878517 10 //Function declarations
emilytrembeth 4:da63962bc0f1 11 void displayOnLcd();
emilytrembeth 4:da63962bc0f1 12 void updateRealTimeClock(char *buffer);
emilytrembeth 4:da63962bc0f1 13 void getLineFromSerial(char *keyBuffer, int bufferLength);
emilytrembeth 4:da63962bc0f1 14 void displayMessageOnConsole();
erolleyparnell 8:dde5976445b4 15 void SettingTimeWithButtons ();
emilytrembeth 5:60e116a1e913 16 void FunctionSensor();
emilytrembeth 5:60e116a1e913 17 void FunctionTime();
cgogay 7:981670f59caf 18 void FunctionSerial();
noutram 0:90e393878517 19
emilytrembeth 4:da63962bc0f1 20 TextLCD lcd(D9, D8, D7, D6, D4, D2); // rs, e, d4-d7
emilytrembeth 4:da63962bc0f1 21 SDBlockDevice sd(PB_5, D12, D13, D10); // mosi, miso, sclk, cs
emilytrembeth 4:da63962bc0f1 22 Serial pc(SERIAL_TX, SERIAL_RX);
emilytrembeth 4:da63962bc0f1 23 time_t currentTime;
emilytrembeth 4:da63962bc0f1 24 char lcdBuffer[32];
emilytrembeth 4:da63962bc0f1 25 DigitalOut myled(LED1);
emilytrembeth 4:da63962bc0f1 26 Ticker ticker;
emilytrembeth 4:da63962bc0f1 27 DigitalIn SWUser(USER_BUTTON);
emilytrembeth 4:da63962bc0f1 28 Mutex date_mutex;
emilytrembeth 5:60e116a1e913 29 int setting;
emilytrembeth 5:60e116a1e913 30 int t;
emilytrembeth 5:60e116a1e913 31 //InterruptIn SW1;
noutram 0:90e393878517 32
noutram 1:948bd552a2a2 33 Thread t1;
noutram 1:948bd552a2a2 34 Thread t2;
cgogay 7:981670f59caf 35 Thread t3;
cgogay 7:981670f59caf 36
cgogay 7:981670f59caf 37
cgogay 7:981670f59caf 38 //LDR sensor
cgogay 7:981670f59caf 39 AnalogIn LDD_ADC_In(A1);
cgogay 7:981670f59caf 40 float fLDR = 0.0;
cgogay 7:981670f59caf 41 float volts = 0.0;
cgogay 7:981670f59caf 42
emilytrembeth 4:da63962bc0f1 43
emilytrembeth 4:da63962bc0f1 44
cgogay 6:2ef9c06ce506 45 //Main thread
cgogay 6:2ef9c06ce506 46 int main() {
cgogay 6:2ef9c06ce506 47
cgogay 6:2ef9c06ce506 48 lcd.printf("Select Time Option\n\n");
cgogay 6:2ef9c06ce506 49
cgogay 6:2ef9c06ce506 50 post();
cgogay 6:2ef9c06ce506 51
cgogay 6:2ef9c06ce506 52 //Initialise the SD card
cgogay 6:2ef9c06ce506 53 if ( sd.init() != 0) {
cgogay 6:2ef9c06ce506 54 printf("Init failed \n");
cgogay 6:2ef9c06ce506 55 errorCode(FATAL);
cgogay 6:2ef9c06ce506 56 }
cgogay 6:2ef9c06ce506 57
cgogay 6:2ef9c06ce506 58 //Create a filing system for SD Card
cgogay 6:2ef9c06ce506 59 FATFileSystem fs("sd", &sd);
cgogay 6:2ef9c06ce506 60
cgogay 6:2ef9c06ce506 61 //Open to WRITE
cgogay 6:2ef9c06ce506 62 FILE* fp = fopen("/sd/test.csv","a");
cgogay 6:2ef9c06ce506 63 if (fp == NULL) {
cgogay 6:2ef9c06ce506 64 error("Could not open file for write\n");
cgogay 6:2ef9c06ce506 65 errorCode(FATAL);
cgogay 6:2ef9c06ce506 66 }
cgogay 6:2ef9c06ce506 67
cgogay 6:2ef9c06ce506 68 // run threads
cgogay 6:2ef9c06ce506 69 t1.start(FunctionSensor);
cgogay 7:981670f59caf 70 t2.start(FunctionTime);
cgogay 7:981670f59caf 71 t3.start(FunctionSerial);
cgogay 6:2ef9c06ce506 72
cgogay 6:2ef9c06ce506 73 }