原作:coopermaa
在 LCD 上顯示 WR-703N 的系統資訊,比如 CPU load, system load, 記憶使用狀況, uptime 等等資訊。
Arduino 軟硬體設定
1. LCD 接法: http://www.osslab.com.tw/Hardware/Open_Embedded_System/MCU/AVR/Arduino/LCD
2. 程式碼:
// 引用 LiquidCrystal Library
#include <LiquidCrystal.h>
// 建立 LiquidCrystal 的變數 lcd
// LCD 接腳: rs, enable, d4, d5, d6, d7
// LCD pin 4, 6, 11, 12, 13, 14
// 對應到 Arduino 接腳: 8, 7, 6, 5, 4, 3
LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
void setup() {
Serial.begin(9600);
// 設定 LCD 的行列數目 (2 x 16)
lcd.begin(16, 2);
lcd.print("LCD Proc");
}
byte serial_getch(){
int incoming;
while (Serial.available()==0){
}
// read the incoming byte:
incoming = Serial.read();
return (incoming &0xff);
}
void loop(){
byte rxbyte;
byte temp;
rxbyte = serial_getch(); // Fetch byte
if(rxbyte==0xFE) // If command
{
lcd.command(serial_getch()); // Pass through
}
else{
lcd.write(rxbyte); //Otherwise just dump it as text
}
}
OpenWRT 設定
安裝 lcdproc:
opkg update
opkg install lcdproc
編輯 /etc/LCDd.conf:
1. 設定 DriverPath:
DriverPath=/usr/lib/lcdproc/
2. 設定 Driver:
Driver=hd44780
3. 設定 hd44780 參數:
## Hitachi HD44780 driver ##
[hd44780]
# Select what type of connection. See documentation for types.
ConnectionType=lcdserializer
# Device of the serial interface [default: /dev/lcd]
Device=/dev/ttyUSB0
# Bitrate of the serial port (0 for interface default)
Speed=9600
# Specifies the size of the LCD.
# In case of multiple combined displays, this should be the total size.
Size=16x2
啟動 lcdproc
/etc/init.d/LCDd start
lcdproc
lcdproc.conf
/etc/lcdproc.conf 檔裏設定 LCD 要顯示的資訊,例如 CPU, Load, Memory 等
Images 0 | ||
---|---|---|
No images to display in the gallery. |