M♪o 之學習筆記本《辰》組元︰【䷝】重明麗正

派生碼訊

辰 龍

離:利貞,亨。 畜牝牛,吉。

彖曰:離,麗也﹔日月麗乎天,百谷草木麗乎土,重明以麗乎正,乃化成天下。 柔麗乎中正,故亨﹔是以畜牝牛吉也。

象曰:明兩作離,大人以繼明照于四方。

︰例假日。

 

派《 文 》文說︰ 離 離,黃倉庚也。鳴則蠶生。从隹离聲。據聞古意是︰鳥兒被網罩住。

昨兒個 廟會 會跳的 朱 雀 舞 朱雀舞,總不覺舞於庭,倒真像被網罩住似的!不過在這個《 阡 陌 網 》阡陌網時代 ,又有幾人不被 網 網罩住了呢?恐怕孔子想的相反了,現今也許 薦 荐儀還有人看,那個 盥 盥禮大概能省就省了吧!!果真早就『天 象 象遠』?『人 事 事近』了的耶??

試想城居幾時能見

220px-Black-naped_Oriole 黃鶯出谷

,哪有緣得識黃倉庚。又怎曉《 詩 》詩言

七月流火,九月授衣。春日載陽,有鳴倉庚。

說何 事 事︰

詩經‧國風‧豳風‧七月

七月流火,九月授衣。一之日觱發,二之日栗烈。無衣無褐,何以卒歲!三之日於耜,四之日擧趾。同我婦子,饁彼南畝。田畯至喜 。

七月流火,九月授衣。春日載陽,有鳴倉庚。女執懿筐,遵彼微行 ,爰求柔桑。春日遲遲,采蘩祁祁。女心傷悲,殆及公子同歸。

七月流火,八月萑葦。蠶月條桑,取彼斧斨。以伐遠颺,猗彼女桑 。七月鳴鵙,八月載績。載玄載黄,我朱孔陽,爲公子裳。

四月秀葽,五月鳴蜩。八月其穫,十月隕萚.一之日於貉,取彼狐狸 ,爲公子裘。二之日其同,載纘武功。言私其豵,獻豜於公。

五月斯螽動股,六月莎雞振羽。七月在野,八月在宇,九月在戶,十月蟋蟀入我床下。穹窒熏鼠,塞向墐戶。嗟我婦子,曰爲改歲,入此室處。

六月食鬱及薁,七月亨葵及菽。八月剝棗,十月穫稻。爲此春酒,以介眉壽。七月食瓜,八月斷壺,九月叔苴,采荼薪樗。食我農夫 。

九月築場圃,十月納禾稼。黍稷重穋,禾麻菽麥。嗟我農夫!我稼既同,上入執宮功。晝爾於茅,宵爾索綯,亟其乘屋,其始播百穀 。

二之日鑿冰沖沖,三之日納於凌陰。四之日其蚤,獻羔祭韭。九月肅霜,十月滌場。朋酒斯饗,曰殺羔羊。躋彼公堂,稱彼兕觥,“萬壽無疆”!

今年 飛 龍 祭 飛龍祭緊接夏至,雖尚講『長陽』之祀,恐怕 星回 回,早已名存實亡。事實上『火把』習俗,也恐怕忘名凋喪 。《火把節》又稱『星回節』,節期一般是在農曆的六月二十五日。這個盛夏『大暑節氣之時,是彝族上半年的『過年日』,更不要說這背後淒美的故事

南詔野史》:

南詔首領皮羅閣圖并吞五詔,將五詔於松明樓焚殺鄧賧妻慈善諫夫勿往夫不從而被殺慈善閉城死滇人以是日燃炬吊之

這位鄧賧詔詔主的妻子慈善夫人,是開元間人,又名『白潔夫人』,真不知其夫皮邏登為何執意不聽,一定要去那個『鴻門宴』,以致不但自己身亡,其妻只能據其夫所帶之『鐵鐲』來為他收屍守喪,並為免於皮邏閣之玷污,百日之後投洱海自盡。十九世紀英國有一位卡萊爾寫了《英雄與英雄崇拜》一書洋洋灑灑的談著『煮酒論英雄』之『英雄觀』,作者心想以那『白潔夫人』之『』與『』的情意來說,也許根本不想『死後立廟』,寧願『生前相守』的吧!!

釋迦牟尼佛在一部了一個『將來』佛的『』事,這就是『光明』燈的由來︰

佛說阿闍世王受決經
西晉三藏沙門釋法炬譯

聞如是。一時佛在羅閱祇國耆闍崛山中。時阿闍世王請佛。飯食已訖佛還祇洹。王與祇婆議曰。今日請佛。佛飯已竟更復所宜。祇婆言。唯多然燈也。於是王乃具百斛麻油膏。從宮門至祇洹精舍。

時有貧窮老母。常有至心欲供養佛而無資財。見王作此功德乃更感激。行乞得兩錢。以至 麻油家買膏。膏主曰。母人大貧窮。乞得兩錢何不買食。以自連繼用此膏為。 母曰。我聞佛生難值百劫一遇。我幸逢佛世而無供養。今日見王作功德。巍巍無量激起我意。雖實貧窮故欲然一燈為後世根本者也。於是膏主嘉其至意。與兩錢膏應 得二合。特益三合凡得五合。母則往當佛前然之。心計此膏不足半夕。乃自誓言。若我後世得道如佛。膏當通夕光明不消。作禮而去 。王所然燈或滅或盡。雖有人侍 恒不周。老母所然一燈光明特朗 。殊勝諸燈通夕不滅。膏又不盡至明朝旦。母復來前頭面作禮叉手却住。

佛告目連。天今已曉可滅諸燈。目連承教以次滅諸燈。燈皆已滅。唯此母一燈三滅不滅。 便舉袈裟以扇之燈光益明。乃以威神引隨藍風以次吹燈。老母燈更盛猛。乃上照梵天。傍照三千世界悉見其光 。佛告目連。止止。此當來佛之光明功德。非汝威神所毀滅。此母宿命供養百八十億佛已。從前佛受決。務以經法教授開化人民。未暇修檀。故今貧窮無有財寶。却後三十劫。功德成滿當得作佛。號曰須彌燈光如來至真。世界無有日月。人民身中皆有大光。宮室眾寶光明相照如忉利天上。老母聞決歡喜。即時輕舉身昇虚空。去地百八十丈。來下頭面作禮而去。

過去作者曾聽過一個『問題』和一個『回答

問題如何『照亮』世界

回答點燃自己心中的『光明』,照亮自己『身旁』的人;另一人因著光照明亮或因偶然燃起他心中的『光明』,如此如是持久長遠,終將『照亮』世界

,今日想來這個『點燈理論』也許出自『佛說』。

 

生 ︰何能繼明照于四方?唯願效法而已矣!續繼昨日之軌跡 ,釐清若干疑義。

Unicode HOWTO

This HOWTO discusses Python support for Unicode, and explains various problems that people commonly encounter when trying to work with Unicode.

Introduction to Unicode

History of Character Codes

In 1968, the American Standard Code for Information Interchange, better known by its acronym ASCII, was standardized. ASCII defined numeric codes for various characters, with the numeric values running from 0 to 127. For example, the lowercase letter ‘a’ is assigned 97 as its code value.

ASCII was an American-developed standard, so it only defined unaccented characters. There was an ‘e’, but no ‘é’ or ‘Í’. This meant that languages which required accented characters couldn’t be faithfully represented in ASCII. (Actually the missing accents matter for English, too, which contains words such as ‘naïve’ and ‘café’, and some publications have house styles which require spellings such as ‘coöperate’.)

For a while people just wrote programs that didn’t display accents. In the mid-1980s an Apple II BASIC program written by a French speaker might have lines like these:

PRINT "MISE A JOUR TERMINEE"
PRINT "PARAMETRES ENREGISTRES"

Those messages should contain accents (terminée, paramètre, enregistrés) and they just look wrong to someone who can read French.

In the 1980s, almost all personal computers were 8-bit, meaning that bytes could hold values ranging from 0 to 255. ASCII codes only went up to 127, so some machines assigned values between 128 and 255 to accented characters. Different machines had different codes, however, which led to problems exchanging files. Eventually various commonly used sets of values for the 128–255 range emerged. Some were true standards, defined by the International Standards Organization, and some were de facto conventions that were invented by one company or another and managed to catch on.

255 characters aren’t very many. For example, you can’t fit both the accented characters used in Western Europe and the Cyrillic alphabet used for Russian into the 128–255 range because there are more than 128 such characters.

You could write files using different codes (all your Russian files in a coding system called KOI8, all your French files in a different coding system called Latin1), but what if you wanted to write a French document that quotes some Russian text? In the 1980s people began to want to solve this problem, and the Unicode standardization effort began.

Unicode started out using 16-bit characters instead of 8-bit characters. 16 bits means you have 2^16 = 65,536 distinct values available, making it possible to represent many different characters from many different alphabets; an initial goal was to have Unicode contain the alphabets for every single human language. It turns out that even 16 bits isn’t enough to meet that goal, and the modern Unicode specification uses a wider range of codes, 0 through 1,114,111 ( 0x10FFFF in base 16).

There’s a related ISO standard, ISO 10646. Unicode and ISO 10646 were originally separate efforts, but the specifications were merged with the 1.1 revision of Unicode.

(This discussion of Unicode’s history is highly simplified. The precise historical details aren’t necessary for understanding how to use Unicode effectively, but if you’re curious, consult the Unicode consortium site listed in the References or the Wikipedia entry for Unicode for more information.)

……

PEP 3111 — Simple input built-in in Python 3000

Abstract

Input and output are core features of computer programs. Currently, Python provides a simple means of output through the print keyword and two simple means of interactive input through the input() and raw_input() built-in functions.

Python 3.0 will introduce various incompatible changes with previous Python versions [1] . Among the proposed changes, print will become a built-in function, print(), while input() and raw_input() would be removed completely from the built-in namespace, requiring importing some module to provide even the most basic input capability.

This PEP proposes that Python 3.0 retains some simple interactive user input capability, equivalent to raw_input(), within the built-in namespace.

It was accepted by the BDFL in December 2006 [5] .

Motivation

With its easy readability and its support for many programming styles (e.g. procedural, object-oriented, etc.) among others, Python is perhaps the best computer language to use in introductory programming classes. Simple programs often need to provide information to the user (output) and to obtain information from the user (interactive input). Any computer language intended to be used in an educational setting should provide straightforward methods for both output and interactive input.

The current proposals for Python 3.0 [1] include a simple output pathway via a built-in function named print(), but a more complicated method for input [e.g. via sys.stdin.readline()], one that requires importing an external module. Current versions of Python (pre-3.0) include raw_input() as a built-in function. With the availability of such a function, programs that require simple input/output can be written from day one, without requiring discussions of importing modules, streams, etc.

……

 

碼 ︰無 習 。無課。

 

行 習 行習︰雖然過程跌跌撞撞,終於得此『入出針語言』之第一嚐︰

#!/usr/bin/python3
# -*- coding: utf-8 -*-

import math
import operator
import string
import threading
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

開 = 亮 = 低 = 0
關 = 滅 = 高 = 1

from time import sleep

import tpg

if tpg.__python__ == 3:
    operator.div = operator.truediv
    raw_input = input

def make_op(op):
    return {
        '加'   : operator.add,
        '減'   : operator.sub,
        '乘'   : operator.mul,
        '除'   : operator.div,
        '剩'   : operator.mod,
        '^'   : lambda x,y:x**y,
        '**'  : lambda x,y:x**y,
        '餘弦' : math.cos,
        '正弦' : math.sin,
        '切弦' : math.tan,
        'acos': math.acos,
        'asin': math.asin,
        'atan': math.atan,
        '平方' : lambda x:x*x,
        '根號': math.sqrt,
        '正值' : abs,
        'norm': lambda x,y:math.sqrt(x*x+y*y),
    }[op]

數碼賦值 = [(滅, 亮, 亮, 滅, 滅, 滅, 滅, 滅), (亮, 亮, 滅, 亮, 亮, 滅, 亮, 滅), (亮, 亮, 亮, 亮, 滅, 滅, 亮, 滅),  (滅, 亮, 亮, 滅, 滅, 亮, 亮, 滅)
]

遲延 = 0.012

# 數碼管

四位數碼管位選一 = 17
四位數碼管位選二 = 27
四位數碼管位選三 = 22
四位數碼管位選四 = 10

LEDA = 21
LEDB = 16
LEDC = 19
LEDD = 6
LEDE = 5
LEDF = 20
LEDG = 26
LEDH = 13

# 初始態

GPIO.setup(四位數碼管位選一, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選二, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選三, GPIO.OUT, initial=關)
GPIO.setup(四位數碼管位選四, GPIO.OUT, initial=關)

GPIO.setup(LEDA, GPIO.OUT, initial=滅)
GPIO.setup(LEDB, GPIO.OUT, initial=滅)
GPIO.setup(LEDC, GPIO.OUT, initial=滅)
GPIO.setup(LEDD, GPIO.OUT, initial=滅)
GPIO.setup(LEDE, GPIO.OUT, initial=滅)
GPIO.setup(LEDF, GPIO.OUT, initial=滅)
GPIO.setup(LEDG, GPIO.OUT, initial=滅)
GPIO.setup(LEDH, GPIO.OUT, initial=滅)



def 數碼管執行緒():
    global 數碼賦值
    global 遲延

    數碼管 = [LEDA, LEDB, LEDC, LEDD, LEDE, LEDF, LEDG, LEDH]

    while True :

        for 單元 in range(0,4):
            if 單元 == 0 :
                GPIO.output(四位數碼管位選一, 開)
                GPIO.output(數碼管, 數碼賦值[單元])
                sleep(0.002)
                GPIO.output(四位數碼管位選一, 關)

            if 單元 == 1 :
                GPIO.output(四位數碼管位選二, 開)
                GPIO.output(數碼管, 數碼賦值[單元])
                sleep(0.002)
                GPIO.output(四位數碼管位選二, 關)

            if 單元 == 2 :
                GPIO.output(四位數碼管位選三, 開)
                GPIO.output(數碼管, 數碼賦值[單元])
                sleep(0.002)
                GPIO.output(四位數碼管位選三, 關)

            if 單元 == 3 :
                GPIO.output(四位數碼管位選四, 開)
                GPIO.output(數碼管, 數碼賦值[單元])
                sleep(0.002)
                GPIO.output(四位數碼管位選四, 關)

        sleep(遲延)

數碼緒 = threading.Thread(name="數碼", target=數碼管執行緒)

數碼緒.start()

數碼管輸出字典 = { "0" : (亮, 亮, 亮, 亮, 亮, 亮, 滅, 滅) ,
                   "1" : (滅, 亮, 亮, 滅, 滅, 滅, 滅, 滅) ,
                   "2" : (亮, 亮, 滅, 亮, 亮, 滅, 亮, 滅) ,
                   "3" : (亮, 亮, 亮, 亮, 滅, 滅, 亮, 滅) ,
                   "4" : (滅, 亮, 亮, 滅, 滅, 亮, 亮, 滅) ,
                   "5" : (亮, 滅, 亮, 亮, 滅, 亮, 亮, 滅) ,
                   "6" : (亮, 滅, 亮, 亮, 亮, 亮, 亮, 滅) ,
                   "7" : (亮, 亮, 亮, 滅, 滅, 滅, 滅, 滅) ,
                   "8" : (亮, 亮, 亮, 亮, 亮, 亮, 亮, 滅) ,
                   "9" : (亮, 亮, 亮, 亮, 滅, 亮, 亮, 滅) ,
                 }


def 輸出數碼管(數據) :
    global 數碼賦值
    global 數碼管輸出字典

    if 數據 > 999.9 :
        return "數值超過 999.9"
    else:

        字符串 = "%05.1f" %數據

        for 單元 in range(0,5):
            if 單元 == 0 :
                數碼賦值[單元] = 數碼管輸出字典[字符串[單元]]
            elif 單元 == 1 :
                數碼賦值[單元] = 數碼管輸出字典[字符串[單元]]
            elif 單元 == 2 :
                暫列 = list(數碼管輸出字典[字符串[單元]])
                暫列[7] = 亮
                數碼賦值[單元] = tuple(暫列)
            elif 單元 == 3 :
                continue
            else:
                數碼賦值[單元 - 1] = 數碼管輸出字典[字符串[單元]]

    return "完成"



GPIO.setup(11, GPIO.OUT, initial=GPIO.HIGH)
小哨子 = GPIO.PWM(11, 130.8)

def 啟動蜂鳴器():
        小哨子.start(100)
        return "蜂鳴器已啟動"

def 響聲控制(頻率):
        小哨子.ChangeFrequency(頻率)
        小哨子.start(50)
        return 頻率

def 噤聲控制(頻率):
        小哨子.ChangeFrequency(頻率)
        小哨子.start(100)
        return "噤聲"

def 控制蜂鳴器(op):
    return {
        '響聲'   : 響聲控制,
        '禁音'   : 噤聲控制,
   }[op]

def 輸入符碼(針碼):
        return GPIO.input(針碼)


def 輸出符碼(針碼, 賦值):
        GPIO.output(針碼, 賦值)
        return "輸出" + str(賦值)

def 出入定義(針碼, 入出):
        if 入出 == "出" :
            GPIO.setup(針碼, GPIO.OUT, initial = GPIO.HIGH)
        else:
            GPIO.setup(針碼, GPIO.IN, pull_up_down = GPIO.PUD_UP)
        return "定義完成"

def 出針定義(針碼):
    GPIO.setup(針碼, GPIO.OUT, initial = GPIO.HIGH)
    return "定義輸出完成"

def 入針定義(針碼):
    GPIO.setup(針碼, GPIO.IN, pull_up_down = GPIO.PUD_UP)
    return "定義輸入完成"


def 入出針定義(op):
    return {
        '入針'   : 入針定義,
        '出針'   : 出針定義,
   }[op]


class 實習機板(tpg.Parser, dict):
    r"""
    此實習基板入出針語言嘗試,自 Calc.py 擴充而來。由於使用中文之故,
    不能使用預設的 NamedGroupLexer 。
    文法定義如下 ::

        set lexer = CacheLexer

        separator space '\s+' ;

        token 指數運算    '\^|\*\*'                                               make_op         token 入出設定    '(入針|出針)\b' 入出針定義
        token 聲音控制    '(響聲|禁音)\b'                                                   控制蜂鳴器         token 加減運算    '[加|減]' make_op
        token 乘除運算    '[乘|除|剩]'                                                 make_op         token 函數一    '(餘弦|正弦|切弦|acos|asin|atan|平方|根號|正值)\b' make_op
        token 函數二    '(norm)\b'                                              make_op         token real      '(\d+\.\d*|\d*\.\d+)([eE][-+]?\d+)?|\d+[eE][-+]?\d+' float
        token integer   '\d+'                                                   int         token VarId     '\w*'                                                    ;          START/e ->                 '變元' e=self.記憶()
            |   VarId/v '=' Expr/e      self[v]=e             |   Expr/e #            |   '定義' Expr/p '出' e=出入定義(p, '出')
#            |   '定義' Expr/p '入'             e=出入定義(p, '入')             |   '入出針'  Expr/p 入出設定/op e=op(p)
            |   '讀入' Expr/p                  e=輸入符碼(p)             |   '寫出' Expr/p '開' e=輸出符碼(p, 0)
            |   '寫出' Expr/p '關'                 e=輸出符碼(p, 1)             |   "打開蜂鳴器" e=啟動蜂鳴器()
            |   "蜂鳴器" 聲音控制/op Expr/p       e = op(p)             |   "顯示" Expr/p e = 輸出數碼管(p)
        ;

        Var/self.get(v,0) -> VarId/v ;

        Expr/e -> Term/e ( 加減運算/op Term/t     e=op(e,t)                          )*         ;         Term/t -> Fact/t ( 乘除運算/op Fact/f t=op(t,f)
                         )*
        ;

        Fact/f ->
                加減運算/op Fact/f                f=op(0,f)             |   Pow/f         ;          Pow/f -> Atom/f ( 指數運算/op Fact/e f=op(f,e)
                        )?
        ;

        Atom/a ->
                real/a
            |   integer/a
            |   Function/a
            |   Var/a
            |   '' Expr/a ''
        ;
        
        Function/y ->
                函數一/f '' Expr/x ''              y = f(x)               | 函數二/f '<img src="http://www.freesandal.org/wp-content/ql-cache/quicklatex.com-5618a7a7b23dfd84e41ef622fed8142e_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="' Expr/x1 ',' Expr/x2 '" title="Rendered by QuickLaTeX.com" height="19" width="165" style="vertical-align: -5px;"/>' y = f(x1,x2)
        ;

    """

    def __init__(self):
        super().__init__()
        self.名稱 = "實習機板"
        self["一藍"] = 5
        self["二藍"] = 6
        self["三藍"] = 13
        self["四藍"] = 19
        self["五綠"] = 0
        self["六綠"] = 1
        self["七黃"] = 7
        self["八紅"] = 8
        self["按鍵一"] = 23
        self["按鍵二"] = 18
        self["撥碼一"] = 24
        self["撥碼二"] = 25



    def 記憶(self):
        vars = sorted(self.items())
        memory = [ "%s = %s"%(var, val) for (var, val) in vars ]
        return "\n\t" + "\n\t".join(memory)



print("Calc (TPG example)")
實習機 = 實習機板()
while 1:
    try:
       l = raw_input("\n:")
    except UnicodeDecodeError:
       continue

    if l:
        try:
            print(實習機(l))
        except Exception:
            print(tpg.exc())
    else:
        break


數碼緒._stop()

GPIO.cleanup()


 

,還得加緊的試,趕在那開課之先︰

IMG_0660s

 

pi@raspberrypi ~ $ sudo python3 Miomachine.py 
Calc (TPG example)

:顯示 3
完成

:顯示 正弦( 3.14 除 6)
完成

:打開蜂鳴器
蜂鳴器已啟動

:蜂鳴器 響聲 2
2

:蜂鳴器 禁音 10
噤聲

:入出針 七黃 出針
定義輸出完成

:寫出 七黃 開
輸出0

:顯示 1000 除 365.25
完成

:顯示 根號(179)
完成

:變元

	一藍 = 5
	七黃 = 7
	三藍 = 13
	二藍 = 6
	五綠 = 0
	八紅 = 8
	六綠 = 1
	四藍 = 19
	按鍵一 = 23
	按鍵二 = 18
	撥碼一 = 24
	撥碼二 = 25

:入出針 撥碼一 入針
定義輸入完成

:讀入 撥碼一
1

:讀入 撥碼一
0

:

 

訊 如今或將曉 禮記‧中庸》:

或生而知之,或學而知之,或困而知之,及其知之一也。或安而行之,或利而行之,或勉強而行之,及其成功一也。

,所謂之困知勉行何謂也?