MCU單晶片韌體設計

2017年7月30日 星期日

題目一: CSS + AJAX + JQuery + Node.js 應用


題目一: CSS + AJAX + JQuery + Node.js 應用


功能說明:


1. 瀏覽器利用AJAX 送出HTTP GET,URL路徑為/sensor/temp , 伺服端 (Node.js)會傳回Raspberry Pi CPU溫度.
2. 伺服端傳回格式為JSON , 如右格式: {“Sensor”: [{“Temp”:28}]}
3. 瀏覽器頁面必須及時更新溫度值, 並呈現如下內容. 溫度圖表設為20格,溫度範圍: 45~65 ℃
4. 當溫度 <= 55℃ 顯示綠色, >= 55 ℃ 黃色, >=60時℃顯示紅色





提示:
1.          讀取Raspberry Pi CPU溫度:  vcgencmd measure_temp
cat /sys/class/thermal/thermal_zone0/temp
2.          及時更新溫度的方式使用JQuery
3.          參考課程範例: WebFrontend/JQuery/industrial.js/demo.html  

4.          參考課程範例: Node_basic/example03/spwan.js  


完成結果:











2017年7月11日 星期二

Linux git push 使用



1) 先設定好 who you are.

Run

  git config --global user.email "xxxx@ittraining.com.tw"
  git config --global user.name "ittraining"


2) git commit: 顯示所有 Changes not staged for commit 的檔案

3) Staged for commit

git commit *  -m "............." 或
git commit <file list> -m ".........................."


4) git push : 將commit 的檔案全部上傳至git server







2017年7月6日 星期四

Raspberry Pi 3 使用紅外線

硬體準備


一個 IR 發射器及一個接收器 (使用Raspberry pi 3 Education Kit)

Demo




LIRC 軟體安裝及設定


Step 1: We need to install LIRC utility
pi@raspberrypi ~ $ sudo apt-get update
pi@raspberrypi ~ $ sudo apt-get install lirc

Step 2: 修改 /boot/config.txt

# Uncomment this to enable the lirc-rpi Module
dtoverlay=lirc-rpi
dtparam=gpio_in_pull=up   #將GPIO Input 均先設為Pull Up 

# Override the defaults for the lirc-rpi module

dtparam=gpio_in_pin=17   #IR接收
dtparam=gpio_out_pin=25 #IR發射


Step 3: 修改 /boot/config.txt

# /etc/lirc/hardware.conf
#
# Arguments which will be used when launching lircd
LIRCD_ARGS="--uinput"

#Don't start lircmd even if there seems to be a good config file
#START_LIRCMD=false

#Don't start irexec, even if a good config file seems to exist.
#START_IREXEC=false

#Try to load appropriate kernel modules
LOAD_MODULES=true

# Run "lircd --driver=help" for a list of supported drivers.
DRIVER="UNCONFIGURED"
# usually /dev/lirc0 is the correct setting for systems using udev
DEVICE="/dev/lirc0"
MODULES="lirc_rpi"

# Default configuration files for your hardware if any
LIRCD_CONF=""
LIRCMD_CONF=""

step 4:

Reboot