Commit c06e3c42 authored by Dave Griffiths's avatar Dave Griffiths

fixes for possible demo

parent 0ff7085c
# invisible driver...
import RPi.GPIO as io
......@@ -22,18 +21,25 @@ def quick_read(pins):
for i in range(0,len(pins)):
t = io.input(pins[i])
print("pin "+str(i)+" is "+str(t))
def value_read(pins):
v = 0
for i in range(0,len(pins)):
# low is 1, pull up resistor
t = not io.input(pins[i])
#print("pin:"+str(pins[i])+" is "+str(io.input(pins[i])))
v |= t<<i
return v
def value_read_inverse(pins):
v = 0
for i in range(0,len(pins)):
# low is 1, pull up resistor
t = not io.input(len(pins)-pins[i]-1)
v |= t<<i
return v
value_pins = [7,8,25,24,23,18,15,14]
address_pins = [27,17,4,3,2]
......@@ -46,9 +52,9 @@ def read_addr_4bit(addr):
# flip addr zero due to plug hw error
if addr==0 or addr==1:
if addr%2==0:
return value_read(value_pins) & 0x0f
return value_read_inverse(value_pins) & 0x0f
else:
return (value_read(value_pins)>>4) & 0x0f
return (value_read_inverse(value_pins)>>4) & 0x0f
if addr%2==0:
return (value_read(value_pins)>>4) & 0x0f
......@@ -67,7 +73,7 @@ def init():
quick_setup(value_pins, io.IN)
quick_setup(address_pins, io.OUT)
quick_set(address_pins, 0)
except:
print "error"
......
import pygame
#import driver
import driver
import time
# standard lsystem stuff
......@@ -124,6 +124,7 @@ weave_width = 60
weave_height = 40
def draw_weave(time,kernel,warp_yarn,weft_yarn):
if warp_yarn=="" or weft_yarn=="": return
for y in range(0,weave_height):
rect.top=y*cell_spacing
for x in range(0,weave_width):
......@@ -143,8 +144,8 @@ def draw_weave(time,kernel,warp_yarn,weft_yarn):
screen.blit(weft_sprite, rect)
emu = [2,0,0,0,0,0,0,0,
2,4,0,0,0,0,0,0,
4,4,8,2,0,0,0,0,
2,0,0,0,0,0,0,0,
0,0,8,2,0,0,0,0,
0,0,0,0,0,0,0,0]
......@@ -158,6 +159,7 @@ print(driver.read_all())
while 1:
yarn = lsys_from_blocks(driver.read_all())
#yarn = lsys_from_blocks(emu)
print(yarn)
screen.fill([0,0,0])
draw_weave(frame,k,yarn,yarn)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment