-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_input.ino
65 lines (49 loc) · 1.57 KB
/
user_input.ino
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
void initUserInput(){
pinMode( ME_SWITCH, INPUT_PULLUP );
pinMode( PLAYBACK_SWITCH, INPUT_PULLUP);
pinMode(SHUTTER_BUTTON, INPUT_PULLUP );
pinMode( VIDEO_MODE_SWITCH, INPUT_PULLUP);
//registerRoataryInterrupts();
}
void registerRoataryInterrupts(){
pinMode( ROTARY_ENCODER_L, INPUT_PULLUP );
pinMode( ROTARY_ENCODER_R, INPUT_PULLUP );
attachInterrupt( digitalPinToInterrupt( ROTARY_ENCODER_L ), rotaryL, FALLING);
attachInterrupt( digitalPinToInterrupt( ROTARY_ENCODER_R ), rotaryR, HIGH);
}
void rotaryL(){
Serial.println("L");
}
void rotaryR(){
Serial.println("R");
}
void updateUserInput(){
ui.me_switch = digitalRead( ME_SWITCH ); //what does the ME switch say?
ui.playback_switch = digitalRead(PLAYBACK_SWITCH);
ui.video_mode_switch = digitalRead(VIDEO_MODE_SWITCH);
ui.shutter_button_down = !digitalRead( SHUTTER_BUTTON ) ; //invert input because pullup.
ui.shutter_button_pressed = false;
if( ui.shutter_button_down && millis() > ui.shutter_ready_at){
ui.shutter_ready_at = millis() + SHUTTER_COOLDOWN;
ui.shutter_button_pressed = true;
}
ui.exposure_pot = analogRead( EXPOSURE_POT );
ui.exposure_index = map(ui.exposure_pot, 0, 4095, 0, 11);
ui.exposure_display = exposure_table[ui.exposure_index][0];
ui.exposure_period = exposure_table[ui.exposure_index][1];
}
bool getVideoModeSwitch(){
return ui.video_mode_switch;
}
bool getMeSwitch(){
return ui.me_switch;
}
bool getPlaybackSwitch(){
return ui.playback_switch;
}
bool getShutterButton(){
return ui.shutter_button_pressed;
}
uint getExpPot(){
return ui.exposure_pot;
}