//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include "Unit1.h"
#include "dwdptest.h"
#include "common.h"
#include <stdlib.h>
#include <stdio.h>
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
enum {
KEY_NONE = -3, /* no key is pressed */
KEY_SHIFT = -2, /* only SHIFT key pressed */
KEY_FREE = -1, /* unassigned key */
KEY_1 = 1, /* number 1 */
KEY_2 = 2, /* number 2 */
KEY_3 = 3, /* number 3 */
KEY_4 = 4, /* number 4 */
KEY_5 = 5, /* number 5 */
KEY_6 = 6, /* number 6 */
KEY_7 = 7, /* number 7 */
KEY_8 = 8, /* number 8 */
KEY_9 = 9, /* number 9 */
KEY_0 = 10, /* number 0 */
KEY_OK = 182, /* 0xB6 MENU */
KEY_LSO = 42, /* 0x2A LEFT SOFT KEY */
KEY_RSO = 180, /* 0xB4 RIGHT SOFT KEY */
KEY_DEL = 21, /* 0x15 DELETE */
KEY_STAR = 28, /* * */
KEY_HASH = 14, /* # */
KEY_DOWN = 15, /* DOWN */
KEY_UP = 16, /* UP */
KEY_LEFT = 18, /* LEFT */
KEY_RIGHT = 19, /* RIGHT */
KEY_DIAL = 189, /* DIAL */
KEY_VOL_UP = 19, /* +VOLUME */
KEY_VOL_DOWN = 20, /* -VOLUME */
KEY_ON_OFF = 21, /* POWER ON/OFF */
KEY_FLIP_OPEN = 12, /* POWER ON/OFF */
KEY_FLIP_CLOSED = 13, /* POWER ON/OFF */
KEY_HEADSET = 0x0B, /* Key on HEADSET */
KEY_C = 0x1E, /* 30 CLEAR */
KEY_SIDE = 29 /* side key */
};
typedef struct {
unsigned char b;
unsigned char g;
unsigned char r;
} TRgb;
TForm1 *Form1;
int handle = 0;
#define VRAM_SIZE 128*200*2
#define MAX_SEG_SIZE 128
#define BMPHeight 160
#define BMPWidth 128
#define TitleMsg "GDD tool"
unsigned short gbuf[BMPWidth*BMPHeight];
unsigned char vram_buf[VRAM_SIZE];
unsigned char rgb_buf[VRAM_SIZE];
int comport = 3;
Graphics::TBitmap *mg_pBitmap = new Graphics::TBitmap();
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
#if 0
//handle = 0;
unsigned int input[255], output[255];
unsigned short len;
if !FileExists("config.txt")
{
edtMessage->Text= "Connection failed";
btnConnect->Caption = "Connect";
return;
}
if (DWD_set_com_port(comport, &handle)==TRUE)
{
edtMessage->Text= "Connection OK";
btnConnect->Caption = "Disconnect";
}
else
{
edtMessage->Text= "Connection failed";
btnConnect->Caption = "Connect";
}
#endif
edtMessage->Text= "";
comAction->AddItem("On", this);
comAction->AddItem("Off", this);
comAction->ItemIndex = 0;
comFade->AddItem("On", this);
comFade->AddItem("Off", this);
comFade->ItemIndex = 1;
comKeyAction->AddItem("On", this);
comKeyAction->AddItem("Off", this);
comKeyAction->ItemIndex = 0;
comKeyFade->AddItem("On", this);
comKeyFade->AddItem("Off", this);
comKeyFade->ItemIndex = 1;
comAudioCommand->AddItem("Input Mode", this);
comAudioCommand->AddItem("Mono Volume", this);
comAudioCommand->AddItem("Left Volume", this);
comAudioCommand->AddItem("Right Volume", this);
comAudioCommand->AddItem("Output Mode", this);
comAudioCommand->AddItem("Control register", this);
comAudioCommand->ItemIndex = 0;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnDisplayIDClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
unsigned int id;
char buf[50];
memset(buf, 0, sizeof(buf));
input[0]=250;
len=200 * sizeof(unsigned int);
DWD_gdd_generic(atctst_gdd_get_hw_capabilities, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);
if (output[0] == dwd_ok)
{
id=output[10];
memcpy(buf,idstring[id],sizeof(buf));
edtDisplayID->Text = idstring[id];
}
else
edtMessage->Text = edtMessage->Text + "Read Display ID error/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormDestroy(TObject *Sender)
{
if (DWD_close_com_port(handle)==FALSE)
{
::MessageBox(NULL,"Close com port error", TitleMsg, 0);
return;
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnTestImageClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
AnsiString temp;
// unsigned int id;
// char buf[80];
input[0] = 250;//hw_id;
temp = edtTestImage->Text;
input[1] = temp.ToIntDef(0);
len=4;
DWD_gdd_generic(atctst_gdd_lcd_test_image_start, 2 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnReadContrastClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0] = 250;//hw_id;
len=4*4;
DWD_gdd_generic(atctst_gdd_lcd_get_contrast_limits, 1 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
if (output[0] == dwd_ok)
{
edtMin->Text = output[1];
edtDef->Text = output[2];
edtMax->Text = output[3];
}
// else
// m_messages = m_messages + "Get contrast limits failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnSetContrastClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
AnsiString temp;
input[0] = 250;//hw_id;
temp = edtContrast->Text;
input[1] = temp.ToIntDef(0);
len=4;
DWD_gdd_generic(atctst_gdd_lcd_set_contrast, 2 * sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnStandbyonClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0] = 250;//hw_id;
input[1] = 0;
len=0;
DWD_gdd_generic(atctst_gdd_lcd_set_power_save_mode, 2*sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnStandbyoffClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0] = 250;//hw_id;
input[1] = 1;
len=0;
DWD_gdd_generic(atctst_gdd_lcd_set_power_save_mode, 2*sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnShutdownClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0] = 250;//hw_id;
len=0;
DWD_gdd_generic(atctst_gdd_lcd_shutdown, sizeof(int32), (unsigned char*)input, &len, (unsigned char*)output, 0);
}
//---------------------------------------------------------------------------
#if 0
void __fastcall TForm1::btnBrowseClick(TObject *Sender)
{
AnsiString BitMap;
Dialogs::TOpenDialog *OpenDialog1 = new Dialogs::TOpenDialog(NULL);
OpenDialog1->Filter = "BMP files (*.bmp)|*.bmp";
if (OpenDialog1->Execute())
{
if (FileExists(OpenDialog1->FileName))
edtBitmapfile->Text = OpenDialog1->FileName;
}
delete OpenDialog1;
}
#endif
//---------------------------------------------------------------------------
static void convertBMP_RGB24_to_RGB16(unsigned char *vram_out, Graphics::TBitmap *pBitmap)
{
unsigned char *ptr1 = vram_out;
unsigned char *ptr2;
for (int y = 0; y < pBitmap->Height; y++)
{
ptr2 = (unsigned char *)pBitmap->ScanLine[y];
for (int i=0; i < pBitmap->Width; i++)
{
int16 a = ((ptr2[i*3+2]<<8)&0xF800)|((ptr2[i*3+1]<<3)&0x07E0)|((ptr2[i*3]>>3)&0x001F);
memcpy(ptr1,(unsigned char *)&a,2);
ptr1+=2;
}
}
}
static void change_endianess(unsigned char *vram_out, unsigned char *vram_in,unsigned int16 num_pix)
{
unsigned int16 i,pix_hi, pix_low;
unsigned char *vramptr;
vramptr = (unsigned char *)vram_out;
for(i=0;i<num_pix;i++)
{
pix_low= *vram_in;
vram_in++;
pix_hi=*vram_in;
vram_in++;
*vramptr=pix_hi;
vramptr++;
*vramptr=pix_low;
vramptr++;
}
}
static unsigned int min(unsigned int a, unsigned int b)
{
return ( (a < b) ? a : b);
}
static int TC_lcd_test_BMP_image(AnsiString fileName,unsigned int min_width, unsigned int min_height)
{
unsigned int output_width;
unsigned int output_height;
unsigned int startx, starty, size, addroffset, i, j,k;
unsigned int input[255], output[255];
unsigned short len;
//FILE *fp; //for test
char tempstr[50];
//gdd_result_type res;
TPixelFormat format;
int result = RES_PASS;
Graphics::TBitmap *Bitmap1 = new Graphics::TBitmap();
// Open file
/*fp=fopen("c://test.565", "wb");
if(fp == NULL)
return -1; */
if (FileExists(fileName))
{
Bitmap1->LoadFromFile(fileName);
output_width = min_width;
output_height = min(min_height,Bitmap1->Height);
memset(vram_buf, 0x00, sizeof(vram_buf));
if (Bitmap1->Width!= min_width)
{
::MessageBox(NULL,"Width should be equal 128", TitleMsg, 0);
Bitmap1->ReleaseHandle();
delete Bitmap1;
return RES_FAIL;
}
if (Bitmap1->PixelFormat != pf24bit)
{
//AddLogLine(clBlack, LOG_LEVEL_1, "IMAGE Is not BMP 24 BIT!!!...");
result = RES_FAIL;
}
else
{
convertBMP_RGB24_to_RGB16(vram_buf,Bitmap1);
change_endianess(rgb_buf,vram_buf,output_width*output_height); //not Change endian
// show RGB on target
startx = 0;
starty = 0;
addroffset = 0;
for (i=0; i<output_width*output_height*2/MAX_SEG_SIZE;i++)
//for (i=0; i<1;i++)
{
input[0]=startx;
input[1]=starty;
input[2]=addroffset;
input[3]=MAX_SEG_SIZE;
// for (j=0;j<32;j++)
// input[j+4]= 0x1F001F00;
memcpy((char *)(void *)(input+4), rgb_buf+addroffset, MAX_SEG_SIZE);
//memcpy((char *)(void *)(input+4), vram_buf+addroffset, MAX_SEG_SIZE); //not Change endian
sprintf(tempstr, "starty=%d",starty);
// ::MessageBox(NULL,tempstr, "display testsuite", 0);
Form1->Caption = tempstr;
len = 4;
if (DWD_gdd_generic(300, MAX_SEG_SIZE+4*4, (unsigned char*)input, &len, (unsigned char*)output, 0)== FALSE)
{
break;
}
if (output[0] == dwd_ok)
sprintf(tempstr, "starty=%d",starty);
else
break;
//fwrite(&input[4], 1, MAX_SEG_SIZE, fp); //for test
if (startx==0)
startx = startx + MAX_SEG_SIZE/2;
else
startx = 0;
//startx = startx + MAX_SEG_SIZE/2;
//if (startx==128)
// startx = 0;
if (startx==0)
starty++;
addroffset = addroffset + MAX_SEG_SIZE;
//Sleep(1000);
} // for (i=0; i<output_width*output_height*2/MAX_SEG_SIZE;i++)
//When transfer is finished, then notify mobile phone to update data
//fclose(fp); //for test
input[0]=output_width - 1;
input[1]=output_height - 1;
//input[1]=1 - 1;
input[2]=0;
input[3]=0;
DWD_gdd_generic(300, 4*4, (unsigned char*)input, &len, (unsigned char*)output, 0);
} //else
} //if (Bitmap1->PixelFormat != pf24bit)
else
{
//AddLogLine(clBlack, LOG_LEVEL_1, "Cannot open file!!!...");
result = RES_FAIL;
}
Bitmap1->ReleaseHandle();
delete Bitmap1;
return result;
}
void __fastcall TForm1::btnShowbitmapClick(TObject *Sender)
{
AnsiString BitMap;
int result;
Dialogs::TOpenDialog *OpenDialog1 = new Dialogs::TOpenDialog(NULL);
OpenDialog1->Filter = "BMP files (*.bmp)|*.bmp";
if (OpenDialog1->Execute())
{
if (!FileExists(OpenDialog1->FileName))
{
::MessageBox(NULL,"File not exist!", TitleMsg, 0);
return;
}
edtMessage->Text = edtMessage->Text + "Please wait.../r/n";
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
result = TC_lcd_test_BMP_image(OpenDialog1->FileName,128,160);
edtMessage->Text = edtMessage->Text + "Show bitmap file finished/r/n";
Screen->Cursor = Save_Cursor;
}
delete OpenDialog1;
}
//---------------------------------------------------------------------------
static void ConvertPixFromRgb565(unsigned short *w, TRgb *Ptr)
{
unsigned char uc1;
uc1 = ((*w & 0xf800) >> 11);
Ptr->r = (uc1 << 3) ;//| (uc1 >> 2);
uc1 = ((*w & 0x07e0) >> 5);
Ptr->g = (uc1 << 2) ;//| (uc1 >> 4);
uc1 = ((*w & 0x001f) >> 0);
Ptr->b = (uc1 << 3) ;//| (uc1 >> 2);
}
static void ConvertBmpFromRgb565(unsigned short wData[], Graphics::TBitmap *pBitmap)
{
TRgb* ptr;
short y,i;
pBitmap->Height = BMPHeight;
pBitmap->Width = BMPWidth;
for (i=y=0; y < pBitmap->Height; y++) {
ptr = (TRgb*)pBitmap->ScanLine[y];
for (int x = 0; x < pBitmap->Width; x++)
ConvertPixFromRgb565(&wData[i++], ptr++);
}
}
void __fastcall TForm1::btnReadRamClick(TObject *Sender)
{
unsigned int count,j;
unsigned int input[255], output[255];
unsigned short len;
FILE *fp;
unsigned long size = 128*160*2, i;
char buf[80];
char *tempbuf=NULL;
TCursor Save_Cursor = Screen->Cursor;
Screen->Cursor = crHourGlass;
edtMessage->Text = edtMessage->Text + "Please wait.../r/n";
//Graphics::TBitmap *mg_pBitmap = new Graphics::TBitmap();
// Open file
// fp=fopen("c://temp.565", "wb");
// if(fp == NULL)
// return ;
//Read data from memory
tempbuf = vram_buf;
for(i=0; i< size;)
{
input[0]=i;
if(i + MAX_SEG_SIZE < size)
{
input[1]=MAX_SEG_SIZE;
}
else
{
input[1]=size - i;
}
len=MAX_SEG_SIZE + 4;
DWD_gdd_generic(303, 8, (unsigned char*)input, &len, (unsigned char*)output, 0);
// fwrite(&output[1], 1, input[1], fp);
memcpy(tempbuf, &output[1], input[1]);
tempbuf=tempbuf+input[1];
i+=input[1];
}
// fclose(fp);
// fp=fopen("c://temp.565", "rb");
// fread((char *)vram_buf, BMPWidth*BMPHeight*2, 1, fp);
// fclose(fp);
change_endianess((unsigned char *)gbuf,(unsigned char *)vram_buf,BMPWidth*BMPHeight);
mg_pBitmap->PixelFormat = pf24bit;
ConvertBmpFromRgb565(gbuf, mg_pBitmap);
Image1->Picture->Assign(mg_pBitmap); // Render it!
edtMessage->Text = edtMessage->Text + "Read RAM finished/r/n";
Screen->Cursor = Save_Cursor;
//fclose(fp);
// return RES_PASS;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnSaveasClick(TObject *Sender)
{
mg_pBitmap->SaveToFile("c://temp.bmp");
::MessageBox(NULL,"Save to c://temp.bmp", TitleMsg, 0);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnConnectClick(TObject *Sender)
{
comport = edtCom->Text.ToIntDef(0);
if (DWD_set_com_port(comport, &handle)==FALSE)
{
edtMessage->Text = edtMessage->Text + "Connection failed/r/n";
}
/* if ( DWD_set_baud_rate(115200, handle)==FALSE)
{
edtMessage->Text = edtMessage->Text + "Connection failed/r/n";
return;
}
if (DWD_set_ms_baudrate(DWD_BAUDRATE_115200, handle)==FALSE)
{
edtMessage->Text = edtMessage->Text + "Connection failed/r/n";
return;
} */
if (DWD_set_v24_mode(dwd_at_hash_on, handle)==FALSE)
{
edtMessage->Text = edtMessage->Text + "Connection failed/r/n";
return;
}
edtMessage->Text = edtMessage->Text + "Connection OK/r/n";
}
void __fastcall TForm1::btnDisconnectClick(TObject *Sender)
{
if (DWD_close_com_port(handle)==TRUE)
edtMessage->Text = edtMessage->Text + "Disconnection OK/r/n";
else
edtMessage->Text = edtMessage->Text + "Disconnection failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnCheckClick(TObject *Sender)
{
if (DWD_check_comm_link(handle)==TRUE)
{
edtMessage->Text= edtMessage->Text + "Connection OK/r/n";
if (DWD_lcd_backlight_init(0))
DWD_set_lcd_backlight(0, // lcd_tp (0=MAIN)
1, // action (0=OFF, 1=ON)
0, // fade
250, // intensity
0);
}
else
{
edtMessage->Text= edtMessage->Text + "Connection failed/r/n";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnClearClick(TObject *Sender)
{
edtMessage->Text= "";
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::btnSetLcdBacklightClick(TObject *Sender)
{
int dll_handle = 0;
int action, fade, intensity;
if (comAction->Text=="On")
action = 1;
else
action = 0;
if (comFade->Text=="On")
fade = 1;
else
fade = 0;
intensity = edtIntensity->Text.ToIntDef(0);
if (DWD_lcd_backlight_init(dll_handle))
DWD_set_lcd_backlight(0, // lcd_tp (0=MAIN)
action, // action (0=OFF, 1=ON)
fade, // fade
intensity, // intensity
dll_handle);
}
void __fastcall TForm1::btnSetKeybacklightClick(TObject *Sender)
{
int dll_handle = 0;
int action, fade, intensity;
if (comKeyAction->Text=="On")
action = 1;
else
action = 0;
if (comKeyFade->Text=="On")
fade = 1;
else
fade = 0;
intensity = edtKeyIntensity->Text.ToIntDef(0);
if (DWD_keypad_backlight_init(dll_handle))
DWD_set_keypad_backlight(action, // action (0=OFF, 1=ON)
fade, // fade
intensity, // intensity
dll_handle);
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnExitClick(TObject *Sender)
{
this->Close();
}
//---------------------------------------------------------------------------
//---------------------------------------------------------------------------
void __fastcall TForm1::btnStartReinitClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0]=1; //start
len = 4;
DWD_gdd_generic(301, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);
if (output[0]==dwd_ok)
edtMessage->Text= edtMessage->Text + "Start Reinit Ok/r/n";
else
edtMessage->Text= edtMessage->Text + "Start Reinit failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnStopReinitClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
input[0]=0; //stop
len = 4;
DWD_gdd_generic(301, 4, (unsigned char*)input, &len, (unsigned char*)output, 0);
if (output[0]==dwd_ok)
edtMessage->Text= edtMessage->Text + "Stop Reinit Ok/r/n";
else
edtMessage->Text= edtMessage->Text + "Stop Reinit failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnLskClick(TObject *Sender)
{
int key = KEY_LSO;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnOkClick(TObject *Sender)
{
int key = KEY_OK;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnUpClick(TObject *Sender)
{
int key = KEY_UP;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnRskClick(TObject *Sender)
{
int key = KEY_RSO;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnLeftClick(TObject *Sender)
{
int key = KEY_LEFT;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnSendClick(TObject *Sender)
{
int key = KEY_DIAL;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnDownClick(TObject *Sender)
{
int key = KEY_DOWN;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnEndClick(TObject *Sender)
{
int key = KEY_ON_OFF;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
int key = KEY_1;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button2Click(TObject *Sender)
{
int key = KEY_2;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button3Click(TObject *Sender)
{
int key = KEY_3;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button4Click(TObject *Sender)
{
int key = KEY_4;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button5Click(TObject *Sender)
{
int key = KEY_5;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button6Click(TObject *Sender)
{
int key = KEY_6;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button7Click(TObject *Sender)
{
int key = KEY_7;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button8Click(TObject *Sender)
{
int key = KEY_8;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button9Click(TObject *Sender)
{
int key = KEY_9;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button10Click(TObject *Sender)
{
int key = KEY_STAR;
if (!CheckBox1->Checked)
{
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
else
{
if (!DWD_external_longkeypress(key, 10, 0))
edtMessage->Text= edtMessage->Text + "Long press key failed/r/n";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button11Click(TObject *Sender)
{
int key = KEY_0;
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button12Click(TObject *Sender)
{
int key = KEY_HASH;
if (!CheckBox1->Checked)
{
if (!DWD_external_keypress(key, 0))
edtMessage->Text= edtMessage->Text + "Press key failed/r/n";
}
else
{
if (!DWD_external_longkeypress(key, 10, 0))
edtMessage->Text= edtMessage->Text + "Long press key failed/r/n";
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::btnWriteLcdRegClick(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
AnsiString temp;
input[0]=250;
temp = edtLcdReg->Text;
if (temp.Trim() =="")
{
::MessageBox(NULL,"Please input register!", TitleMsg, 0);
return;
}
input[1] = temp.ToIntDef(0);
temp = edtLcdValue->Text;
len=sizeof(unsigned int);
if (temp.Trim() =="")
DWD_gdd_generic(atctst_gdd_llc_txi, 8, (unsigned char*)input, &len, (unsigned char*)output, 0);
else
{
input[1]=0x0100 | (0xff & input[1]);
input[2]=temp.ToIntDef(0);
DWD_gdd_generic(atctst_gdd_llc_txi, 12, (unsigned char*)input, &len, (unsigned char*)output, 0);
}
// if (dwd_ok!=output[0])
// edtMessage->Text= edtMessage->Text + "Write register failed/r/n";
}
//---------------------------------------------------------------------------
#if 0
void __fastcall TForm1::Button13Click(TObject *Sender)
{
unsigned int input[255], output[255];
unsigned short len;
unsigned int startx, starty, size, color;
char tempstr[50];
size = 16;
startx = 0;
starty =0 ;
color =0x00F8;
for (int i=0; i<128*160/size;i++)
//for (int i=0; i<1;i++)
{
input[0] = startx;//hw_id;
input[1] = starty;
input[2]= size;
input[3]= color;
len=4;
DWD_gdd_generic(306, 4*4, (unsigned char*)input, &len, (unsigned char*)output, 0);
sprintf(tempstr, "starty=%d",starty);
Form1->Caption = tempstr;
if (startx + size == 128 )
startx=0;
else
startx = startx + size;
if (startx==0)
starty++;
//Sleep(100);
}
}
#endif
//---------------------------------------------------------------------------
void __fastcall TForm1::btnSetClick(TObject *Sender)
{
unsigned int value, status;
unsigned char buf_i[100];
unsigned char buf_o[100];
unsigned char buf[100];
unsigned int16 hw_coding;
unsigned int16 result;
unsigned int16 modecontrol;
AnsiString temp;
temp = edtAudioData->Text;
buf_i[2] = temp.ToIntDef(0); // B4-B0: Mode Control
value = 5;
modecontrol = comAudioCommand->ItemIndex;
DWD_afr_generic(modecontrol, (unsigned int16)3, (unsigned char *)buf_i, (unsigned int16 *)&value, (unsigned char *)buf_o, 0);
/*if (buf_o[0]!= dwd_ok)
edtMessage->Text = "Audio mode control error/r/n"+ edtMessage->Text ;
else
edtMessage->Text = "Audio mode control Ok/r/n"+ edtMessage->Text ;
*/
}
//---------------------------------------------------------------------------