Raspberry Pi(中文名為“樹莓派”,簡寫為RPi闪水,(或者RasPi / RPI)是為學(xué)習(xí)計算機編程教育而設(shè)計),只有信用卡大小的微型電腦,其系統(tǒng)基于Linux。隨著Windows 10 IoT的發(fā)布浪箭,我們也將可以用上運行Windows的樹莓派。
自問世以來拜鹤,受眾多計算機發(fā)燒友和創(chuàng)客的追捧,曾經(jīng)一“派”難求。別看其外表“嬌小”,內(nèi)“心”卻很強大挠铲,視頻、音頻等功能通通皆有,可謂是“麻雀雖小嗅绰,五臟俱全”财边。
相關(guān)信息參考:百度百科
個人站點:https://whl1207.github.io/,記錄一些學(xué)習(xí)筆記,主要寫點基于anylogic的仿真和web開發(fā)方面的知識點晚缩。有興趣的同學(xué)可以探討一下!
一、硬件
本次購買的硬件包括樹莓派4b我纪,微雪3.5寸顯示屏汹碱,外殼,其使用目的是搭建個人服務(wù)器及NAS系統(tǒng)轴术。因此使用3.5寸屏幕作為這些服務(wù)的監(jiān)控屏。
在安裝屏幕時注意宣肚,需要先將屏幕安裝到外殼中楼镐,然后對準(zhǔn)樹莓派的gpio接口接入,若拼接順序出錯可能會導(dǎo)致卡殼忱叭。
二、安裝操作系統(tǒng)
1铲掐、本次選用樹莓派官方完整版Raspbian鏡像咳秉,下載地址如下https://www.raspberrypi.org/downloads/炕舵。選擇完整版系統(tǒng)進行下載。
2徊件、使用ImageWriter磁盤鏡像工具將鏡像寫入到sd卡庇忌,可以考慮在燒錄完鏡像后更改樹莓派的配置文件使其能主動接入wifi疏橄。(如外接屏幕可忽略該步驟)
3窄绒、將sd卡插入樹莓派中即可完成操作系統(tǒng)的安裝敲茄。
4陶缺、配置中文系統(tǒng)。使用如下命令安裝字體:
sudo apt-get install ttf-wqy-zenhei
設(shè)置中文
sudo raspi-config
按方向選擇【localisation options】荠诬,選擇【change琅翻,locale】,選擇【zh _cn 】柑贞。按回車鍵方椎,選擇確定,按tab切換到finish钧嘶。
然后輸入命令:
sudo reboot
重啟系統(tǒng)棠众,系統(tǒng)就會變成了中文了。
三有决、配置3.5寸觸摸屏
初次使用樹莓派默認利用hdmi接口輸出屏幕信號闸拿。此時3.5寸屏顯示為全白色。購買的屏幕參考資料如下:http://www.waveshare.net/wiki/3.5inch_RPi_LCD_(A)
現(xiàn)在我們來讓屏幕工作起來书幕!
1新荤、下載屏幕驅(qū)動(提取碼:cyyv)
2、將文件放到需要的目錄下
3台汇、使用屏幕驅(qū)動點亮屏幕
cd LCD-show/
sudo ./LCD35-show X
#X可選0苛骨、90、180和270苟呐。分別表示LCD旋轉(zhuǎn)0度智袭、90度、180度和270度掠抬。
4吼野、校準(zhǔn)觸屏
安裝校準(zhǔn)軟件進行校準(zhǔn),本LCD可以通過xinput-calibrator程序進行校準(zhǔn)两波。運行以下命令瞳步,進行安裝:
sudo apt-get install xinput-calibrator
點擊任務(wù)欄的Menu鍵闷哆,選擇【首選項-> Calibrate Touchscreen】。按顯示提示進行觸摸校準(zhǔn)单起。
如果要保存這些觸摸值抱怔,需要在以下路徑新建一個99-calibration.conf文件(如果已存在則不需要新建)
/etc/X11/xorg.conf.d/99-calibration.conf
將觸摸參數(shù)(不同LCD,下圖數(shù)據(jù)可能不同)保存至99-calibration.conf嘀倒,即可屈留。
有時需要修改該文件中的該值調(diào)整觸摸方向。
Option "swapAxes" "0"
5测蘑、切換輸出模式
有時我們需要使用hdmi對信號進行輸出灌危。將樹莓派當(dāng)電腦使用,我們可以使用如下命令切換屏幕輸出方式:
cd LCD-show/
sudo ./LCD-hdmi
四碳胳、使用VNC進行遠程連接
為了方便操作勇蝙,有時需要使用遠程連接來操作樹莓派。
在終端輸入以下命令進入配置界面挨约。
sudo raspi-config
依次操作:Interfacing Options -> VNC -> Yes味混。之后系統(tǒng)會提示你是否要安裝 VNC 服務(wù),輸入 y 之后回車诫惭,等待系統(tǒng)自動下載安裝完成翁锡,一切順利的話 VNC 服務(wù)就啟動了!
五夕土、使用conky監(jiān)視系統(tǒng)狀態(tài)
為了能夠使用3.5寸觸摸屏監(jiān)控系統(tǒng)狀態(tài)盗誊,這里推薦使用conky來監(jiān)視系統(tǒng)狀態(tài)。
1隘弊、安裝conky
apt-get install conky
2哈踱、運行conky
conky
運行后發(fā)現(xiàn)默認監(jiān)控界面不適合3.5寸屏幕,因此需要對配置文件按進行修改梨熙。
配置文件的位置如下/etc/conky/conky.conf
為充分利用3.5寸屏幕开镣,修改配置后顯示如圖所示:
其修改后的配置文件如下:
-- vim: ts=4 sw=4 noet ai cindent syntax=lua
--[[
Conky, a system monitor, based on torsmo
Any original torsmo code is licensed under the BSD license
All code written since the fork of torsmo is licensed under the GPL
Please see COPYING for details
Copyright (c) 2004, Hannu Saransaari and Lauri Hakkarainen
Copyright (c) 2005-2012 Brenden Matthews, Philip Kovacs, et. al. (see AUTHORS)
All rights reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
]]
conky.config = {
alignment = 'top_left',
background = true,
border_width = 1,
cpu_avg_samples = 2,
default_color = 'white',
default_outline_color = 'white',
default_shade_color = 'white',
double_buffer = true,
draw_borders = false,
draw_graph_borders = true,
draw_outline = false,
draw_shades = false,
use_xft = true,
font = 'ttf-wqy-zenhei:size=12',
gap_x = 10,
gap_y = 35,
minimum_height = 5,
minimum_width = 300,
net_avg_samples = 2,
no_buffers = true,
out_to_console = false,
out_to_stderr = false,
extra_newline = false,
own_window = true,
own_window_class = 'Conky',
own_window_type = 'desktop',
own_window_transparent = true,
stippled_borders = 0,
update_interval = 1.0,
uppercase = false,
use_spacer = 'none',
show_graph_scale = false,
show_graph_range = false,
}
conky.text = [[
${color #78af78}運行時間:${color #db7093} $uptime
${color #78af78}主頻:${color #db7093}$freq MHz ${color #78af78}溫度:${color #db7093}$acpitemp℃ ${color #78af78} I/O: $alignr${color #db7093}${diskio}
${color #78af78}CPU:$color $cpu% ${cpubar 4}
${color #78af78}內(nèi)存:$color $memperc% ${membar 4}
${color #78af78}容量:$color${fs_used /}/${fs_size /} ${fs_bar 6 /}
$hr
${color #78af78}IP:${color #db7093} ${addr wlan0}
${color #78af78}下載:${downspeed wlan0} k/s ${alignr}上傳 ${upspeed wlan0} k/s
${downspeedgraph wlan0 20,125} ${alignr}${upspeedgraph wlan0 20,125}
$color$hr
${color #78af78}進程(共$color $processes ${color #78af78}個) ${alignr}PID CPU% MEM%
${color lightgrey} ${top name 1} ${alignr}${top pid 1} ${top cpu 1} ${top mem 1}
${color lightgrey} ${top name 2} ${alignr}${top pid 2} ${top cpu 2} ${top mem 2}
]]