-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolenoid.cc
More file actions
executable file
·69 lines (63 loc) · 1.94 KB
/
Copy pathsolenoid.cc
File metadata and controls
executable file
·69 lines (63 loc) · 1.94 KB
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
//======================================================================================
/** \file solenoid.cc
* Class which implements the functionality of the solenoid to make a picture or hit the focus
* ME405 boards
*
* Revisions:
* \li 04-17-08 Created files
* \li 04-21-08 Began implementing methods
*
* License:
* This file released under the Lesser GNU Public License. The program is intended
* for educational use only, but its use is not restricted thereto.
*/
//======================================================================================
#include <stdlib.h>
#include <avr/io.h>
#include "rs232.h" // Include header for serial port class
#include "solenoid.h"
/** \brief Initialization
*
* Initializes the data direction register of port C, as well as saving a pointer
* to a serial port object to debug with
* \param p_serial_port Pointer to a serial port
*/
solenoid::solenoid (base_text_serial* p_serial_port)
{
ptr_to_serial = p_serial_port;
*ptr_to_serial << "Setting up solenid controller" << endl;
//Sets up the data direction register to open the relevant bit of Port C
DDRC = 0x01;
//Sets the output to zero at the beginning
PORTC = 0x00;
}
/** \brief Sets the amount of time the shutter needs to be held down to take a picture
* \param time Time needed to take a picture, in milliseconds
*/
bool solenoid::set_pic_time (int time)
{
time_for_pic = time;
return true;
}
/** \brief Sets the amount of time the shutter needs to be held down to focus the camera
* \param time Time needed to focus, in milliseconds
*/
bool solenoid::set_focus_time (int time)
{
time_for_focus = time;
return true;
}
/** \brief Turns on %solenoid
*/
void solenoid::turn_on (void)
{
*ptr_to_serial << "Turning on solenoid" << endl;
PORTC |= 0x01;
}
/** \brief Turns off %solenoid
*/
void solenoid::turn_off (void)
{
*ptr_to_serial << "Turning off solenoid" << endl;
PORTC &= 0x00;
}