Ref: Remove unecessary files
This commit is contained in:
@@ -1 +0,0 @@
|
|||||||
input events entprellen über flanken statt zeit
|
|
||||||
37
init/init.py
37
init/init.py
@@ -1,37 +0,0 @@
|
|||||||
#!/usr/bin/python3
|
|
||||||
|
|
||||||
from time import sleep
|
|
||||||
import os
|
|
||||||
import subprocess
|
|
||||||
import re
|
|
||||||
import wiringpi
|
|
||||||
|
|
||||||
p = subprocess.Popen(['gpio', 'i2cdetect'],stdout=subprocess.PIPE,)
|
|
||||||
#cmdout = str(p.communicate())
|
|
||||||
|
|
||||||
mcps = list()
|
|
||||||
p.stdout.readline()
|
|
||||||
for i in range(1,9):
|
|
||||||
line = str(p.stdout.readline()).split(' ')[1:]
|
|
||||||
base_multiplier = 1
|
|
||||||
for mcp in line:
|
|
||||||
base_multiplier += 1
|
|
||||||
if re.search('\d\d', mcp):
|
|
||||||
base = 64+16*base_multiplier
|
|
||||||
mcps.append((mcp,base))
|
|
||||||
|
|
||||||
wiringpi.wiringPiSetup()
|
|
||||||
for mcp in mcps:
|
|
||||||
print("Setting base for MCP: ", mcp[0], " with base: ", mcp[1])
|
|
||||||
wiringpi.mcp23017Setup(mcp[1], int(mcp[0], 16))
|
|
||||||
for pin in range(16):
|
|
||||||
wiringpi.pinMode(mcp[1] + pin, 1)
|
|
||||||
wiringpi.digitalWrite(mcp[1] + pin, 1)
|
|
||||||
sleep(0.1)
|
|
||||||
|
|
||||||
except_pins = [2, 3]
|
|
||||||
|
|
||||||
for i in range(32):
|
|
||||||
wiringpi.pinMode(i, 1)
|
|
||||||
wiringpi.digitalWrite(pin, 1)
|
|
||||||
sleep(0.1)
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
Binary file not shown.
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
#echo "hello world"
|
|
||||||
|
|
||||||
cd /home/pi/firmware/flippr-code
|
|
||||||
OUTPUT="$(git pull)"
|
|
||||||
if [ "$OUTPUT" != "Already up-to-date." ]; then
|
|
||||||
echo "repo has updated. compile now..."
|
|
||||||
cd /home/pi/firmware/flippr-code/FlippR-Driver/build
|
|
||||||
cmake ..
|
|
||||||
make
|
|
||||||
fi
|
|
||||||
echo "repo on track, nothing to do here..."
|
|
||||||
174
test/andi/v1.py
174
test/andi/v1.py
@@ -1,174 +0,0 @@
|
|||||||
import wiringpi as wp
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
i2c_addr = 0x21
|
|
||||||
base_addr = 81
|
|
||||||
pins = range(base_addr, base_addr + 16)
|
|
||||||
pins = [22, 27, 17, 19, 13, 6, 5, 20, 21, 26, 1, 12, 16, 4]
|
|
||||||
|
|
||||||
""" has to be inverted
|
|
||||||
pins_segment_select = [81, 82, 83]"""
|
|
||||||
pins_segment_select = [83, 82, 81]
|
|
||||||
pins_segment_select = [22, 27, 17]
|
|
||||||
|
|
||||||
""" has to be inverted
|
|
||||||
pins_digit_select = [84, 85, 86, 87] """
|
|
||||||
#pins_digit_select = [87, 86, 85, 84]
|
|
||||||
pins_digit_select = [19, 13, 6, 5]
|
|
||||||
|
|
||||||
#pins_display_select = [89, 90, 91, 92, 93]
|
|
||||||
pins_display_select = [1, 20, 12, 16, 4]
|
|
||||||
pin_run = 95
|
|
||||||
pin_run = 21
|
|
||||||
pin_lt = 88
|
|
||||||
pin_lt = 26
|
|
||||||
|
|
||||||
high = False
|
|
||||||
low = not high
|
|
||||||
|
|
||||||
"""
|
|
||||||
def init():
|
|
||||||
wp.mcp23017Setup(base_addr, i2c_addr)
|
|
||||||
for pin in pins:
|
|
||||||
wp.pinMode(pin, 1)
|
|
||||||
init()
|
|
||||||
"""
|
|
||||||
def init():
|
|
||||||
wp.wiringPiSetupGpio()
|
|
||||||
for pin in pins:
|
|
||||||
wp.pinMode(pin, 1)
|
|
||||||
init()
|
|
||||||
|
|
||||||
def init_ones():
|
|
||||||
for pin in pins:
|
|
||||||
wp.digitalWrite(pin, 1)
|
|
||||||
def init_zeros():
|
|
||||||
for pin in pins:
|
|
||||||
wp.digitalWrite(pin, 0)
|
|
||||||
def init_high():
|
|
||||||
for pin in pins:
|
|
||||||
wp.digitalWrite(pin, high)
|
|
||||||
def init_low():
|
|
||||||
for pin in pins:
|
|
||||||
wp.digitalWrite(pin, low)
|
|
||||||
def dec2bin_high(dec, digits):
|
|
||||||
bin_str = format(dec, '#0' + str(digits + 2) + 'b')[2:]
|
|
||||||
return map(lambda x: high if x == '1' else low, bin_str)
|
|
||||||
def dec2bin_low(dec, digits):
|
|
||||||
bin_str = format(dec, '#0' + str(digits + 2) + 'b')[2:]
|
|
||||||
return map(lambda x: low if x == '1' else high, bin_str)
|
|
||||||
def toggle_run():
|
|
||||||
if wp.digitalRead(pin_run) == 0:
|
|
||||||
#print("enable RUN")
|
|
||||||
wp.digitalWrite(pin_run, 1)
|
|
||||||
else:
|
|
||||||
#print("disable RUN")
|
|
||||||
wp.digitalWrite(pin_run, 0)
|
|
||||||
def toggle_lt():
|
|
||||||
if wp.digitalRead(pin_lt) == 0:
|
|
||||||
#print("enable LT")
|
|
||||||
wp.digitalWrite(pin_lt, 1)
|
|
||||||
else:
|
|
||||||
#print("disable LT")
|
|
||||||
wp.digitalWrite(pin_lt, 0)
|
|
||||||
def check_decimal_for_validity(decimal, lower, upper):
|
|
||||||
if type(decimal) is not type(1):
|
|
||||||
print("input not a decimal")
|
|
||||||
return False
|
|
||||||
if decimal < lower or decimal > upper:
|
|
||||||
print("decimal out of range")
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
|
|
||||||
def select_segment(decimal):
|
|
||||||
#if not check_decimal_for_validity(decimal, 0, 7):
|
|
||||||
# print("input error, no segment selected")
|
|
||||||
# return
|
|
||||||
values = dec2bin_high(decimal, 3)
|
|
||||||
pss = pins_segment_select
|
|
||||||
wp.digitalWrite(pss[0], values[0])
|
|
||||||
wp.digitalWrite(pss[1], values[1])
|
|
||||||
wp.digitalWrite(pss[2], values[2])
|
|
||||||
|
|
||||||
def select_digit(decimal):
|
|
||||||
#if not check_decimal_for_validity(decimal, 0, 9):
|
|
||||||
# print("input error, no digit selected")
|
|
||||||
# return
|
|
||||||
values = dec2bin_low(decimal, 4)
|
|
||||||
pds = pins_digit_select
|
|
||||||
wp.digitalWrite(pds[0], values[0])
|
|
||||||
wp.digitalWrite(pds[1], values[1])
|
|
||||||
wp.digitalWrite(pds[2], values[2])
|
|
||||||
wp.digitalWrite(pds[3], values[3])
|
|
||||||
|
|
||||||
def select_display(decimal):
|
|
||||||
#if not check_decimal_for_validity(decimal, 1, 5):
|
|
||||||
# print("input error, no display selected")
|
|
||||||
# return
|
|
||||||
wp.digitalWrite(pins_display_select[int(decimal) - 1], high)
|
|
||||||
|
|
||||||
def unselect_display(decimal):
|
|
||||||
#if not check_decimal_for_validity(decimal, 1, 5):
|
|
||||||
# print("input error, no display unselected")
|
|
||||||
# return
|
|
||||||
wp.digitalWrite(pins_display_select[int(decimal) - 1], low)
|
|
||||||
|
|
||||||
def unselect_all_displays():
|
|
||||||
for pin in pins_display_select:
|
|
||||||
wp.digitalWrite(pin, low)
|
|
||||||
|
|
||||||
def select_all_displays():
|
|
||||||
for pin in pins_display_select:
|
|
||||||
wp.digitalWrite(pin, high)
|
|
||||||
|
|
||||||
def toggle_display(decimal):
|
|
||||||
select_display(decimal)
|
|
||||||
unselect_display(decimal)
|
|
||||||
|
|
||||||
def read_pins():
|
|
||||||
for pin in pins:
|
|
||||||
print(str(pin) + ' --> ' + str(wp.digitalRead(pin)))
|
|
||||||
|
|
||||||
def digit2display(disp, dig):
|
|
||||||
select_display(disp)
|
|
||||||
select_digit(dig)
|
|
||||||
unselect_all_displays()
|
|
||||||
|
|
||||||
def num2seg(num, seg):
|
|
||||||
select_segment(seg)
|
|
||||||
select_digit(num)
|
|
||||||
toggle_display(3)
|
|
||||||
|
|
||||||
def fancy(number,disp):
|
|
||||||
num_arr = map(int, list(str(number)))
|
|
||||||
num_arr = num_arr + [0] * max(0, (8 - len(num_arr)))
|
|
||||||
if len(num_arr) > 8:
|
|
||||||
num_arr = num_arr[:8]
|
|
||||||
print(num_arr)
|
|
||||||
num_arr = num_arr[-1::-1]
|
|
||||||
|
|
||||||
for j in range(5000):
|
|
||||||
for i in range(8):
|
|
||||||
select_segment(i)
|
|
||||||
select_digit(num_arr[i])
|
|
||||||
toggle_display(disp)
|
|
||||||
sleep(0.001)
|
|
||||||
|
|
||||||
def al(number,s):
|
|
||||||
num_arr = map(int, list(str(number)))[-1::-1]
|
|
||||||
for i in range(5000):
|
|
||||||
for segment in range(8):
|
|
||||||
for disp in range(2,6):
|
|
||||||
select_segment(segment)
|
|
||||||
select_digit(num_arr[segment])
|
|
||||||
num_arr = num_arr[-1::-1]
|
|
||||||
toggle_display(disp)
|
|
||||||
sleep(s)
|
|
||||||
|
|
||||||
def ini():
|
|
||||||
init()
|
|
||||||
init_low()
|
|
||||||
toggle_run()
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
BIN
test/andi/v1.pyc
BIN
test/andi/v1.pyc
Binary file not shown.
@@ -1,187 +0,0 @@
|
|||||||
import wiringpi
|
|
||||||
import tty
|
|
||||||
import itertools
|
|
||||||
import sys
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
class Test(object):
|
|
||||||
|
|
||||||
def __init__(self, i2c_addr, base):
|
|
||||||
self.i2c_addr = i2c_addr
|
|
||||||
self.base = base
|
|
||||||
self.pins = range(base, base+16)
|
|
||||||
self.init_component()
|
|
||||||
|
|
||||||
def init_component(self):
|
|
||||||
wiringpi.mcp23017Setup(self.base, self.i2c_addr)
|
|
||||||
for i in self.pins:
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 1)
|
|
||||||
print(self.pins)
|
|
||||||
|
|
||||||
def write(self, pin, value):
|
|
||||||
print(str(self.pins[pin]) + " " + str(value))
|
|
||||||
wiringpi.digitalWrite(self.pins[pin], value)
|
|
||||||
|
|
||||||
class Test_Display(Test):
|
|
||||||
def __init__(self, i2c_addr = 0x21, base = 65 + 16):
|
|
||||||
super(Test_Display, self).__init__(i2c_addr, base)
|
|
||||||
self.pin_dic = {'d0' : base, 'd1' : base + 1, 'd2' : base + 2, 'bcd0': base + 3, 'bcd1': base + 4, 'bcd2' : base + 5, 'bcd3' : base + 6, 'bcdLT' : base + 7, 'disp1' : base + 8, 'disp2' : base + 9, 'disp3' : base + 10, 'disp4' : base + 11, 'disp5' : base + 12, 'disp6' : base + 13, 'run' : base + 14}
|
|
||||||
|
|
||||||
def write_number(self, number):
|
|
||||||
print('Writing number: ' + str(number))
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd0'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd1'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd2'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd3'], bool(number % 2))
|
|
||||||
|
|
||||||
def select_digit(self, digit):
|
|
||||||
print('Selecting 7 segment number: ' + str(digit))
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d0'], bool(digit % 2))
|
|
||||||
digit = digit / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d1'], bool(digit % 2))
|
|
||||||
digit = digit / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d2'], bool(digit % 2))
|
|
||||||
|
|
||||||
def disp_select(self, number):
|
|
||||||
print('Selecting Display: ' + str(number))
|
|
||||||
for i in range(1, 6):
|
|
||||||
if(i == number):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 0)
|
|
||||||
else:
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 1)
|
|
||||||
#sleep(.1)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 0)
|
|
||||||
#sleep(.001)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 1)
|
|
||||||
|
|
||||||
def toggleLT(self):
|
|
||||||
sleep(.1)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcdLT'], 0)
|
|
||||||
sleep(.1)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcdLT'], 1)
|
|
||||||
def clear_disp_select(self):
|
|
||||||
print("Clearing Display")
|
|
||||||
for i in range(1, 7):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 1)
|
|
||||||
|
|
||||||
def test_digit1(self):
|
|
||||||
for i in range(0, 8):
|
|
||||||
for j in range(0, 10):
|
|
||||||
self.select_digit(i)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.write_number(j)
|
|
||||||
self.disp_select(1)
|
|
||||||
self.run()
|
|
||||||
def test(self):
|
|
||||||
for k in range(1, 6):
|
|
||||||
for i in range(0, 8):
|
|
||||||
self.select_digit(i)
|
|
||||||
for j in range(0, 10):
|
|
||||||
self.write_number(j)
|
|
||||||
# self.toggleLT()
|
|
||||||
self.disp_select(k)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.run()
|
|
||||||
|
|
||||||
def test123(self):
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.select_digit(0)
|
|
||||||
self.write_number(7)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 0)
|
|
||||||
self.disp_select(1)
|
|
||||||
|
|
||||||
def manual_test(self, display, digit, number):
|
|
||||||
self.select_digit(digit)
|
|
||||||
self.write_number(number)
|
|
||||||
self.disp_select(display)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.run()
|
|
||||||
def test_digits(self):
|
|
||||||
tty.setcbreak(sys.stdin.fileno())
|
|
||||||
self.write_number(3)
|
|
||||||
for i in range(0,8):
|
|
||||||
self.select_digit(i)
|
|
||||||
self.disp_select(0)
|
|
||||||
self.run()
|
|
||||||
sleep(.5)
|
|
||||||
def permutation_test(self):
|
|
||||||
self.select_digit(3)
|
|
||||||
self.write_number(0)
|
|
||||||
functions = [self.disp_select, self.clear_disp_select, self.run, self.toggleLT]
|
|
||||||
i = 0
|
|
||||||
for permutation in itertools.permutations(functions, 4):
|
|
||||||
print(str(i))
|
|
||||||
for function in permutation:
|
|
||||||
function(3)
|
|
||||||
print(permutation)
|
|
||||||
i = i+1
|
|
||||||
raw_input()
|
|
||||||
|
|
||||||
class Sound_Test(Test):
|
|
||||||
def __init__(self, i2c_addr = 0x22, base = 65):
|
|
||||||
super(Sound_Test, self).__init__(i2c_addr, base)
|
|
||||||
self.pins = [x + base for x in [15, 14, 12, 10, 8, 9, 11, 13]]
|
|
||||||
|
|
||||||
def fire(self):
|
|
||||||
self.write(7, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self.write(7, 1)
|
|
||||||
|
|
||||||
def init_component(self):
|
|
||||||
super(Sound_Test, self).init_component()
|
|
||||||
wiringpi.digitalWrite(self.base + 12, 1)
|
|
||||||
|
|
||||||
def fire_sound(self, i):
|
|
||||||
self.write(0, bool(i & 0b00000001))
|
|
||||||
self.write(1, bool(i & 0b00000010))
|
|
||||||
self.write(2, bool(i & 0b00000100))
|
|
||||||
self.write(3, bool(i & 0b00001000))
|
|
||||||
self.write(4, bool(i & 0b00010000))
|
|
||||||
self.write(5, bool(i & 0b00100000))
|
|
||||||
self.write(6, bool(i & 0b01000000))
|
|
||||||
self.write(7, bool(i & 0b10000000))
|
|
||||||
self.fire()
|
|
||||||
a = raw_input()
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
def rotate(self):
|
|
||||||
for i in range(22, 78):
|
|
||||||
self.fire_sound(i)
|
|
||||||
|
|
||||||
"""
|
|
||||||
def init_flipper(self):
|
|
||||||
init_driver()
|
|
||||||
init_display()
|
|
||||||
init_sound()
|
|
||||||
|
|
||||||
def init_driver(self):
|
|
||||||
i2c_driver = 0x20
|
|
||||||
base_driver = 65
|
|
||||||
wiringpi.mcp23017Setup(base_driver, i2c_driver)
|
|
||||||
|
|
||||||
def init_display(self):
|
|
||||||
i2c_display= 0x21
|
|
||||||
base_display = 65 + 16
|
|
||||||
wiringpi.mcp23017Setup(base_display, i2c_display)
|
|
||||||
for i in range(base_display, base_display+16):
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 0)
|
|
||||||
|
|
||||||
def init_sound(self):
|
|
||||||
i2c_sound = 0x22
|
|
||||||
base_sound = 65 + 32
|
|
||||||
wiringpi.mcp23017Setup(base_sound, i2c_sound)
|
|
||||||
for i in range(base_sound, base_sound+16):
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 0)
|
|
||||||
# set fire to 1 (out)
|
|
||||||
|
|
||||||
def """
|
|
||||||
@@ -1,186 +0,0 @@
|
|||||||
import wiringpi
|
|
||||||
import tty
|
|
||||||
import itertools
|
|
||||||
import sys
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
class Test(object):
|
|
||||||
|
|
||||||
def __init__(self, i2c_addr, base):
|
|
||||||
self.i2c_addr = i2c_addr
|
|
||||||
self.base = base
|
|
||||||
self.pins = range(base, base+16)
|
|
||||||
self.init_component()
|
|
||||||
|
|
||||||
def init_component(self):
|
|
||||||
wiringpi.mcp23017Setup(self.base, self.i2c_addr)
|
|
||||||
for i in self.pins:
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 1)
|
|
||||||
print(self.pins)
|
|
||||||
|
|
||||||
def write(self, pin, value):
|
|
||||||
print(self.pins[pin])
|
|
||||||
wiringpi.digitalWrite(self.pins[pin], value)
|
|
||||||
|
|
||||||
class Test_Display(Test):
|
|
||||||
def __init__(self, i2c_addr = 0x21, base = 65 + 16):
|
|
||||||
super(Test_Display, self).__init__(i2c_addr, base)
|
|
||||||
self.pin_dic = {'d0' : base, 'd1' : base + 1, 'd2' : base + 2, 'bcd0': base + 3, 'bcd1': base + 4, 'bcd2' : base + 5, 'bcd3' : base + 6, 'bcdLT' : base + 7, 'disp1' : base + 8, 'disp2' : base + 9, 'disp3' : base + 10, 'disp4' : base + 11, 'disp5' : base + 12, 'disp6' : base + 13, 'run' : base + 14}
|
|
||||||
|
|
||||||
def write_number(self, number):
|
|
||||||
print('Writing number: ' + str(number))
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd0'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd1'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd2'], bool(number % 2))
|
|
||||||
number = number / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcd3'], bool(number % 2))
|
|
||||||
|
|
||||||
def select_digit(self, digit):
|
|
||||||
print('Selecting 7 segment number: ' + str(digit))
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d0'], bool(digit % 2))
|
|
||||||
digit = digit / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d1'], bool(digit % 2))
|
|
||||||
digit = digit / 2
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['d2'], bool(digit % 2))
|
|
||||||
|
|
||||||
def disp_select(self, number):
|
|
||||||
print('Selecting Display: ' + str(number))
|
|
||||||
for i in range(1, 6):
|
|
||||||
if(i == number):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 0)
|
|
||||||
else:
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 1)
|
|
||||||
#sleep(.1)
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 0)
|
|
||||||
#sleep(.001)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 1)
|
|
||||||
|
|
||||||
def toggleLT(self):
|
|
||||||
sleep(.1)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcdLT'], 0)
|
|
||||||
sleep(.1)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['bcdLT'], 1)
|
|
||||||
def clear_disp_select(self):
|
|
||||||
print("Clearing Display")
|
|
||||||
for i in range(1, 7):
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['disp' + str(i)], 1)
|
|
||||||
|
|
||||||
def test_digit1(self):
|
|
||||||
for i in range(0, 8):
|
|
||||||
for j in range(0, 10):
|
|
||||||
self.select_digit(i)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.write_number(j)
|
|
||||||
self.disp_select(1)
|
|
||||||
self.run()
|
|
||||||
def test(self):
|
|
||||||
for k in range(1, 6):
|
|
||||||
for i in range(0, 8):
|
|
||||||
self.select_digit(i)
|
|
||||||
for j in range(0, 10):
|
|
||||||
self.write_number(j)
|
|
||||||
# self.toggleLT()
|
|
||||||
self.disp_select(k)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.run()
|
|
||||||
|
|
||||||
def test123(self):
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.select_digit(0)
|
|
||||||
self.write_number(7)
|
|
||||||
wiringpi.digitalWrite(self.pin_dic['run'], 0)
|
|
||||||
self.disp_select(1)
|
|
||||||
|
|
||||||
def manual_test(self, display, digit, number):
|
|
||||||
self.select_digit(digit)
|
|
||||||
self.write_number(number)
|
|
||||||
self.disp_select(display)
|
|
||||||
self.clear_disp_select()
|
|
||||||
self.run()
|
|
||||||
def test_digits(self):
|
|
||||||
tty.setcbreak(sys.stdin.fileno())
|
|
||||||
self.write_number(3)
|
|
||||||
for i in range(0,8):
|
|
||||||
self.select_digit(i)
|
|
||||||
self.disp_select(0)
|
|
||||||
self.run()
|
|
||||||
sleep(.5)
|
|
||||||
def permutation_test(self):
|
|
||||||
self.select_digit(3)
|
|
||||||
self.write_number(0)
|
|
||||||
functions = [self.disp_select, self.clear_disp_select, self.run, self.toggleLT]
|
|
||||||
i = 0
|
|
||||||
for permutation in itertools.permutations(functions, 4):
|
|
||||||
print(str(i))
|
|
||||||
for function in permutation:
|
|
||||||
function(3)
|
|
||||||
print(permutation)
|
|
||||||
i = i+1
|
|
||||||
raw_input()
|
|
||||||
|
|
||||||
class Sound_Test(Test):
|
|
||||||
def __init__(self, i2c_addr = 0x22, base = 65 + 32):
|
|
||||||
super(Sound_Test, self).__init__(i2c_addr, base)
|
|
||||||
self.pins = [x + base for x in [15, 14, 12, 10, 8, 9, 11, 13]]
|
|
||||||
|
|
||||||
def fire(self):
|
|
||||||
self.write(7, 0)
|
|
||||||
|
|
||||||
|
|
||||||
def stop(self):
|
|
||||||
self.write(7, 1)
|
|
||||||
|
|
||||||
def init_component(self):
|
|
||||||
super(Sound_Test, self).init_component()
|
|
||||||
wiringpi.digitalWrite(self.base + 12, 1)
|
|
||||||
|
|
||||||
def rotate(self):
|
|
||||||
for i in range(22, 78):
|
|
||||||
self.write(0, i & 0b00000001)
|
|
||||||
self.write(1, i & 0b00000010)
|
|
||||||
self.write(2, i & 0b00000100)
|
|
||||||
self.write(3, i & 0b00001000)
|
|
||||||
self.write(4, i & 0b00010000)
|
|
||||||
self.write(5, i & 0b00100000)
|
|
||||||
self.write(6, i & 0b01000000)
|
|
||||||
self.write(7, i & 0b10000000)
|
|
||||||
|
|
||||||
self.fire()
|
|
||||||
# sleep(1)
|
|
||||||
a = raw_input()
|
|
||||||
self.stop()
|
|
||||||
|
|
||||||
"""
|
|
||||||
def init_flipper(self):
|
|
||||||
init_driver()
|
|
||||||
init_display()
|
|
||||||
init_sound()
|
|
||||||
|
|
||||||
def init_driver(self):
|
|
||||||
i2c_driver = 0x20
|
|
||||||
base_driver = 65
|
|
||||||
wiringpi.mcp23017Setup(base_driver, i2c_driver)
|
|
||||||
|
|
||||||
def init_display(self):
|
|
||||||
i2c_display= 0x21
|
|
||||||
base_display = 65 + 16
|
|
||||||
wiringpi.mcp23017Setup(base_display, i2c_display)
|
|
||||||
for i in range(base_display, base_display+16):
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 0)
|
|
||||||
|
|
||||||
def init_sound(self):
|
|
||||||
i2c_sound = 0x22
|
|
||||||
base_sound = 65 + 32
|
|
||||||
wiringpi.mcp23017Setup(base_sound, i2c_sound)
|
|
||||||
for i in range(base_sound, base_sound+16):
|
|
||||||
wiringpi.pinMode(i,1)
|
|
||||||
wiringpi.digitalWrite(i, 0)
|
|
||||||
# set fire to 1 (out)
|
|
||||||
|
|
||||||
def """
|
|
||||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
import sys
|
|
||||||
import test
|
|
||||||
|
|
||||||
test.s.manual_test(sys.argv[1], sys.argv[2], sys.argv[3])
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
gpio export 14 out
|
|
||||||
gpio export 15 out
|
|
||||||
gpio export 18 out
|
|
||||||
gpio export 23 out
|
|
||||||
gpio export 24 out
|
|
||||||
gpio export 25 out
|
|
||||||
gpio export 9 in
|
|
||||||
|
|
||||||
# missing driver board
|
|
||||||
|
|
||||||
gpio -g write 14 0
|
|
||||||
gpio -g write 15 0
|
|
||||||
gpio -g write 18 0
|
|
||||||
gpio -g write 23 1
|
|
||||||
gpio -g write 24 1
|
|
||||||
gpio -g write 25 0
|
|
||||||
gpio -g write 8 0
|
|
||||||
gpio -g write 16 0
|
|
||||||
gpio -g write 20 0
|
|
||||||
gpio -g write 21 0
|
|
||||||
gpio -g write 2 0
|
|
||||||
gpio -g write 3 0
|
|
||||||
gpio -g write 4 0
|
|
||||||
gpio -g write 6 0
|
|
||||||
gpio -g write 13 0
|
|
||||||
gpio -g write 19 0
|
|
||||||
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
shopt -s expand_aliases
|
|
||||||
source ./.bash_aliases
|
|
||||||
mux1 1
|
|
||||||
mux2 0
|
|
||||||
for(( i = 0; i < 8; i++))
|
|
||||||
do
|
|
||||||
echo "Activating Latch $((i+1))"
|
|
||||||
let "a = $i % 2"
|
|
||||||
let "b = $i / 2 % 2"
|
|
||||||
let "c = $i / 4 % 2"
|
|
||||||
ma0 $a
|
|
||||||
ma1 $b
|
|
||||||
ma2 $c
|
|
||||||
for(( j = 0; j < 8; j++))
|
|
||||||
do
|
|
||||||
echo "Activating Pin $j"
|
|
||||||
let "d = $j % 2"
|
|
||||||
let "e = $j / 2 % 2"
|
|
||||||
let "f = $j / 4 % 2"
|
|
||||||
|
|
||||||
fa0 $d
|
|
||||||
fa1 $e
|
|
||||||
fa2 $f
|
|
||||||
sleep $1
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
mux1 0
|
|
||||||
mux2 1
|
|
||||||
for(( i = 0; i < 5; i++))
|
|
||||||
do
|
|
||||||
echo "Activating Latch $((i + 9))"
|
|
||||||
let "a = $i % 2"
|
|
||||||
let "b = $i / 2 % 2"
|
|
||||||
let "c = $i / 4 % 2"
|
|
||||||
ma0 $a
|
|
||||||
ma1 $b
|
|
||||||
ma2 $c
|
|
||||||
for(( j = 0; j < 8; j++))
|
|
||||||
do
|
|
||||||
echo "Activating Pin $j"
|
|
||||||
let "d = $j % 2"
|
|
||||||
let "e = $j / 2 % 2"
|
|
||||||
let "f = $j / 4 % 2"
|
|
||||||
|
|
||||||
fa0 $d
|
|
||||||
fa1 $e
|
|
||||||
fa2 $f
|
|
||||||
sleep $1
|
|
||||||
done
|
|
||||||
done
|
|
||||||
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
for(( i=0; i<5; i++))
|
|
||||||
do
|
|
||||||
let "a = $i % 2"
|
|
||||||
let "b = $i / 2 % 2"
|
|
||||||
let "c = $i / 4 % 2"
|
|
||||||
gpio -g write 14 $a
|
|
||||||
gpio -g write 15 $b
|
|
||||||
gpio -g write 18 $c
|
|
||||||
for(( j=0; j<8; j++))
|
|
||||||
do
|
|
||||||
let "d = $j % 2"
|
|
||||||
let "e = $j / 2 % 2"
|
|
||||||
let "f = $j / 4 % 2"
|
|
||||||
gpio -g write 23 $d
|
|
||||||
gpio -g write 24 $e
|
|
||||||
gpio -g write 25 $f
|
|
||||||
sleep .01
|
|
||||||
x=`gpio -g read 8`
|
|
||||||
if [ "$x" -eq "0" ]; then
|
|
||||||
echo "Row[$i], Col[$j]"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,41 +0,0 @@
|
|||||||
import wiringpi
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
base = 65
|
|
||||||
i2c = 0x20
|
|
||||||
|
|
||||||
timer = .5
|
|
||||||
|
|
||||||
wiringpi.wiringPiSetupGpio()
|
|
||||||
wiringpi.mcp23017Setup(base, i2c)
|
|
||||||
|
|
||||||
|
|
||||||
for i in range(base, base+16):
|
|
||||||
wiringpi.pinMode(i, 1)
|
|
||||||
|
|
||||||
wiringpi.digitalWrite(base+8, 0)
|
|
||||||
wiringpi.digitalWrite(base+9, 0)
|
|
||||||
|
|
||||||
def data(value):
|
|
||||||
wiringpi.digitalWrite(base+3, value)
|
|
||||||
|
|
||||||
def select_mux(mux):
|
|
||||||
wiringpi.digitalWrite(base+8, not mux)
|
|
||||||
wiringpi.digitalWrite(base+8 + 1, mux)
|
|
||||||
|
|
||||||
def select_latch(A,B,C):
|
|
||||||
wiringpi.digitalWrite(base + 5, A)
|
|
||||||
wiringpi.digitalWrite(base + 6, B)
|
|
||||||
wiringpi.digitalWrite(base + 7, C)
|
|
||||||
|
|
||||||
def select_latch_pin(A0,A1,A2):
|
|
||||||
wiringpi.digitalWrite(base, A0)
|
|
||||||
wiringpi.digitalWrite(base +1, A1)
|
|
||||||
wiringpi.digitalWrite(base+2, A2)
|
|
||||||
|
|
||||||
def trigger_pin(lA, lB, lC, A0, A1, A2):
|
|
||||||
select_latch(lA, lB, lC)
|
|
||||||
select_latch_pin(A0,A1,A2)
|
|
||||||
data(1)
|
|
||||||
sleep(timer)
|
|
||||||
data(0)
|
|
||||||
Binary file not shown.
@@ -1,27 +0,0 @@
|
|||||||
#!/usr/bin/python
|
|
||||||
import wiringpi
|
|
||||||
import output_manual as o
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
timerInner = .5
|
|
||||||
|
|
||||||
def rotate():
|
|
||||||
for i in range(8):
|
|
||||||
print("Selecting Latch: " + str(i))
|
|
||||||
o.select_latch(i & 1, i & 2, i & 4)
|
|
||||||
|
|
||||||
for j in range(8):
|
|
||||||
o.select_latch_pin(j & 1, j & 2, j & 4)
|
|
||||||
print("Triggering Pin: " + str(j))
|
|
||||||
o.data(1)
|
|
||||||
sleep(timerInner)
|
|
||||||
o.data(0)
|
|
||||||
|
|
||||||
print("Selecting MUX1")
|
|
||||||
o.select_mux(0)
|
|
||||||
|
|
||||||
rotate()
|
|
||||||
|
|
||||||
print("Selecting MUX2")
|
|
||||||
o.select_mux(1)
|
|
||||||
rotate()
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
import wiringpi
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
base = 65
|
|
||||||
i2c = 0x20
|
|
||||||
|
|
||||||
timer = 0.7
|
|
||||||
pins = {"A0" : 9,#
|
|
||||||
"A1" : 8,#
|
|
||||||
"A2" : 1,#
|
|
||||||
"D0" : 0,
|
|
||||||
"RUN" : 7,#
|
|
||||||
"E1" : 2,#
|
|
||||||
"E2" : 10,
|
|
||||||
"E3" : 3,#
|
|
||||||
"E4" : 11,
|
|
||||||
"E5" : 4,#
|
|
||||||
"E6" : 12,
|
|
||||||
"E7" : 5,
|
|
||||||
"E8" : 13,
|
|
||||||
"E9" : 10,#PGIO06 wegen fehlender Porterweiterung
|
|
||||||
"E10" : 9,#GPIO12 wegen fehlender Porterweiterung
|
|
||||||
"E11" : 6,#
|
|
||||||
"E12" : 14,
|
|
||||||
"E13" : 15 }#
|
|
||||||
|
|
||||||
"""
|
|
||||||
A0 = 3
|
|
||||||
A1 = 2
|
|
||||||
A2 = 1
|
|
||||||
D0 = 17
|
|
||||||
E13 = 15
|
|
||||||
RUN = 16
|
|
||||||
E1 = 5
|
|
||||||
E2 = 6
|
|
||||||
E3 = 7
|
|
||||||
E4 = 8
|
|
||||||
E5 = 9
|
|
||||||
E6 = 10
|
|
||||||
E7 = 11
|
|
||||||
E8 = 12
|
|
||||||
E9 = pi
|
|
||||||
E10 = pi
|
|
||||||
E11 = 13
|
|
||||||
E12 = 14
|
|
||||||
E13 = 15
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
GPA0 0= 16
|
|
||||||
GPA1 1= 14
|
|
||||||
GPA2 2= 12
|
|
||||||
GPA3 3= 10
|
|
||||||
GPA4 4= 8
|
|
||||||
GPA5 5= 6
|
|
||||||
GPA6 6= 2
|
|
||||||
GPA7 7= 17
|
|
||||||
GPB0 8= 1
|
|
||||||
GPB1 9= 3
|
|
||||||
GPB2 10= 5
|
|
||||||
GPB3 11= 7
|
|
||||||
GPB4 12= 9
|
|
||||||
GPB5 13= 11
|
|
||||||
GPB6 14= 13
|
|
||||||
GPB7 15= 15
|
|
||||||
|
|
||||||
"""
|
|
||||||
for key in pins.keys():
|
|
||||||
pins[key] += base
|
|
||||||
|
|
||||||
pins["E10"] -= base
|
|
||||||
pins["E9"] -= base
|
|
||||||
|
|
||||||
def init():
|
|
||||||
wiringpi.wiringPiSetupGpio()
|
|
||||||
wiringpi.mcp23017Setup(base, i2c)
|
|
||||||
for i in pins.values():
|
|
||||||
wiringpi.pinMode(i, 1)
|
|
||||||
wiringpi.digitalWrite(i, 1)
|
|
||||||
data(0)
|
|
||||||
wiringpi.digitalWrite(pins["RUN"], 0)
|
|
||||||
|
|
||||||
def data(value):
|
|
||||||
wiringpi.digitalWrite(pins["D0"], value)
|
|
||||||
|
|
||||||
def select_latch(latch):
|
|
||||||
deselect_latches()
|
|
||||||
wiringpi.digitalWrite(pins["E" + str(latch)], 0)
|
|
||||||
|
|
||||||
def deselect_latches():
|
|
||||||
for i in range(1,14):
|
|
||||||
wiringpi.digitalWrite(pins["E" + str(i)], 1)
|
|
||||||
|
|
||||||
def select_pin(pin):
|
|
||||||
wiringpi.digitalWrite(pins["A0"], pin & 0b001)
|
|
||||||
wiringpi.digitalWrite(pins["A1"], pin & 0b010)
|
|
||||||
wiringpi.digitalWrite(pins["A2"], pin & 0b100)
|
|
||||||
|
|
||||||
def trigger_pin(latch, pin, t=timer):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
|
|
||||||
data(1)
|
|
||||||
sleep(t)
|
|
||||||
data(0)
|
|
||||||
|
|
||||||
def rotate():
|
|
||||||
for i in range(1, 14):
|
|
||||||
for j in range(8):
|
|
||||||
trigger_pin(i, j)
|
|
||||||
print("activated latch "+str(i)+ "\t pin "+str(j))
|
|
||||||
|
|
||||||
def activate_all_lamps():
|
|
||||||
for latch in range(1,11):
|
|
||||||
for pin in range(8):
|
|
||||||
data(1)
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
sleep(0.03)
|
|
||||||
def all_lamps():
|
|
||||||
activate_all_lamps()
|
|
||||||
|
|
||||||
def outhole():
|
|
||||||
trigger_pin(11,0)
|
|
||||||
def right_kicker():
|
|
||||||
trigger_pin(12,5)
|
|
||||||
|
|
||||||
def right_flap():
|
|
||||||
trigger_pin(13,5,0.4)
|
|
||||||
|
|
||||||
def right_bank():
|
|
||||||
trigger_pin(13,2,0.4)
|
|
||||||
|
|
||||||
def activate_pin(latch, pin):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
data(1)
|
|
||||||
deselect_latches()
|
|
||||||
|
|
||||||
def deactivate_pin(latch, pin):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
data(0)
|
|
||||||
deselect_latches()
|
|
||||||
def activate_flipper():
|
|
||||||
activate_pin(8, 4)
|
|
||||||
|
|
||||||
def activate_top_flipper():
|
|
||||||
activate_pin(12, 4)
|
|
||||||
|
|
||||||
def deactivate_flipper():
|
|
||||||
deactivate_pin(8, 4)
|
|
||||||
|
|
||||||
def deactivate_top_flipper():
|
|
||||||
deactivate_pin(12, 4)
|
|
||||||
|
|
||||||
init()
|
|
||||||
@@ -1,156 +0,0 @@
|
|||||||
import wiringpi
|
|
||||||
from time import sleep
|
|
||||||
|
|
||||||
base = 65
|
|
||||||
i2c = 0x20
|
|
||||||
|
|
||||||
timer = 0.7
|
|
||||||
pins = {"A0" : 9,#
|
|
||||||
"A1" : 6,#
|
|
||||||
"A2" : 8,#
|
|
||||||
"D0" : 7,
|
|
||||||
"RUN" : 0,#
|
|
||||||
"E1" : 10,#
|
|
||||||
"E2" : 5,
|
|
||||||
"E3" : 11,#
|
|
||||||
"E4" : 4,
|
|
||||||
"E5" : 12,#
|
|
||||||
"E6" : 3,
|
|
||||||
"E7" : 13,
|
|
||||||
"E8" : 2,
|
|
||||||
"E9" : 9,#PGIO06 wegen fehlender Porterweiterung
|
|
||||||
"E10" : 10,#GPIO12 wegen fehlender Porterweiterung
|
|
||||||
"E11" : 14,#
|
|
||||||
"E12" : 1,
|
|
||||||
"E13" : 15 }#
|
|
||||||
|
|
||||||
"""
|
|
||||||
A0 = 3
|
|
||||||
A1 = 2
|
|
||||||
A2 = 1
|
|
||||||
D0 = 17
|
|
||||||
E13 = 15
|
|
||||||
RUN = 16
|
|
||||||
E1 = 5
|
|
||||||
E2 = 6
|
|
||||||
E3 = 7
|
|
||||||
E4 = 8
|
|
||||||
E5 = 9
|
|
||||||
E6 = 10
|
|
||||||
E7 = 11
|
|
||||||
E8 = 12
|
|
||||||
E9 = pi
|
|
||||||
E10 = pi
|
|
||||||
E11 = 13
|
|
||||||
E12 = 14
|
|
||||||
E13 = 15
|
|
||||||
"""
|
|
||||||
"""
|
|
||||||
GPA0 0= 16
|
|
||||||
GPA1 1= 14
|
|
||||||
GPA2 2= 12
|
|
||||||
GPA3 3= 10
|
|
||||||
GPA4 4= 8
|
|
||||||
GPA5 5= 6
|
|
||||||
GPA6 6= 2
|
|
||||||
GPA7 7= 17
|
|
||||||
GPB0 8= 1
|
|
||||||
GPB1 9= 3
|
|
||||||
GPB2 10= 5
|
|
||||||
GPB3 11= 7
|
|
||||||
GPB4 12= 9
|
|
||||||
GPB5 13= 11
|
|
||||||
GPB6 14= 13
|
|
||||||
GPB7 15= 15
|
|
||||||
|
|
||||||
"""
|
|
||||||
for key in pins.keys():
|
|
||||||
pins[key] += base
|
|
||||||
|
|
||||||
pins["E9"] -= base
|
|
||||||
pins["E10"] -= base
|
|
||||||
|
|
||||||
def init():
|
|
||||||
wiringpi.wiringPiSetupGpio()
|
|
||||||
wiringpi.mcp23017Setup(base, i2c)
|
|
||||||
for i in pins.values():
|
|
||||||
wiringpi.pinMode(i, 1)
|
|
||||||
wiringpi.digitalWrite(i, 1)
|
|
||||||
data(0)
|
|
||||||
wiringpi.digitalWrite(pins["RUN"], 0)
|
|
||||||
|
|
||||||
def data(value):
|
|
||||||
wiringpi.digitalWrite(pins["D0"], value)
|
|
||||||
|
|
||||||
def select_latch(latch):
|
|
||||||
deselect_latches()
|
|
||||||
wiringpi.digitalWrite(pins["E" + str(latch)], 0)
|
|
||||||
|
|
||||||
def deselect_latches():
|
|
||||||
for i in range(1,14):
|
|
||||||
wiringpi.digitalWrite(pins["E" + str(i)], 1)
|
|
||||||
|
|
||||||
def select_pin(pin):
|
|
||||||
wiringpi.digitalWrite(pins["A0"], pin & 0b001)
|
|
||||||
wiringpi.digitalWrite(pins["A1"], pin & 0b010)
|
|
||||||
wiringpi.digitalWrite(pins["A2"], pin & 0b100)
|
|
||||||
|
|
||||||
def trigger_pin(latch, pin, t=timer):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
|
|
||||||
data(1)
|
|
||||||
sleep(t)
|
|
||||||
data(0)
|
|
||||||
|
|
||||||
def rotate():
|
|
||||||
for i in range(1, 14):
|
|
||||||
for j in range(8):
|
|
||||||
trigger_pin(i, j)
|
|
||||||
print("activated latch "+str(i)+ "\t pin "+str(j))
|
|
||||||
|
|
||||||
def activate_all_lamps():
|
|
||||||
for latch in range(1,11):
|
|
||||||
for pin in range(8):
|
|
||||||
data(1)
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
sleep(0.03)
|
|
||||||
def all_lamps():
|
|
||||||
activate_all_lamps()
|
|
||||||
|
|
||||||
def outhole():
|
|
||||||
trigger_pin(11,0)
|
|
||||||
def right_kicker():
|
|
||||||
trigger_pin(12,5)
|
|
||||||
|
|
||||||
def right_flap():
|
|
||||||
trigger_pin(13,5,0.4)
|
|
||||||
|
|
||||||
def right_bank():
|
|
||||||
trigger_pin(13,2,0.4)
|
|
||||||
|
|
||||||
def activate_pin(latch, pin):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
data(1)
|
|
||||||
deselect_latches()
|
|
||||||
|
|
||||||
def deactivate_pin(latch, pin):
|
|
||||||
select_latch(latch)
|
|
||||||
select_pin(pin)
|
|
||||||
data(0)
|
|
||||||
deselect_latches()
|
|
||||||
def activate_flipper():
|
|
||||||
activate_pin(8, 4)
|
|
||||||
|
|
||||||
def activate_top_flipper():
|
|
||||||
activate_pin(12, 4)
|
|
||||||
|
|
||||||
def deactivate_flipper():
|
|
||||||
deactivate_pin(8, 4)
|
|
||||||
|
|
||||||
def deactivate_top_flipper():
|
|
||||||
deactivate_pin(12, 4)
|
|
||||||
|
|
||||||
init()
|
|
||||||
Binary file not shown.
@@ -1,4 +0,0 @@
|
|||||||
import initialize as si
|
|
||||||
|
|
||||||
s = si.Test_Display()
|
|
||||||
#s.test()
|
|
||||||
BIN
test/test.pyc
BIN
test/test.pyc
Binary file not shown.
Binary file not shown.
@@ -1,91 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
#include <wiringPi.h>
|
|
||||||
#include <mcp23017.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
const char disp_numbers[] = {89, 90, 91, 92, 93};
|
|
||||||
const char run = 95;
|
|
||||||
const char lt = 88;
|
|
||||||
|
|
||||||
const char base = 81;
|
|
||||||
void init(void)
|
|
||||||
{
|
|
||||||
wiringPiSetup();
|
|
||||||
mcp23017Setup(base, 0x21) ;
|
|
||||||
|
|
||||||
for(int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
pinMode(base + i, OUTPUT);
|
|
||||||
digitalWrite(base + i, 1);
|
|
||||||
}
|
|
||||||
digitalWrite(run, 0);
|
|
||||||
}
|
|
||||||
void clear_displays(void)
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 5; i++)
|
|
||||||
{
|
|
||||||
digitalWrite(disp_numbers[i], 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void select_display(int number)
|
|
||||||
{
|
|
||||||
digitalWrite(disp_numbers[number-1], 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void toggle_display(int number)
|
|
||||||
{
|
|
||||||
select_display(number);
|
|
||||||
clear_displays();
|
|
||||||
}
|
|
||||||
void print_pins()
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 16; i++)
|
|
||||||
{
|
|
||||||
int state = digitalRead(base + i);
|
|
||||||
printf("PIN %d is %d\n", i, state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void select_digit(char number)
|
|
||||||
{
|
|
||||||
// MSB to LSB
|
|
||||||
digitalWrite(84, (number % 2));
|
|
||||||
number = number / 2;
|
|
||||||
digitalWrite(85, (number % 2));
|
|
||||||
number = number / 2;
|
|
||||||
digitalWrite(86, (number % 2));
|
|
||||||
number = number / 2;
|
|
||||||
digitalWrite(87, (number % 2));
|
|
||||||
}
|
|
||||||
void select_segment(int number)
|
|
||||||
{
|
|
||||||
digitalWrite(81, (number % 2));
|
|
||||||
number = number / 2;
|
|
||||||
digitalWrite(82, (number % 2));
|
|
||||||
number = number / 2;
|
|
||||||
digitalWrite(83, (number % 2));
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
|
|
||||||
clock_t t;
|
|
||||||
init();
|
|
||||||
print_pins();
|
|
||||||
int numbers[] = {0, 1, 2 ,3 ,4 ,5, 6, 7};
|
|
||||||
for(int i = 0; i < 50000; i++)
|
|
||||||
{
|
|
||||||
for(int j = 0; j < 3; j++)
|
|
||||||
{
|
|
||||||
//t = clock();
|
|
||||||
select_segment(j);
|
|
||||||
//printf("select_segment %d\n", j);
|
|
||||||
select_digit(numbers[j]);
|
|
||||||
//printf("select_digit %d\n", numbers[j]);
|
|
||||||
toggle_display(3);
|
|
||||||
//t = clock() - t;
|
|
||||||
//printf("took %f ms \n" , (((float) t)/CLOCKS_PER_SEC)*1000);
|
|
||||||
}
|
|
||||||
//print_pins();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
import initialize
|
|
||||||
|
|
||||||
s = initialize.Sound_Test()
|
|
||||||
s.rotate()
|
|
||||||
Reference in New Issue
Block a user