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 SDFileSystem ATParser
Revision 6:57e646faac4d, committed 2020-04-26
- Comitter:
- bleverett3
- Date:
- Sun Apr 26 01:42:51 2020 +0000
- Parent:
- 5:c25fe08829a4
- Commit message:
- Ben, did the stupid BITCH ASS MOTHAFUCKING SD CARD!
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Apr 26 01:03:34 2020 +0000
+++ b/main.cpp Sun Apr 26 01:42:51 2020 +0000
@@ -41,6 +41,41 @@
//Time variable
time_t seconds;
+//Function to store data to sd card
+void log_sd_card()
+{
+ serial_lock.lock();
+ FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
+ if(fp == NULL) {
+ error("Could not open file for write\n");
+ }
+ int curr_time = (int)ctime(&seconds) % 86400;
+ int curr_hour = curr_time / 3600;
+ int curr_min = curr_time / 60;
+ int curr_sec = curr_time % 60;
+
+
+ fprintf(fp, "Date & time: Tuesday 28, April 2020 ");
+ fprintf(fp, "%i", curr_hour);
+ fprintf(fp, ":");
+ fprintf(fp, "%i", curr_min);
+ fprintf(fp, ":");
+ fprintf(fp, "%i", curr_sec);
+ fprintf(fp, "\n");
+ fprintf(fp, "Risk Level: ");
+ fprintf(fp, "%i", risk_level);
+ fprintf(fp, "\n");
+ for (int i = 0; i < 15; i++) {
+ fprintf(fp, "%i", RSSI_array[i]);
+ if (i < 14) {
+ fprintf(fp, ", ");
+ }
+ }
+ fprintf(fp, "\n\n");
+ fclose(fp);
+ serial_lock.unlock();
+}
+
//Helper function for parse_RSSI
int calculate_average(volatile int *input, int size)
{
@@ -99,6 +134,8 @@
changed = 1;
}
risk_level = temp_risk_level;
+ serial_lock.unlock();
+ log_sd_card();
}
}
serial_lock.unlock();
@@ -119,27 +156,6 @@
}
*/
-void logging_SD_card()
-{
- serial_lock.lock();
- FILE *fp = fopen("/sd/mydir/sdtest.txt", "w");
- if(fp == NULL) {
- error("Could not open file for write\n");
- }
-
- if(risk_level <= 1){
- fprintf(fp, "Risk level 1");
- fprintf(fp, "Time" , ctime(&seconds));
- } else if(risk_level == 2){
- fprintf(fp, "Risk level 2");
- fprintf(fp, "Time" , ctime(&seconds));
- } else if(risk_level == 3) {
- fprintf(fp, "Risk level 3");
- fprintf(fp, "Time" , ctime(&seconds));
- }
- fclose(fp);
-}
-
void blink_leds()
{
while(1){
@@ -212,7 +228,7 @@
ble.baud(9600);\
//Time initialization
- set_time(1256729737); // Set RTC time to Wed, 28 Oct 2009 11:35:37
+ set_time(1588089600); // Set RTC time to Tuesday 28, April 2020 16:00:00
seconds = time(NULL);
//SD card initialization