Merge branch 'master' of github.com:swinginbird/flippr-code
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,3 @@
|
|||||||
*.idea*
|
*.idea*
|
||||||
cmake-build-debug
|
cmake-build-debug
|
||||||
.idea/*
|
*__pycache__*
|
||||||
*__pycache__/*
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ set(LIB_DIR lib)
|
|||||||
set(DEFAULT_BUILD_TYPE DEBUG)
|
set(DEFAULT_BUILD_TYPE DEBUG)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14)
|
set(CMAKE_CXX_STANDARD 14)
|
||||||
SET(DBoost_NO_BOOST_CMAKE=ON)
|
|
||||||
|
|
||||||
IF(NOT_PI)
|
IF(NOT_PI)
|
||||||
add_definitions(-DNOT_PI)
|
add_definitions(-DNOT_PI)
|
||||||
@@ -86,6 +85,8 @@ endif(Boost_FOUND)
|
|||||||
|
|
||||||
##################### WIRING_PI ##########################
|
##################### WIRING_PI ##########################
|
||||||
find_library(wiringPi_LIB wiringPi)
|
find_library(wiringPi_LIB wiringPi)
|
||||||
|
|
||||||
|
add_definitions(-DNO_WIRING_PI)
|
||||||
if(NOT wiringPi_LIB)
|
if(NOT wiringPi_LIB)
|
||||||
message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.")
|
message(WARNING "Could not find wiringPi library, used testing wiring pi lib instead.")
|
||||||
add_definitions(-DNO_WIRING_PI)
|
add_definitions(-DNO_WIRING_PI)
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
static int wiringPiSetup()
|
static int wiringPiSetup()
|
||||||
{
|
{
|
||||||
std::cout << "WiringPiSetup() called" << std::endl;
|
std::cout << "WiringPiSetup() called" << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void pinMode(int pin, int mode)
|
void pinMode(int pin, int mode)
|
||||||
@@ -23,6 +24,7 @@ void pinMode(int pin, int mode)
|
|||||||
int digitalRead(int pin)
|
int digitalRead(int pin)
|
||||||
{
|
{
|
||||||
std::cout << "Reading pin " << pin << std::endl;
|
std::cout << "Reading pin " << pin << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void digitalWrite(int pin, int value)
|
void digitalWrite(int pin, int value)
|
||||||
@@ -34,6 +36,7 @@ void digitalWrite(int pin, int value)
|
|||||||
int mcp23017Setup(const int pinBase, const int i2cAddress)
|
int mcp23017Setup(const int pinBase, const int i2cAddress)
|
||||||
{
|
{
|
||||||
std::cout << "mcp23017Setup called with pinBase " << pinBase << " and i2cAddress " << i2cAddress << std::endl;
|
std::cout << "mcp23017Setup called with pinBase " << pinBase << " and i2cAddress " << i2cAddress << std::endl;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ class Networking:
|
|||||||
return self.get("/displays").json()
|
return self.get("/displays").json()
|
||||||
|
|
||||||
def triggerSolenoid(self, solenoid):
|
def triggerSolenoid(self, solenoid):
|
||||||
self.get("/solenoids" + solenoid + "/trigger")
|
self.get("/solenoids/" + solenoid + "/trigger")
|
||||||
|
|
||||||
def playSound(self, sound):
|
def playSound(self, sound):
|
||||||
self.get("/sounds/" + sound + "/play")
|
self.get("/sounds/" + sound + "/play")
|
||||||
@@ -46,4 +46,4 @@ class Networking:
|
|||||||
self.get("/displays" + display + "/write_score/" + str(score))
|
self.get("/displays" + display + "/write_score/" + str(score))
|
||||||
|
|
||||||
def getInputEvent(self):
|
def getInputEvent(self):
|
||||||
pass
|
return ''
|
||||||
|
|||||||
38
cli/game.py
Normal file
38
cli/game.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
from FlippR_Networking import Networking
|
||||||
|
|
||||||
|
output_server_address = ''
|
||||||
|
input_server_address = ''
|
||||||
|
|
||||||
|
#network = Networking(output_server_address, input_server_address)
|
||||||
|
network = ''
|
||||||
|
|
||||||
|
class EventHandler():
|
||||||
|
def __init__(self, network):
|
||||||
|
# brace yourselves, python incoming
|
||||||
|
self.subclasses = {subcls.__name__: subcls for subcls in self.__class__.__subclasses__()}
|
||||||
|
self.network = network
|
||||||
|
|
||||||
|
def handle(self, name):
|
||||||
|
self.subclasses[name](network)
|
||||||
|
|
||||||
|
class LeftFlapEventHandler(EventHandler):
|
||||||
|
def __init__(self, network):
|
||||||
|
print('Left Flap Event gets handled')
|
||||||
|
self.handle()
|
||||||
|
|
||||||
|
def handle(self):
|
||||||
|
# do stuff...
|
||||||
|
pass
|
||||||
|
|
||||||
|
def snake_to_camel(word):
|
||||||
|
return ''.join(x.capitalize() or '' for x in word.split('_'))
|
||||||
|
|
||||||
|
handler = EventHandler(network)
|
||||||
|
# handler.handle(snake_to_camel('left_flap') + 'EventHandler')
|
||||||
|
|
||||||
|
# while True:
|
||||||
|
# event_name = snake_to_camel(network.getInputEvent())
|
||||||
|
# handler.handle(event_name + 'EventHandler')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user