Hardware Reference
In-Depth Information
os.environ['SDL_VIDEO_WINDOW_POS'] = 'center'
pygame.display.set_caption(“Harmonograph”)
screen = pygame.display.set_mode([800,800],0,32)
background = pygame.Surface((800,800))
cBackground =(255,255,255)
background.fill(cBackground) # make background colour
col = (0,0,0) # drawing colour
reading = [0, 0, 0, 0]
lastX = 0
lastY = 0
picture = 1 # picture number
nextTime = time.time()
timeInc = 0.2 # update screen every half a second
fileName = “harmo”
running = False
def main():
openPort()
getData()
drawData() # to get the starting positions
blank_screen()
while True :
checkForQuit()
getData()
drawData()
def drawData():
global readings, nextTime, lastX, lastY
x = reading[0]
y = reading[1]
pygame.draw.line(screen,col,(lastX,lastY),(x,y),1)
lastX = x
lastY = y
# see if it is time to update the screen
if time.time() > nextTime :
pygame.display.update()
nextTime = time.time() + timeInc
def openPort():
global running
continued
Search WWH ::




Custom Search