shell mode下 驅動mouse定義winodws size,應該是可以的.要花點時間.
現在腦袋跳出來的想法是透過Frame Buffer.不過….應該可以WiFi遙控?
(都要IOT了,靠藍芽遙控一點都沒有Internet on thing的feeling).
使用Putty,藉由telnet login後.利用WiFi控制呢.
如可行 亦可以使用Smartphone連線操作.
以下版本是用 鍵盤上下左右按鍵 做為控制的版本 但尚未完成,不清楚telent是否能控制,擔心需要使用到Xwindow…
#!/usr/bin/python
import RPi.GPIO as GPIO
import time
import pygame
# Use physical pin numbers
GPIO.cleanup()
GPIO.setmode(GPIO.BOARD)
# Set up header 4 GPIO pin as an input
PinIN1 = 31 # GPIO6 as IN1
PinIN2 = 33 # GPIO13 as IN2
PinIN3 = 35 # GPIO19 as IN3
PinIN4 = 37 # GPIO26 as IN4
GPIO.setup(PinIN1, GPIO.OUT)
GPIO.setup(PinIN2, GPIO.OUT)
GPIO.setup(PinIN3, GPIO.OUT)
GPIO.setup(PinIN4, GPIO.OUT)
def InitialMoto():
GPIO.output(PinIN1, False)
GPIO.output(PinIN2, False)
GPIO.output(PinIN3, False)
GPIO.output(PinIN4, False)
def TurnRight():
GPIO.output(PinIN1, False)
GPIO.output(PinIN2, True)
GPIO.output(PinIN3, False)
GPIO.output(PinIN4, True)
def TurnLeft():
GPIO.output(PinIN1, True)
GPIO.output(PinIN2, False)
GPIO.output(PinIN3, True)
GPIO.output(PinIN4, False)
def Backward():
GPIO.output(PinIN1, False)
GPIO.output(PinIN2, True)
GPIO.output(PinIN3, True)
GPIO.output(PinIN4, False)
def Fordward():
GPIO.output(PinIN1, True)
GPIO.output(PinIN2, False)
GPIO.output(PinIN3, False)
GPIO.output(PinIN4, True)
def StopMoving():
GPIO.output(PinIN1, False)
GPIO.output(PinIN2, False)
GPIO.output(PinIN3, False)
GPIO.output(PinIN4, False)
pygame.init()
print('Start Test')
pygame.display.set_caption('Keyboard Example')
size= [640, 480]
screen= pygame.display.set_mode(size)
InitialMoto()
while True:
pygame.event.get()
key=pygame.key.get_pressed()
if key[pygame.K_DOWN] ==0 and key[pygame.K_UP] == 0 and key[pygame.K_RIGHT] == 0 and key[pygame.K_LEFT] == 0:# Stop Moving
StopMoving()
print('No Pressed')
if key[pygame.K_DOWN] !=0: # Backward
Backward()
print('Down')
if key[pygame.K_UP] != 0: # Fordward
Fordward()
print('Up')
if key[pygame.K_RIGHT] != 0: # Turn Right
TurnRight()
print('Right')
if key[pygame.K_LEFT] != 0: # Turn Left
TurnLeft()
print('Left')
pygame.display.update()
# clock.tick(20)
沒有留言:
張貼留言