📄 buxx_adsc.c
字号:
int aDSC_ExOvlmemory_write(const UINT16 * rgb_data)
{
UINT16 u16Ovl_H, u16Ovl_V;
u16Ovl_H = *rgb_data;
u16Ovl_V = *(rgb_data+1);
data_write(OVL_CNT,0x0013);
data_write(OVL_TRANS,0xffff);
data_write(OVL_TRMSK,0x0000);
data_write(OVLSIZE, (u16Ovl_H<<8)|u16Ovl_V); //32*32
// data_write(OVL_FRMST1,0x5b04);
// data_write(OVL_FRMST2,0x0878);
data_write(OVL_ST1,0x0000);
data_write(OVL_ED1,((u16Ovl_H-1)<<8)|(u16Ovl_V/2-1));
data_write(OVL_ST2,u16Ovl_V/2);
data_write(OVL_ED2,((u16Ovl_H-1)<<8)|(u16Ovl_V-1));
aDSC_ExOvlMemory_write_rgb565(rgb_data); //william for overlay
data_write(OVL_CNT,0x0000);
return 0;
}
//-----------------------------------------------------------------------------
// frame memory write(rgb565 data)
//-----------------------------------------------------------------------------
int aDSC_transparent_write_rgb565(const UINT16 * rgb_data,
const UINT16 st_x, const UINT16 st_y,
const UINT16 color, const UINT16 c_mask)
{
int cnt, write_count;
UINT16 xsize, ysize;
int err_code = 0;
aDSC_Quit_Preview();
xsize = *rgb_data;
rgb_data++;
ysize = *rgb_data;
rgb_data++;
data_write(MEMTRANS, color);
data_write(MEMTRMSK, c_mask);
bit_write(MEMCNT, bINCMTH | bADRINC, LOW); //rectangle increment丄auto increment off
err_code =
mem_adrst_ed_set(st_x, st_y, st_x + xsize - 1, st_y + ysize - 1);
if (err_code)
err_code |= 0x3100;
bit_write(MEMCNT, bTRON | bINCMTH | bADRINC, HIGH); //rectangle increment丄auto increment on
write_count = xsize * ysize;
mem_acs_write_st(MEMACS_RGB);
for (cnt = 0; cnt < write_count; cnt++)
{
reg_write(REG, *rgb_data); //RGB Data are written
rgb_data++;
}
data_write(MEMTRANS, 0x0000);
data_write(MEMTRMSK, 0xffff);
bit_write(MEMCNT, bTRON | bINCMTH | bADRINC, LOW); //rectangle increment丄auto increment on
if (err_code)
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
//-----------------------------------------------------------------------------
// frame memory write(color select)
//-----------------------------------------------------------------------------
int aDSC_fmemory_clear(const UINT16 st_x, const UINT16 st_y,
const UINT16 xsize, const UINT16 ysize,
const UINT16 color)
{
int cnt, write_count;
int err_code = 0;
aDSC_Quit_Preview();
bit_write(MEMCNT, bINCMTH | bADRINC, LOW); //rectangle increment丄auto increment off
err_code =
mem_adrst_ed_set(st_x, st_y, st_x + xsize - 1, st_y + ysize - 1);
if (err_code)
err_code |= 0x3200;
bit_write(MEMCNT, bINCMTH | bADRINC, HIGH); //rectangle increment丄auto increment on
write_count = xsize * ysize;
mem_acs_write_st(MEMACS_RGB);
for (cnt = 0; cnt < write_count; cnt++)
{
reg_write(REG, color); //RGB Data are written
}
bit_write(MEMCNT, bINCMTH | bADRINC, LOW); //rectangle increment丄auto increment on
if (err_code)
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
//-----------------------------------------------------------------------------
// mask memory write
//-----------------------------------------------------------------------------
//int aDSC_maskmemory_write(const UINT16 xsize, const UINT16 ysize)
int aDSC_maskmemory_write(const UINT16 xstart, const UINT16 ystart,
const UINT16 xsize, const UINT16 ysize, const UINT16 alpha_color)
{
int err_code = 0;
aDSC_Quit_Preview();
// err_code = mem_maskmemory_set(xsize, ysize);//kris test 2006-5-12 15:02
err_code = mem_maskmemory_set(xstart, ystart,xsize, ysize, alpha_color);
if (err_code)
{
err_code |= 0x3300;
DEBUG_WRITE((0, 0, "%x", err_code));
}
return (err_code);
}
//-----------------------------------------------------------------------------
// overlayframe on dispose
//-----------------------------------------------------------------------------
void aDSC_overlayframe_on(void)
{
UINT16 reg_data;
reg_data = aDSC_Quit_Preview();
bit_write(MEMCNT, bMSKON, HIGH); //MASK ON
if (reg_data == sNVIEWER)
mode_change(sNVIEWER);
}
//-----------------------------------------------------------------------------
// overlayframe off dispose
//-----------------------------------------------------------------------------
void aDSC_overlayframe_off(void)
{
UINT16 reg_data;
reg_data = aDSC_Quit_Preview();
bit_write(MEMCNT, bMSKON, LOW); //MASK OFF
if (reg_data == sNVIEWER)
mode_change(sNVIEWER);
}
//-----------------------------------------------------------------------------
// Data transfer start
//-----------------------------------------------------------------------------
int aDSC_data_trans_st(const UINT16 st_x, const UINT16 st_y,
const UINT16 xsize, const UINT16 ysize)
{
int err_code = 0;
aDSC_Quit_Preview();
err_code = lcd_trans_set(st_x, st_y, xsize, ysize);
if (err_code)
return (err_code | 0x4000);
mode_change(sLCDMANUAL);
gl_check_int = 0;
data_write(INTST, 0x0000); //Interrupt status clear
data_write(INTMSK, 0x077e); //lcded_int enable
bit_write(MLCDCNT, bMSCANST, HIGH); //Data transfer start
#if defined BUXX_POLLING
wait(10);
reg_write(INDEX, INTST);
while (reg_read(REG) == 0);
mode_change(sREADY);
#else
while (gl_check_int == 0);
#endif
data_write(INTMSK, 0xffff); //all mask cleared
// wait_int0(bLCDED_MSK);
mode_change(sREADY);
if (bit_read(LCDCNT, bLCD_SEL) == sMAIN_ACS)
{
column_page_set(0, M_LCD_WSIZE - 1, 0, M_LCD_HSIZE - 1);
}
else
{
column_page_set(0, S_LCD_WSIZE - 1, 0, S_LCD_HSIZE - 1);
}
return 0;
}
//-----------------------------------------------------------------------------
// MainLCD or SubLCD select, LCD initialize
//-----------------------------------------------------------------------------
int aDSC_lcdaccess_set(const int access)
{
int err_code = 0;
int ret_code = 0;
hostcnt_write(sDIRECT_ACS | sDIRECT_ENABLE | HOST_TYPE);
if (access == sMAIN_ACS)
{
data_write(MLCDTYPE, M_LCD_CTYPE); //???color
ret_code = lcd_wav_set(M_LCDWL, M_LCDWH);
if (ret_code)
err_code = ret_code | 0x4100;
ret_code = lcd_size_set(M_LCD_WSIZE, M_LCD_HSIZE);
if (ret_code)
err_code = ret_code | 0x4200;
ret_code = lcd_point_set(0, 0, M_LCD_WSIZE - 1, M_LCD_HSIZE - 1);
if (ret_code)
err_code = ret_code | 0x4300;
}
else
{
data_write(MLCDTYPE, S_LCD_CTYPE); //???color
ret_code = lcd_wav_set(S_LCDWL, S_LCDWH);
if (ret_code)
err_code = ret_code | 0x4100;
ret_code = lcd_size_set(S_LCD_WSIZE, S_LCD_HSIZE);
if (ret_code)
err_code = ret_code | 0x4200;
ret_code = lcd_point_set(0, 0, S_LCD_WSIZE - 1, S_LCD_HSIZE - 1);
if (ret_code)
err_code = ret_code | 0x4300;
}
ret_code = lcd_cmd_set(access);
if (ret_code)
err_code = ret_code | 0x4400;
//---- MAIN LCD愝掕 ----
bit_write(LCDCNT, bPARA_SERI | bLCD_SEL, LOW);
bit_write(LCDCNT, sPARALLEL | access, HIGH);
if (err_code)
DEBUG_WRITE((0, 0, "%x", err_code));
return err_code;
}
//-----------------------------------------------------------------------------
// Frame JPEG Encode dispose
//-----------------------------------------------------------------------------
int aDSC_FrameEncode(UINT16 * start_add, UINT32 * const jpeg_size,
const UINT16 st_x, const UINT16 st_y,
const UINT16 xsize, const UINT16 ysize,
const UINT16 je_q)
{
int err_code = 0;
UINT16 reg_camflt;
aDSC_Quit_Preview();
if (je_q > maxJE_Q)
{
err_code = 0x11000;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
reg_camflt = data_write(CAMFLT, sDISABLE);
err_code =
lcd_point_set(st_x, st_y, st_x + xsize - 1, st_y + ysize - 1);
if (err_code)
{
err_code |= 0x11100;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
err_code =
jpeg_encode(start_add, jpeg_size, sFRAMEJPEG, je_q, sJE_HFLIP_OFF);
if (err_code)
{
err_code |= 0x11200;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
data_write(CAMFLT, reg_camflt);
return (err_code);
}
//-----------------------------------------------------------------------------
// Camera JPEG Encode dispose
//-----------------------------------------------------------------------------
int aDSC_CameraEncode(UINT16 * start_add, UINT32 * const jpeg_size,
const CAMSET * const cam, const UINT16 je_q,
const UINT16 je_hflip)
{
int err_code = 0;
aDSC_Quit_Preview();
if (je_q > maxJE_Q)
{
err_code = 0x11500;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
err_code = cam_capture_set(cam);
if (err_code)
{
err_code |= 0x11600;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
err_code = jpeg_encode(start_add, jpeg_size, sRINGBUFFER, je_q, je_hflip);
if (err_code)
{
err_code |= 0x11700;
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
return (err_code);
}
//-----------------------------------------------------------------------------
// Jpeg Decode dispose
//-----------------------------------------------------------------------------
int aDSC_Decode(UINT16 * start_add, UINT32 * const jpeg_size,
const CAMSET * cam)
{
int err_code = 0;
aDSC_Quit_Preview();
err_code = jpeg_decode((UINT8 *) start_add, jpeg_size, cam);
if (err_code)
{
err_code |= 0x12000;
DEBUG_WRITE((0, 0, "%x", err_code));
}
return (err_code);
}
int aDSC_HostJpegDec(UINT16 * start_add, UINT32 * const jpeg_size, UINT16* p_u16Rgb_addr,
const CAMSET * cam)
{
int err_code = 0;
aDSC_Quit_Preview();
err_code = jpeg_HostDec((UINT8 *) start_add, jpeg_size, p_u16Rgb_addr, cam);
if (err_code)
{
err_code |= 0x13000;
DEBUG_WRITE((0, 0, "%x", err_code));
}
return (err_code);
}
//-----------------------------------------------------------------------------
// Red LED setup
//-----------------------------------------------------------------------------
int aDSC_redled_set(const UINT16 ledon, const UINT16 ledoff,
const UINT16 slope, const UINT16 duty)
{
int err_code = 0;
if (ledon > maxRON)
err_code = 0x5000;
if (ledoff > maxROFF)
err_code = 0x5001;
if (slope > maxRSLOPE)
err_code = 0x5002;
if (duty > maxRDUTY)
err_code = 0x5003;
data_write(PWMRCNT, (ledon << 8) | (ledoff));
bit_write(PWMSLOPE, bRSLOPE, LOW);
bit_write(PWMSLOPE, slope << 8, HIGH);
bit_write(PWMDUTY, bRDUTY, LOW);
bit_write(PWMDUTY, duty << 8, HIGH);
if (err_code)
DEBUG_WRITE((0, 0, "%x", err_code));
return (err_code);
}
//-----------------------------------------------------------------------------
// Green LED setup
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -