亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? lcd-color.cpp

?? LCD using AVR controller
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/*	LCD-color.cpp
*
*	Class for controlling Spark Fun's 130x130 color LCD.
*	The LCD requires 9-bit serial communication, which this
*	code does via the SPI feature.
*
*	Revisions:
*		07-13-06	included in LCDSample project
*		07-10-06	version 1 in master library
*
*	Written by Cathy Saxton
*	robotics@idleloop.com
*/

#include <stdio.h>
#include <avr/io.h>
#include <avr/pgmspace.h>
#include "Util.h"
#include "LCD-color.h"
#include "Fonts.h"
#include "Timer.h"

/* set up defines for using SPI registers */
#if defined(__AVR_ATmega8__) || defined(__AVR_ATmega16__) \
	|| defined(__AVR_ATmega32__) || defined(__AVR_ATmega128__)
#define regSPCR	SPCR
#define regSPSR	SPSR
#define regSPDR	SPDR
#define bitSPE	SPE
#define bitSPIF	SPIF
#elif (defined(__AVR_ATmega644__))
#define regSPCR	SPCR0
#define regSPSR	SPSR0
#define regSPDR	SPDR0
#define bitSPE	SPE0
#define bitSPIF	SPIF0
#else
#warning "unrecognized microcontroller (add/verify it)"
#endif

extern TIMER g_timer;

/* horiz: 0-129 (inclusive); vert: 2-131 */
/* Hungarian naming: xl and yl are x and y coordinates on LCD
   (handling offset for visible pixels) */
static const uint xlMin = 0;
static const uint ylMin = 2;
static const uint xlMax = xlMin + dxLCDScreen;
static const uint ylMax = ylMin + dyLCDScreen;
static const uint xlMost = xlMin + dxLCDScreen - 1;
static const uint ylMost = ylMin + dyLCDScreen - 1;

static const uint dxLeading = 1;	// spacing between chars
static const uint dyLeading = 1;	// spacing between lines of text
static const uint dxMargin = 3;		// margin to leave at left when drawing text
static const uint dyMargin = 2;		// margin to leave at top when drawing text


enum	// LCD Communication Type
{
	lctCmd = 0,		// command
	lctData = 1,	// data
};

/* Epson S1D15G10 Command Set */
#define DISON       0xaf
#define DISOFF      0xae
#define DISNOR      0xa6
#define DISINV      0xa7
#define COMSCN      0xbb
#define DISCTL      0xca
#define SLPIN       0x95
#define SLPOUT      0x94
#define PASET       0x75
#define CASET       0x15
#define DATCTL      0xbc
#define RGBSET8     0xce
#define RAMWR       0x5c
#define RAMRD       0x5d
#define PTLIN       0xa8
#define PTLOUT      0xa9
#define RMWIN       0xe0
#define RMWOUT      0xee
#define ASCSET      0xaa
#define SCSTART     0xab
#define OSCON       0xd1
#define OSCOFF      0xd2
#define PWRCTR      0x20
#define VOLCTR      0x81
#define VOLUP       0xd6
#define VOLDOWN     0xd7
#define TMPGRD      0x82
#define EPCTIN      0xcd
#define EPCOUT      0xcc
#define EPMWR       0xfc
#define EPMRD       0xfd
#define EPSRRD1     0x7c
#define EPSRRD2     0x7d
#define NOP         0x25


bool LCD::s_fInit = fFalse;
OUT *LCD::s_poutE;
OUT *LCD::s_poutSCK;
OUT *LCD::s_poutMOSI;
OUT *LCD::s_poutReset;

LCD::LCD(OUT *poutE, OUT *poutMOSI, OUT *poutSCK, OUT *poutReset,
		 const FONT *pfont, uchar clrBack, uchar clrFore)
		 : m_pfont(pfont),
		   m_clrBack(clrBack),
		   m_clrFore(clrFore),
		   m_x(0),
		   m_y(0)
{
	if (!s_fInit)
	{
		s_poutE = poutE;
		s_poutSCK = poutSCK;
		s_poutMOSI = poutMOSI;
		s_poutReset = poutReset;
		poutE->SetHigh();	// signal is !ChipSelect; this disables it
		poutSCK->SetLow();	// get ready for first send
		Init();
	}

	SetPos(0, 1);	// start at beginning of line 1
}

void LCD::Init() const
{
	s_fInit = fTrue;

	/* SPI setup:
	   SPI Control Register (SPCR): (0101 0001)
			bit 7	SPIE (interrupt enable)	0 = not enabled
			bit 6	SPE (enable)		1 = enable
			bit 5	DORD (data order)	0 = MSB transmitted first
			bit 4	MSTR (master sel.)	1 = master
			bit 3	CPOL (clk polarity)	0 = idle low (leading edge is rising)
			bit 2	CPHA (clock phase)	0 = sample data on leading edge of pulse
			bit 1-0	SPR1/0 (clock rate)	00 = fOSC/4
	   But, we need to disable for starters... every command needs 9 bits,
	   so we'll send one manually, the use SPI for the next 8.
	*/
	regSPCR = 0x10;	// 0001 0000


	/* comms with LCD: longest write requirement is 90 ns
	   8 MHz uC executes one instruction every 125 ns */

	/* give LCD a little time to react to power on */
	g_timer.WaitMs(20);

	/* send reset */
	s_poutReset->SetLow();
	/* reset pulse wants to be low for 350 ns (min) */
	asm("nop");
	asm("nop");
	asm("nop");
#ifdef CLOCK_16M
	asm("nop");
	asm("nop");
	asm("nop");
#endif
	s_poutReset->SetHigh();
	g_timer.WaitMs(2);	// wait for reset to complete

	WriteCommand(lctCmd, DISCTL);	// Display Control
	WriteCommand(lctData, 0x00);	// default
	WriteCommand(lctData, 0x20);	// (32 + 1) * 4 = 132 lines (of which 130 are visible)
	WriteCommand(lctData, 0x0a);	// default

	WriteCommand(lctCmd, COMSCN);	// Common Scan
	WriteCommand(lctData, 0x01);	// COM1-80: 1->80; COM81-160: 160<-81 (otherwise bottom of screen is upside down)

	WriteCommand(lctCmd, OSCON);	// Oscillation On
	WriteCommand(lctCmd, SLPOUT);	// Sleep Out (exit sleep mode)

	WriteCommand(lctCmd, VOLCTR);	// Electronic Volume Control (brightness/contrast)
	WriteCommand(lctData, 28);
	WriteCommand(lctData, 3);

	WriteCommand(lctCmd, TMPGRD);
	WriteCommand(lctData, 0);		// default

	WriteCommand(lctCmd, PWRCTR);	// Power Control Set
	/* 0x0b = ref V / V reg + primary booster
	   0x0f = all on (0x0b + secondary booster)
	   (0x03, 0x07 don't work)
	   */
//	WriteCommand(lctData, 0x0b);
	WriteCommand(lctData, 0x0f);

	WriteCommand(lctCmd, DISINV);	// Inverse Display
	WriteCommand(lctCmd, PTLOUT);	// Partial Out (no partial display)
#if 0	// unused feature
	WriteCommand(lctCmd, ASCSET);	// Area Scroll Set
	WriteCommand(lctCmd, SCSTART);	// Scroll Start Address Set
#endif

	WriteCommand(lctCmd, DATCTL);	// Data Control
	WriteCommand(lctData, 0x00);	// normal orientation; scan across cols, then rows
	WriteCommand(lctData, 0x00);	// RGB arrangement (RGB all rows/cols)
//	WriteCommand(lctData, 0x04);	// RGB arrangement (RGB row 1, BGR row 2)
	WriteCommand(lctData, 0x01);	// 8-color display
//	WriteCommand(lctData, 0x02);	// 16-color display

	/* if 256-color mode, bytes represent RRRGGGBB; the following
	   maps to 4-bit color for each value in range (0-7 R/G, 0-3 B) */
	WriteCommand(lctCmd, RGBSET8);	// 256-color position set
	WriteCommand(lctData, 0x00);	// 000 RED
	WriteCommand(lctData, 0x02);	// 001  
	WriteCommand(lctData, 0x04);	// 010
	WriteCommand(lctData, 0x06);	// 011
	WriteCommand(lctData, 0x08);	// 100
	WriteCommand(lctData, 0x0a);	// 101
	WriteCommand(lctData, 0x0c);	// 110
	WriteCommand(lctData, 0x0f);	// 111
	WriteCommand(lctData, 0x00);	// 000 GREEN
	WriteCommand(lctData, 0x02);	// 001  
	WriteCommand(lctData, 0x04);	// 010
	WriteCommand(lctData, 0x06);	// 011
	WriteCommand(lctData, 0x08);	// 100
	WriteCommand(lctData, 0x0a);	// 101
	WriteCommand(lctData, 0x0c);	// 110
	WriteCommand(lctData, 0x0f);	// 111
	WriteCommand(lctData, 0x00);	//  00 BLUE
	WriteCommand(lctData, 0x06);	//  01
	WriteCommand(lctData, 0x09);	//  10
	WriteCommand(lctData, 0x0f);	//  11

	/* clear screen */
	FillRect(0, 0, dxLCDScreen, dyLCDScreen, m_clrBack);

	g_timer.WaitMs(100);
	WriteCommand(lctCmd, DISON);	// Display On
}

/* prints given string on the specified line; unused portion of
   line will be padded with background color by default; use a
   1-based value for a specific line, or 0 for the current line;
   line is updated after outputting text */
void LCD::Print(const char *psz, uchar line, bool fPad)
{
	const char *pch;
	uchar dy;

	if (m_pfont == NULL)
		return;

	SetPos(0, line);
	pch = psz;
	while (*pch != 0)
		WriteCh(*pch++);
	dy = m_pfont->DyFont() + dyLeading;

	if (fPad && m_clrBack != clrTransparent)	// blank rest of line
	{
		FillRect(0, m_y, dxMargin, dy, m_clrBack);
		FillRect(m_x, m_y, dxLCDScreen - m_x, dy, m_clrBack);
	}

	/* update default output position */
	m_y += dy;
	m_x = dxMargin;
}

/* sets current text output location to the specified position
   (ich, 0-based) on the specified line; note that for proportional
   fonts, horizontal position is an approximation (based on the
   width of a space); using line=0 will leave line unchanged */
void LCD::SetPos(uchar ich, uchar line)
{
	uchar dx;
	uchar f;

	if (m_pfont == NULL)
		return;

	if (line != 0)
		m_y = dyMargin + (m_pfont->DyFont() + dyLeading) * (line - 1);

	m_x = dxMargin;
	if (ich > 0)
	{
		/* get width of space */
		m_pfont->PbForCh(' ', &f, &dx);
		m_x += ich * (dx + dxLeading);
	}
}

/* writes a character at the current location, updates current location */
void LCD::WriteCh(char ch)
{
	uchar dx, dy;
	uint cpx;
	uchar f;
	uchar grf;
	const uchar *pb;

	if (m_pfont == NULL)
		return;

	dy = m_pfont->DyFont();
	pb = m_pfont->PbForCh(ch, &f, &dx);

	cpx = CpxSetAndValidateLCDRect(m_x, m_y, dx, dy);
	if (cpx != (uint)dx * dy)		// not enough room
		return;

	memcpy_P(&grf, pb, sizeof(uchar));

	if (m_clrBack == clrTransparent)
	{
		uchar x, y;

		/* just set desired bits manually */
		for (y = m_y; y < m_y + dy; ++y)
		{
			for (x = m_x; x < m_x + dx; ++x)
			{
				if (grf & f)
					ColorPixel(x, y, m_clrFore);
				if ((f >>= 1) == 0)
				{
					memcpy_P(&grf, ++pb, sizeof(uchar));
					f = 0x80;
				}
			}
		}
		/* update current position */
		m_x += dx + dxLeading;
	}
	else
	{
		/* area set above; just fill in the pixels */
		while (cpx-- > 0)
		{
			WriteCommand(lctData, (grf & f) ? m_clrFore : m_clrBack);
			if ((f >>= 1) == 0)
			{
				memcpy_P(&grf, ++pb, sizeof(uchar));
				f = 0x80;
			}
		}
		/* fill in background for leading below text */
		FillRect(m_x, m_y + dy, dx + dxLeading, dyLeading, m_clrBack);

		/* update current position */
		m_x += dx;
		/* fill in background for leading after character */
		FillRect(m_x, m_y, dxLeading, dy, m_clrBack);
		m_x += dxLeading;
	}
}

/* set the color of given pixel; note that pixels off screen will be ignored */
void LCD::ColorPixel(uchar x, uchar y, uchar clr) const

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
夜夜嗨av一区二区三区四季av| 中日韩av电影| 色综合欧美在线| 国产精品综合网| 国产一区二区精品久久| 另类中文字幕网| 久草这里只有精品视频| 国内精品免费**视频| 极品美女销魂一区二区三区| 黑人精品欧美一区二区蜜桃| 国产露脸91国语对白| 国产高清久久久久| 播五月开心婷婷综合| 91美女福利视频| 欧美日韩国产首页| 日韩久久精品一区| 久久综合久久综合亚洲| 国产精品热久久久久夜色精品三区| 国产欧美日韩三级| 亚洲猫色日本管| 三级久久三级久久| 国产毛片精品视频| 一本久道中文字幕精品亚洲嫩| 欧美性猛交xxxx乱大交退制版| 91精品国产乱码| 精品福利在线导航| 亚洲欧洲日产国码二区| 亚洲国产视频一区| 国模少妇一区二区三区| 欧美无砖专区一中文字| 欧美情侣在线播放| 久久在线免费观看| 亚洲一区二区综合| 久久99精品国产91久久来源| 成人午夜在线播放| 91精品国产免费| 国产精品国产三级国产aⅴ无密码| 亚洲一区二区三区爽爽爽爽爽| 蜜臀99久久精品久久久久久软件| 国产精品一区二区久激情瑜伽| 91视频一区二区| 26uuu亚洲| 亚洲一级在线观看| 成人午夜激情在线| 日韩一本二本av| 亚洲最色的网站| 不卡av在线免费观看| 91精品国产福利| 亚洲乱码国产乱码精品精的特点 | 亚洲丝袜美腿综合| 理论电影国产精品| 91福利小视频| 国产欧美综合在线| 激情综合五月婷婷| 制服丝袜成人动漫| 亚洲女爱视频在线| 国产91精品免费| 日韩欧美在线1卡| 亚洲成人黄色影院| 91视频一区二区| 国产精品免费视频网站| 国产一区二区不卡老阿姨| 欧美猛男gaygay网站| 亚洲女同女同女同女同女同69| 国产成人啪午夜精品网站男同| 欧美日韩午夜影院| 亚洲国产日日夜夜| 欧美视频一区二区| 夜夜亚洲天天久久| 91国产免费看| 亚洲欧美日韩国产综合| 成人av网站在线观看| 久久久www成人免费无遮挡大片| 日韩国产在线观看一区| 欧美日韩一区二区三区不卡| 亚洲摸摸操操av| 一本到三区不卡视频| 国产精品水嫩水嫩| 成人av在线网站| 中文一区一区三区高中清不卡| 国产精品一级在线| 国产日韩欧美精品在线| 成人深夜在线观看| 国产精品乱人伦| 91免费在线播放| 亚洲卡通欧美制服中文| 欧美午夜精品久久久久久超碰| 亚洲天堂精品在线观看| 欧美影院一区二区| 五月激情综合婷婷| 久久精品一区二区| av电影在线不卡| 色乱码一区二区三区88| 一区二区三区小说| 色噜噜狠狠成人中文综合| 亚洲国产三级在线| 欧美一区二区美女| 国产精品综合一区二区| 国产精品美女一区二区在线观看| 99精品国产99久久久久久白柏| 亚洲免费观看高清完整| 555夜色666亚洲国产免| 精品一区精品二区高清| 国产精品美女久久久久久久网站| 色屁屁一区二区| 日本欧美一区二区三区乱码| 久久免费精品国产久精品久久久久| 高清视频一区二区| 一区二区三区国产豹纹内裤在线| 欧美日本不卡视频| 国产激情视频一区二区三区欧美 | 91免费看`日韩一区二区| 亚洲综合在线第一页| 欧美成人精品二区三区99精品| 成人激情免费网站| 亚洲成在人线在线播放| 久久这里都是精品| 欧美午夜电影在线播放| 国产成人无遮挡在线视频| 亚洲小少妇裸体bbw| 国产欧美综合在线| 欧美日韩大陆在线| 国产成人亚洲精品青草天美| 一区二区三区高清不卡| 中文字幕欧美日韩一区| 3d动漫精品啪啪| 欧美精品自拍偷拍动漫精品| 国产麻豆91精品| 天天综合色天天| 有码一区二区三区| 中文一区一区三区高中清不卡| 欧美一区二区三区视频在线观看| 91丨九色丨黑人外教| 国产一区二区三区不卡在线观看| 午夜伦欧美伦电影理论片| 亚洲天堂成人网| 国产精品午夜在线观看| 精品国产乱码久久久久久浪潮| 欧美日韩一区在线| 91碰在线视频| 成人97人人超碰人人99| 国内精品免费在线观看| 婷婷久久综合九色综合绿巨人| 亚洲蜜桃精久久久久久久| 亚洲色图.com| 亚洲人被黑人高潮完整版| 国产视频一区二区在线| 久久久久久黄色| 精品处破学生在线二十三| 欧美一区二区三区公司| 欧美亚洲动漫制服丝袜| 欧美综合久久久| 在线观看av一区二区| 91成人在线精品| 91国模大尺度私拍在线视频| 91丨porny丨最新| 一本在线高清不卡dvd| av中文字幕在线不卡| 波多野洁衣一区| 一本色道久久综合亚洲aⅴ蜜桃 | 欧美一区二区三区喷汁尤物| 精品国产乱码久久久久久牛牛| 在线不卡欧美精品一区二区三区| 欧美熟乱第一页| 欧美精品18+| 日韩视频国产视频| 久久夜色精品国产噜噜av| 国产亚洲婷婷免费| 国产精品护士白丝一区av| 亚洲精选视频在线| 亚洲成人激情综合网| 免费看日韩精品| 国产在线播放一区三区四| 成人午夜私人影院| 在线亚洲人成电影网站色www| 色吧成人激情小说| 4438亚洲最大| 国产欧美视频在线观看| 亚洲三级理论片| 日本亚洲天堂网| 粉嫩嫩av羞羞动漫久久久| 色综合色狠狠综合色| 91精品婷婷国产综合久久| 久久久久久久一区| 一区二区三区在线免费| 麻豆国产精品官网| 成人av午夜电影| 欧美一区国产二区| 中文无字幕一区二区三区 | 欧美日韩中文字幕精品| 欧美一区二区三区播放老司机| 久久精品人人爽人人爽| 亚洲韩国一区二区三区| 国产在线观看免费一区| 91国产成人在线| 久久精品视频一区二区| 午夜私人影院久久久久| 成人精品高清在线| 91麻豆精品91久久久久同性| 中文字幕不卡在线观看|