summaryrefslogtreecommitdiffhomepage
path: root/digital/beacon/src/calibration.h
blob: 3512eedfe31a9de72bb5ac9af3d2602575bad7cb (plain)
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
/* calibration.h */
/* Beacon servomotor calibration. {{{
 *
 * Copyright (C) 2012 Florent Duchon
 *
 * APBTeam:
 *        Web: http://apbteam.org/
 *      Email: team AT apbteam DOT org
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 * }}} */

#ifndef _CALIBRATION_H
#define _CALIBRATION_H

#include "servo.h"

#define CALIBRATION_FAST_TASK_PERIOD 		11L
#define CALIBRATION_SLOW_TASK_PERIOD 	110L

#define FAST_SCANNING_OFFSET 		10
#define SCANNING_STEP 			1

typedef enum
{
	CLEAR,
	SET
} TLaser_flag_type;

typedef enum
{
	FAST_SCANNING,
	SLOW_SCANNING
} TScanning_mode;

typedef enum
{
	CALIBRATION_INIT,
	CALIBRATION_FAST_SCANNING,
	CALIBRATION_SLOW_SCANNING,
	SCANNING_STATE_CALIBRATED
} TCalibration_state;

typedef struct
{
	TCalibration_state state;
	TLaser_flag_type laser_flag;
} calibration_s;

/* This function iniatializes the calibration structure*/
void calibration_init_structure(void);

/* This function starts the calibration task */
void calibration_start_task(void);

/* This function stops the calibration task */
void calibration_stop_task(void);

/* This function starts or stops the calibration task depending on the current state */
void calibration_start_stop_task(void);

/* This function restarts the calibration task changing its frequency */
void calibration_change_task_frequency(uint32_t frequency);

/* Calibration task is used to calibrated the servo motors in order to run the laser parallel to the table */
void calibration_task(void);

/* This function drives the defined servo motor in order to scan verticaly */
void calibration_scanning(TServo_ID servo_id);

/* This function sets the laser flag according the given value SET or CLEAR */
void calibration_set_laser_flag(TLaser_flag_type value);

/* This function returns the laser flag */
TLaser_flag_type calibration_get_laser_flag(void);

/* This function returns the calibration state */
TCalibration_state calibration_get_state(void);

#endif