迷宮 λαβύρινθος,labyrinthos 在希臘神話中是一座精心製作的建築物,由名匠代達羅斯為克里特島的國王米諾斯所設計,建造於克諾索斯。這座迷宮用來囚禁米諾斯的兒子,半人半牛怪物的彌諾陶洛斯。代達羅斯巧妙地建造這座迷宮,使得在完成後他本人幾乎無法從中逃脫。雅典英雄忒修斯得到阿里阿德涅的襄相,在殺害彌諾陶洛斯後,順著阿里阿德涅的線帶領之下成功逃出迷宮。
當一個系統存在多年,經歷眾多的發展者,各種新舊功能交織,很容易形成盤根錯節的複雜現象,甚至某些基本想法的衝突。這對於開源的 Linux 系統來說,更是如此。即使就大的骨幹 grub boot、 kernel 、gnu gcc 、gnome gtk 、kde qt 、等等已經改代多次,繼至系統的管理辦法,友善的桌面環境種種,在出名的發行版逐鹿競爭之下,真是洋洋灑灑,儼然是個迷宮。果然,一個裝置或某種功能,此家可以彼家不行,這版沒問題,那版沒得救。於是各家論壇鼎沸,議論是非真假,誰對誰錯!既然『樹莓派』已有『官方版』,也有『官方論壇』,也許碰到問題時,最好從此出發,或許會有類似遭遇者的吧!當然要是有忒修斯的本事,何不勇闖迷宮,縱橫五湖四海的呢??不過忒修斯還是需要『線頭』的吧!!對於想學 python 的讀者,在此推薦 Albert Sweigart 之『用騛罿創造』免費讀書網。
事實上『軟體工程』的歷史很短,假使從一九六八年『克努斯』的《電腦程式設計藝術》 The Art of Computer Programming 算起, 也還不到半個世紀,尚不要說『藝術』一詞所指的『意義』是什麼呢?因而□□『軟體標準化』 Software standard 大概還是某些○○『系統平台』 Computing platform 圈內的事。這樣難道不好嗎?如果用『螺絲釘』與『螺絲帽』來比喻,有人說軟體『工程化』的好處就是彼此間說『同一國的語言』,因此『協作容易』。作者認為自然中豐富之『多樣性』,正是『生態平衡』的大道;地球上不同的『方言』,產生『社會文化』的消長,所以無須強求一致的吧!然而這或許就得面對『甲軟體』和『乙軟體』 No Talking 的問題的了?!
如果把不能『簡單化』的『疑難』強迫簡化,也許只是『過度化』的吧!奥卡姆的『剃刀原理』去除『多餘的假設』,就像『歸謬證法』排除『邏輯之矛盾』一樣,難到『科學』果能有『神奇』之『其他辦法』的嗎??假使『科學精神』是建立在人人可得之『事實』,大家可以『實驗』驗證的基礎上,所謂的『科學假設』或許是喜歡被打敗的事吧!於是愛因斯坦設想『光速不變』,真的是宛如『燃素說』一般的嗎?當然不是,邏輯上講,要是 ,那麼要『 A 』又有何用?因是之故,『科學假設』 通常是說, ,因此才可以判定『是非對錯』的吧!!
怎麽『解』迷宮,『尋』出路的呢?大數學家『尤拉』是第一位使用平面連通之『分析方法』來解決『迷途』 Maze 的人,後來此種研究『方式』被稱之為『拓撲學』。依據『右 手定律』,或者對等的說就是『左手定則』,這就是著名的『迷宮演算法』︰
如果那個迷宮是由簡單的路徑連接起來,也就是說,要是所有牆壁都是連接著的,這樣只要用右手指延著入口之某一堵 牆,如斯的前進,那將肯定不會迷路,並且可能尋着出口,也許最壞的打算祇是回到原點。
假使按造『尤拉』的解法,即使是『迷宮般的軟體』,也都有『方法可循』,只要堅持到底,總有找到答案的一天。或許有人認為那作法『太慢』了『不好』,但是『快』也得要能『解決』問題吧!否則『快』又有什麼用呢?
那麼這個回覆
However, if you’re running graphical SDL apps on the framebuffer as a normal user via ssh, take into account how SDL framebuffer choses the active console and keyboard: take a look at src/video/fbcon/SDL_fbevents.c, around line 263 where it tests it you’re root or a normal user. Only the root path works via ssh… tell me if you manage to fix it.
,是這個問題
Traceback (most recent call last):
File "pygametest.py", line 14, in <module>
DISPLAYSURF = pygame.display.set_mode((480, 320), 0, 32)
pygame.error: Unable to open a console terminal
的答案嗎??
點擊閱讀一個可以同時用於『命令列』與『視窗』環境的︰
#!/usr/bin/env python
import os
import pygame
import time
import random
class pyscope :
screen = None;
def __init__(self):
"Ininitializes a new pygame screen using the framebuffer"
# Based on "Python GUI in Linux frame buffer"
# http://www.karoltomala.com/blog/?p=679
disp_no = os.getenv("DISPLAY")
if disp_no:
print "I'm running under X display = {0}".format(disp_no)
# Check which frame buffer drivers are available
# Start with fbcon since directfb hangs with composite output
drivers = ['fbcon', 'directfb', 'svgalib']
found = False
for driver in drivers:
# Make sure that SDL_VIDEODRIVER is set
if not os.getenv('SDL_VIDEODRIVER'):
os.putenv('SDL_VIDEODRIVER', driver)
os.putenv('SDL_FBDEV', '/dev/fb1')
try:
pygame.display.init()
except pygame.error:
print 'Driver: {0} failed.'.format(driver)
continue
found = True
break
if not found:
raise Exception('No suitable video driver found!')
size = (pygame.display.Info().current_w, pygame.display.Info().current_h)
print "Framebuffer size: %d x %d" % (size[0], size[1])
self.screen = pygame.display.set_mode(size, pygame.FULLSCREEN)
# Clear the screen to start
self.screen.fill((0, 0, 0))
# Initialise font support
pygame.font.init()
# Render the screen
pygame.display.update()
def __del__(self):
"Destructor to make sure pygame shuts down, etc."
def drawGraticule(self):
"Renders an empty graticule"
# The graticule is divided into 10 columns x 8 rows
# Each cell is 50x40 pixels large, with 5 subdivisions per
# cell, meaning 10x8 pixels each. Subdivision lines are
# displayed on the central X and Y axis
# Active area = 10,30 to 510,350 (500x320 pixels)
borderColor = (255, 255, 255)
lineColor = (64, 64, 64)
subDividerColor = (128, 128, 128)
# Outer border: 2 pixels wide
pygame.draw.rect(self.screen, borderColor, (8,28,504,324), 2)
# Horizontal lines (40 pixels apart)
for i in range(0, 7):
y = 70+i*40
pygame.draw.line(self.screen, lineColor, (10, y), (510, y))
# Vertical lines (50 pixels apart)
for i in range(0, 9):
x = 60+i*50
pygame.draw.line(self.screen, lineColor, (x, 30), (x, 350))
# Vertical sub-divisions (8 pixels apart)
for i in range(1, 40):
y = 30+i*8
pygame.draw.line(self.screen, subDividerColor, (258, y), (262, y))
# Horizontal sub-divisions (10 pixels apart)
for i in range(1, 50):
x = 10+i*10
pygame.draw.line(self.screen, subDividerColor, (x, 188), (x, 192))
def test(self):
"Test method to make sure the display is configured correctly"
adcColor = (255, 255, 0) # Yellow
self.drawGraticule()
# Render the Adafruit logo at 10,360
#logo = pygame.image.load('images/adafruit_logo.gif').convert()
#self.screen.blit(logo, (10, 335))
# Get a font and use it render some text on a Surface.
font = pygame.font.Font(None, 30)
text_surface = font.render('pyScope (%s)' % "0.1",
True, (255, 255, 255)) # White text
# Blit the text at 10, 0
self.screen.blit(text_surface, (10, 0))
# Render some text with a background color
text_surface = font.render('Channel 0',
True, (0, 0, 0), (255, 255, 0)) # Black text with yellow BG
# Blit the text
self.screen.blit(text_surface, (540, 30))
# Update the display
pygame.display.update()
# Random adc data
yLast = 260
for x in range(10, 509):
y = random.randrange(30, 350, 2) # Even number from 30 to 350
pygame.draw.line(self.screen, adcColor, (x, yLast), (x+1, y))
yLast = y
pygame.display.update()
# Create an instance of the PyScope class
scope = pyscope()
scope.test()
# Wait 10 seconds
time.sleep(10)