-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_patterns.c
429 lines (338 loc) · 12.5 KB
/
test_patterns.c
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
#include <unistd.h>
#include <time.h>
#include "common.h"
#include "error.h"
#include "lcr_cmd.h"
static void mSleep(unsigned long int mSeconds);
static void flash_solid_color();
static void flash_solid_color_at_speed(int speed, int exposure_time);
static void flash_half_color();
static void flash_half_color_at_speed(int speed, int exposure_time);
static void flash_diag_pattern();
static void scan_vertical_lines();
static void scan_vert_seven();
static void dynamic_load_test();
static void scan_gray_code();
static void moire();
/* main() function */
int main(int argc, char *argv[])
{
uint8 ch;
//Connect to the LCr H/W via TCP interface
if(LCR_CMD_Open())
{
printf("Unable to connect to the DLP LCr\n");
return -1;
}
printf("press 'x' to quit, enter '1' to flash a solid frame, enter '2' to flash a half-filled-frame.\n");
while((ch = getchar()) != 'x') {
if (ch == '1') {
flash_solid_color();
} else if (ch == '2') {
flash_half_color();
} else if (ch == '3') {
flash_diag_pattern();
} else if (ch == '4') {
scan_vertical_lines();
} else if (ch == '5') {
scan_vert_seven();
} else if (ch == '6') {
scan_gray_code();
} else if (ch == '0') {
dynamic_load_test();
} else if (ch == '7') {
moire();
}
}
LCR_CMD_Close();
return 0;
}
static void flash_solid_color() {
int speed = 13950;
int exposure_time = 600;
flash_solid_color_at_speed(speed, exposure_time);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
if (ch == 'u') {
speed = speed + 100;
flash_solid_color_at_speed(speed, exposure_time);
} else if (ch == 'y') {
speed = speed - 100;
flash_solid_color_at_speed(speed, exposure_time);
} else if (ch == 'r') {
exposure_time = exposure_time + 100;
flash_solid_color_at_speed(speed, exposure_time);
} else if (ch == 'e') {
exposure_time = exposure_time - 100;
flash_solid_color_at_speed(speed, exposure_time);
} else if (ch == 'j') {
speed = speed + 50;
flash_solid_color_at_speed(speed, exposure_time);
} else if (ch == 'h') {
speed = speed - 50;
flash_solid_color_at_speed(speed, exposure_time);
}
}
LCR_CMD_StartPatternSeq(0); //Stop pattern sequence
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00)); //Setting back to static display mode
}
static void flash_solid_color_at_speed(int speed, int exposure_time) {
LCR_PatternSeqSetting_t patSeqSet;
printf("\n\nrunning flash_solid_color demo\n\n");
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 2;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = speed;
patSeqSet.ExposureTime = exposure_time;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
printf("Downloading pat0\n");
LCR_CMD_DefinePatternBMP(0,"./Images/test/white.bmp");
printf("Downloading pat1...\n");
LCR_CMD_DefinePatternBMP(1,"./Images/test/black.bmp");
printf("Starting Pattern Sequence at speed %d, and exposure %d\n", speed, exposure_time);
LCR_CMD_StartPatternSeq(1);
}
static void flash_half_color() {
int speed = 13950;
int exposure_time = 600;
flash_half_color_at_speed(speed, exposure_time);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
if (ch == 'u') {
speed = speed + 100;
flash_half_color_at_speed(speed, exposure_time);
} else if (ch == 'y') {
speed = speed - 100;
flash_half_color_at_speed(speed, exposure_time);
} else if (ch == 'r') {
exposure_time = exposure_time + 100;
flash_half_color_at_speed(speed, exposure_time);
} else if (ch == 'e') {
exposure_time = exposure_time - 100;
flash_half_color_at_speed(speed, exposure_time);
} else if (ch == 'j') {
speed = speed + 50;
flash_half_color_at_speed(speed, exposure_time);
} else if (ch == 'h') {
speed = speed - 50;
flash_half_color_at_speed(speed, exposure_time);
}
}
LCR_CMD_StartPatternSeq(0); //Stop pattern sequence
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00)); //Setting back to static display mode
}
static void flash_half_color_at_speed(int speed, int exposure_time) {
LCR_PatternSeqSetting_t patSeqSet;
printf("\n\nrunning flash_half_color demo for ten seconds\n\n");
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 2;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = speed;
patSeqSet.ExposureTime = exposure_time;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
printf("Downloading pat0\n");
LCR_CMD_DefinePatternBMP(0,"./Images/test/half1.bmp");
printf("Downloading pat1...\n");
LCR_CMD_DefinePatternBMP(1,"./Images/test/half2.bmp");
printf("Starting Pattern Sequence...\n");
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
// nothing yet.
}
LCR_CMD_StartPatternSeq(0); //Stop pattern sequence
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00)); //Setting back to static display mode
}
static void flash_diag_pattern() {
LCR_PatternSeqSetting_t patSeqSet;
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 2;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = 13950;
patSeqSet.ExposureTime = 600;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
printf("Downloading pat0\n");
LCR_CMD_DefinePatternBMP(0,"./Images/test/diag1.bmp");
printf("Downloading pat1...\n");
LCR_CMD_DefinePatternBMP(1,"./Images/test/diag2.bmp");
printf("Starting Pattern Sequence...\n");
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
// nothing yet.
}
LCR_CMD_StartPatternSeq(0); //Stop pattern sequence
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00)); //Setting back to static display mode
}
static void scan_vertical_lines() {
LCR_PatternSeqSetting_t patSeqSet;
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
int frame_count = 96;
int multiplier = 608 / frame_count;
int frame_duration = 250000;
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = frame_count;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = frame_duration;
patSeqSet.ExposureTime = frame_duration;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
int i;
for (i = 0; i < frame_count; i++) {
char buf[35];
sprintf(buf, "./Images/test/vertical/line%d.bmp", i * multiplier);
printf("downloading pattern %s\n", buf);
LCR_CMD_DefinePatternBMP(i, buf);
}
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
// nothing yet.
}
LCR_CMD_StartPatternSeq(0);
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00));
}
static void scan_vert_seven() {
LCR_PatternSeqSetting_t patSeqSet;
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 86;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = 25000;
patSeqSet.ExposureTime = 25000;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
int i;
for (i = 0; i < 86; i++) {
char buf[37];
sprintf(buf, "./Images/test/vert_seven/line%d.bmp", i);
printf("downloading pattern %s\n", buf);
LCR_CMD_DefinePatternBMP(i, buf);
}
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
// nothing yet.
}
LCR_CMD_StartPatternSeq(0);
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00));
}
static void scan_gray_code() {
LCR_PatternSeqSetting_t patSeqSet;
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 4;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = 250000;
patSeqSet.ExposureTime = 250000;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
LCR_CMD_DefinePatternBMP(0, "Images/test/code/frame00.bmp");
LCR_CMD_DefinePatternBMP(1, "Images/test/code/frame01.bmp");
LCR_CMD_DefinePatternBMP(2, "Images/test/code/frame02.bmp");
LCR_CMD_DefinePatternBMP(3, "Images/test/code/frame03.bmp");
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {}
LCR_CMD_StartPatternSeq(0);
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00));
}
static void moire() {
LCR_PatternSeqSetting_t patSeqSet;
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 1;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = 250000;
patSeqSet.ExposureTime = 250000;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
LCR_CMD_DefinePatternBMP(0, "Images/test/lines600.bmp");
LCR_CMD_StartPatternSeq(1);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {}
LCR_CMD_StartPatternSeq(0);
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00));
}
static void dynamic_load_test() {
LCR_PatternSeqSetting_t patSeqSet;
printf("\n\nrunning flash_solid_color demo\n\n");
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x04));
patSeqSet.BitDepth = 1;
patSeqSet.NumPatterns = 2;
patSeqSet.PatternType = PTN_TYPE_NORMAL;
patSeqSet.InputTriggerDelay = 0;
patSeqSet.InputTriggerType = TRIGGER_TYPE_AUTO;
patSeqSet.AutoTriggerPeriod = 500000;
patSeqSet.ExposureTime = 500000;
patSeqSet.LEDSelect = LED_GREEN;
patSeqSet.Repeat = 0;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
printf("Downloading pat0\n");
LCR_CMD_DefinePatternBMP(0,"./Images/test/white.bmp");
printf("Downloading pat1...\n");
LCR_CMD_DefinePatternBMP(1,"./Images/test/black.bmp");
LCR_CMD_DefinePatternBMP(2, "./Images/test/whitetop.bmp");
LCR_CMD_DefinePatternBMP(3, "./Images/test/whitebottom.bmp");
LCR_CMD_StartPatternSeq(1);
mSleep(5000);
clock_t begin, end;
double time_spent;
begin = clock();
patSeqSet.NumPatterns = 4;
LCR_CMD_SetPatternSeqSetting(&patSeqSet);
printf("Downloading pat3...\n");
LCR_CMD_StartPatternSeq(1);
end = clock();
time_spent = (double)(end - begin) / CLOCKS_PER_SEC;
printf("loading of an extra 2 frames took %f seconds\n", time_spent);
uint8 ch;
printf("enter 's' to stop sequence.\n");
while((ch = getchar()) != 's') {
// nothing yet.
}
LCR_CMD_StartPatternSeq(0); //Stop pattern sequence
LCR_CMD_SetDisplayMode((LCR_DisplayMode_t)(0x00)); //Setting back to static display mode
}
/*Function is used to create delay in mSeconds */
/* This is used in demo code to show code flow */
static void mSleep(unsigned long int mSeconds)
{
/*Add logic and call system function that will create mSeconds millisecond delay */
sleep((mSeconds/1000.0));
}