2011年6月28日 星期二

Android Starter

一、下載 JAVA SE JDK,安裝


二、下載 Android SDK,安裝






三、下載 Eclipse Classic,安裝


四、執行 Eclipse,按下列步驟安裝 ADT  Plug-in (摘自 http://developer.android.com/sdk/eclipse-adt.html#installing)

  1. Start Eclipse, then select Help > Install New Software....
  2. Click Add, in the top-right corner.
  3. In the Add Repository dialog that appears, enter "ADT Plugin" for the Name and the following URL for the Location:
    https://dl-ssl.google.com/android/eclipse/
  4. Click OK Note: If you have trouble acquiring the plugin, try using "http" in the Location URL, instead of "https" (https is preferred for security reasons).
  5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.
  6. In the next window, you'll see a list of the tools to be downloaded. Click Next.
  7. Read and accept the license agreements, then click Finish. Note: If you get a security warning saying that the authenticity or validity of the software can't be established, click OK.
  8. When the installation completes, restart Eclipse. 這邊會開始下載安裝比較久的時間。

五、 執行 Eclipse,到選單 > Windows > Android SDK and ADV Manager 開啟 ADV Manager (或透過直接執行 ADV Manager 亦可)。
此時若出現找不到 ADV Manager 位置的話,則要到選單 > Windows > Preferences > Andriod 頁面進行設定。




六、第一次執行 ADV Manager 要先安裝相關套件,這邊也是會開始下載安裝一段時間




七、新增加一個 ADV (Android模擬器),名稱自己取



八、OK 後就可以在 ECLIPSE 開 Android 專案了,Build Target 記得選剛剛建立好的 ADV 版本。





九、寫個範例程式…(摘自 http://developer.android.com/resources/tutorials/hello-world.html)

package example.HelloAndroid;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroidActivity extends Activity {
       /** Called when the activity is first created. */
       @Override
       public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           TextView tv = new TextView(this);
           tv.setText("Hello, Android");
           setContentView(tv);
       }
}

十、執行結果…

2011年6月20日 星期一

MIDI Code 在 Windows & Apple - Mac 的差別

同樣是 MIDI out 到 device,Windows 跟 Mac 卻有差別…

-----------------------------
差別一:
例如:一個 Note 「09 90 01 7f」,在 Windows 作輸出時,透過 Bus Hound (監視 USB 通訊的軟體) 來看是底下這樣…
Device  Length    Phase  Data         Description       Delta  Cmd.Phase.Ofs(rep)
------  --------  -----  -----------  ----------------  -----  ------------------
  27.4        64  OUT    09 90 01 7f  ....              5.1sc        28.1.0       
                         00 00 00 00  ....                           28.1.4       
                         00 00 00 00  ....                           28.1.8       
                         00 00 00 00  ....                           28.1.12      
                         00 00 00 00  ....                           28.1.16      
                         00 00 00 00  ....                           28.1.20      
                         00 00 00 00  ....                           28.1.24      
                         00 00 00 00  ....                           28.1.28      
                         00 00 00 00  ....                           28.1.32      
                         00 00 00 00  ....                           28.1.36      
                         00 00 00 00  ....                           28.1.40      
                         00 00 00 00  ....                           28.1.44      
                         00 00 00 00  ....                           28.1.48      
                         00 00 00 00  ....                           28.1.52      
                         00 00 00 00  ....                           28.1.56      
                         00 00 00 00  ....                           28.1.60      

Windows 一次「至少」就傳了 64 bytes 的資料給 device ,後面無用的資料都補 0。

但是 Mac 卻只有傳了…「09 90 01 7f」這 4 個 bytes,並且沒有 0 作結尾。

-----------------------------
差別二:
很多 MIDI Code 要傳輸時,Windows 都是遵照上述的原則,一定會傳出 64 bytes (或許有別的 MIDI API 可以作不一樣長度的輸出,但以音控軟體 Traktor 而言是如此)

但是 Mac 在這個情況下有可能會傳出 4*N 個 bytes,也就是 4、8、12、16…。

------------------------------------
於是在韌體的撰寫上就要特別注意這二個不同的差別來作 MIDI Code 的解析,才能同時相容於 Windows 及 Mac!!!

看起來 Mac 的效能會比較好。

更高效處理 micro second 的方式

更高效處理 micro second 的方式…  以 STM32 為例… __IO unsigned long sys_tick = 0; void SysTick_Handler(void) {     HAL_IncTick();     sys_tick += (SysTi...