-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLFlash.h
114 lines (85 loc) · 1.96 KB
/
LFlash.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
//
// LFlash.h
// DNOCR_LIB
//
// Created by Simon Hewitt on 08/01/2015.
// Copyright (c) 2015 Simon Hewitt. All rights reserved.
//
#ifndef __DNOCR_LIB__LFlash__
#define __DNOCR_LIB__LFlash__
#include <stdio.h>
#include <fstream>
#include <iostream>
#include <ctime>
#define FILE_READ 1
#define FILE_WRITE 2
// This definition of F() does nothing!
// However in native Arduino, it tells the compiler to keep the string in Flash program memory,
// so it does not use RAM on program load
#define F(string_literal) (string_literal)
// Classless Arduino functions
#define INPUT 1
#define OUTPUT 2
void pinMode (int pin, int Mode);
unsigned long millis();
int digitalRead (int pin);
class LFile
{
public:
LFile(const char *f, int io);
int read();
int write (char c);
int available();
void close();
void flush();
public:
std::fstream f;
};
class LFlash
{
public:
static bool exists (const char * fname);
static void remove (const char *fname);
static LFile open (const char *fname, int io);
static bool mkdir (const char * dirName);
};
/*
** DateTime
*/
typedef struct {
int year;
int mon;
int day;
int hour;
int min;
int sec;
} datetimeInfo;
class LDateTimeClass
{
public:
static int getTime(
datetimeInfo * time
);
static int getRtc(
unsigned int * rtc
);
static int setTime( // does nothing in this sim
datetimeInfo * time
);
};
class Serial
{
// Emulation for Arduino Serial class
// just writes to std::cout
// for real - use the Arduino library!
public:
static long print (const char * msg);
static long println (const char * msg);
static long print (int v );
static long println (int v );
static long print (float f);
static long println (float f);
// static long print (bool b);
// static long println (bool b);
};
#endif /* defined(__DNOCR_LIB__LFlash__) */