Difference between revisions of "BakeBit - OLED 128x64"
From FriendlyELEC WiKi
(→Introduction) |
(→特性) |
||
Line 6: | Line 6: | ||
* Users can set the I2C's address to either 0X3C or 0X3D and place two OLED modules on one I2C bus. | * Users can set the I2C's address to either 0X3C or 0X3D and place two OLED modules on one I2C bus. | ||
− | == | + | ==Hardware Spec== |
− | * | + | * Standard 2.0mm pitch 4-Pin BakeBit I2C Interface |
− | * | + | * Resolution: 128 x 64 |
− | * | + | * Color: blue |
− | * | + | * I2C's address configurable |
− | * | + | * PCB dimension(mm): 24 x 42 |
[[File:BakeBit - OLED_Top_PCB.png | frameless|400px|BakeBit - OLED_Top]] | [[File:BakeBit - OLED_Top_PCB.png | frameless|400px|BakeBit - OLED_Top]] | ||
[[File:BakeBit - OLED_Bottom_PCB.png | frameless|359px|BakeBit - OLED_Bottom]] | [[File:BakeBit - OLED_Bottom_PCB.png | frameless|359px|BakeBit - OLED_Bottom]] | ||
− | * | + | * Pin Description: |
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
− | | | + | |Pin || Description |
|- | |- | ||
− | |GND || | + | |GND || Ground |
|- | |- | ||
− | |5V || | + | |5V || 5V Supply Voltage |
|- | |- | ||
|SDA || I2C-SDA | |SDA || I2C-SDA |
Revision as of 15:21, 14 December 2016
Contents
1 Introduction
- The BakeBit - OLED is a monochromatic OLED module. The OLED is 0.96" and its resoltuion is 128 x 64. Its interface is I2C.
- Users can set the I2C's address to either 0X3C or 0X3D and place two OLED modules on one I2C bus.
2 Hardware Spec
- Standard 2.0mm pitch 4-Pin BakeBit I2C Interface
- Resolution: 128 x 64
- Color: blue
- I2C's address configurable
- PCB dimension(mm): 24 x 42
- Pin Description:
Pin | Description |
GND | Ground |
5V | 5V Supply Voltage |
SDA | I2C-SDA |
SCL | I2C-SCL |
3 示例程序(1):Display System Info
这个例子我们使用显示屏来显示系统信息,例如IP地址,存储空间和内存信息,CPU当前频率等。
3.1 硬件连接
简单的将 OLED 模块插入随便一个 I2C 接口,如下面这样:
3.2 示例源代码
import time import bakebit import os import psutil from math import log import multiprocessing import platform import socket import bakebit_128_64_oled as oled oled.init() #initialze SEEED OLED display oled.clearDisplay() #clear the screen and set start position to top left corner oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) oled.setPageMode() #Set addressing mode to Page Mode byteunits = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') def filesizeformat(value): exponent = int(log(value, 1024)) return "%.1f %s" % (float(value) / pow(1024, exponent), byteunits[exponent]) memUsage = psutil.phymem_usage() diskUsage = psutil.disk_usage('/') oled.setTextXY(0,0) oled.putString("%s" % socket.gethostbyname(socket.gethostname())) oled.setTextXY(0,1) oled.putString("Mem:%s" % filesizeformat(memUsage.total)) import time import bakebit import os import psutil from math import log import multiprocessing import platform import socket import bakebit_128_64_oled as oled oled.init() #initialze SEEED OLED display oled.clearDisplay() #clear the screen and set start position to top left corner oled.setNormalDisplay() #Set display to normal mode (i.e non-inverse mode) oled.setPageMode() #Set addressing mode to Page Mode byteunits = ('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB') def filesizeformat(value): exponent = int(log(value, 1024)) return "%.1f %s" % (float(value) / pow(1024, exponent), byteunits[exponent]) memUsage = psutil.phymem_usage() diskUsage = psutil.disk_usage('/') oled.setTextXY(0,0) oled.putString("%s" % socket.gethostbyname(socket.gethostname())) oled.setTextXY(0,1) oled.putString("Mem:%s" % filesizeformat(memUsage.total)) oled.setTextXY(0,2) oled.putString("Usage:%d%%" % memUsage.percent) oled.setTextXY(0,3) oled.putString("Disk:%s" % filesizeformat(diskUsage.total)) oled.setTextXY(0,4) oled.putString("Usage:%d%%" % diskUsage.percent) oled.setTextXY(0,5) oled.putString("CPU:%s" % platform.processor()) oled.setTextXY(0,6) oled.putString("Cores:%d" % multiprocessing.cpu_count()) with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq") as f: freq = int(f.readlines()[0])/1000 freqStr = "%d MHz" % freq if freq > 1000: freqStr = "%.1f GHz" % (float(freq)/1000.0) oled.setTextXY(0,7) oled.putString("Freq:%s" % freqStr) oled.setTextXY(0,2) oled.putString("Usage:%d%%" % memUsage.percent) oled.setTextXY(0,3) oled.putString("Disk:%s" % filesizeformat(diskUsage.total)) oled.setTextXY(0,4) oled.putString("Usage:%d%%" % diskUsage.percent) oled.setTextXY(0,5) oled.putString("CPU:%s" % platform.processor()) oled.setTextXY(0,6) oled.putString("Cores:%d" % multiprocessing.cpu_count()) with open("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_cur_freq") as f: freq = int(f.readlines()[0])/1000 freqStr = "%d MHz" % freq if freq > 1000: freqStr = "%.1f GHz" % (float(freq)/1000.0) oled.setTextXY(0,7) oled.putString("Freq:%s" % freqStr)
3.3 运行示例
假设你已经参考bakebit教程安装了BakeBit源代码,
要运行示例程序,可以在开发板上进入 BakeBit/Software/Python目录,运行bakebit_prj_SystemInfo.py:
cd ~/BakeBit/Software/Python sudo python bakebit_prj_SystemInfo.py
3.4 运行结果
4 示例程序(2):UI Control via Joystick
该示例是配合BakeBit - JoyStick来实现的,可参考BakeBit - JoyStick页面。
5 相关资料
- [Schematic](BakeBit - OLED 128x64.pdf)
- [Datasheet](BakeBit - OLED 128x64 Datasheet.pdf)
- [BakeBit Github项目](https://github.com/friendlyarm/BakeBit)
- [BakeBit Starter Kit手册](http://wiki.friendlyarm.com/bakebit/bakebit_starter_kit_manual_cn.pdf)