Ai
1 Star 7 Fork 4

合宙Luat/LuatOS-Air724UG

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
mono_lcd_spi_ssd1306.lua 2.85 KB
一键复制 编辑 原始数据 按行查看 历史
豆豆 提交于 2021-11-20 16:43 +08:00 . 目录切换至gitee
--- 模块功能:SSD 1306驱动芯片LCD命令配置
-- @author openLuat
-- @module ui.mono_std_spi_ssd1306
-- @license MIT
-- @copyright openLuat
-- @release 2018.03.27
--[[
注意:disp库目前支持I2C接口和SPI接口的屏,此文件的配置,硬件上使用的是LCD专用的SPI引脚,不是标准的SPI引脚
硬件连线图如下:
Air模块 LCD
GND--地
SPI_CS--片选
SPI_CLK--时钟
SPI_DO--数据
SPI_DI--数据/命令选择
VDDIO--电源
UART1_CTS--复位
注意:Air202早期的开发板,UART1的CTS和RTS的丝印反了
]]
module(...,package.seeall)
--[[
函数名:init
功能 :初始化LCD参数
参数 :无
返回值:无
]]
local function init()
local para =
{
width = 128, --分辨率宽度,128像素;用户根据屏的参数自行修改
height = 64, --分辨率高度,64像素;用户根据屏的参数自行修改
bpp = 1, --位深度,1表示单色。单色屏就设置为1,不可修改
bus = disp.BUS_SPI4LINE, --led位标准SPI接口,不可修改
yoffset = 32, --Y轴偏移
hwfillcolor = 0x0, --填充色,黑色
pinrst = pio.P0_6, --reset,复位引脚
pinrs = pio.P0_1, --rs,命令/数据选择引脚
--初始化命令
initcmd =
{
0xAE, --display off
0x20, --Set Memory Addressing Mode
0x10, --00,Horizontal Addressing Mode;01,Vertical Addressing Mode;10,Page Addressing Mode (RESET);11,Invalid
0xb0, --Set Page Start Address for Page Addressing Mode,0-7
0xc8, --Set COM Output Scan Direction
0x00, --set low column address
0x10, --set high column address
0x60, --set start line address
0x81, --set contrast control register
0xdf, --
0xa1, --set segment re-map 0 to 127
0xa6, --set normal display
0xa8, --set multiplex ratio(1 to 64)
0x3f, --
0xa4, --0xa4,Output follows RAM content;0xa5,Output ignores RAM content
0xd3, --set display offset
0x20, --not offset
0xd5, --set display clock divide ratio/oscillator frequency
0xf0, --set divide ratio
0xd9, --set pre-charge period
0x22, --
0xda, --set com pins hardware configuration
0x12, --
0xdb, --set vcomh
0x20, --0x20,0.77xVcc
0x8d, --set DC-DC enable
0x14, --
0xaf, --turn on oled panel
},
--休眠命令
sleepcmd = {
0xAE,
},
--唤醒命令
wakecmd = {
0xAF,
}
}
disp.init(para)
disp.clear()
disp.update()
end
--控制SPI引脚的电压域
pmd.ldoset(15,pmd.LDO_VLCD)
init()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/openLuat/LuatOS-Air724UG.git
git@gitee.com:openLuat/LuatOS-Air724UG.git
openLuat
LuatOS-Air724UG
LuatOS-Air724UG
master

搜索帮助