Add the 74HC595 Snake game project
This commit is contained in:
40
08-74HC595-Snake/controls.h
Normal file
40
08-74HC595-Snake/controls.h
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef _JOYSTICK_H_
|
||||
#define _JOYSTICK_H_
|
||||
|
||||
#include <Arduino.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define PIN_BUTTON_LEFT 1 // Red
|
||||
#define PIN_BUTTON_UP 2 // Green
|
||||
#define PIN_BUTTON_DOWN 47 // Yellow
|
||||
#define PIN_BUTTON_RIGHT 13 // Blue
|
||||
|
||||
#define PIN_DIFFICULTY 10
|
||||
|
||||
#define BUTTON_STABLETIME 100
|
||||
|
||||
// Button states
|
||||
#define BUTTON_STATE_BOUNCING (1 << 0)
|
||||
#define BUTTON_STATE_DOWN (1 << 1)
|
||||
#define BUTTON_STATE_UP (1 << 2)
|
||||
#define BUTTON_STATE_HELD (1 << 3)
|
||||
|
||||
|
||||
typedef struct Button {
|
||||
// What pin is this button on
|
||||
uint8_t pin;
|
||||
// What is the state of this button (bitmask of BUTTON_STATE_*)
|
||||
uint8_t state;
|
||||
// Is this button pressed when it is LOW or HIGH?
|
||||
uint32_t pressedvalue;
|
||||
// How long do we wait when debouncing this button
|
||||
uint32_t debouncetime;
|
||||
// When did we start debouncing
|
||||
uint32_t debounce_start_time;
|
||||
} Button;
|
||||
|
||||
int initButton(Button *button);
|
||||
int readButton(Button *button);
|
||||
uint32_t readDifficulty();
|
||||
|
||||
#endif // _JOYSTICK_H_
|
||||
Reference in New Issue
Block a user