summaryrefslogtreecommitdiffhomepage
path: root/digital/io/src/top.h
blob: 024231ecbef60966d78015a44c6c446eb4c82608 (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
#ifndef top_h
#define top_h
/* top.h */
/* io - Input & Output with Artificial Intelligence (ai) support on AVR. {{{
 *
 * Copyright (C) 2008 Nélio Laranjeiro
 *
 * 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.
 *
 * }}} */

#define BLUE_DISTRIBUTOR_X 700
#define BLUE_DISTRIBUTOR_Y 2100

#define RED_DISTRIBUTOR_X 2300
#define RED_DISTRIBUTOR_Y 2100

#define ICE_DISTRIBUTOR_LEFT 0 
#define ICE_DISTRIBUTOR_RIGHT 3000 
#define ICE_DISTRIBUTOR_Y 1350

enum sequence_e
{
    /* 3 color balls, 2 ice */
    SEQUCENCE_ONE = 0x15,
    /* 2 color balls, 3 ice */
    SEQUENCE_TWO = 0xA
};

struct top_data_t
{
    /** The sequence to get.
     * Each bit corresponds to the slot in the collector (where the balls a
     * stored in the robot).
     * bit 0 = slot 0
     * bit 1 = slot 1 and so on.
     */
    uint8_t sequence;
    /** The boxes already in use. */
    uint8_t boxes_used;
    /** sequence to realize. */
    uint8_t sequence_to_do;
};

extern struct top_data_t top_data;

/** Start a Top FSM. */
void
top_start (void);

/**
 * Do we need to tell the top FSM the settings has been acknowledged?
 * You need to call this function in the main loop to ensure we pass a
 * requested event (settings_acknowledged) to the top FSM.
 * @return
 *   - 0 if you do not need to generate the event for the top FSM ;
 *   - 1 if you need to generate the event.
 */
uint8_t
top_generate_settings_ack_event (void);

#endif /* top_h */