emfrp 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/examples/LCDClock/LCDClock.c +580 -0
- data/examples/LCDClock/LCDClock.h +6 -0
- data/examples/LCDClock/LCDClock.mfrp +93 -0
- data/examples/LCDClock/LCDClockMain.c +42 -0
- data/examples/LCDClock/LCDClock_LPC1768.bin +0 -0
- data/examples/LCDClock/README.md +24 -0
- data/examples/LCDClock/graph.dot +55 -0
- data/examples/LCDClock/graph.png +0 -0
- data/lib/emfrp/parser/misc.rb +1 -1
- data/lib/emfrp/version.rb +1 -1
- data/tests/compiler/LCDClock/LCDClock.mfrp +90 -0
- data/tests/compiler/LCDClock/LCDClockMain.c +26 -0
- data/tests/compiler/LCDClock/Rakefile +2 -0
- data/tests/compiler/LCDClock/actual_out.txt +60 -0
- data/tests/compiler/LCDClock/expected_out.txt +60 -0
- data/tests/compiler/LCDClock/in.txt +60 -0
- data/tests/compiler/UseData/UseData.mfrp +3 -3
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8c76aeb70edc85f68ce0412805037f3edd13f585
|
4
|
+
data.tar.gz: b2ea35157930fd7911dfaf3a5ece84ac0dfbe6ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d43fd34857af5a6a55293fc5b1ccdb699fb468cf1d9b3cbc5b7b39dba9c51a7e077939536c60c621e82b10cff3404780892461cd2f6ed2a08de39b613c0db23f
|
7
|
+
data.tar.gz: b1f3486218100ed207900d54c26797ed5d2c17dcadfdf0cc63b4405b65d46b01e3d0f4482bd42faa241e772fcfdabe790414dd068288d6ffb012d4ce88b8503f
|
data/README.md
CHANGED
@@ -0,0 +1,580 @@
|
|
1
|
+
#include "LCDClock.h"
|
2
|
+
/* Primitive functions (Macros) */
|
3
|
+
#define _anpersand_anpersand(a, b) (a && b)
|
4
|
+
#define _eq__eq_(a, b) (a == b)
|
5
|
+
#define _exclamation__eq_(a, b) (a != b)
|
6
|
+
#define _parcent_(a, b) (a % b)
|
7
|
+
#define _plus_(a, b) (a + b)
|
8
|
+
#define _lt_(a, b) (a < b)
|
9
|
+
#define _slash_(a, b) (a / b)
|
10
|
+
#define _at__exclamation_(a) (!a)
|
11
|
+
/* Data types */
|
12
|
+
struct Time{
|
13
|
+
int mark;
|
14
|
+
union {
|
15
|
+
struct {
|
16
|
+
int member0;
|
17
|
+
int member1;
|
18
|
+
int member2;
|
19
|
+
}Time;
|
20
|
+
}value;
|
21
|
+
};
|
22
|
+
struct Tuple3_Int_Int_Int{
|
23
|
+
int mark;
|
24
|
+
union {
|
25
|
+
struct {
|
26
|
+
int member0;
|
27
|
+
int member1;
|
28
|
+
int member2;
|
29
|
+
}Tuple3;
|
30
|
+
}value;
|
31
|
+
};
|
32
|
+
struct Tuple3_Bool_Bool_Bool{
|
33
|
+
int mark;
|
34
|
+
union {
|
35
|
+
struct {
|
36
|
+
int member0;
|
37
|
+
int member1;
|
38
|
+
int member2;
|
39
|
+
}Tuple3;
|
40
|
+
}value;
|
41
|
+
};
|
42
|
+
/* Global variables */
|
43
|
+
int node_memory_btnMode[2];
|
44
|
+
int node_memory_btnNext[2];
|
45
|
+
int node_memory_btnRotate[2];
|
46
|
+
int node_memory_pulse100ms[2];
|
47
|
+
int node_memory_counter[2];
|
48
|
+
int node_memory_curMode[2];
|
49
|
+
int node_memory_curPos[2];
|
50
|
+
int node_memory_pulse1s[2];
|
51
|
+
int node_memory_flash[2];
|
52
|
+
struct Tuple3_Int_Int_Int* node_memory_anonymous69880537178160[2];
|
53
|
+
struct Tuple3_Bool_Bool_Bool* node_memory_anonymous69880541228320[2];
|
54
|
+
int node_memory_dh[2];
|
55
|
+
int node_memory_dm[2];
|
56
|
+
int node_memory_ds[2];
|
57
|
+
int node_memory_maskHour[2];
|
58
|
+
int node_memory_maskMin[2];
|
59
|
+
int node_memory_maskSec[2];
|
60
|
+
struct Time* node_memory_curTime[2];
|
61
|
+
int node_memory_hour[2];
|
62
|
+
int node_memory_min[2];
|
63
|
+
int node_memory_sec[2];
|
64
|
+
struct Time memory_Time[3];
|
65
|
+
int size_Time = 3;
|
66
|
+
int counter_Time = 0;
|
67
|
+
struct Tuple3_Int_Int_Int memory_Tuple3_Int_Int_Int[1];
|
68
|
+
int size_Tuple3_Int_Int_Int = 1;
|
69
|
+
int counter_Tuple3_Int_Int_Int = 0;
|
70
|
+
struct Tuple3_Bool_Bool_Bool memory_Tuple3_Bool_Bool_Bool[1];
|
71
|
+
int size_Tuple3_Bool_Bool_Bool = 1;
|
72
|
+
int counter_Tuple3_Bool_Bool_Bool = 0;
|
73
|
+
int Counter = 1;
|
74
|
+
int NodeSize = 17;
|
75
|
+
/* Static prototypes */
|
76
|
+
static struct Time* Time_0(int, int, int);
|
77
|
+
static void mark_Time(struct Time*, int);
|
78
|
+
static struct Tuple3_Int_Int_Int* Tuple3_0(int, int, int);
|
79
|
+
static void mark_Tuple3_Int_Int_Int(struct Tuple3_Int_Int_Int*, int);
|
80
|
+
static struct Tuple3_Bool_Bool_Bool* Tuple3_1(int, int, int);
|
81
|
+
static void mark_Tuple3_Bool_Bool_Bool(struct Tuple3_Bool_Bool_Bool*, int);
|
82
|
+
static int init_btnMode();
|
83
|
+
static int init_btnNext();
|
84
|
+
static int init_btnRotate();
|
85
|
+
static int node_counter(int, int, int*);
|
86
|
+
static int init_counter();
|
87
|
+
static int node_curMode(int, int, int, int*);
|
88
|
+
static int init_curMode();
|
89
|
+
static int node_curPos(int, int, int, int*);
|
90
|
+
static int init_curPos();
|
91
|
+
static int node_pulse1s(int, int, int*);
|
92
|
+
static int node_flash(int, int*);
|
93
|
+
static int node_anonymous69880537178160(int, int, int, int, struct Tuple3_Int_Int_Int**);
|
94
|
+
static int node_anonymous69880541228320(int, int, int, struct Tuple3_Bool_Bool_Bool**);
|
95
|
+
static int node_dh(struct Tuple3_Int_Int_Int*, int*);
|
96
|
+
static int node_dm(struct Tuple3_Int_Int_Int*, int*);
|
97
|
+
static int node_ds(struct Tuple3_Int_Int_Int*, int*);
|
98
|
+
static int node_maskHour(struct Tuple3_Bool_Bool_Bool*, int*);
|
99
|
+
static int node_maskMin(struct Tuple3_Bool_Bool_Bool*, int*);
|
100
|
+
static int node_maskSec(struct Tuple3_Bool_Bool_Bool*, int*);
|
101
|
+
static int node_curTime(int, struct Time*, int, int, int, struct Time**);
|
102
|
+
static struct Time* init_curTime();
|
103
|
+
static int node_hour(struct Time*, int*);
|
104
|
+
static int init_hour();
|
105
|
+
static int node_min(struct Time*, int*);
|
106
|
+
static int init_min();
|
107
|
+
static int node_sec(struct Time*, int*);
|
108
|
+
static int init_sec();
|
109
|
+
static struct Time* roundingTime_0(struct Time*, int, int, int);
|
110
|
+
static struct Time* proceedTime_0(struct Time*);
|
111
|
+
static int editable_0(int);
|
112
|
+
static int positiveEdge_0(int, int);
|
113
|
+
static int nextMode_0(int);
|
114
|
+
static int nextPos_0(int);
|
115
|
+
static void refreshMark();
|
116
|
+
extern void Input(int*, int*, int*, int*);
|
117
|
+
extern void Output(int*, int*, int*, int*, int*, int*);
|
118
|
+
/* Functions, Constructors, GCMarkers, etc... */
|
119
|
+
static struct Time* Time_0(int member0, int member1, int member2) {
|
120
|
+
struct Time* x;
|
121
|
+
while (1) {
|
122
|
+
counter_Time++;
|
123
|
+
counter_Time %= size_Time;
|
124
|
+
if (memory_Time[counter_Time].mark < Counter) { x = memory_Time + counter_Time; break; }
|
125
|
+
}
|
126
|
+
x->value.Time.member0 = member0;
|
127
|
+
x->value.Time.member1 = member1;
|
128
|
+
x->value.Time.member2 = member2;
|
129
|
+
return x;
|
130
|
+
}
|
131
|
+
static void mark_Time(struct Time* x, int mark) {
|
132
|
+
x->mark = mark;
|
133
|
+
}
|
134
|
+
static struct Tuple3_Int_Int_Int* Tuple3_0(int member0, int member1, int member2) {
|
135
|
+
struct Tuple3_Int_Int_Int* x;
|
136
|
+
while (1) {
|
137
|
+
counter_Tuple3_Int_Int_Int++;
|
138
|
+
counter_Tuple3_Int_Int_Int %= size_Tuple3_Int_Int_Int;
|
139
|
+
if (memory_Tuple3_Int_Int_Int[counter_Tuple3_Int_Int_Int].mark < Counter) { x = memory_Tuple3_Int_Int_Int + counter_Tuple3_Int_Int_Int; break; }
|
140
|
+
}
|
141
|
+
x->value.Tuple3.member0 = member0;
|
142
|
+
x->value.Tuple3.member1 = member1;
|
143
|
+
x->value.Tuple3.member2 = member2;
|
144
|
+
return x;
|
145
|
+
}
|
146
|
+
static void mark_Tuple3_Int_Int_Int(struct Tuple3_Int_Int_Int* x, int mark) {
|
147
|
+
x->mark = mark;
|
148
|
+
}
|
149
|
+
static struct Tuple3_Bool_Bool_Bool* Tuple3_1(int member0, int member1, int member2) {
|
150
|
+
struct Tuple3_Bool_Bool_Bool* x;
|
151
|
+
while (1) {
|
152
|
+
counter_Tuple3_Bool_Bool_Bool++;
|
153
|
+
counter_Tuple3_Bool_Bool_Bool %= size_Tuple3_Bool_Bool_Bool;
|
154
|
+
if (memory_Tuple3_Bool_Bool_Bool[counter_Tuple3_Bool_Bool_Bool].mark < Counter) { x = memory_Tuple3_Bool_Bool_Bool + counter_Tuple3_Bool_Bool_Bool; break; }
|
155
|
+
}
|
156
|
+
x->value.Tuple3.member0 = member0;
|
157
|
+
x->value.Tuple3.member1 = member1;
|
158
|
+
x->value.Tuple3.member2 = member2;
|
159
|
+
return x;
|
160
|
+
}
|
161
|
+
static void mark_Tuple3_Bool_Bool_Bool(struct Tuple3_Bool_Bool_Bool* x, int mark) {
|
162
|
+
x->mark = mark;
|
163
|
+
}
|
164
|
+
static int init_btnMode() {
|
165
|
+
return 0;
|
166
|
+
}
|
167
|
+
static int init_btnNext() {
|
168
|
+
return 0;
|
169
|
+
}
|
170
|
+
static int init_btnRotate() {
|
171
|
+
return 0;
|
172
|
+
}
|
173
|
+
static int node_counter(int pulse100ms, int counter_at_last, int* output) {
|
174
|
+
int _tmp000;
|
175
|
+
if (pulse100ms == 1) {
|
176
|
+
_tmp000 = _plus_(counter_at_last, 1);
|
177
|
+
}
|
178
|
+
else if (pulse100ms == 0) {
|
179
|
+
_tmp000 = counter_at_last;
|
180
|
+
}
|
181
|
+
*output = _parcent_(_tmp000, 10);
|
182
|
+
return 1;
|
183
|
+
}
|
184
|
+
static int init_counter() {
|
185
|
+
return 0;
|
186
|
+
}
|
187
|
+
static int node_curMode(int btnMode_at_last, int btnMode, int curMode_at_last, int* output) {
|
188
|
+
int _tmp002;
|
189
|
+
int _tmp001;
|
190
|
+
_tmp002 = positiveEdge_0(btnMode_at_last, btnMode);
|
191
|
+
if (_tmp002 == 1) {
|
192
|
+
_tmp001 = nextMode_0(curMode_at_last);
|
193
|
+
}
|
194
|
+
else if (_tmp002 == 0) {
|
195
|
+
_tmp001 = curMode_at_last;
|
196
|
+
}
|
197
|
+
*output = _tmp001;
|
198
|
+
return 1;
|
199
|
+
}
|
200
|
+
static int init_curMode() {
|
201
|
+
return 0;
|
202
|
+
}
|
203
|
+
static int node_curPos(int btnNext_at_last, int btnNext, int curPos_at_last, int* output) {
|
204
|
+
int _tmp004;
|
205
|
+
int _tmp003;
|
206
|
+
_tmp004 = positiveEdge_0(btnNext_at_last, btnNext);
|
207
|
+
if (_tmp004 == 1) {
|
208
|
+
_tmp003 = nextPos_0(curPos_at_last);
|
209
|
+
}
|
210
|
+
else if (_tmp004 == 0) {
|
211
|
+
_tmp003 = curPos_at_last;
|
212
|
+
}
|
213
|
+
*output = _tmp003;
|
214
|
+
return 1;
|
215
|
+
}
|
216
|
+
static int init_curPos() {
|
217
|
+
return 0;
|
218
|
+
}
|
219
|
+
static int node_pulse1s(int counter, int counter_at_last, int* output) {
|
220
|
+
*output = _anpersand_anpersand(_eq__eq_(counter, 0), _exclamation__eq_(counter_at_last, 0));
|
221
|
+
return 1;
|
222
|
+
}
|
223
|
+
static int node_flash(int counter, int* output) {
|
224
|
+
*output = _lt_(counter, 5);
|
225
|
+
return 1;
|
226
|
+
}
|
227
|
+
static int node_anonymous69880537178160(int curMode, int btnRotate_at_last, int btnRotate, int curPos, struct Tuple3_Int_Int_Int** output) {
|
228
|
+
int _tmp006;
|
229
|
+
struct Tuple3_Int_Int_Int* _tmp005;
|
230
|
+
_tmp006 = _anpersand_anpersand(editable_0(curMode), positiveEdge_0(btnRotate_at_last, btnRotate));
|
231
|
+
if (_tmp006 == 1) {
|
232
|
+
struct Tuple3_Int_Int_Int* _tmp007;
|
233
|
+
if (curPos == 0) {
|
234
|
+
_tmp007 = Tuple3_0(1, 0, 0);
|
235
|
+
}
|
236
|
+
else if (curPos == 1) {
|
237
|
+
_tmp007 = Tuple3_0(0, 1, 0);
|
238
|
+
}
|
239
|
+
else if (curPos == 2) {
|
240
|
+
_tmp007 = Tuple3_0(0, 0, 1);
|
241
|
+
}
|
242
|
+
_tmp005 = _tmp007;
|
243
|
+
}
|
244
|
+
else if (_tmp006 == 0) {
|
245
|
+
_tmp005 = Tuple3_0(0, 0, 0);
|
246
|
+
}
|
247
|
+
*output = _tmp005;
|
248
|
+
return 1;
|
249
|
+
}
|
250
|
+
static int node_anonymous69880541228320(int curMode, int flash, int curPos, struct Tuple3_Bool_Bool_Bool** output) {
|
251
|
+
int _tmp009;
|
252
|
+
struct Tuple3_Bool_Bool_Bool* _tmp008;
|
253
|
+
_tmp009 = _anpersand_anpersand(editable_0(curMode), flash);
|
254
|
+
if (_tmp009 == 1) {
|
255
|
+
struct Tuple3_Bool_Bool_Bool* _tmp010;
|
256
|
+
if (curPos == 0) {
|
257
|
+
_tmp010 = Tuple3_1(1, 0, 0);
|
258
|
+
}
|
259
|
+
else if (curPos == 1) {
|
260
|
+
_tmp010 = Tuple3_1(0, 1, 0);
|
261
|
+
}
|
262
|
+
else if (curPos == 2) {
|
263
|
+
_tmp010 = Tuple3_1(0, 0, 1);
|
264
|
+
}
|
265
|
+
_tmp008 = _tmp010;
|
266
|
+
}
|
267
|
+
else if (_tmp009 == 0) {
|
268
|
+
_tmp008 = Tuple3_1(0, 0, 0);
|
269
|
+
}
|
270
|
+
*output = _tmp008;
|
271
|
+
return 1;
|
272
|
+
}
|
273
|
+
static int node_dh(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
|
274
|
+
int _tmp011;
|
275
|
+
if (1) {
|
276
|
+
int pvar0_dh = anonymous69880537178160->value.Tuple3.member0;
|
277
|
+
int pvar0_dm = anonymous69880537178160->value.Tuple3.member1;
|
278
|
+
int pvar0_ds = anonymous69880537178160->value.Tuple3.member2;
|
279
|
+
_tmp011 = pvar0_dh;
|
280
|
+
}
|
281
|
+
*output = _tmp011;
|
282
|
+
return 1;
|
283
|
+
}
|
284
|
+
static int node_dm(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
|
285
|
+
int _tmp012;
|
286
|
+
if (1) {
|
287
|
+
int pvar1_dh = anonymous69880537178160->value.Tuple3.member0;
|
288
|
+
int pvar1_dm = anonymous69880537178160->value.Tuple3.member1;
|
289
|
+
int pvar1_ds = anonymous69880537178160->value.Tuple3.member2;
|
290
|
+
_tmp012 = pvar1_dm;
|
291
|
+
}
|
292
|
+
*output = _tmp012;
|
293
|
+
return 1;
|
294
|
+
}
|
295
|
+
static int node_ds(struct Tuple3_Int_Int_Int* anonymous69880537178160, int* output) {
|
296
|
+
int _tmp013;
|
297
|
+
if (1) {
|
298
|
+
int pvar2_dh = anonymous69880537178160->value.Tuple3.member0;
|
299
|
+
int pvar2_dm = anonymous69880537178160->value.Tuple3.member1;
|
300
|
+
int pvar2_ds = anonymous69880537178160->value.Tuple3.member2;
|
301
|
+
_tmp013 = pvar2_ds;
|
302
|
+
}
|
303
|
+
*output = _tmp013;
|
304
|
+
return 1;
|
305
|
+
}
|
306
|
+
static int node_maskHour(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
|
307
|
+
int _tmp014;
|
308
|
+
if (1) {
|
309
|
+
int pvar3_maskHour = anonymous69880541228320->value.Tuple3.member0;
|
310
|
+
int pvar3_maskMin = anonymous69880541228320->value.Tuple3.member1;
|
311
|
+
int pvar3_maskSec = anonymous69880541228320->value.Tuple3.member2;
|
312
|
+
_tmp014 = pvar3_maskHour;
|
313
|
+
}
|
314
|
+
*output = _tmp014;
|
315
|
+
return 1;
|
316
|
+
}
|
317
|
+
static int node_maskMin(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
|
318
|
+
int _tmp015;
|
319
|
+
if (1) {
|
320
|
+
int pvar4_maskHour = anonymous69880541228320->value.Tuple3.member0;
|
321
|
+
int pvar4_maskMin = anonymous69880541228320->value.Tuple3.member1;
|
322
|
+
int pvar4_maskSec = anonymous69880541228320->value.Tuple3.member2;
|
323
|
+
_tmp015 = pvar4_maskMin;
|
324
|
+
}
|
325
|
+
*output = _tmp015;
|
326
|
+
return 1;
|
327
|
+
}
|
328
|
+
static int node_maskSec(struct Tuple3_Bool_Bool_Bool* anonymous69880541228320, int* output) {
|
329
|
+
int _tmp016;
|
330
|
+
if (1) {
|
331
|
+
int pvar5_maskHour = anonymous69880541228320->value.Tuple3.member0;
|
332
|
+
int pvar5_maskMin = anonymous69880541228320->value.Tuple3.member1;
|
333
|
+
int pvar5_maskSec = anonymous69880541228320->value.Tuple3.member2;
|
334
|
+
_tmp016 = pvar5_maskSec;
|
335
|
+
}
|
336
|
+
*output = _tmp016;
|
337
|
+
return 1;
|
338
|
+
}
|
339
|
+
static int node_curTime(int pulse1s, struct Time* curTime_at_last, int dh, int dm, int ds, struct Time** output) {
|
340
|
+
struct Time* _tmp017;
|
341
|
+
if (pulse1s == 1) {
|
342
|
+
_tmp017 = roundingTime_0(proceedTime_0(curTime_at_last), dh, dm, ds);
|
343
|
+
}
|
344
|
+
else if (pulse1s == 0) {
|
345
|
+
_tmp017 = roundingTime_0(curTime_at_last, dh, dm, ds);
|
346
|
+
}
|
347
|
+
*output = _tmp017;
|
348
|
+
return 1;
|
349
|
+
}
|
350
|
+
static struct Time* init_curTime() {
|
351
|
+
return Time_0(0, 0, 0);
|
352
|
+
}
|
353
|
+
static int node_hour(struct Time* curTime, int* output) {
|
354
|
+
int _tmp018;
|
355
|
+
if (1) {
|
356
|
+
struct Time* pvar6_curTime = curTime;
|
357
|
+
int pvar6_hour = curTime->value.Time.member0;
|
358
|
+
int pvar6_min = curTime->value.Time.member1;
|
359
|
+
int pvar6_sec = curTime->value.Time.member2;
|
360
|
+
_tmp018 = pvar6_hour;
|
361
|
+
}
|
362
|
+
*output = _tmp018;
|
363
|
+
return 1;
|
364
|
+
}
|
365
|
+
static int init_hour() {
|
366
|
+
struct Time* _tmp020;
|
367
|
+
int _tmp019;
|
368
|
+
_tmp020 = Time_0(0, 0, 0);
|
369
|
+
if (1) {
|
370
|
+
struct Time* pvar7_curTime = _tmp020;
|
371
|
+
int pvar7_hour = _tmp020->value.Time.member0;
|
372
|
+
int pvar7_min = _tmp020->value.Time.member1;
|
373
|
+
int pvar7_sec = _tmp020->value.Time.member2;
|
374
|
+
_tmp019 = pvar7_hour;
|
375
|
+
}
|
376
|
+
return _tmp019;
|
377
|
+
}
|
378
|
+
static int node_min(struct Time* curTime, int* output) {
|
379
|
+
int _tmp021;
|
380
|
+
if (1) {
|
381
|
+
struct Time* pvar8_curTime = curTime;
|
382
|
+
int pvar8_hour = curTime->value.Time.member0;
|
383
|
+
int pvar8_min = curTime->value.Time.member1;
|
384
|
+
int pvar8_sec = curTime->value.Time.member2;
|
385
|
+
_tmp021 = pvar8_min;
|
386
|
+
}
|
387
|
+
*output = _tmp021;
|
388
|
+
return 1;
|
389
|
+
}
|
390
|
+
static int init_min() {
|
391
|
+
struct Time* _tmp023;
|
392
|
+
int _tmp022;
|
393
|
+
_tmp023 = Time_0(0, 0, 0);
|
394
|
+
if (1) {
|
395
|
+
struct Time* pvar9_curTime = _tmp023;
|
396
|
+
int pvar9_hour = _tmp023->value.Time.member0;
|
397
|
+
int pvar9_min = _tmp023->value.Time.member1;
|
398
|
+
int pvar9_sec = _tmp023->value.Time.member2;
|
399
|
+
_tmp022 = pvar9_min;
|
400
|
+
}
|
401
|
+
return _tmp022;
|
402
|
+
}
|
403
|
+
static int node_sec(struct Time* curTime, int* output) {
|
404
|
+
int _tmp024;
|
405
|
+
if (1) {
|
406
|
+
struct Time* pvar10_curTime = curTime;
|
407
|
+
int pvar10_hour = curTime->value.Time.member0;
|
408
|
+
int pvar10_min = curTime->value.Time.member1;
|
409
|
+
int pvar10_sec = curTime->value.Time.member2;
|
410
|
+
_tmp024 = pvar10_sec;
|
411
|
+
}
|
412
|
+
*output = _tmp024;
|
413
|
+
return 1;
|
414
|
+
}
|
415
|
+
static int init_sec() {
|
416
|
+
struct Time* _tmp026;
|
417
|
+
int _tmp025;
|
418
|
+
_tmp026 = Time_0(0, 0, 0);
|
419
|
+
if (1) {
|
420
|
+
struct Time* pvar11_curTime = _tmp026;
|
421
|
+
int pvar11_hour = _tmp026->value.Time.member0;
|
422
|
+
int pvar11_min = _tmp026->value.Time.member1;
|
423
|
+
int pvar11_sec = _tmp026->value.Time.member2;
|
424
|
+
_tmp025 = pvar11_sec;
|
425
|
+
}
|
426
|
+
return _tmp025;
|
427
|
+
}
|
428
|
+
static struct Time* roundingTime_0(struct Time* t, int dh, int dm, int ds) {
|
429
|
+
struct Time* _tmp027;
|
430
|
+
if (1) {
|
431
|
+
int pvar12_h = t->value.Time.member0;
|
432
|
+
int pvar12_m = t->value.Time.member1;
|
433
|
+
int pvar12_s = t->value.Time.member2;
|
434
|
+
_tmp027 = Time_0(_parcent_(_plus_(pvar12_h, dh), 24), _parcent_(_plus_(pvar12_m, dm), 60), _parcent_(_plus_(pvar12_s, ds), 60));
|
435
|
+
}
|
436
|
+
return _tmp027;
|
437
|
+
}
|
438
|
+
static struct Time* proceedTime_0(struct Time* t) {
|
439
|
+
struct Time* _tmp028;
|
440
|
+
if (1) {
|
441
|
+
int _tmp030;
|
442
|
+
int pvar13_h = t->value.Time.member0;
|
443
|
+
int pvar13_m = t->value.Time.member1;
|
444
|
+
int pvar13_s = t->value.Time.member2;
|
445
|
+
struct Time* _tmp029;
|
446
|
+
_tmp030 = _plus_(pvar13_s, 1);
|
447
|
+
if (1) {
|
448
|
+
int _tmp032;
|
449
|
+
int pvar14_newS = _tmp030;
|
450
|
+
struct Time* _tmp031;
|
451
|
+
_tmp032 = _plus_(pvar13_m, _slash_(pvar14_newS, 60));
|
452
|
+
if (1) {
|
453
|
+
int _tmp034;
|
454
|
+
int pvar15_newM = _tmp032;
|
455
|
+
struct Time* _tmp033;
|
456
|
+
_tmp034 = _plus_(pvar13_h, _slash_(pvar15_newM, 60));
|
457
|
+
if (1) {
|
458
|
+
int pvar16_newH = _tmp034;
|
459
|
+
_tmp033 = Time_0(_parcent_(pvar16_newH, 24), _parcent_(pvar15_newM, 60), _parcent_(pvar14_newS, 60));
|
460
|
+
}
|
461
|
+
_tmp031 = _tmp033;
|
462
|
+
}
|
463
|
+
_tmp029 = _tmp031;
|
464
|
+
}
|
465
|
+
_tmp028 = _tmp029;
|
466
|
+
}
|
467
|
+
return _tmp028;
|
468
|
+
}
|
469
|
+
static int editable_0(int m) {
|
470
|
+
int _tmp035;
|
471
|
+
if (m == 0) {
|
472
|
+
_tmp035 = 0;
|
473
|
+
}
|
474
|
+
else if (m == 1) {
|
475
|
+
_tmp035 = 1;
|
476
|
+
}
|
477
|
+
return _tmp035;
|
478
|
+
}
|
479
|
+
static int positiveEdge_0(int a, int b) {
|
480
|
+
return _anpersand_anpersand(_at__exclamation_(a), b);
|
481
|
+
}
|
482
|
+
static int nextMode_0(int m) {
|
483
|
+
int _tmp036;
|
484
|
+
if (m == 0) {
|
485
|
+
_tmp036 = 1;
|
486
|
+
}
|
487
|
+
else if (m == 1) {
|
488
|
+
_tmp036 = 0;
|
489
|
+
}
|
490
|
+
return _tmp036;
|
491
|
+
}
|
492
|
+
static int nextPos_0(int p) {
|
493
|
+
int _tmp037;
|
494
|
+
if (p == 0) {
|
495
|
+
_tmp037 = 1;
|
496
|
+
}
|
497
|
+
else if (p == 1) {
|
498
|
+
_tmp037 = 2;
|
499
|
+
}
|
500
|
+
else if (p == 2) {
|
501
|
+
_tmp037 = 0;
|
502
|
+
}
|
503
|
+
return _tmp037;
|
504
|
+
}
|
505
|
+
static void refreshMark() {
|
506
|
+
int i;
|
507
|
+
for (i = 0; i < size_Time; i++) {
|
508
|
+
if (memory_Time[i].mark < Counter) memory_Time[i].mark = 0;
|
509
|
+
else memory_Time[i].mark -= Counter - 1;
|
510
|
+
}
|
511
|
+
for (i = 0; i < size_Tuple3_Int_Int_Int; i++) {
|
512
|
+
if (memory_Tuple3_Int_Int_Int[i].mark < Counter) memory_Tuple3_Int_Int_Int[i].mark = 0;
|
513
|
+
else memory_Tuple3_Int_Int_Int[i].mark -= Counter - 1;
|
514
|
+
}
|
515
|
+
for (i = 0; i < size_Tuple3_Bool_Bool_Bool; i++) {
|
516
|
+
if (memory_Tuple3_Bool_Bool_Bool[i].mark < Counter) memory_Tuple3_Bool_Bool_Bool[i].mark = 0;
|
517
|
+
else memory_Tuple3_Bool_Bool_Bool[i].mark -= Counter - 1;
|
518
|
+
}
|
519
|
+
}
|
520
|
+
void ActivateLCDClock() {
|
521
|
+
int current_side = 0, last_side = 1;
|
522
|
+
node_memory_btnMode[last_side] = init_btnMode();
|
523
|
+
node_memory_btnNext[last_side] = init_btnNext();
|
524
|
+
node_memory_btnRotate[last_side] = init_btnRotate();
|
525
|
+
node_memory_counter[last_side] = init_counter();
|
526
|
+
node_memory_curMode[last_side] = init_curMode();
|
527
|
+
node_memory_curPos[last_side] = init_curPos();
|
528
|
+
node_memory_curTime[last_side] = init_curTime();
|
529
|
+
mark_Time(node_memory_curTime[last_side], 14);
|
530
|
+
node_memory_hour[last_side] = init_hour();
|
531
|
+
node_memory_min[last_side] = init_min();
|
532
|
+
node_memory_sec[last_side] = init_sec();
|
533
|
+
Counter = NodeSize + 1;
|
534
|
+
refreshMark();
|
535
|
+
while (1) {
|
536
|
+
Counter = 1;
|
537
|
+
Input(&node_memory_btnMode[current_side], &node_memory_btnNext[current_side], &node_memory_btnRotate[current_side], &node_memory_pulse100ms[current_side]);
|
538
|
+
node_counter(node_memory_pulse100ms[current_side], node_memory_counter[last_side], &node_memory_counter[current_side]);
|
539
|
+
Counter++;
|
540
|
+
node_curMode(node_memory_btnMode[last_side], node_memory_btnMode[current_side], node_memory_curMode[last_side], &node_memory_curMode[current_side]);
|
541
|
+
Counter++;
|
542
|
+
node_curPos(node_memory_btnNext[last_side], node_memory_btnNext[current_side], node_memory_curPos[last_side], &node_memory_curPos[current_side]);
|
543
|
+
Counter++;
|
544
|
+
node_pulse1s(node_memory_counter[current_side], node_memory_counter[last_side], &node_memory_pulse1s[current_side]);
|
545
|
+
Counter++;
|
546
|
+
node_flash(node_memory_counter[current_side], &node_memory_flash[current_side]);
|
547
|
+
Counter++;
|
548
|
+
node_anonymous69880537178160(node_memory_curMode[current_side], node_memory_btnRotate[last_side], node_memory_btnRotate[current_side], node_memory_curPos[current_side], &node_memory_anonymous69880537178160[current_side]);
|
549
|
+
mark_Tuple3_Int_Int_Int(node_memory_anonymous69880537178160[current_side], Counter + 4);
|
550
|
+
Counter++;
|
551
|
+
node_anonymous69880541228320(node_memory_curMode[current_side], node_memory_flash[current_side], node_memory_curPos[current_side], &node_memory_anonymous69880541228320[current_side]);
|
552
|
+
mark_Tuple3_Bool_Bool_Bool(node_memory_anonymous69880541228320[current_side], Counter + 6);
|
553
|
+
Counter++;
|
554
|
+
node_dh(node_memory_anonymous69880537178160[current_side], &node_memory_dh[current_side]);
|
555
|
+
Counter++;
|
556
|
+
node_dm(node_memory_anonymous69880537178160[current_side], &node_memory_dm[current_side]);
|
557
|
+
Counter++;
|
558
|
+
node_ds(node_memory_anonymous69880537178160[current_side], &node_memory_ds[current_side]);
|
559
|
+
Counter++;
|
560
|
+
node_maskHour(node_memory_anonymous69880541228320[current_side], &node_memory_maskHour[current_side]);
|
561
|
+
Counter++;
|
562
|
+
node_maskMin(node_memory_anonymous69880541228320[current_side], &node_memory_maskMin[current_side]);
|
563
|
+
Counter++;
|
564
|
+
node_maskSec(node_memory_anonymous69880541228320[current_side], &node_memory_maskSec[current_side]);
|
565
|
+
Counter++;
|
566
|
+
node_curTime(node_memory_pulse1s[current_side], node_memory_curTime[last_side], node_memory_dh[current_side], node_memory_dm[current_side], node_memory_ds[current_side], &node_memory_curTime[current_side]);
|
567
|
+
mark_Time(node_memory_curTime[current_side], Counter + 17);
|
568
|
+
Counter++;
|
569
|
+
node_hour(node_memory_curTime[current_side], &node_memory_hour[current_side]);
|
570
|
+
Counter++;
|
571
|
+
node_min(node_memory_curTime[current_side], &node_memory_min[current_side]);
|
572
|
+
Counter++;
|
573
|
+
node_sec(node_memory_curTime[current_side], &node_memory_sec[current_side]);
|
574
|
+
Counter++;
|
575
|
+
Output(&node_memory_hour[current_side], &node_memory_min[current_side], &node_memory_sec[current_side], &node_memory_maskHour[current_side], &node_memory_maskMin[current_side], &node_memory_maskSec[current_side]);
|
576
|
+
refreshMark();
|
577
|
+
current_side ^= 1;
|
578
|
+
last_side ^= 1;
|
579
|
+
}
|
580
|
+
}
|
@@ -0,0 +1,93 @@
|
|
1
|
+
module LCDClock
|
2
|
+
in
|
3
|
+
btnMode(False) : Bool, # Is mode-button pushed now?
|
4
|
+
btnNext(False) : Bool, # Is next-button pushed now?
|
5
|
+
btnRotate(False) : Bool, # Is rotate-button pushed now?
|
6
|
+
pulse100ms : Bool # input to be True only once per 100ms
|
7
|
+
out
|
8
|
+
hour, min, sec, # current time to display
|
9
|
+
maskHour, maskMin, maskSec # Is it now needed to display -- instead of two-digits?
|
10
|
+
use
|
11
|
+
Std
|
12
|
+
|
13
|
+
# Functions
|
14
|
+
# --------------------
|
15
|
+
|
16
|
+
type Mode = Normal | Edit
|
17
|
+
type EditPos = HourPos | MinPos | SecPos
|
18
|
+
type Time = Time(Int, Int, Int)
|
19
|
+
|
20
|
+
func nextMode(m) = m of Normal -> Edit, Edit -> Normal
|
21
|
+
|
22
|
+
func editable(m) = m of Normal -> False, Edit -> True
|
23
|
+
|
24
|
+
func nextPos(p) = p of:
|
25
|
+
HourPos -> MinPos
|
26
|
+
MinPos -> SecPos
|
27
|
+
SecPos -> HourPos
|
28
|
+
|
29
|
+
func positiveEdge(a, b) = !a && b
|
30
|
+
|
31
|
+
# proceed Time by 1sec
|
32
|
+
func proceedTime(t) = {
|
33
|
+
Time(h, m, s) = t
|
34
|
+
newS = s + 1
|
35
|
+
newM = m + (newS / 60)
|
36
|
+
newH = h + (newM / 60)
|
37
|
+
Time(newH % 24, newM % 60, newS % 60)
|
38
|
+
}
|
39
|
+
|
40
|
+
func roundingTime(t, dh, dm, ds) = {
|
41
|
+
Time(h, m, s) = t
|
42
|
+
Time((h + dh) % 24, (m + dm) % 60, (s + ds) % 60)
|
43
|
+
}
|
44
|
+
|
45
|
+
# Nodes
|
46
|
+
# --------------------
|
47
|
+
|
48
|
+
# mod-10 counter incremented by every 100ms
|
49
|
+
node init[0] counter : Int =
|
50
|
+
(if pulse100ms then counter@last + 1 else counter@last) % 10
|
51
|
+
|
52
|
+
# time-varying value to be True only once per 1sec
|
53
|
+
node pulse1s : Bool =
|
54
|
+
counter == 0 && counter@last != 0
|
55
|
+
|
56
|
+
# time-varying value switching True/False by every 500ms
|
57
|
+
node flash : Bool =
|
58
|
+
counter < 5
|
59
|
+
|
60
|
+
# time-varying value representing current time-set mode
|
61
|
+
node init[Normal] curMode : Mode =
|
62
|
+
if btnMode@last `positiveEdge` btnMode then curMode@last.nextMode else curMode@last
|
63
|
+
|
64
|
+
# time-varying value representing current editing-cursor-position
|
65
|
+
node init[HourPos] curPos : EditPos =
|
66
|
+
if btnNext@last `positiveEdge` btnNext then curPos@last.nextPos else curPos@last
|
67
|
+
|
68
|
+
# time-varying value representing diffs to add to current time.
|
69
|
+
node (dh, dm, ds) : (Int, Int, Int) =
|
70
|
+
if curMode.editable && (btnRotate@last `positiveEdge` btnRotate) then
|
71
|
+
curPos of:
|
72
|
+
HourPos -> (1, 0, 0)
|
73
|
+
MinPos -> (0, 1, 0)
|
74
|
+
SecPos -> (0, 0, 1)
|
75
|
+
else
|
76
|
+
(0, 0, 0)
|
77
|
+
|
78
|
+
# time-varying value representing current time
|
79
|
+
node init[Time(0, 0, 0)] Time(hour, min, sec) as curTime =
|
80
|
+
if pulse1s then
|
81
|
+
curTime@last.proceedTime.roundingTime(dh, dm, ds)
|
82
|
+
else
|
83
|
+
curTime@last.roundingTime(dh, dm, ds)
|
84
|
+
|
85
|
+
# time-varying value representing need of masking
|
86
|
+
node (maskHour, maskMin, maskSec) =
|
87
|
+
if curMode.editable && flash then
|
88
|
+
curPos of:
|
89
|
+
HourPos -> (True, False, False)
|
90
|
+
MinPos -> (False, True, False)
|
91
|
+
SecPos -> (False, False, True)
|
92
|
+
else
|
93
|
+
(False, False, False)
|
@@ -0,0 +1,42 @@
|
|
1
|
+
#include "LCDClock.h"
|
2
|
+
#include "mbed.h"
|
3
|
+
#include "C12832_lcd.h"
|
4
|
+
|
5
|
+
C12832_LCD lcd;
|
6
|
+
Ticker t;
|
7
|
+
DigitalIn center(p14), up(p15), right(p16);
|
8
|
+
int pulse100_flag = 0;
|
9
|
+
|
10
|
+
void timer_callback() {
|
11
|
+
pulse100_flag = 1;
|
12
|
+
}
|
13
|
+
|
14
|
+
void display(int n, int mask, char c) {
|
15
|
+
if (mask) {
|
16
|
+
lcd.printf("--%c", c);
|
17
|
+
} else {
|
18
|
+
lcd.printf("%02d%c", n, c);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
void Input(int* btnMode, int* btnNext, int* btnRotate, int* pulse100ms) {
|
23
|
+
*btnMode = center.read();
|
24
|
+
*btnNext = right.read();
|
25
|
+
*btnRotate = up.read();
|
26
|
+
*pulse100ms = pulse100_flag;
|
27
|
+
pulse100_flag = 0;
|
28
|
+
}
|
29
|
+
|
30
|
+
void Output(int* hour, int* min, int* sec, int* maskHour, int* maskMin, int* maskSec) {
|
31
|
+
lcd.cls();
|
32
|
+
lcd.locate(45, 10);
|
33
|
+
display(*hour, *maskHour, ':');
|
34
|
+
display(*min, *maskMin, ':');
|
35
|
+
display(*sec, *maskSec, '\n');
|
36
|
+
wait(0.01);
|
37
|
+
}
|
38
|
+
|
39
|
+
int main() {
|
40
|
+
t.attach(&timer_callback, 0.1);
|
41
|
+
ActivateLCDClock();
|
42
|
+
}
|
Binary file
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# LCD Clock
|
2
|
+
|
3
|
+
This is a program of the digital clock.
|
4
|
+
|
5
|
+
## Functions
|
6
|
+
* Center (push) button (of joystick) toggles on-off of time-set mode.
|
7
|
+
* Right button moves cursor of time-set targets (hour, minute and second).
|
8
|
+
* Up button raises time-set target's value (+1) if time-set mode is on.
|
9
|
+
|
10
|
+
## Target device
|
11
|
+
mbed LPC1768 with application board
|
12
|
+
|
13
|
+
## IO library
|
14
|
+
Following libraries are required.
|
15
|
+
* Basic IO library `mbed` (official)
|
16
|
+
* LCD's manipulation library `C12832_lcd` (third-party)
|
17
|
+
|
18
|
+
Both they are available from official library repository of *mbed.org*.
|
19
|
+
|
20
|
+
## Sample
|
21
|
+
|
22
|
+

|
23
|
+
|
24
|
+
* [Watch on YouTube](https://www.youtube.com/watch?v=Fah2iJAaouo)
|
@@ -0,0 +1,55 @@
|
|
1
|
+
digraph LCDClock {
|
2
|
+
pulse100ms [label = "pulse100ms : Bool", shape = "invhouse"];
|
3
|
+
counter [label = "counter : Int"];
|
4
|
+
pulse1s [label = "pulse1s : Bool"];
|
5
|
+
btnMode [label = "btnMode : Bool", shape = "invhouse"];
|
6
|
+
curMode [label = "curMode : Mode"];
|
7
|
+
btnRotate [label = "btnRotate : Bool", shape = "invhouse"];
|
8
|
+
btnNext [label = "btnNext : Bool", shape = "invhouse"];
|
9
|
+
curPos [label = "curPos : TPos"];
|
10
|
+
anonymous69998036981860 [label = "anonymous69998036981860 : Tuple3[Int, Int, Int]"];
|
11
|
+
dh [label = "dh : Int"];
|
12
|
+
dm [label = "dm : Int"];
|
13
|
+
ds [label = "ds : Int"];
|
14
|
+
curTime [label = "curTime : Time"];
|
15
|
+
hour [label = "hour : Int", style = filled, fillcolor = "#e4e4e4"];
|
16
|
+
min [label = "min : Int", style = filled, fillcolor = "#e4e4e4"];
|
17
|
+
sec [label = "sec : Int", style = filled, fillcolor = "#e4e4e4"];
|
18
|
+
flash [label = "flash : Bool"];
|
19
|
+
anonymous69998035646520 [label = "anonymous69998035646520 : Tuple3[Bool, Bool, Bool]"];
|
20
|
+
maskHour [label = "maskHour : Bool", style = filled, fillcolor = "#e4e4e4"];
|
21
|
+
maskMin [label = "maskMin : Bool", style = filled, fillcolor = "#e4e4e4"];
|
22
|
+
maskSec [label = "maskSec : Bool", style = filled, fillcolor = "#e4e4e4"];
|
23
|
+
curTime -> hour;
|
24
|
+
pulse1s -> curTime;
|
25
|
+
counter -> pulse1s;
|
26
|
+
pulse100ms -> counter;
|
27
|
+
counter -> counter [style = dashed];
|
28
|
+
counter -> pulse1s [style = dashed];
|
29
|
+
curTime -> curTime [style = dashed];
|
30
|
+
dh -> curTime;
|
31
|
+
anonymous69998036981860 -> dh;
|
32
|
+
curMode -> anonymous69998036981860;
|
33
|
+
btnMode -> curMode [style = dashed];
|
34
|
+
btnMode -> curMode;
|
35
|
+
curMode -> curMode [style = dashed];
|
36
|
+
btnRotate -> anonymous69998036981860 [style = dashed];
|
37
|
+
btnRotate -> anonymous69998036981860;
|
38
|
+
curPos -> anonymous69998036981860;
|
39
|
+
btnNext -> curPos [style = dashed];
|
40
|
+
btnNext -> curPos;
|
41
|
+
curPos -> curPos [style = dashed];
|
42
|
+
dm -> curTime;
|
43
|
+
anonymous69998036981860 -> dm;
|
44
|
+
ds -> curTime;
|
45
|
+
anonymous69998036981860 -> ds;
|
46
|
+
curTime -> min;
|
47
|
+
curTime -> sec;
|
48
|
+
anonymous69998035646520 -> maskHour;
|
49
|
+
curMode -> anonymous69998035646520;
|
50
|
+
flash -> anonymous69998035646520;
|
51
|
+
counter -> flash;
|
52
|
+
curPos -> anonymous69998035646520;
|
53
|
+
anonymous69998035646520 -> maskMin;
|
54
|
+
anonymous69998035646520 -> maskSec;
|
55
|
+
}
|
Binary file
|
data/lib/emfrp/parser/misc.rb
CHANGED
data/lib/emfrp/version.rb
CHANGED
@@ -0,0 +1,90 @@
|
|
1
|
+
module LCDClock
|
2
|
+
in
|
3
|
+
btnMode(False) : Bool, # Is mode-button pushed now?
|
4
|
+
btnNext(False) : Bool, # Is next-button pushed now?
|
5
|
+
btnRotate(False) : Bool, # Is rotate-button pushed now?
|
6
|
+
pulse100ms : Bool # input to be True only once per 100ms
|
7
|
+
out
|
8
|
+
hour, min, sec, # current time to display
|
9
|
+
maskHour, maskMin, maskSec # Is it now needed to display -- instead of two-digits?
|
10
|
+
use
|
11
|
+
Std
|
12
|
+
|
13
|
+
# Functions
|
14
|
+
# --------------------
|
15
|
+
|
16
|
+
type Mode = Normal | Edit
|
17
|
+
type TPos = HPos | MPos | SPos
|
18
|
+
type Time = Time(Int, Int, Int)
|
19
|
+
|
20
|
+
func nextMode(m) = m of Normal -> Edit, Edit -> Normal
|
21
|
+
|
22
|
+
func editable(m) = m of Normal -> False, Edit -> True
|
23
|
+
|
24
|
+
func nextPos(p) = p of HPos -> MPos, MPos -> SPos, SPos -> HPos
|
25
|
+
|
26
|
+
func positiveEdge(a, b) = !a && b
|
27
|
+
|
28
|
+
# proceed Time by 1sec
|
29
|
+
func proceedTime(t) = {
|
30
|
+
Time(h, m, s) = t
|
31
|
+
newS = s + 1
|
32
|
+
newM = m + (newS / 60)
|
33
|
+
newH = h + (newM / 60)
|
34
|
+
Time(newH % 24, newM % 60, newS % 60)
|
35
|
+
}
|
36
|
+
|
37
|
+
func roundingTime(t, dh, dm, ds) = {
|
38
|
+
Time(h, m, s) = t
|
39
|
+
Time((h + dh) % 24, (m + dm) % 60, (s + ds) % 60)
|
40
|
+
}
|
41
|
+
|
42
|
+
# Nodes
|
43
|
+
# --------------------
|
44
|
+
|
45
|
+
# mod-10 counter incremented by every 100ms
|
46
|
+
node init[0] counter : Int =
|
47
|
+
(if pulse100ms then counter@last + 1 else counter@last) % 10
|
48
|
+
|
49
|
+
# time-varying value to be True only once per 1sec
|
50
|
+
node pulse1s : Bool =
|
51
|
+
counter == 0 && counter@last != 0
|
52
|
+
|
53
|
+
# time-varying value switching True/False by every 500ms
|
54
|
+
node flash : Bool =
|
55
|
+
counter < 5
|
56
|
+
|
57
|
+
# time-varying value representing current time-set mode
|
58
|
+
node init[Normal] curMode : Mode =
|
59
|
+
if btnMode@last `positiveEdge` btnMode then curMode@last.nextMode else curMode@last
|
60
|
+
|
61
|
+
# time-varying value representing current editing-cursor-position
|
62
|
+
node init[HPos] curPos : TPos =
|
63
|
+
if btnNext@last `positiveEdge` btnNext then curPos@last.nextPos else curPos@last
|
64
|
+
|
65
|
+
# time-varying value representing diffs to add to current time.
|
66
|
+
node (dh, dm, ds) : (Int, Int, Int) =
|
67
|
+
if curMode.editable && (btnRotate@last `positiveEdge` btnRotate) then
|
68
|
+
curPos of:
|
69
|
+
HPos -> (1, 0, 0)
|
70
|
+
MPos -> (0, 1, 0)
|
71
|
+
SPos -> (0, 0, 1)
|
72
|
+
else
|
73
|
+
(0, 0, 0)
|
74
|
+
|
75
|
+
# time-varying value representing current time
|
76
|
+
node init[Time(0, 0, 0)] Time(hour, min, sec) as curTime =
|
77
|
+
if pulse1s then
|
78
|
+
curTime@last.proceedTime.roundingTime(dh, dm, ds)
|
79
|
+
else
|
80
|
+
curTime@last.roundingTime(dh, dm, ds)
|
81
|
+
|
82
|
+
# time-varying value representing need of masking
|
83
|
+
node (maskHour, maskMin, maskSec) =
|
84
|
+
if curMode.editable && flash then
|
85
|
+
curPos of:
|
86
|
+
HPos -> (True, False, False)
|
87
|
+
MPos -> (False, True, False)
|
88
|
+
SPos -> (False, False, True)
|
89
|
+
else
|
90
|
+
(False, False, False)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#include "LCDClock.h"
|
2
|
+
#include <stdio.h>
|
3
|
+
#include <stdlib.h>
|
4
|
+
|
5
|
+
void display(int n, int mask, char c) {
|
6
|
+
if (mask) {
|
7
|
+
printf("--%c", c);
|
8
|
+
} else {
|
9
|
+
printf("%02d%c", n, c);
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
void Input(int* btnMode, int* btnNext, int* btnRotate, int* pulse100ms) {
|
14
|
+
if (scanf("%d %d %d %d", btnMode, btnNext, btnRotate, pulse100ms) == EOF) {
|
15
|
+
exit(0);
|
16
|
+
}
|
17
|
+
}
|
18
|
+
void Output(int* hour, int* min, int* sec, int* maskHour, int* maskMin, int* maskSec) {
|
19
|
+
display(*hour, *maskHour, ':');
|
20
|
+
display(*min, *maskMin, ':');
|
21
|
+
display(*sec, *maskSec, '\n');
|
22
|
+
}
|
23
|
+
|
24
|
+
int main() {
|
25
|
+
ActivateLCDClock();
|
26
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
00:00:00
|
2
|
+
00:00:00
|
3
|
+
00:00:00
|
4
|
+
00:00:00
|
5
|
+
00:00:00
|
6
|
+
00:00:00
|
7
|
+
--:00:00
|
8
|
+
--:00:00
|
9
|
+
--:00:00
|
10
|
+
00:00:00
|
11
|
+
00:00:00
|
12
|
+
00:00:00
|
13
|
+
00:00:00
|
14
|
+
00:00:00
|
15
|
+
--:00:01
|
16
|
+
--:00:01
|
17
|
+
--:00:01
|
18
|
+
--:00:01
|
19
|
+
--:00:01
|
20
|
+
00:00:01
|
21
|
+
00:00:01
|
22
|
+
00:00:01
|
23
|
+
00:00:01
|
24
|
+
00:00:01
|
25
|
+
--:00:02
|
26
|
+
--:00:02
|
27
|
+
--:00:02
|
28
|
+
--:00:02
|
29
|
+
--:00:02
|
30
|
+
01:00:02
|
31
|
+
01:00:02
|
32
|
+
01:00:02
|
33
|
+
01:00:02
|
34
|
+
01:00:02
|
35
|
+
01:--:03
|
36
|
+
01:--:03
|
37
|
+
01:--:03
|
38
|
+
01:--:03
|
39
|
+
01:--:03
|
40
|
+
01:00:03
|
41
|
+
01:00:03
|
42
|
+
01:00:03
|
43
|
+
01:00:03
|
44
|
+
01:00:03
|
45
|
+
01:00:--
|
46
|
+
01:00:--
|
47
|
+
01:00:--
|
48
|
+
01:00:--
|
49
|
+
01:00:--
|
50
|
+
01:00:04
|
51
|
+
01:00:04
|
52
|
+
01:00:04
|
53
|
+
01:00:04
|
54
|
+
01:00:04
|
55
|
+
--:00:05
|
56
|
+
--:00:05
|
57
|
+
--:00:05
|
58
|
+
--:00:05
|
59
|
+
--:00:05
|
60
|
+
01:00:05
|
@@ -0,0 +1,60 @@
|
|
1
|
+
00:00:00
|
2
|
+
00:00:00
|
3
|
+
00:00:00
|
4
|
+
00:00:00
|
5
|
+
00:00:00
|
6
|
+
00:00:00
|
7
|
+
--:00:00
|
8
|
+
--:00:00
|
9
|
+
--:00:00
|
10
|
+
00:00:00
|
11
|
+
00:00:00
|
12
|
+
00:00:00
|
13
|
+
00:00:00
|
14
|
+
00:00:00
|
15
|
+
--:00:01
|
16
|
+
--:00:01
|
17
|
+
--:00:01
|
18
|
+
--:00:01
|
19
|
+
--:00:01
|
20
|
+
00:00:01
|
21
|
+
00:00:01
|
22
|
+
00:00:01
|
23
|
+
00:00:01
|
24
|
+
00:00:01
|
25
|
+
--:00:02
|
26
|
+
--:00:02
|
27
|
+
--:00:02
|
28
|
+
--:00:02
|
29
|
+
--:00:02
|
30
|
+
01:00:02
|
31
|
+
01:00:02
|
32
|
+
01:00:02
|
33
|
+
01:00:02
|
34
|
+
01:00:02
|
35
|
+
01:--:03
|
36
|
+
01:--:03
|
37
|
+
01:--:03
|
38
|
+
01:--:03
|
39
|
+
01:--:03
|
40
|
+
01:00:03
|
41
|
+
01:00:03
|
42
|
+
01:00:03
|
43
|
+
01:00:03
|
44
|
+
01:00:03
|
45
|
+
01:00:--
|
46
|
+
01:00:--
|
47
|
+
01:00:--
|
48
|
+
01:00:--
|
49
|
+
01:00:--
|
50
|
+
01:00:04
|
51
|
+
01:00:04
|
52
|
+
01:00:04
|
53
|
+
01:00:04
|
54
|
+
01:00:04
|
55
|
+
--:00:05
|
56
|
+
--:00:05
|
57
|
+
--:00:05
|
58
|
+
--:00:05
|
59
|
+
--:00:05
|
60
|
+
01:00:05
|
@@ -0,0 +1,60 @@
|
|
1
|
+
0 0 0 0
|
2
|
+
0 0 0 0
|
3
|
+
0 0 0 0
|
4
|
+
0 0 0 0
|
5
|
+
0 0 0 0
|
6
|
+
0 0 0 1
|
7
|
+
1 0 0 1
|
8
|
+
0 0 0 1
|
9
|
+
0 0 0 1
|
10
|
+
0 0 0 1
|
11
|
+
0 0 0 1
|
12
|
+
0 0 0 1
|
13
|
+
0 0 0 1
|
14
|
+
0 0 0 1
|
15
|
+
0 0 0 1
|
16
|
+
0 0 0 1
|
17
|
+
0 0 0 1
|
18
|
+
0 0 0 1
|
19
|
+
0 0 0 1
|
20
|
+
0 0 0 1
|
21
|
+
0 0 0 1
|
22
|
+
0 0 0 1
|
23
|
+
0 0 0 1
|
24
|
+
0 0 0 1
|
25
|
+
0 0 1 1
|
26
|
+
0 0 0 1
|
27
|
+
0 0 0 1
|
28
|
+
0 0 0 1
|
29
|
+
0 0 0 1
|
30
|
+
0 0 0 1
|
31
|
+
0 0 0 1
|
32
|
+
0 0 0 1
|
33
|
+
0 1 0 1
|
34
|
+
0 0 0 1
|
35
|
+
0 0 0 1
|
36
|
+
0 0 0 1
|
37
|
+
0 0 0 1
|
38
|
+
0 0 0 1
|
39
|
+
0 0 0 1
|
40
|
+
0 0 0 1
|
41
|
+
0 0 0 1
|
42
|
+
0 0 0 1
|
43
|
+
0 0 0 1
|
44
|
+
0 1 0 1
|
45
|
+
0 0 0 1
|
46
|
+
0 0 0 1
|
47
|
+
0 0 0 1
|
48
|
+
0 0 0 1
|
49
|
+
0 0 0 1
|
50
|
+
0 0 0 1
|
51
|
+
0 0 0 1
|
52
|
+
0 1 0 1
|
53
|
+
0 0 0 1
|
54
|
+
0 0 0 1
|
55
|
+
0 0 0 1
|
56
|
+
0 0 0 1
|
57
|
+
0 0 0 1
|
58
|
+
0 0 0 1
|
59
|
+
0 0 0 1
|
60
|
+
0 0 0 1
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emfrp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kensuke Sawada
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-01-
|
11
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colorize
|
@@ -83,6 +83,14 @@ files:
|
|
83
83
|
- bin/emfrp
|
84
84
|
- bin/emfrpi
|
85
85
|
- emfrp.gemspec
|
86
|
+
- examples/LCDClock/LCDClock.c
|
87
|
+
- examples/LCDClock/LCDClock.h
|
88
|
+
- examples/LCDClock/LCDClock.mfrp
|
89
|
+
- examples/LCDClock/LCDClockMain.c
|
90
|
+
- examples/LCDClock/LCDClock_LPC1768.bin
|
91
|
+
- examples/LCDClock/README.md
|
92
|
+
- examples/LCDClock/graph.dot
|
93
|
+
- examples/LCDClock/graph.png
|
86
94
|
- examples/LCDPositioner/LCDPositioner.c
|
87
95
|
- examples/LCDPositioner/LCDPositioner.h
|
88
96
|
- examples/LCDPositioner/LCDPositioner.mfrp
|
@@ -137,6 +145,12 @@ files:
|
|
137
145
|
- tests/compiler/ComplexDataType/expected_out.txt
|
138
146
|
- tests/compiler/ComplexDataType/graph.png
|
139
147
|
- tests/compiler/ComplexDataType/in.txt
|
148
|
+
- tests/compiler/LCDClock/LCDClock.mfrp
|
149
|
+
- tests/compiler/LCDClock/LCDClockMain.c
|
150
|
+
- tests/compiler/LCDClock/Rakefile
|
151
|
+
- tests/compiler/LCDClock/actual_out.txt
|
152
|
+
- tests/compiler/LCDClock/expected_out.txt
|
153
|
+
- tests/compiler/LCDClock/in.txt
|
140
154
|
- tests/compiler/LCDPositioner/LCDPositioner.mfrp
|
141
155
|
- tests/compiler/LCDPositioner/LCDPositionerMain.c
|
142
156
|
- tests/compiler/LCDPositioner/Rakefile
|