-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbracket.c
133 lines (109 loc) · 1.99 KB
/
bracket.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
/** \file
* Test bracketing
*/
#include "dryos.h"
#include "tasks.h"
#include "bmp.h"
#include "menu.h"
#include "lens.h"
static struct semaphore * bracket_sem;
static void
bracket_start( void * priv )
{
DebugMsg( DM_MAGIC, 3, "%s: Starting bracket task", __func__ );
gui_stop_menu();
give_semaphore( bracket_sem );
}
static int ae_count = 5;
static int ae_step = 3;
static void
ae_display(
void * priv,
int x,
int y,
int selected
)
{
bmp_printf(
selected ? MENU_FONT_SEL : MENU_FONT,
x, y,
//2349012
"AE %s %2d",
priv == &ae_count ? "Count:" :
priv == &ae_step ? "Step: " :
"?????:",
*(int*) priv
);
}
static void
ae_adjust_count(
void * priv
)
{
ae_count += 2;
if( ae_count > 13 )
ae_count = 3;
}
static void
ae_adjust_step(
void * priv
)
{
ae_step++;
if( ae_step > 8 )
ae_step = 1;
}
static struct menu_entry bracket_menu[] = {
{
.priv = "Test bracket",
.display = menu_print,
.select = bracket_start,
},
{
.priv = &ae_count,
.display = ae_display,
.select = ae_adjust_count,
},
{
.priv = &ae_step,
.display = ae_display,
.select = ae_adjust_step,
},
};
static void
bracket_task( void * priv )
{
bracket_sem = create_named_semaphore( "bracket_sem", 0 );
menu_add( "Brack", bracket_menu, COUNT(bracket_menu) );
while( 1 )
{
take_semaphore( bracket_sem, 0 );
DebugMsg( DM_MAGIC, 3, "%s: Awake", __func__ );
bmp_printf( FONT_SMALL, 400, 30, "%s: Awake", __func__ );
// Get the current value for a starting point
const int ae = lens_get_ae();
DebugMsg( DM_MAGIC, 3,
"%s: Current AE %d. Count=%d step=%d",
__func__,
ae,
ae_count,
ae_step
);
msleep( 100 );
int i;
for( i=-ae_count/2 ; i<=ae_count/2 ; i++ )
{
int new_ae = ae + ae_step * i;
DebugMsg( DM_MAGIC, 3,
"%s: Exposure %d: ae %d",
__func__,
i,
new_ae
);
lens_set_ae( new_ae );
lens_take_picture( 1000 );
}
lens_set_ae( ae );
}
}
TASK_CREATE( "bracket_task", bracket_task, 0, 0x10, 0x1000 );