-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdata_storage.h
63 lines (57 loc) · 1.63 KB
/
data_storage.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/*
* SPDX-License-Identifier: LGPL-2.1-or-later
*
* Copyright 2022 Sony Semiconductor Solutions Corporation.
*/
#ifndef _DATA_STORAGE_H_
#define _DATA_STORAGE_H_
#include <Arduino.h>
#include <SDHCI.h>
#include <File.h>
#include <RTC.h>
#include <Flash.h>
#define DATA_FOLDER "mm-s50mv"
#define DATA_MOUNTPT_SDCARD "/mnt/sd0/" DATA_FOLDER
#define DATA_MOUNTPT_SPIFLASH "/mnt/spif/" DATA_FOLDER
#define CSV_FORMAT ","
#define FILE_PATH_LEN 128
#define DATA_HEADER_LEN 128
/*
* @class DataStorageClass
* @brief DataStorageClass Library Class Definitions.
*/
class DataStorageClass {
public:
/* To avoid create multiple instance*/
static DataStorageClass* GetInstance() {
static DataStorageClass instance;
return &instance;
}
void Initialize(unsigned int time_interval);
unsigned int GetInterval(void);
void SaveData(int32_t onedimensional_distance, uint16_t onedimensional_lightquantity,
int32_t* threedimensional_distance ,uint16_t* threedimensional_lightquantity);
typedef enum {
INTO_SD,
INTO_FLASH
}WhereInto;
private:
DataStorageClass() {}
DataStorageClass(const DataStorageClass&);
DataStorageClass& operator=(const DataStorageClass&);
~DataStorageClass() { myFile.close(); }
void DisplayMenu(void);
void CreatePath(void);
void SaveHeader(void);
void OpenFile(bool is_delete);
void SetInterval(unsigned int time_interval);
//private member
unsigned int interval_;
SDClass SD;
File myFile;
RtcTime rtc;
WhereInto where_;
char file_path_[FILE_PATH_LEN];
char header_[DATA_HEADER_LEN];
};
#endif /* _DATA_STORAGE_H_ */