- 树莓派 Raspberry Pi 512M B型,214¥
- 8G SD card, 29¥
- HP Deskjet 1010 printer (含墨盒),淘宝上最便宜的一款彩色喷墨打印机,174¥
- 8寸1024*768 液晶屏显示器套件HDMI+VGA+2AV,278¥
- 一条短hdmi线,5¥
- A7相纸100张,10¥
- 8cm散热风扇5V,10¥
- 电源插板,变压器,一个大纸箱,30¥
总成本750¥。0_0算一算还是挺贵的啊。
- 安装Win32DiskImager
- 下载RASPBIAN的image。http://www.raspberrypi.org/downloads/
- 使用Win32DiskImager将Raspbian的镜像灌入SD卡
- 连接显示器和键盘。接上电源。启动数秒后进入Raspberry Pi Software Configuration Tool。选择3,Enable Boot to Desktop/Scratch。再选择第二项:Desktop Log in as user 'pi' at the graphical desktop。选择finish退出。然后reboot。
- 这次启动直接进入了桌面
- 连接网线。或插入无线网卡,输入密码,连入互联网。
- (可选)使用电脑通过ssh来操作RPi
- 使用ifconfig查看RPi的ip地址
- 打开电脑的控制台,输入ssh [email protected](RPi的ip)
- 输入密码:raspberry(这是RPi的默认登录密码)
- 登陆成功。现在可以用电脑的控制台来输入命令了控制RPi了。
- 接下来为了使用方便,安装远程桌面来控制RPi。
- 打开控制台
- 更新apt-get。sudo apt-get update
- 安装vnc服务。sudo apt-get install tightvncserver
- 输入vncserver :1,并设置密码(如果忘记了这个密码,可以用vncpasswd来重设。然后service vncserver restart重启服务)
- 使用ifconfig查看Raspberry Pi的ip地址
- 使用vnc viewer连接vnc://192.168.xxx.xxx:5901,并输入刚才设置的密码(为什么是5901?因为vnc默认端口是5900,刚才输入的vncserver :1表示端口号+1)
- 现在应该可以看到RPi的桌面了
- 安装打印机驱动
- 打开控制台
- 安装cups驱动。输入sudo apt-get install cups
- 安装cups-pdf虚拟pdf打印机(可选,我只是用它来调试)。sudo apt-get install cups-pdf
- 将打印机管理程序lpadmin的权限赋给用户pi。输入sudo usermod -a -G lpadmin pi
- 用浏览器访问RPi的631端口,打开打印机配置页面。此时只能用RPi自己的浏览器访问,因为它默认不接受外来的连接。在administration页面勾选”Allow remote administration“后可以用PC的浏览器来登录这个配置页面,这是可以关掉远程桌面,速度会快很多。
- 连接打印机到Raspberry Pi的USB口
- 在administrator标签页点击add printer (这里开始网页反应比较慢,需耐心等待)
- 输入用户名pi,密码raspberry
- 选择你的打印机。由于我的打印机型号是HP Deskjet, 默认的list上没有这款机型,所以我还需要安装hplip的最新版本(HP打印机的开源驱动程序)。
- 接下来设置打印机默认纸张大小为A6。(LOMO照片尺寸为A7,只有A6的一半大小,但打印机最小只能支持A6)
- (可选)安装hplip
- 在http://hplipopensource.com/ 下载hplip的最新版安装包。我安装时最新版是3.15.2。需要说明的是Rasbian系统里已经自带了一个hplip,但不是最新版本,而且用apt-get upgrade升级后仍然不是最新版,所以需要从官网下载安装包。另外,下载时要选择tar格式的安装文件,不要下载sh后缀的那个,后者在RPi上编译时会死机。
- 参照这篇文章进行安装:http://hplipopensource.com/hplip-web/install/manual/distros/debian.html
- 安装完成后,就应该可以在驱动列表里找到HP Deskjet 1010了。
- 下载wechat-printer代码。
- 安装git。sudo apt-get install git
- 下载代码。git clone https://github.com/vic-w/wechat_printer.git
- 运行代码。python wechat_printer/printer.py
- 至此微信打印机终端配置完成。
- 安装pyexiv2(可读取图像的EXIF信息,以便矫正图像的Orientation): sudo apt-get install python-pyexiv2
- 设置开机启动
- 启动vncserver
- sudo vim /etc/init.d/tightvncserver
- 输入
export USER='pi' eval cd ~$USER case "$1" in start) su $USER -c '/usr/bin/vncserver :1 -geometry 800x600' echo 'Starting vncserver for $USER' ;; stop) pkill Xtightvnc echo 'Vncserver Stopped' ;; *) echo "Usage: /etc/init.d/vncserver {start|stop}" exit 1 ;; esac exit 0
- sudo chmod 755 /etc/init.d/tightvncserver
- sudo update-rc.d tightvncserver defaults
- 启动printer.py
- vim .profile
- 在最后添加
PYTHON_IS_RUNNING=`ps -e|grep 'python'|sed -e "/grep/d"` if [ -z "$PYTHON_IS_RUNNING" ]; then cd ~/wechat_printer python printer.py fi
- 此段代码在启动时运行,但会阻止进入X,我并未弄明白是为什么。