📄 806_sh3_example.c
字号:
#include <stdio.h>
#include "Hal.h"
#include "Appcfg.h"
#include "Hal_regs.h"
int main(void);
#define RED16BPP 0xf800
#define GREEN16BPP 0x07e0
#define BLUE16BPP 0x001f
int main(void)
{
int DevId;
UINT height, width, Bpp;
const char *p1, *p2, *p3;
DWORD color_red, color_blue;
BYTE RedBlueLut[3][3] = {
{0, 0, 0}, /* Black */
{0xF0, 0, 0}, /* Red */
{0, 0, 0xF0} /* Blue */
};
BOOL verbose = TRUE;
long x1, x2, y1, y2;
/*
** Call this to get hal.c linked into the image, and HalInfoArray
** which is defined in hal.c and used by other HAL pieces.
*/
seGetHalVersion( &p1, &p2, &p3 );
printf("1356 Hal version %s\n", p1);
/*
** Register the device with the HAL
** NOTE: HalInfo is an instance of HAL_STRUCT and is defined
** in Appcfg.h
*/
if (seRegisterDevice(&HalInfo, &DevId) != ERR_OK)
{
printf("\r\nERROR: Unable to register device with HAL\r\n");
return -1;
}
/*
** Init the S1D13506 with the defaults stored in the HAL_STRUCT
*/
if (seSetInit(DevId) != ERR_OK)
{
printf("\r\nERROR: Unable to initialize the S1D13506\r\n");
return -1;
}
/*
** Determine the screen size
*/
if (seGetScreenSize(DevId, &width, &height) != ERR_OK)
{
printf("\r\nERROR: Unable to get screen size\r\n");
return -1;
}
/*
** Determine the Bpp mode, and set colors appropriately
** Note: if less than 15Bpp set the color Lookup Table (LUT)
** local color variables contain either index into LUT or RGB value
*/
seGetBitsPerPixel(DevId, &Bpp);
if (verbose)
printf("Bpp is %d\n", Bpp);
switch(Bpp)
{
case 1: /* Can't really do red and blue here */
seSetLut(DevId, (BYTE *)&RedBlueLut[0][0], 3);
color_red = 1;
color_blue = 1;
break;
/* Set the LUT to values appropriate to Black, Red, and Blue */
case 2:
case 4:
case 8:
seSetLut(DevId, (BYTE *)&RedBlueLut[0][0], 3);
color_red = 1;
color_blue = 2;
break;
default: /* 15 or 16 bpp */
color_red = RED16BPP;
color_blue = BLUE16BPP;
break;
}
/*
** Draw a Blue line from top left hand corner to bottom right hand corner
*/
if (seDrawLine(DevId, 0,0, width-1, height-1, color_blue) != ERR_OK)
{
printf("\r\nERROR: Unable to draw line\r\n");
return -1;
}
/*
** Delay for 2 seconds and then draw a filled rectangle
*/
seDelay(DevId, (DWORD)2);
/*
** Centre the rectangle at 1/4 x,y and 3/4 x,y
*/
x1 = width/4;
x2 = width/2 + x1;
y1 = height/4;
y2 = height/2 + y1;
seDrawRect(DevId, x1, y1, x2, y2, color_red, TRUE);
/*
** Draw a box around the screen
*/
if ((seDrawLine(DevId, 0, 0, width-1, 0, color_blue) != ERR_OK)
|(seDrawLine(DevId, 0, height-1, width-1, height-1, color_blue) != ERR_OK)
|(seDrawLine(DevId, 0, 0, 0, height-1, color_blue) != ERR_OK)
|(seDrawLine(DevId, width-1, 0, width-1, height-1, color_blue) != ERR_OK))
{
printf("\r\nERROR: Unable to draw box\r\n");
return -1;
}
/*
** Load a cursor with a blue outlined green rectangle
*/
seInitCursor(DevId);
seCursorOff(DevId);
seSetCursorColor(DevId, 0, GREEN16BPP);
seSetCursorColor(DevId, 1, BLUE16BPP);
seDrawCursorRect(DevId, 0, 0, 63, 63, 1, FALSE);
seDrawCursorRect(DevId, 1, 1, 62, 62, 0, TRUE);
seCursorOn(DevId);
/*
** Delay for 2 seconds
*/
seDelay(DevId, (DWORD)2);
/*
** Move the cursor
*/
seMoveCursor(DevId, width-1-63, 0);
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -