-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLCD.h
More file actions
77 lines (59 loc) · 1.74 KB
/
Copy pathLCD.h
File metadata and controls
77 lines (59 loc) · 1.74 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
70
71
72
73
74
75
76
77
#ifndef CHESS_CONTROLLER_LCD
#define CHESS_CONTROLLER_LCD
#include <LiquidCrystal_I2C.h>
#include "Coord.h"
#include "Timer.h"
#define LCD_COLS (16)
#define LCD_ROWS (2)
/* This displays a simple hello message */
#define LCD_STATE_HELLO (0)
/* This shows the timer, which is not passing, before starting the game */
#define LCD_STATE_STANDBY (1)
/* This waits until cpu move by motor is done */
#define LCD_STATE_MOVING_CPU (2)
/* This waits until player move by motor is done */
#define LCD_STATE_MOVING_PLAYER (3)
/* This waits player input */
#define LCD_STATE_WAIT_PLAYER (4)
/* This is player victory */
#define LCD_STATE_VICTORY (5)
/* This is cpu victory */
#define LCD_STATE_GAMEOVER (6)
/* This warns player for trying an illegal move */
#define LCD_STATE_WARN_PLAYER (7)
/* This is draw (possibly stalemate) */
#define LCD_STATE_DRAW (8)
#define LCD_EDIT_TARGET_NONE (0)
#define LCD_EDIT_TARGET_FROM (1)
#define LCD_EDIT_TARGET_TO (2)
class LCD {
public:
LCD(uint8_t addr, Timer *timer);
void set_state(uint8_t state);
/**
* Set the edit target of which we are aiming to change coord value.
*/
void set_edit_target(uint8_t target);
void set_edit_value(struct Coord coord);
void reset_edit_target(uint8_t target);
/**
* Notation must be shorter than 8 characters (excluding \0)
*/
void set_move_algebraic_notation(char *notation);
void update();
private:
uint8_t addr;
LiquidCrystal_I2C *lc;
Timer *timer;
uint8_t state;
bool is_from_set;
struct Coord from;
bool is_to_set;
struct Coord to;
uint8_t edit_target;
char *algebraic_notation;
bool algebraic_notation_lock;
};
char *coord_display(struct Coord coord);
char *time_display(uint32_t time);
#endif