樹莓派 0W 狂想曲︰ 不大聲以色《𝄡》

當學習者開始『反思學習』時,或明白大樹之所以『盤根錯節』,是適應『時空變化』的結果。這對『知識』與『經驗』來說,也是一樣的 ──『新事實』之發現、『老辦法』的褪色︰

要是我們對『declarative 』的了解僅止於『陳述的』、『說明的』或『宣告的』,一般來說並無助於理解

Thus, executing a program means searching for a proof. In traditional (imperative) programming languages, the program is a procedural specification of how a problem needs to be solved. In contrast, a logic program concentrates on a declarative specification of what the problem is.

這一段話的內容。這是因為我們還不知道『declarative 』語詞在『邏輯編程』語境中的『意指』,將之對比於『procedural』程序的,也只能帶來模糊的印象而已。如果用昨兒的互動程式為例,

pi@raspberrypi ~ 
*** QuickLaTeX cannot compile formula:
python3
Python 3.2.3 (default, Mar  1 2013, 11:53:50) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from pyDatalog import pyDatalog
>>> pyDatalog.create_terms('X單位, Y單位, Z單位, V數值, 單位轉換, 重量轉換')
>>> 單位轉換['公斤', '公克'] = 1000
>>> 單位轉換['台斤', '公克'] = 600
>>> 單位轉換['市斤', '公克'] = 500
>>> 單位轉換['英磅', '公克'] = 453.59237
>>> 單位轉換[X單位, Y單位] = 單位轉換[X單位, Z單位] * 單位轉換[Z單位, Y單位]
>>> 單位轉換[X單位, Y單位] = 1 / 單位轉換[Y單位, X單位]
>>> print(單位轉換['公斤', '台斤'] == V數值)
V數值               
------------------
1.6666666666666667
>>> print(單位轉換['英磅', '台斤'] == V數值)
V數值               
------------------
0.7559872833333334
>>> 單位轉換['台斤', '台兩'] = 16
>>> 重量轉換[V數值, X單位, Y單位] = V數值 * 單位轉換[X單位, Y單位]
>>> print(重量轉換[1, '公斤', '台兩'] == V數值)
V數值               
------------------
26.666666666666668
>>> 
</pre>
 

,是否會令人懷疑,讀了那篇文章所說的種種,真的足以『寫作』且『詮釋』那個『程式』的嗎?假使有一人宣稱他已 經仔細閱讀過那些種種,他將發現自己處於『術語叢林』,面對『理解 A 』得先『理解 B 』…… ,需要『理解 X 』,它卻又依賴於『理解 A 』。舉例講嬰兒學會母語,是那麼的天經地義,然而這個『能力』是因為『天生的』── 本能 ──?『環境的』── 學習 ── ?總在爭論中!彼此誰也不能完全說服了誰!!

雖話說如此,那些『術語』還是有『親疏遠近』,或許不該一開始就『捨近求遠』,如是我們會認為『知識表示』與『推理』
<h1 id="firstHeading" class="firstHeading" lang="en"><a href="https://en.wikipedia.org/wiki/Knowledge_representation_and_reasoning">Knowledge representation and reasoning</a></h1>
The starting point for knowledge representation is the <i>knowledge representation hypothesis</i> first formalized by <a title="Brian Cantwell Smith" href="https://en.wikipedia.org/wiki/Brian_Cantwell_Smith">Brian C. Smith</a> in 1985:<sup id="cite_ref-7" class="reference"><a href="https://en.wikipedia.org/wiki/Knowledge_representation_and_reasoning#cite_note-7">[7]</a></sup>
<blockquote><i>Any mechanically embodied intelligent process will be comprised of structural ingredients that a) we as external observers naturally take to represent a propositional account of the knowledge that the overall process exhibits, and b) independent of such external semantic attribution, play a formal but causal and essential role in engendering the behavior that manifests that knowledge.</i></blockquote>
和『邏輯編程』的關係較為緊密。而且能夠設想『 □□ 知識』就是『 ○○ 理論』裡,關於『 ☆☆ 世界』中的『事實』或是『定律』 。這樣我們可以揣測

<span style="color: #808080;">單位轉換[□, ○]= ??
</span>

說的就是某個世界中的約定『事實』。更由

<span style="color: #808080;">單位轉換<span class="crayon-sy">[</span><span class="crayon-i">□</span><span class="crayon-sy">, ○</span><span class="crayon-sy">]</span><span class="crayon-o">=</span>單位轉換<span class="crayon-sy">[</span><span class="crayon-i">□</span><span class="crayon-sy">,☆</span><span class="crayon-sy">]   乘</span><span class="crayon-o">   </span>單位轉換<span class="crayon-sy">[☆</span><span class="crayon-sy">,○</span><span class="crayon-sy">]</span></span>

<span style="color: #808080;">單位轉換<span class="crayon-sy">[□</span><span class="crayon-sy">,○</span><span class="crayon-sy">]</span><span class="crayon-o">=</span><span class="crayon-cn">1   除以  </span>單位轉換<span class="crayon-sy">[○</span><span class="crayon-sy">,□</span><span class="crayon-sy">]</span></span>

知道符合一般單位轉換運算『性質』。

當 這些『具足』時,『pyDatalog』就能『自動推導』作單位轉換,而且可以『添加』新事實以及新規則。於是從『作中學』Learning by doing ,我們可以了解,這跟用一般的程式語言寫作方式不同,這時『宣告的』一詞或許就有了『操作』 Operational 上的『意義』 ,它與『程序的』一詞的『對比』,也將更為『鮮明』。至於那個程式『中文化』的目的,大概只能始於『臆想』?用著『試誤法』作初步『嘗試』,閱讀 『pyDatalog』原始碼意圖『確認』。藉著對『派生三』 Python3 萬國碼的了解,做出的『待證明』假設吧!?看過《<a href="http://www.freesandal.org/?m=20150517">M♪o 之學習筆記本</a>》系列文本 TPG <a href="http://www.freesandal.org/?m=20150616">Toy Parser Generator</a> 的讀者,大概對此『中文表現』並不陌生,主要不過是希望程式能夠『易讀』,寫來比較精簡清楚罷了。

所以學會

《<a href="http://www.freesandal.org/?p=15025">如何閱讀□○??</a>》

<div class="wc-shortcodes-row wc-shortcodes-item wc-shortcodes-clearfix"><div class="wc-shortcodes-column wc-shortcodes-content wc-shortcodes-one-half wc-shortcodes-column-first ">

<a href="http://www.freesandal.org/wp-content/uploads/金文大篆智.png"><img class="alignnone size-full wp-image-15941" src="http://www.freesandal.org/wp-content/uploads/金文大篆智.png" alt="金文大篆智" width="62" height="72" /></a>
<a href="http://www.freesandal.org/wp-content/uploads/蛛網.jpg"><img class="alignnone size-full wp-image-15933" src="http://www.freesandal.org/wp-content/uploads/蛛網.jpg" alt="蛛網" width="2048" height="1267" /></a>

</div><div class="wc-shortcodes-column wc-shortcodes-content wc-shortcodes-one-half wc-shortcodes-column-last ">

<span style="color: #ff99cc;">其實『<strong>知識</strong>』如同『<strong>蛛網</strong>』,經由各種『<strong>學習渠道</strong>』與『<strong>自身經驗</strong>』,逐步建立起來。果真能像『<strong>蜘蛛</strong>』一樣,牽一髮而動全身的去『<strong>捕捉</strong>』,又何止是談『<strong>閱讀</strong>』一本書?智慧不只可以『<strong>閱讀</strong>』一個『<strong>時代</strong>』! 更能夠『<strong>閱讀</strong>』整個『<strong>自然</strong>』與『<strong>社會</strong>』的啊!!</span>

</div></div>

,往往是學習者在『反思學習』時,所應作的第一件事。

─── 摘自《<a href="http://www.freesandal.org/?p=36922">勇闖新世界︰ 《 pyDatalog 》 導引《二》</a>》

 

<span style="color: #666699;">因此『縱貫橫通』者之『閱讀』是『主動』的,也是『思辨』的,於是能夠將『舊工具』</span>
<h1 class="gh-header-title instapaper_title"><span style="color: #808080;"><a style="color: #808080;" href="https://github.com/notro/fbtft/wiki/Framebuffer-use">Framebuffer use</a></span></h1>
<h1><span style="color: #ff9900;">Framebuffer mirroring</span></h1>
<span style="color: #ff9900;">By mirroring <code>/dev/fb0</code> onto <code>/dev/fb1</code>, we can take advantage of the GPU for hardware accelrated video playback.</span>
<span style="color: #808080;">fbcp takes a snapshot of /dev/fb0, copies it to /dev/fb1 and waits 25ms before repeating.</span>
<span style="color: #808080;"> Snapshotting takes ~10ms and with a 25ms delay it gives roughly 1000/(10+25) = 28fps</span>
<span style="color: #808080;"> CPU usage: ~2%</span>
<span style="color: #808080;"> Note: Snapshot and /dev/fb1 driver refresh is not syncronized.</span>

<span style="color: #808080;">Install fbcp</span>
<pre lang="text"><code>sudo apt-get install cmake
git clone https://github.com/tasanakorn/rpi-fbcp
cd rpi-fbcp/
mkdir build
cd build/
cmake ..
make
sudo install fbcp /usr/local/bin/fbcp
</code></pre>
<span style="color: #808080;">Load drivers and fbcp</span>
<pre lang="text"><code>sudo modprobe fbtft dma
sudo modprobe fbtft_device name=tinylcd35 rotate=90 speed=48000000 fps=50

# Start fb copying process in the background
fbcp &
</code></pre>
<span style="color: #808080;">Play video on /dev/fb0, which will also show up on /dev/fb1</span>
<pre lang="text"><code>omxplayer test_480_320.mpg
</code></pre>
<span style="color: #808080;">Stop framebuffer copy</span>
<pre lang="text"><code>killall fbcp
</code></pre>
<span style="color: #808080;">syslog output</span>
<pre lang="text"><code>

*** Error message:
Unicode character 單 (U+55AE)
leading text: >>> pyDatalog.create_terms('X單
Unicode character 位 (U+4F4D)
leading text: >>> pyDatalog.create_terms('X單位
Unicode character 單 (U+55AE)
leading text: >>> pyDatalog.create_terms('X單位, Y單
Unicode character 位 (U+4F4D)
leading text: >>> pyDatalog.create_terms('X單位, Y單位
Unicode character 單 (U+55AE)
leading text: ...talog.create_terms('X單位, Y單位, Z單
Unicode character 位 (U+4F4D)
leading text: ...og.create_terms('X單位, Y單位, Z單位
Unicode character 數 (U+6578)
leading text: ...ate_terms('X單位, Y單位, Z單位, V數
Unicode character 值 (U+503C)
leading text: ..._terms('X單位, Y單位, Z單位, V數值
Unicode character 單 (U+55AE)
leading text: ...s('X單位, Y單位, Z單位, V數值, 單

tail /var/log/messages
Dec 15 17:38:07 raspberrypi fbcp[4836]: Primary display is 720 x 480
Dec 15 17:38:07 raspberrypi fbcp[4836]: Second display is 480 x 320 16bps

Links:
http://www.stuffaboutcode.com/2012/06/raspberry-pi-run-program-at-start-up.html

 

,轉化到『新系統』。不但知道『kodi』可以依樣畫葫蘆,想知道如何『自動化』哩︰

Add-on:Kodi Callbacks

Provides user definable actions for specific events within Kodi. Credit to Yesudeep Mangalapilly (gorakhargosh on github) and contributors for watchdog and pathtools modules.

 

如斯者,聽到有人說︰用 Python 寫個小程式,將觸控螢幕手勢事件模擬成鍵盤符碼

勇闖新世界︰ 《 Kernel 4.X 》之整裝蓄勢‧事件驅動‧一

勇闖新世界︰ 《 Kernel 4.X 》之整裝蓄勢‧設備管理及應用‧一

勇闖新世界︰ 《 Kernel 4.X 》之整裝蓄勢‧開場白

 

,不知是否會『即知即行』乎☆