Orange Pi Lite 玩耍备忘
OLED
准备 Waveshare SSD1331 RGB OLED
连线
Display Board Remark
DATA MOSI
CLK CLK
DC PA8
Rst PA7
CS SPI0-CE0 Chip Select
Vin VCC3V3-EXT
GND GND
FEX设置
用bin2fex还原/boot/script.bin,检查 GPIO 配置
[gpio_para]
gpio_used = 1
gpio_num = 19
gpio_pin_1 = port:PA06<1><default><default><0>
gpio_pin_2 = port:PA13<1><default><default><0>
gpio_pin_3 = port:PA14<1><default><default><0>
gpio_pin_4 = port:PA01<1><default><default><0>
gpio_pin_5 = port:PD14<1><default><default><0>
gpio_pin_6 = port:PA00<1><default><default><0>
gpio_pin_7 = port:PA03<1><default><default><0>
gpio_pin_8 = port:PC04<1><default><default><0>
gpio_pin_9 = port:PC07<1><default><default><0>
gpio_pin_10 = port:PA02<1><default><default><0>
gpio_pin_11 = port:PA21<1><default><default><0>
gpio_pin_12 = port:PA07<1><default><default><0>
gpio_pin_13 = port:PA08<1><default><default><0>
gpio_pin_14 = port:PG08<1><default><default><0>
gpio_pin_15 = port:PA09<1><default><default><0>
gpio_pin_16 = port:PA10<1><default><default><0>
gpio_pin_17 = port:PG09<1><default><default><0>
gpio_pin_18 = port:PG06<1><default><default><0>
gpio_pin_19 = port:PG07<1><default><default><0>
得到对应的 Linux 下导出的 GPIO 定义为
GPIO12 -> PA7
GPIO13 -> PA8
加载驱动 如果是 linux-sunxi 内核,则
modprobe gpio_sunxi
dmesg |grep gpio
modprobe fbtft_device name=ssd1331 gpios=reset:8,dc:7 init=-1,0xae,-1,0xa0,0x72,-1,0xa0,0x72,-1,0xa1,0x00,-1,0xa2,0x00,-1,0xa4,-1,0xa8,0x3f,-1,0xad,0x8e,-1,0xb1,0x31,-1,0xb3,0xf0,-1,0x8a,0x64,-1,0x8b,0x78,-1,0x8c,0x64,-1,0xbb,0x3a,-1,0xbe,0x3e,-1,0x87,0x06,-1,0x81,0x91,-1,0x82,0x50,-1,0x83,0x7d,-1,0xaf,-3
PS: init 参数参考 https://github.com/notro/fbtft/issues/300
PyGame 测试
# Source: http://inventwithpython.com/drawing.py
import pygame, sys, os
from pygame.locals import *
os.environ["SDL_FBDEV"] = "/dev/fb8"
# Uncomment if you have a touch panel and find the X value for your device
#os.environ["SDL_MOUSEDRV"] = "TSLIB"
#os.environ["SDL_MOUSEDEV"] = "/dev/input/eventX"
pygame.init()
# set up the window
DISPLAYSURF = pygame.display.set_mode((96, 64), 0, 16)
pygame.display.set_caption('Drawing')
# set up the colors
BLACK = ( 0, 0, 0)
WHITE = (255, 255, 255)
RED = (255, 0, 0)
GREEN = ( 0, 255, 0)
BLUE = ( 0, 0, 255)
basicfont = pygame.font.SysFont(None, 16)
text = basicfont.render('Hello World!', True, (255, 0, 0), (255, 255, 255))
textrect = text.get_rect()
textrect.centerx = DISPLAYSURF.get_rect().centerx
textrect.centery = DISPLAYSURF.get_rect().centery
# draw on the surface object
DISPLAYSURF.fill(WHITE)
DISPLAYSURF.blit(text, textrect)
# run the game loop
while True:
for event in pygame.event.get():
if event.type == QUIT:
pygame.quit()
sys.exit()
if event.type == pygame.MOUSEBUTTONDOWN:
print("Pos: %sx%s\n" % pygame.mouse.get_pos())
#if box.collidepoint(pygame.mouse.get_pos()):
# pygame.quit()
# sys.exit()
pygame.display.update()
调试命令 查看 GPIO 占用状态
cat /sys/kernel/debug/gpio
测试 framebuffer
git clone https://github.com/prpplague/fb-test-app
cd fb-test-app
make
./fb-test -f 对应的fb