📄 sanosgui.c
字号:
// file: SanOSgui.c
// by : Sanicle
// ver : 2005.04.22
// from: http://3mn.net
#include <string.h>
#include "2410lib.h"
#include "def.h"
#include "SanOSlib.h"
#include "Drivers\lcdlib.h"
#include "Drivers\glib.h"
#include "Drivers\lcd.h"
#include "Drivers\SanDriverMouse.h"
#include "Drivers\SanDriverLCD.h"
#include "SanOSgui.h"
int cursorW=10; // Cursor width
int cursorH=10; // Cursor height
int fpsCount=0; // Var to count fps(frames per second)
void Lcd_Tft_8Bit_640480_Init(void)
{
SET_IF();
Lcd_Palette8Bit_Init();
Lcd_Port_Init();
Lcd_Init(MODE_TFT_8BIT_640480);
Glib_Init(MODE_TFT_8BIT_640480);
Lcd_PowerEnable(0, 1);
Lcd_EnvidOnOff(1);
rTPAL = 0;
Glib_ClearScr(0, MODE_TFT_8BIT_640480);
CLR_IF();
}
void Lcd_Tft_8Bit_640480_GUI(void)
{
// Cursor location
static int ci,cj,li,lj;
// Draw Desktop Background
// This is a test background constructed by color-box
int k=0;
for(ci=0;ci<640;ci+=40)
for(cj=0;cj<480;cj+=30)
{
Glib_FilledRectangle(ci,cj,ci+39,cj+29,(k%256));
k++;
}
k=0;
for(ci=0;ci<640;ci+=40)
for(cj=480;cj<960;cj+=30)
{
Glib_FilledRectangle(ci,cj,ci+39,cj+29,(k%256));
k++;
}
// Write surface flag and init buffers and vars
surfaceFlag=ci=cj=li=lj=0;
_Save8Bit_640480(ci,cj+480,ci+cursorW,cj+cursorH+480);
_Save8Bit_640480_2(ci,cj+480,ci+cursorW,cj+cursorH+480);
// Display Main loop
while(TRUE)
{
// Draw backbuffer
if(surfaceFlag==0)
{
// Copy updated pixels from current surface to back buffer surface
_Recover8Bit_640480_2(li,lj+480,li+cursorW,lj+cursorH+480);
Glib_FilledRectangle(ci,cj+480,ci+cursorW,cj+cursorH+480,1);
// Recover latest cursor position bmp
_Recover8Bit_640480(ci,cj+480,ci+cursorW,cj+cursorH+480);
_Save8Bit_640480_2(ci,cj+480,ci+cursorW,cj+cursorH+480);
li=ci;
lj=cj;
// Get current cursor position
if(mouseX<0)mouseX=0;
if(mouseY<0)mouseY=0;
if(mouseX>640)mouseX=640;
if(mouseY>480)mouseY=480;
ci=mouseX;
cj=mouseY;
// Save current position bmp
_Save8Bit_640480(ci,cj+480,ci+cursorW,cj+cursorH+480);
// Draw cursor
Glib_FilledRectangle(ci,cj+480,ci+cursorW,cj+cursorH+480,1);
}
else //if(surfaceFlag==1)
{
// Copy updated pixels from current surface to back buffer surface
_Recover8Bit_640480_2(li,lj,li+cursorW,lj+cursorH);
Glib_FilledRectangle(ci,cj,ci+cursorW,cj+cursorH,1);
// Recover latest cursor position bmp
_Recover8Bit_640480(ci,cj,ci+cursorW,cj+cursorH);
_Save8Bit_640480_2(ci,cj,ci+cursorW,cj+cursorH);
li=ci;
lj=cj;
// Get current cursor position
if(mouseX<0)mouseX=0;
if(mouseY<0)mouseY=0;
if(mouseX>640)mouseX=640;
if(mouseY>480)mouseY=480;
ci=mouseX;
cj=mouseY;
// Save current position bmp
_Save8Bit_640480(ci,cj,ci+cursorW,cj+cursorH);
// Draw cursor
Glib_FilledRectangle(ci,cj,ci+cursorW,cj+cursorH,1);
}
// Flip surface
_Flip8Bit_640480();
// Delay in order to decrease flicker
//** Surface buffer has been used
//** This flicker i don't know why..
//** There's something strange when we use 2410x MoveViewPort
Delay(20000);
// FPS Count
//fpsCount+=surfaceFlag*2;
//Uart_SendDWORD((U32)fpsCount,TRUE);
//if(fpsCount>=256)fpsCount=0;
}
// When we exit from display main loop, LCD or CRT power off
Lcd_EnvidOnOff(0);
// Recover GPIO settings to non-GUI status, so enter again we should reinitialize.
Lcd_Port_Return();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -