📄 lcd_test._c
字号:
/***********************************************************************
Content: Test for graphic library for Epson SED-1335 based LCD displays.
Last modified: 15.05.2003
Copyrights: Free to use, free to change, free to delete :-)
Compiler: ImageCraft AVR
Written by: Knut Baardsen @ Baardsen Software, Norway
Updates: http://www.baso.no
***********************************************************************/
/***********************************************************************
This software is provided "as is"; Without warranties either express or
implied, including any warranty regarding merchantability, fitness for
a particular purpose or noninfringement.
In no event shall Baardsen Software or its suppliers be liable for any
special,indirect,incidential or concequential damages resulting from
the use or inability to use this software.
***********************************************************************/
/***********************************************************************
Includes
***********************************************************************/
#include "global.h"
/***********************************************************************
Defines and globals
***********************************************************************/
#define ClockX 160
#define ClockY 120
#define ClockOR 40
#define ClockIR 2
int sec = 0;
int min = 0;
/***********************************************************************
Main
***********************************************************************/
void main()
{
int i = 0;
int j = 0;
int o = 0;
// Init the display
lcd_init();
lcd_clear_text();
lcd_clear_graphics();
lcd_write_command(0x4f);
/*lcd_write_command(0x46);
lcd_write_data(0x00);
lcd_write_data(0x10);
lcd_show_cursor(1);
// lcd_show_cursor(0);
lcd_write_command(0x42);
for (i = 0;i < 16; i++)
{
lcd_write_data(jian4[i]);
}
lcd_write_command(0x46);
lcd_write_data(0x01);
lcd_write_data(0x10);
lcd_write_command(0x42);
for (i = 16;i < 32; i++)
{
lcd_write_data(jian4[i]);
}*/
for(j= 0; j < 40 ; j++ )
{
lcd_write_command(0x46);
lcd_write_data(0x00+j);
lcd_write_data(0x10);
lcd_write_command(0x42);
for(i = j*240; i < (240*j+240) ; i++)
{
lcd_write_data(windows[i]);
}
}
while(1);
// Disable all interrupts
CLI();
// Set up timer 1 for about 1 second
TCCR1B = 0x00; //stop
TCNT1H = 0xE3; //setup
TCNT1L = 0xE1;
OCR1AH = 0x1C;
OCR1AL = 0x1F;
OCR1BH = 0x1C;
OCR1BL = 0x1F;
OCR1CH = 0x1C;
OCR1CL = 0x1F;
ICR1H = 0x1C;
ICR1L = 0x1F;
TCCR1A = 0x00;
TCCR1B = 0x05; //start Timer
MCUCR = 0x00;
EICRA = 0x00; //extended ext ints
EICRB = 0x00; //extended ext ints
EIMSK = 0x00;
TIMSK = 0x04; //timer interrupt sources
ETIMSK = 0x00; //extended timer interrupt sources
//lcd_chinesechar(0, 0,jian4 ,2,16,0);
// lcd_chinesechar(50, 50,jian4 ,2,16,1);
//lcd_chinesechar(10, 12,jian4 ,2,16,1);
//while(1);
// Draw a frame
lcd_rectangle(1,1,320,240,1);
lcd_rectangle(3,3,318,238,1);
// Write some text
lcd_goto(10,4);
lcd_write_string(" Baardsen Software");
lcd_goto(10,5);
lcd_write_string(" Svennahaugen 39");
lcd_goto(10,6);
lcd_write_string("5516 Haugesund, Norway");
//DrawClockOutline();
lcd_circle(ClockX,ClockY,ClockIR,1);
lcd_circle(ClockX,ClockY,ClockOR,1);
i = 0;
SEI();
while (i < 360)
{
lcd_degree_line(ClockX,ClockY,i,ClockOR-5,ClockOR,1);
i = i + 30;
}
// Ok, then we enable interrupts and timer which will simulate
// a good old analog clock. Enjoy !
while(1);
}
/***********************************************************************
Interrupt handler for Timer 1 - 1 Second
***********************************************************************/
#pragma interrupt_handler timer1_ovf_isr:iv_TIM1_OVF
void timer1_ovf_isr(void)
{
//TIMER1 has overflowed
TCNT1H = 0xE3; //reload counter high value
TCNT1L = 0xE1; //reload counter low value
// Draw seconds
lcd_degree_line(ClockX,ClockY,sec,ClockIR+1,ClockOR-7,0);
sec = sec + 6;
lcd_degree_line(ClockX,ClockY,sec,ClockIR+1,ClockOR-7,1);
// Draw minute
lcd_degree_line(ClockX,ClockY,min,ClockIR+1,ClockOR-15,1);
// Some simple checking....
if (sec >= 360)
{
sec = 0;
lcd_degree_line(ClockX,ClockY,min,ClockIR+1,ClockOR-15,0);
min = min + 6;
lcd_degree_line(ClockX,ClockY,min,ClockIR+1,ClockOR-15,1);
}
if (min >= 360)
{
min = 0;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -