-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsystemLib.h
88 lines (71 loc) · 2.28 KB
/
systemLib.h
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
#ifndef _SYSTEMLIB_H_
#define _SYSTEMLIB_H_
//#define __SIN_PSEUDOWIRINGPI__
#include <time.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <sys/time.h>
#include "pseudoWiringPi.h"
//#include <wiringPi.h>
#include "kbhit.h" // para poder detectar teclas pulsadas sin bloqueo y leer las teclas pulsadas
#include "fsm.h"
#include "tmr.h"
#define CLK_MS 1
#define TIMEOUT 1000
#define TIMEOUT_RAPIDO 750
#define TIMEOUT_RAPIDO2 500
// ATENCION: Valores a modificar por el alumno
// INTERVALO DE GUARDA ANTI-REBOTES
#define DEBOUNCE_TIME 200
#define TIMEOUT_ACTUALIZA_JUEGO 1000
// A 'key' which we can lock and unlock - values are 0 through 3
// This is interpreted internally as a pthread_mutex by wiringPi
// which is hiding some of that to make life simple.
// CLAVES PARA MUTEX
// ATENCION: Valores a modificar por el alumno
#define KEYBOARD_KEY 0
#define SYSTEM_FLAGS_KEY 1
#define MATRIX_KEY 2
#define STD_IO_BUFFER_KEY 3
// Distribucion de pines GPIO empleada para el teclado y el display
// ATENCION: Valores a modificar por el alumno
#define GPIO_KEYBOARD_COL_1 0
#define GPIO_KEYBOARD_COL_2 1
#define GPIO_KEYBOARD_COL_3 2
#define GPIO_KEYBOARD_COL_4 3
#define GPIO_KEYBOARD_ROW_1 5
#define GPIO_KEYBOARD_ROW_2 6
#define GPIO_KEYBOARD_ROW_3 12
#define GPIO_KEYBOARD_ROW_4 13
#define GPIO_LED_DISPLAY_COL_1 11
#define GPIO_LED_DISPLAY_COL_2 14
#define GPIO_LED_DISPLAY_COL_3 17
//#define GPIO_LED_DISPLAY_COL_4
#define GPIO_LED_DISPLAY_ROW_1 4
#define GPIO_LED_DISPLAY_ROW_2 7
#define GPIO_LED_DISPLAY_ROW_3 8
#define GPIO_LED_DISPLAY_ROW_4 10
#define GPIO_LED_DISPLAY_ROW_5 22
#define GPIO_LED_DISPLAY_ROW_6 23
#define GPIO_LED_DISPLAY_ROW_7 24
// FLAGS FSM CONTROL DE SERPIENTE Y GESTION JUEGO
// ATENCION: Valores a modificar por el alumno
#define FLAG_MOV_ARRIBA 0x01
#define FLAG_MOV_ABAJO 0x02
#define FLAG_MOV_DERECHA 0x04
#define FLAG_MOV_IZQUIERDA 0x08
#define FLAG_TIMER_JUEGO 0x10
#define FLAG_BOTON 0x20
#define FLAG_FIN_JUEGO 0x40
#define FLAG_PAUSA_JUEGO 0x80 //Para pausar el juego
enum fsm_state {
WAIT_START,
WAIT_PUSH,
WAIT_PAUSE,
WAIT_END};
extern int flags;
#endif /* SYSTEMLIB_H_ */