-
Notifications
You must be signed in to change notification settings - Fork 16
/
Gamer.h
executable file
·105 lines (90 loc) · 1.88 KB
/
Gamer.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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#ifndef Gamer_h
#define Gamer_h
#include "Arduino.h"
#include <avr/interrupt.h>
#include <avr/io.h>
class Gamer {
public:
// Constructor
Gamer();
// Keywords
#define UP 0
#define LEFT 1
#define RIGHT 2
#define DOWN 3
#define START 4
//Note: Gamer v1.9 is Capacitive touch instead of LDR.
#define LDR 5
// Setup
void begin();
void update();
// Inputs
bool isPressed(uint8_t input);
bool isHeld(uint8_t input);
//Note: Gamers preceding v1.9
int ldrValue();
void setldrThreshold(uint16_t threshold);
//Note: Gamer v1.9
bool capTouch();
// Outputs
void setRefreshRate(uint16_t refreshRate);
void updateDisplay();
void allOn();
void clear();
void printImage(byte* img);
void printImage(byte* img, int x, int y);
void setLED(bool value);
void toggleLED();
void playTone(int note);
void stopTone();
void printString(String string);
void appendColumn(byte* screen, byte col);
void showScore(int n);
// Infrared
void irBegin();
void irEnd();
// Variables
byte display[8][8];
byte pulseCount;
byte buzzerCount;
byte nextRow;
byte currentRow;
byte counter;
byte image[8];
// Routines attached to the timer's ISR
void isrRoutine();
private:
// Keywords
#define CLK1 6
#define DAT 8
#define LAT 9
#define CLK2 7
#define DAT 8
#define LAT 9
#define OE 10
#define LED 13
#define BUZZER 2
#define RX 5
#define TX 4
#define DEBOUNCETIME 50
// Variables
uint16_t _refreshRate;
bool buttonFlags[6];
unsigned long buttonLastPressed[6];
int lastInputState[6];
uint16_t ldrThreshold;
// Functions
void setupLetters();
void writeToDriver(byte dataOut);
void writeToRegister(byte dataOut);
void checkSerial();
void checkInputs();
void updateRow();
int currentInputState[6];
boolean tog;
// Numbers and letters for printString
#define LETEND B10101010
const static uint8_t allLetters[85][9];
const static uint8_t allNumbers[10][8];
};
#endif