--[[
ģƣGC 9106оƬ
ģ鹦ܣʼоƬ
ģ޸ʱ䣺2017.08.08
]]

--[[
ע⣺ļãӲʹõLCDרõSPIţǱ׼SPI
dispĿǰ֧SPIӿڵӲͼ£
Airģ			LCD
GND-------------
LCD_CS----------Ƭѡ
LCD_CLK---------ʱ
LCD_DATA--------
LCD_DC----------/ѡ
VDDIO-----------Դ
LCD_RST---------λ
]]

module(...,package.seeall)

--[[
init
  ʼLCD
  
ֵ
]]
local function init()
	local para =
	{
		width = 128, --ֱʿȣ128أûĲ޸
		height = 128, --ֱʸ߶ȣ128أûĲ޸
		bpp = 16, --λȣ֧16λ
		bus = disp.BUS_SPI4LINE, --LCDרSPIŽӿڣ޸
		xoffset = 0, --Xƫ
		yoffset = 32, --Yƫ
		freq = 13000000, --spiʱƵʣ֧110K13M11000013000000֮11000013000000
		hwfillcolor = 0xFFFFFF, --ɫɫ
		pinrst = pio.P0_14, --resetλ
		pinrs = pio.P0_18, --rs/ѡ
		--ʼ
		--ǰֽڱʾͣ0001ʾʱ00000002ʾ0003ʾ
		--ʱֽͣڱʾʱʱ䣨λ룩
		--ֵֽͣ
		--ֽͣݵֵ
		initcmd =
		{
			0xfe,
			0xef,
			0xb3,
			0x0030003,
			0x21,
			0x36,
			0x00300c8,
			0x3a,
			0x0030005,
			0xb4,
			0x0030021,
			0xF0,
			0x003002d,
			0x0030054,
			0x0030024,
			0x0030061,
			0x00300ab,
			0x003002e,
			0x003002f, 
			0x0030000,
			0x0030020,
			0x0030010,
			0x0030010,
			0x0030017,
			0x0030013,
			0x003000f, 
			0xF1,
			0x0030002,
			0x0030022,
			0x0030025,
			0x0030035,
			0x00300a8,
			0x0030008,
			0x0030008,
			0x0030000,
			0x0030000,
			0x0030009,
			0x0030009,
			0x0030017,
			0x0030018,
			0x003000f,
			0xfe,
			0xff,
			0x11,
			0x010078,
			0x29,
		},
		--
		sleepcmd = {
			0x00020010,
		},
		--
		wakecmd = {
			0x00020011,
		}
	}
	disp.init(para)
	disp.clear()
	disp.update()
end

--SPIŵĵѹ
pmd.ldoset(6,pmd.LDO_VLCD)
init()
--򿪱
--ʵʹʱûԼlcdƷʽȥ޸ıƴ
pmd.ldoset(6,pmd.KP_LEDR)
