Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 112

Notice: Trying to access array offset on value of type bool in /home1/freesand/public_html/wp-content/plugins/wiki-embed/WikiEmbed.php on line 116
2 月 | 2016 | FreeSandal

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧辛

壬一

壬二

壬三

《説文解字》:壬,位北方也。陰極陽生 ,故《易》曰:“龍戰于野。”戰者,接也 。象人褢妊之形。承亥壬以子,生之敘也 。與巫同意。壬承辛,象人脛。脛,任體也。凡壬之屬皆从壬。

本義:善於使用巧具,勝任事務。

論語》‧泰伯第八

曾子曰:士不可以不弘毅任重道遠,仁以為己任,不亦重乎!死而後已,不亦遠乎!

曾子曰:以能問於不能,以多問於寡;有若無,實若虛,犯而不校;昔者吾友【顏淵】,嘗從事於斯矣。

……

無論人們喜歡與否,我們已經活在了『大數據』的『礦坑』之中,我們本身就是『資訊礦石』。舉例來說,許多便利商店裝設著資訊收集、分析、儲存……的 『攝像鏡頭』,用著『影像辨識』的科技追蹤『消費者』之『視線』,分析『消費者』的性別、年齡、喜好 ……等等數據,可用於廣告、促銷、商品管理……種種用途,企圖達到『別家』或『門可羅雀』,此處卻『人滿為患』的成效。那麼這是『合理』的嗎?應該『同 意』的嗎??想像未來當你進入一個『賣場』,你的『手機』就已經告訴你今天有哪些你『喜歡』的『食品』正在『特價』,挑動著你的『感性欲望』;或許由於其 它非食品業 APP 軟體廠商的大力『宣傳』,你的『手機』上也有那種分析『食品』對『身體健康』影響的 APP,它正提醒你的『理性』再吃就『超標』了……這難道不是…資訊轟炸……更像是……擺脫不掉,自己找來的麻煩!!

也許那還是自己可以選擇之『好』的一面。因為不是所有人利用『大數據』來『淘金』,都具有『專業訓練』以及『道德良心』。因此常有『□□ 研究』的『數據』『證實』吃『○○食品』能降低『☆☆指數』如何?如之何的『廣告』??一 旦發生了『事故』,大概全成了那是『個案』以及『例外』的了。就像『風起雲湧』,天未必會下雨,『艷陽高照』,未必天就不下雨。比方說『徵候』是講時間 『先行』的『現象』,與伴隨該『現象』之後『而來』的『現象』,『現象』之間可能會有『統計相關性』,但不一定具有什麼『因果關係』。或許可以讀一讀 《知未知‧既未濟》所言︰

………

─── 摘自《《派生》 Python 作坊【壬】任重道遠

 

身在雲端大數據的今天,資訊駁雜巨量,或許需要掌握的工具不只是『搜尋谷歌』而已,更須具有『慎思明辨』的能力吧!

為了了解超音波感測器的運作原理

grove_pi_v1_2_5.ino

# line 125
 //Ultrasonic Read
else if(cmd[0]==7)
{
   pin=cmd[1];
   pinMode(pin, OUTPUT);
   digitalWrite(pin, LOW);
   delayMicroseconds(2);
   digitalWrite(pin, HIGH);
   delayMicroseconds(5);
   digitalWrite(pin,LOW);
   pinMode(pin,INPUT);
   dur = pulseIn(pin,HIGH);
   RangeCm = dur/29/2;
   b[1]=RangeCm/256;
   b[2]=RangeCm%256;
   //Serial.println(b[1]);
   //Serial.println(b[2]);
}

 

探究問題所指

API of grovepi.read_i2c_block is unsafe and chashes grovepi.ultrasonicRead #141

read_i2c_block normally returns a list but in case of an IOError it returns -1 (int). This is extremely difficult to handle as one would had to test the return value of read_i2c_block.

One would have to use something like this:

number = read_i2c_block(address)
if type(number) is list:
     do something_usefull()
else:
  handle_error()

which is the same thing as catching the exception.
ultrasonicRead and all the other function I saw in grovepi.py use the function in unsafe manor:

def ultrasonicRead(pin):
        write_i2c_block(address, uRead_cmd + [pin, unused, unused])
        time.sleep(.2)
        read_i2c_byte(address)
        number = read_i2c_block(address)
        return (number[1] * 256 + number[2])

Which leads to an TypeError and the program to crash as one is not expecting an TypeError.

This also happens in the wild:
http://www.dexterindustries.com/forum/?topic=ultrasonic-ranger-1-0-broken/

It would be much clearer to just raise the IOError as this is what is happening as to convert it in an TypeError.

I have not checked all the other i2c routines maybe there are more problems like this.

Edit: Typo

───

 

作者一路追跡 □○ ,經過 Grove WiKi 的田野,

Grove – Ultrasonic Ranger

中文 This Grove – Ultrasonic sensor is a non-contact distance measurement module which works at 42KHz, suitable for projects that require middle distance measurement.

350px-Ultrasonic_Ranger

Specification

Parameter Value/Range
Operating voltage 3.3~5V
Operating current 15mA
Ultrasonic frequency 42kHz
Measuring range 3-400cm
Resolution 1cm
Output PWM

───

 

尋至 Cooper Maa 的家園,

Cooper Maa
一家烤肉萬家香,開放分享才會快樂

2012年9月17日 星期一

HC-SR04 超音波感測器介紹

2012-09-16_23h53_28

超音波感測器(老外好像把它叫作 PING))) sensor)是由超音波發射器、接收器和控制電路所組成。當它被觸發的時候,會發射一連串 40 kHz 的聲波並且從離它最近的物體接收回音。超音波是人類耳朵無法聽見的聲音,因為它的頻率很高。

如下圖所示,超音波測量距離的方法,是測量聲音在感測器與物體之間往返經過的時間:

image記 得國中理化有教過,聲音在空氣中的傳播速度大約是每秒 340 公尺,傳播速度會受溫度影響,溫度愈高,傳播速度愈快。假設以 340 公尺計算,1000000 / 340 * 100 = 29.4 microseconds,四捨五入後,可知聲音傳播 1 公分所需的時間為 29 microseconds (百萬分之一秒)。

由於超音波從發射到返迴是兩段距離,因此在計算時必須將結果除以 2 才是正確的物體距離。所以我們可以利用底下的公式算出物體距離(距離單位為公分,其中 timing 是測量得到的音波傳播時間):

timing / 29 / 2

超音波感測器主要應用在機器人或自走車避障、物體測距等。

───

 

終抵超音波感測器的故鄉︰

HC-SR04-Timing

───

 

在先進的光照之下︰

Three Ways To Read A PWM Signal With Arduino

PWM (Pulse-Width Modulation) is a modulation technique that controls the width of the pulse based on modulator signal information. PWM can be used to encode information for transmission or to control of the power supplied to electrical devices such as motors.

Generating a PWM signal with an Arduino is quite easy. There is significantly less documentation on how best to read a PWM signal. I needed to read the receiver signals for a remote controlled Quadcopter and after doing some research, I discovered three methods of reading a PWM signal with an Arduino.

The Gist

PWM works by varying the width of the on signal (read Duty Cycle) within a fixed signal frequency or period of time. So what we are really looking for is the length of time the signal remains high for each cycle. There are several ways to do this. The easiest is using the pulseIn function as shown below.

1. The pulseIn() Function

The pulseIn() waits for the pin to go HIGH, starts timing, then waits for the pin to go LOW and stops timing. Returns the length of the pulse in microseconds.

The pulseIn Function
byte PWM_PIN = 3;
 
int pwm_value;
 
void setup() {
  pinMode(PWM_PIN, INPUT);
  Serial.begin(115200);
}
 
void loop() {
  pwm_value = pulseIn(PWM_PIN, HIGH);
  Serial.println(pwm_value);
}

2. External Interrupts

The pulseIn function works well and is really simple. However, the downside is that the processor cannot be used while it is waiting for the pin to go low. This is not a very efficient use of our CPU cycles. We can improve this by using an event-driven interrupt system to handle the measurement of the PWM signal. Arduino provides the attachInterrupt function to do just this.

───

 

明白 pulseIn() 可能引發的麻煩。發現答案或將透過

GreyGnome/PinChangeInt
—- README ——————————————————————–
PinChangeInt README. Find instructions and more information at
https://github.com/GreyGnome/PinChangeInt/wiki
NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE
This library is deprecated as of April 3, 2015. This means that I will be
providing bug fixes for some time, but users are encouraged to migrate to the EnableInterrupt library, at https://github.com/GreyGnome/EnableInterrupt .
It is faster and easier to use. Thank you.
—- DESCRIPTION —————————————————————
This is the PinChangeInt library for the Arduino. It provides an extension to the interrupt support for ATmega328 and ATmega2560-based Arduinos, and some ATmega32u4 and Sanguinos. It adds pin change interrupts, giving a way for users
to have interrupts drive off of any pin (ATmega328-based Arduinos), by the Port B, J, and K pins on the Arduino Mega and its ilk, and on the appropriate ports (including Port A) on the Sanguino and its ilk. Yun and Sanguino support are weak, quite honestly, as I don’t have either a Sanguino or a Yun. Theoretically the library would work with a Leonardo but I have no reports regarding that platform. The ATmega32u4 has port B (8 pins) pin change interrupts only.

───

 

落在

GreyGnome/EnableInterrupt

EnableInterrupt

New Arduino interrupt library, designed for all versions of the Arduino. NEW: ATtiny support! ATtiny 44/84 and 45/85 supported!

Functions:

enableInterrupt- Enables interrupt on a selected Arduino pin.
disableInterrupt - Disables interrupt on the selected Arduino pin.

 

*What’s New? Fri Nov 6 19:13:20 CST 2015 Version 0.9.4 of the library has been released. Thanks to RobertClemenzi, who pointed out 2 bugs: 1. A spurious comma in some array definitions caused a compiler warning, and 2. More importantly, it was impossible to use arduinoInterruptedPin if this library was used to support other libraries.

IMPORTANT NOTE: In 0.9.2 I discovered a rather pernicious bug, wherein the library was setting the global interrupt enable bit. This could cause a serious and difficult-to-debug race condition, as it is not the job of the library to manage that bit. The chips come with interrupts enabled so existing code should not be affected, but if you were relying on that behavior note that it has changed. My thanks to http://gammon.com.au/interrupts (the ‘How are interrupts queued?’ section).

The EnableInterrupt library is an Arduino interrupt library, designed for all versions of the Arduino- at this writing, the Uno (and other ATmega328p-based boards, like the mini), Due, Zero, Leonardo (and other ATmega32u4-based boards, like the Micro), the Mega2560 (and other ATmega2560-based boards, like the MegaADK), and for non-Arduino chips: the 644/1284p (using the Mighty1284 for support files and pin numbering), ATtiny 44/84, and ATtiny 45/85 (using DA Mellis’ support files). The library enables you to assign an interrupt to pins on your chip that support them, and presents a common interface to all supported chips. This means that on the Arduino Uno and Mega you don’t give it an interrupt number, as per http://arduino.cc/en/Reference/attachInterrupt. Rather, your first argument is a pin number of a pin that’s supported on that chip (see https://github.com/GreyGnome/EnableInterrupt/wiki/Usage#pin–port-bestiary ).

───

 

的耶!!??

 

 

 

 

 

 

 

 

 

 

 

 

重逢已千年!!??

隔開日

教宗與牧首

千年一會!天主教宗擁抱東正教主教長

 

哥林多前書 第十三章

 

  • 我若能說萬人的方言,並天使的話語,卻沒有愛,我就成了鳴的鑼,響的鈸一般。
  • 我若有先知講道之能,也明白各樣的奧祕,各樣的知識,而且有全備的信,叫我能夠移山,卻沒有愛,我就算不得什麼。
  • 我若將所有的賙濟窮人,又捨己身叫人焚燒,卻沒有愛,仍然於我無益。
  • 愛是恆久忍耐,又有恩慈;愛是不嫉妒;愛是不自誇,不張狂,
  • 不做害羞的事,不求自己的益處,不輕易發怒,不計算人的惡,
  • 不喜歡不義,只喜歡真理;
  • 凡事包容,凡事相信,凡事盼望,凡事忍耐。
  • 愛是永不止息。先知講道之能終必歸於無有;說方言之能終必停止;知識也終必歸於無有。
  • 我們現在所知道的有限,先知所講的也有限,
  • 等那完全的來到,這有限的必歸於無有了。
  • 我作孩子的時候,話語像孩子,心思像孩子,意念像孩子,既成了人,就把孩子的事丟棄了。
  • 我們如今彷彿對著鏡子觀看,糢糊不清(原文作:如同猜謎);到那時就要面對面了。我如今所知道的有限,到那時就全知道,如同主知道我一樣。
  • 如今常存的有信,有望,有愛這三樣,其中最大的是愛。

 

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧庚

辛一

辛二

辛三

《説文解字》:辛,秋時萬物成而孰;金剛,味辛,辛痛即泣出。从一,从 辠辠,辠也 。辛承庚,象人股。凡辛之屬皆从辛。

本義:遠古時代用来给奴隸或罪犯刺字的刺刀;在漢字中“辛”通常代表罪行、罪人或施刑。

─── 摘自《《派生》 Python 作坊【辛】岱宗封禪

 

若說我們已經對 GrovePi 這個開源軟硬體 IOT 系統做了詳細的

逆向工程

逆向工程(又稱反向工程),是一種技術過程,即對一專案標產品進行逆向分析及研究,從而演繹並得出該產品的處理流程、組織結構、功能 效能規格等設計要素,以製作出功能相近,但又不完全一樣的產品。逆向工程源於商業及軍事領域中的硬體分析。其主要目的是,在不能輕易獲得必要的生產資訊 下,直接從成品的分析,推匯出產品的設計原理。

逆向工程可能會被誤認為是對智慧財產權的嚴重侵害,但是在實際應用上,反而可能會保護智慧財產權所有者。例如在積體電路領域,如果懷疑某公司侵犯智慧財產權,可以用逆向工程技術來尋找證據。

動機

需要逆向工程的原因如下:

  • 介面設計。由於互操作性,逆向工程被用來找出系統之間的協作協定。
  • 軍事或商業機密。竊取敵人或競爭對手的最新研究或產品原型。
  • 改善文件。當原有的文件有不充分處,又當系統被更新而原設計人員不在時,逆向工程被用來取得所需資料,以補充說明或了解系統的最新狀態。
  • 軟體升級或更新。出於功能、合規、安全等需求更改,逆向工程被用來了解現有或遺留軟體系統,以評估更新或移植系統所需的工作。
  • 製造沒有許可/未授權的副本。
  • 學術/學習目的。
  • 去除複製保護和偽裝的登入權限。
  • 檔案遺失:採取逆向工程的情況往往是在某一個特殊裝置的檔案已經遺失了(或者根本就沒有),同時又找不到工程的負責人。完整的系統時常需要基於陳舊的系統上進行再設計,這就意味著想要整合原有的功能進行專案的唯一方法便是採用逆向工程的方法分析已有的碎片進行再設計。
  • 產品分析:用於調查產品的運作方式,部件構成,估計預算,識別潛在的侵權行為。

───

 

實在是有點奇怪!!若講反思之動機卻是來自懷疑

GrovePi Protocol and Adding Custom Sensors

文本的程式內容??經過了多個篇章的實證,懷疑終能解惑的矣。在此新年伊始之時,樹莓派更新之際,或應隨順 upgrade 系統,並整理修正資訊回饋於眾多 GrovePi 的學習者也。

且趕快加緊腳步

隨著斗轉星移,過去曾經麻煩的事情

Bit-banged I²C kernel driver

by kadamski » Tue Apr 16, 2013 10:10 am

I’ve made a handy kernel module for everybody wanting to use bit-banged host instead (or in addition to) hardware one. It’s like a wrapper for i2c-gpio kernel built-in module that let you dynamically create and remove i2c hosts on different gpio pins. It can be handy if you experience problems with hardware i2c clock stretching or you need more i2c hosts for some reason.

The code and some instructions can be found on my github. You need a custom kernel (with CONFIG_I2C_GPIO enabled) in order to use it. It got some limited testing so it should work but of course I don’t guarantee anything.

Anybody interested in testing this?

……

也已經簡單了。

# Overlay

Name:   i2c-gpio
Info:   Adds support for software i2c controller on gpio pins
Load:   dtoverlay=i2c-gpio,<param>=<val>
Params: i2c_gpio_sda             GPIO used for I2C data (default "23")

        i2c_gpio_scl             GPIO used for I2C clock (default "24")

        i2c_gpio_delay_us        Clock delay in microseconds
                                 (default "2" = ~100kHz)

※請參考『 Linux/drivers/i2c/busses/i2c-gpio.c

 

或許我們也應從善如流,一探春花春景的耶!!

【 dtoverlay=i2c-gpio 】

使用 i2c-gpio 預設值︰ GPIO23 是 SDA , GPIO24 為 SCL ,串接回硬體 I2C : GPIO0 SDA , GPIO1 SCL 。因此樹莓派上有兩個 I2C Master 。

Bit-Banging-I2C

pi@raspberrypi ~ ls /dev/i2c* -l crw-rw---- 1 root i2c 89, 1  1月 29 14:52 /dev/i2c-1 crw-rw---- 1 root i2c 89, 3  1月 29 14:52 /dev/i2c-3 pi@raspberrypi ~ 

都可定址 GrovePi 也。

pi@raspberrypi ~ i2cdetect -y 3      0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f 00:          -- -- 05 -- -- -- -- -- -- -- -- -- --  10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --  70: -- -- -- -- -- -- -- --                           pi@raspberrypi ~ i2cdetect -y 1
     0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
00:          -- -- 05 -- -- -- -- -- -- -- -- -- -- 
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 
70: -- -- -- -- -- -- -- --                         
pi@raspberrypi ~ </pre> <span style="color: #808080;"><strong>【 Bit-banged I²C 嚐鮮 】</strong></span>  ……  ── 摘自《<a href="http://www.freesandal.org/?m=20160206">W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧戊</a>》     <span style="color: #666699;">完成 I2C 探索之最後一里路的耶!!</span>  <span style="color: #666699;">令人驚訝的是,一個年過去了!版本也更新了︰</span> <pre class="lang:default decode:true "># rpi-update 後之版本 pi@raspberrypi ~ cat /proc/version 
Linux version 4.1.18-v7+ (dc4@dc4-XPS13-9333) (gcc version 4.9.3 (crosstool-NG crosstool-ng-1.22.0-88-g8460611) ) #845 SMP Thu Feb 18 19:45:28 GMT 2016
pi@raspberrypi ~ </pre>    <span style="color: #666699;">結果竟然幾乎與過年前一樣大同小異︰</span> <pre class="lang:default decode:true "># 修改 grovepi.py ,選用 bus = smbus.SMBus(3) 。   pi@raspberrypi ~/example python
Python 2.7.9 (default, Mar  8 2015, 00:52:26)
[GCC 4.9.2] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import grovepi
>>> addr = 0x05
>>> grovepi.debugEnable()
>>> potentiometer = 0
>>> grovepi.pinMode(potentiometer,"INPUT")
1
>>> grovepi.analogRead(potentiometer)
0
[11, 2, 189, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
702
>>> ultrasonic_ranger = 2
>>> grovepi.ultrasonicRead(ultrasonic_ranger)
0
[11, 0, 3, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
3
>>> power=7
>>> grovepi.pinMode(power,"OUTPUT")
1
>>> grovepi.digitalWrite(power,1)
1
>>> grovepi.digitalWrite(power,0)
1
>>> grovepi.bus.write_i2c_block_data(5, 1, [3] + [0, 0, 0])
>>> grovepi.bus.read_i2c_block_data(5, 1)
[0, 2, 189, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.bus.write_i2c_block_data(5, 1, [3] + [0, 0, 0])
>>> grovepi.read_i2c_byte(addr)
0
>>> grovepi.bus.read_i2c_block_data(5, 1)
[0, 2, 189, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_byte(addr)
0
>>> grovepi.read_i2c_block(addr)
[0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 2, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>>

 

pi@raspberrypi ~ stty -F /dev/ttyUSB0 115200 pi@raspberrypi ~ cat /dev/ttyUSB0
CMD = 5, index =  4
 
CMD = 3, index =  4
 
DATA = 0, 2, 189
 
CMD = 3, index =  0
 
CMD = 7, index =  4
 
DATA = 0, 0, 3
 
CMD = 7, index =  0
 
CMD = 5, index =  4
 
CMD = 2, index =  4
 
CMD = 2, index =  4
 
CMD = 3, index =  4
 
CMD = 3, index =  0
 
DATA = 0, 2, 189
 
CMD = 3, index =  4
 
DATA = 0, 2, 189
 
CMD = 3, index =  0
 
DATA = 0, 2, 189
 
DATA = 0, 2, 189
 
CMD = 1, index =  1
 
DATA = 0, 2, 189
 
CMD = 1, index =  2
 
DATA = 0, 2, 189
 
CMD = 1, index =  3
 
DATA = 0, 2, 189
 
CMD = 1, index =  4
 
DATA = 0, 2, 189
 
CMD = 1, index =  0
#

 

難到應該改變的嗎??若從隨機或快或慢的讀取現象來看︰

>>> grovepi.ultrasonicRead(ultrasonic_ranger)
0
[11, 0, 198, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
198
>>> grovepi.read_i2c_block(addr)
[1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 198, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 0, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[11, 198, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_block(addr)
[1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> 
>>> grovepi.read_i2c_byte(addr)
1
>>> grovepi.read_i2c_block(addr)
[1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_byte(addr)
1
>>> grovepi.read_i2c_block(addr)
[1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> grovepi.read_i2c_byte(addr)
1
>>> grovepi.read_i2c_block(addr)
[1, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255]
>>> 

 

CMD = 7, index =  0

CMD = 1, index =  1

DATA = 0, 0, 182

CMD = 1, index =  2

CMD = 1, index =  3

CMD = 1, index =  4

CMD = 1, index =  0

CMD = 1, index =  1

CMD = 1, index =  2

DATA = 0, 0, 182

CMD = 1, index =  3

CMD = 1, index =  4

CMD = 1, index =  0

DATA = 0, 0, 182

DATA = 0, 0, 182

CMD = 1, index = 1

DATA = 0, 0, 182

DATA = 0, 0, 182

CMD = 1, index = 2

DATA = 0, 0, 182

DATA = 0, 0, 182

CMD = 1, index = 3

DATA = 0, 0, 182

 

,或許可以說明即使針對軟體 Bit-banged I²C 而言︰

Extraneous bus.read_byte commands? #169

In various functions in grovepi.py, there are what seem to me to be completely extraneous calls to read_byte, which can just be deleted. Or at least, deleting them doesn’t seem to break anything for me.

e.g. in analogRead it says bus.read_byte(address), then it does the actual read transaction with number = bus.read_i2c_block_data(address, 1). As far as I can tell the bus.read_byte is totally ignored, just does an extra i2c transaction for no reason and makes the code slightly slower.

Maybe I’m missing something and there is a reason for it, but as far as I can tell this is a bug?

When we were building the firmware initially, we found that read_block() didn’t work properly without calling the read_byte() first and this was the way we were able to make it work. It was a workaround then and we seem to have kept it till now.

── 摘自《W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧丙

 

依舊是不可少的也!!!

 

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰ 一窺全豹之系統設計‧探索‧己

庚一

庚二

庚三

《説文解字》庚,位西方,象秋時萬物庚庚有實也。庚承己,象人臍。凡庚之屬皆从庚。

本義:用水桶在水井或水池打水。

不知秋 蟬 解了悟?知了聲聲催 金文禪 心!

在《千江有水千江月》一文中,我們談過『禪宗初祖達摩

欲知達摩西來意?達摩血脈論吾本來此土傳法救迷情一華開五葉結果自然成。它預示著禪宗六祖慧能在成佛後,會帶出多位弟子,將創立五個宗派,後世之佛教徒多以『教外別傳、不立文字』為達摩『禪法』的標誌。此一宗五脈世系是︰初祖達摩 二祖慧可三祖僧璨四祖道信五祖弘忍六祖惠能世系起於達摩所留之一隻草鞋』,『認可』二祖『傳法』慧可之始。

,既然『不立文字』那將如何傳法的呢?或說『直指人心』,見性成佛。這個『』字有一段著名的『公案』︰

指月錄》卷二十八

▲吉州青原惟信禪師

上堂。老僧三十年前。未參禪時。見山是山。見水是水。及至後來親見知識。有個入處。見山不是山。見水不是水。而今得個休歇處  。依前見山祇是山。見水祇是水。大眾。這三般見解是同是別。有人緇素得出。許汝親見老僧(更參三十年迥無入處在)。

這個六個『見』字,由於『山』『水』對舉,該說『三個』,是『同義』的嗎?比方講,那位蘇東坡寫了一首

觀潮

廬山煙雨浙江潮,
未到千般恨不消。
到得還來別無事,
廬山煙雨浙江潮。

, 講『未到』之『聽』『觀』與『到得』的『親』『觀』不同,試問那景緻會變了嗎?也許『觀』者之『心』『情』已然境遷的了!還有那『遠望』山似『枕』,『蟻 觀』枕如『山』,之『遠近』之別,更別說有人方與一代巨星『鄧麗君』之『3D 全像投影』合唱的哩!!所以老子說︰名可名,非常名。試想『無水之河』空有河名 ,滄海已成桑田,又何必『曾是』的呢??所以『眼看』有如『 Camera 』。『心見』宛如『 Recognition 』,這一個『了別』之『心』的科學尚且方將起步,或許果真『』『』不二的耶!!

─── 摘自《《派生》 Python 作坊【庚】話頭機鋒

 

昨宵縱情遊戲中,今朝把握人間事。俗話說︰一元復始,萬象更新 。就在過年之時,

Another new Raspbian release

Some of you may have spotted that there is a new Raspbian release available for download. For most people, this is primarily updates and bug fixes to the existing Jessie image – but there’s one exciting new feature that might be of interest to some people…

……

One more thing…

We hope the above changes are useful, but Raspbian will still look pretty much the same as it did for the last release in November. But we have been working on one other thing behind the scenes for this release: this won’t be of interest to most users, but for some, we hope it will be very useful.

In this release we are shipping an experimental OpenGL driver for the desktop which uses the GPU to provide hardware acceleration. This is turned off by default – if you want to enable it, you can find it in the command-line version of raspi-config, under Advanced Options->GL Driver. Due to memory requirements, this will not work on Pi 1 or Pi Zero boards – it is solely for Pi 2. (raspi-config will only allow it to be enabled on a Pi 2; be warned that if you enable it on a Pi 2 and then move that SD card into a Pi 1 or Pi Zero, the Pi will not boot.)

If you don’t use this option, the desktop does have OpenGL support, but it uses a very slow software renderer, which makes all but the most basic OpenGL applications pretty much unusable. The hardware-accelerated version is much faster, and makes some quite decent OpenGL games playable on the Pi.

───

 

已然悄悄到來。在接續探索前,或該略作回顧?或應接軌未來!!時間製造距離,距離產生所見之不同,如此也許回顧本就是瞻前?誰管他是後到新來??恰似西遊記

靈根育孕源流出‧心性修持大道生

詩曰:

混沌未分天地亂,茫茫渺渺無人見。
自從盤古破鴻濛,開闢從茲清濁辨。
覆載群生仰至仁,發明萬物皆成善。
欲知造化會元功,須看西遊釋厄傳。

 

。隨緣祇得重整皮囊?踏上取經之路的耶!

 

Open source Zephyr™ Project aims to deliver an RTOS; opens call for developers to help advance project for the smallest footprint IoT devices

SAN FRANCISCO – February 17, 2016 – The Linux Foundation, the nonprofit organization enabling mass innovation through open source, today announced the Zephyr™ Project. This open source collaborative effort will unite leaders from across the industry to build a real-time operating system (RTOS) for the Internet of Things (IoT).

Early support for the Zephyr Project includes Intel® Corporation (including its acquired business groups Altera Corporation and Wind River), NXP Semiconductors N.V. (including its recent merger with Freescale), Synopsys, Inc. and UbiquiOS Technology Limited. Zephyr Project is inviting others interested in this technology to participate.

Industrial and consumer IoT devices require software that is scalable, secure and enables seamless connectivity. Developers also need the ability to innovate on top of a highly modular platform that easily integrates with embedded devices regardless of architecture. While Linux has proven to be a wildly successful operating system for embedded development, some IoT devices require an RTOS that addresses the very smallest memory footprints. This complements real-time Linux, which excels at data acquisition systems, manufacturing plants and other time-sensitive instruments and machines that provide the critical infrastructure for some of the world’s most complex computing systems.

“Developers today have many choices when it comes to platforms. The Zephyr Project will offer a modular, connected operating system to support the smallest footprint for IoT devices,” said Jim Zemlin, executive director, The Linux Foundation. “We invite developers to contribute to the Zephyr Project and to help advance a customizable embedded open source RTOS to advance IoT. By hosting this at The Linux Foundation, we look forward to the cross-project collaboration among Linux and this community.”

Modularity and security are key considerations when building systems for embedded IoT devices. The Zephyr Project prioritizes these features by providing the freedom to use the RTOS as is or to tailor a solution. The project’s focus on security includes plans for a dedicated security working group and a delegated security maintainer. Broad communications and networking support is also addressed and will initially include Bluetooth, Bluetooth Low Energy and IEEE 802.15.4, with plans to expand communications and networking support over time.

………

 

 

 

 

 

 

 

 

 

 

 

 

W!o+ 的《小伶鼬工坊演義》︰【新春】 復古派 《十》 RetroPie 活在當下

活在當下

活在當下(常譯作及時行樂)為拉丁語格言Carpe diem」(把握今朝),語出自賀拉斯的拉丁語詩集《頌歌》。

完整詩文為「carpe diem, quam minimum credula postero」,可翻譯為「活在當下,儘量不要相信明天」。頌歌述說未來不可預見,不要盲目追尋未來,而是在今天盡力而為讓明天變得更好。這段話一般被認為是賀拉斯在對抗伊比鳩魯學派的背景下寫出。[1]賀拉斯「carpe diem」這句話的用意並不是要忽視未來,而是不要相信事情會自己到位,並在今天為未來做出行動。[2]

1280px-Yvoire_cadran_solaire

寫有「Carpe diem」的日晷

 

聽 Mrphs 說︰ W!o+ 在玩過多種模擬器和很多遊戲後,發現模擬器與輸入裝置最好能匹配。玩街頭遊戲機就得用搖桿

Picade

 

才道地夠味。玩超級任天堂,若非使用

SNES-CONTROLLER

 

Game Pad ,那麼組合鍵就不能得手應心。於是當下動起手來,製作了數種合宜的輸入裝置,玩的盡興。

作者本以搖桿入手街機,卻發覺不管小朋友或大朋友都喜歡玩超級瑪莉歐,無奈沒有 W!o+ 之巧手能 DIY ,但思曾見

Virtual Gamepad

HerbFargus edited this page · 8 revisions

 

Virtual Gamepad


This project is the result of hard work from Miroof. https://github.com/miroof/node-virtual-gamepads


Install from the experimental menu of the setup script (may only work well with a rpi2)

Usage

Once the nodejs application is launched, you just have to plug your gamepad controller by connecting your device on the same local network and by reaching the address http://node_server_adress (i.e. your Raspberry Pi’s IP address) on your choice of web browser (Chrome Mobile is recommended).

 

,雖然尚是實驗版︰

### Install Node.js

sudo apt-get update && sudo apt-get upgrade
wget http://node-arm.herokuapp.com/node_archive_armhf.deb
sudo dpkg -i node_archive_armhf.deb
rm node_archive_armhf.deb

### Install Virtual Gamepad (Must Be Run As Root!)

# 此 su 是為配合 node pm2 而來。然而目前 pm2 產生之手稿檔與 jessie 的開機手稿不相容。故無益也。
# su
git clone https://github.com/miroof/node-virtual-gamepads
cd node-virtual-gamepads
npm install


# 不要安裝
### Enable Virtual Gamepad on Boot

# sudo npm install pm2 -g
# sudo pm2 start main.js
# sudo pm2 startup
# sudo pm2 save

# 執行
cd node-virtual-gamepads/
sudo node main.js

 

在考察源流始末後︰

miroof/node-virtual-gamepads

node-virtual-gamepads

This nodejs application provides the possibility to use your smarpthone as a gamepad controller on Linux OS simply by reaching a local address. You can virtually plug up to 4 gamepad controllers.

Demo

Demo video 1 player in game here

Demo video 3 players on EmulStation here

Prerequisite

This application is only compatible with Linux OS with the uinput kernel module installed.

Installation

git clone https://github.com/miroof/node-virtual-gamepads
cd node-virtual-gamepads
npm install
sudo node main.js

Usage

Once the nodejs application is launched, you just have to plug your gamepad controller by connecting your device on the same local network and by reaching the address http://node_server_adress

 

依舊也可以用手機,馳騁任天堂的世界也!!

【 RetroPie Show IP Address 】

RetroPie-Show-IP-Address

 

【 Virtual Game Pad 】

Virtual gamepad - Google Chrome

 

那時 Mrphs 還講︰ W!o+ 突發奇想,打算寫自己能玩遊戲的程式。他想擷取螢幕畫面,辨識畫面物件,形成邏輯判斷,而後控制虛擬輸入裝置,完成有智慧的遊戲者程式。當時雖是功敗垂成,卻播下了日後跨科系微機電整合的種子。……

終究這已是後話︰

Picade Sketch

This is the default firmware for the Picade;

  • Maps each of the 10 main input buttons to key presses
  • Maps the 4 joystick directions to Up, Down, Left and Right keys
  • Uses the volume up/down to control the Amp volume

Custom Keybinding

You can customise your key bindings to your preference, or to use multiple Picade boards together for a larger arcade cabinet project or multiplayer.

To create a custom keybinding you should only need to change the inputs mapping at the top of the Sketch.

A list of modifier key constants can be found here: https://www.arduino.cc/en/Reference/KeyboardModifiers

Other keys can be represented as a single character, like space ' ' or x 'x'.

───

 

時到自分明乎!何不活在當下的耶!!

 

 

 

 

 

 

 

 

 

 

 

 

輕。鬆。學。部落客