예제 #1
0
void Key_GetASCII(uint8 KeyValue,uint8 *Data,uint8 InType)
{
  uint8 Index,Length;
	char CodeBuf[200];
	BufferFill(&CodeBuf[0],0,sizeof(CodeBuf));
	if(InType&IT_Dot)StringEndingAppend(".",&CodeBuf[0]);
	if(InType&IT_Minus)StringEndingAppend("-",&CodeBuf[0]);
	if(InType&IT_Num)StringEndingAppend("0123456789",&CodeBuf[0]);
	if(InType&IT_ASCIIS)StringEndingAppend("abcdefghijklmnopqrstuvwxyz",&CodeBuf[0]);
	if(InType&IT_ASCIIB)StringEndingAppend("ABCDEFGHIJKLMNOPQRSTUVWXYZ",&CodeBuf[0]);
	if(InType&IT_CurCLiB)StringEndingAppend((void *)(Tos_GetFontHandle()->P_CIndex),&CodeBuf[0]);
	if(InType&IT_End)StringEndingAppend("\r\n",&CodeBuf[0]);
	StringEndingAppend("\n",&CodeBuf[0]);
	Length=GetTextLength(&CodeBuf[0]);
   if(KeyValue==Key_Up)
   {
       Index=Index_Uchar(CodeBuf,*Data);
				Index++;
       if(Index>=(Length-1))Index=0;       
       *Data=CodeBuf[Index];
	 }
	  if(KeyValue==Key_Down)
   {
       Index=Index_Uchar(CodeBuf,*Data);
		   if(Index==0)Index=(Length-1);
       Index--;
       *Data=CodeBuf[Index];
	 }
}
예제 #2
0
void Ht1621_SHowUpString(uint8 *Str)
{
	uint8 i=0;
	uint8 Buf[8];
	uint8 *P=Str;
	BufferFill(&Buf[0],0x00,sizeof(Buf));
	while(*P)
	{
		if(*P!='.')
		{
			Buf[i]|=Ht1621_GetCode(*P,Ht1621CodeUpList);
			i++;
			P++;
		}
		else 
		{
			P++;
			Buf[i]|=Ht1621_GetCode('.',Ht1621CodeUpList);
		}
		if(i>3)break;
	}
	P=&Buf[0];i=6;
	while(1)
	{
		if(Buf[1]&Ht1621_GetCode('.',Ht1621CodeUpList))
		{
			for(i=3;i>0;i--){Buf[i]=Buf[i-1];Buf[i-1]=0x00;}
		}else break;
	}
	for(i=0;i<4;i++){Ht1621_ShowASCII(6-(i*2),*P++);}
}
예제 #3
0
void MUI_GetString(uint8 *Str,uint8 Length,uint8 Type)
{
	uint8 Buf[18],KeyData,Index=0;
	uint8 Size;
	MUI_ReSetTitle("PutIn");
	BufferFill(&Buf[0],0x00,sizeof(Buf));
	StringCoppy(Str,&Buf[0]);
	while(1)
	{
		MUI_SetDrawClear(False);
		Size=Length+2;//MUI_GetWordLength(&Buf[0])+3;
		if(Buf[Length]>0x80)Buf[Length]='-';
		if(Buf[Length-1]<0x80)Buf[Length]=0;
		Printf_String(&Buf[0],Length,Size,Index);
		KeyData=MUI_GetKey(0);
		if(KeyData==Key_Left)if(Index)Index--;
		if(KeyData==Key_Right)if(Index<(Size-1))Index++;
		if(Index==(Size-1))if(KeyData==Key_Up|KeyData==Key_Down){StringCoppy(&Buf[0],Str);break;}
		if(Index==0)if(KeyData==Key_Up|KeyData==Key_Down)break;
		if(Index<Size) Key_GetWord(KeyData,GetVoidWord(&Buf[0],Index-1),Type);
		Buf[Size-1]=0;
	}
	MUI_SetDrawClear(True);
	Printf_String(&Buf[0],Length,Size,Index);
}
예제 #4
0
void Key_GetWord(uint8 KeyValue,char *D,uint8 InType)
{
  uint8 Index,Length;
	char CodeBuf[200],*Data=D;
	BufferFill(&CodeBuf[0],0,sizeof(CodeBuf));
	if(InType&IT_Dot)StringEndingAppend(".",&CodeBuf[0]);
	if(InType&IT_Minus)StringEndingAppend("-",&CodeBuf[0]);
	if(InType&IT_Num)StringEndingAppend("0123456789",&CodeBuf[0]);
	if(InType&IT_ASCIIS)StringEndingAppend("abcdefghijklmnopqrstuvwxyz",&CodeBuf[0]);
	if(InType&IT_ASCIIB)StringEndingAppend("ABCDEFGHIJKLMNOPQRSTUVWXYZ",&CodeBuf[0]);
	if(InType&IT_CurCLiB)StringEndingAppend((void *)(Tos_GetFontHandle()->P_CIndex),&CodeBuf[0]);
	Length=GetTextLength(&CodeBuf[0]);
	Length++;
	Index=Index_Word(CodeBuf,Data,Length);
	if(Index==0xff)Index=0;
	 if(KeyValue==Key_Up)
   {
		  if(CodeBuf[Index]<0x80)Index++;else Index+=2;if(Index>=Length)Index=0;
       if(CodeBuf[Index]<0x80){*Data=CodeBuf[Index];}else {*(uint16 *)Data=*(uint16 *)&CodeBuf[Index];}
	 }
	  if(KeyValue==Key_Down)
   {
		   if(CodeBuf[Index-2]<0x80)Index--;else Index-=2;if(Index==0xff)Index=(Length);
       if(CodeBuf[Index]<0x80){*Data=CodeBuf[Index];}else {*(uint16 *)Data=*(uint16 *)&CodeBuf[Index];} 
	 }
	 Index=Index_Word(CodeBuf,Data,Length);
	 if(Index==0xff)Index=0;
}
예제 #5
0
파일: lzlib.c 프로젝트: BackupGGCode/teebx
static int __gz_lines_iterator (lua_State *L)
{
  gzFile zf = (gzFile) lua_topointer (L, lua_upvalueindex(1));
  int ch = '\0';
  char* ret;

  if (content_buffer_length == 0)
    ExtendBuffer ();
  else
    ResetBuffer ();

  #ifdef READ_LINE_ONE_BY_ONE

  while ( (ch = gzgetc(zf)) != -1 && ch != '\n') {
    AddToBuffer ((char) ch);
  }

  #else

  do {
    ret = gzgets (zf, content_buffer + BufferFill (), BufferFree ());
    if (ret == Z_NULL)
      break;
    int l = strlen (content_buffer);
    content_length = l;
    if (l > 0) {
      ch = content_buffer[l - 1];
      if (ch != '\n')
	ExtendBuffer ();
      else
	content_buffer[l-1] = '\0';
    }
  } while (ret && ch != '\n');

  #endif

  if (ch == '\n' || BufferFill () > 0) {
    if (ch == '\n')
      
    lua_pushstring (L, FinishBuffer ());
    return 1;
  } else {
    return pushresult(L, &zf, NULL);
  }
}
예제 #6
0
void DaCai_SetTextBox(uint16 ScreenID,uint16 ControlID,uint8 *String,uint8 Length)
{
	uint8 i=0;
	uint8 Buf[50];
	BufferFill(&Buf[0],0,sizeof(Buf));
	i=DaCai_FillHead(&Buf[0],0x10,ScreenID,ControlID);
	i+=BufferCoppy(&String[0],&Buf[i],Length);//Buf[i++]=0;
	i+=DaCai_FillEnd(&Buf[i],i);
	USART1_DMAWriteDatas(&Buf[0],i);
	Tos_TaskDelay(10);
}
예제 #7
0
void DaCai_ShowWidget(uint16 ScreenID,uint16 ControlID,uint8 En)
{
	uint8 i=0;
	uint8 Buf[50];
	BufferFill(&Buf[0],0,sizeof(Buf));
	i=DaCai_FillHead(&Buf[0],0x10,ScreenID,ControlID);
	Buf[i++]=En;
	i+=DaCai_FillEnd(&Buf[i],i);
	USART1_DMAWriteDatas(&Buf[0],i);
	Tos_TaskDelay(10);
}
예제 #8
0
/****************************************************************************
Date:2014-11-12
Func:整行删除
Note:
****************************************************************************/
void CS_DeleteLine(CramSnakeValue *RunValue)
{
	uint8 i,z=0,m=0;
	uint16 Temp[20];
	BufferFill(&Temp[0],0x00,sizeof(Temp[0]));
	for(i=0;i<RunValue->Row;i++)
	if(RunValue->Buf[i]!=0x3ff)Temp[z++]=RunValue->Buf[i];
	for(i=(RunValue->Row-z);i<RunValue->Row;i++)RunValue->Buf[i]=Temp[m++];
	RunValue->Value[2]+=(RunValue->Row-z);
	if(RunValue->Value[2]>100){RunValue->Value[0]++;RunValue->Value[2]=0;}
	if(RunValue->Row-z)CS_DrawWords(RunValue,S1|S2);
}
예제 #9
0
BOOL GPRS_CommandAck(char *Send,uint8 *Ack,uint16 Wating)
{
	uint8 i=3;
	uint8 Length;
	while(i--)
	{
		USART_WriteLine(USART2,Send);
		BufferFill(USART_RX_Buffer[1],0x00,USART_RX_BUFFER_SIZE);
		Length=USART_ReadDatas(USART2,Null,50,Wating);
		if(Length)if(strstr((const char *)USART_RX_Buffer[1],(const char *)Ack))return True;
	}
	return False;
}
예제 #10
0
u8 UpgradeServer_Read(uint8 *ReBuf,uint16 Addr,uint8 Cmd,uint8 *Data,uint16 Length)
{
	uint8 Buf[300];
	BufferFill(USART_RX_Buffer[1],0x00,USART_RX_BUFFER_SIZE);
	BufferFill(&ReBuf[0],0x00,USART_RX_BUFFER_SIZE);
	Length=ZBUS_SendMsg(&Buf[0],Addr,Cmd,&Data[0],Length);
	USART_WriteLine(USART2,"AT+QISEND=%d\r\n",Length);
	if(!GPRS_Ack(">",2000))return 1;
	USART_WriteDatas(USART2,&Buf[0],Length);
	if(!GPRS_Ack("SEND OK",1000))return 2;
	Length=USART_ReadDatas(USART2,&ReBuf[0],USART_RX_BUFFER_SIZE,2000);
	if(Length)
	{
		if(ZBUS_CheckCrc(USART_RX_Buffer[1]))
		{
			QuectelM26Printf_Bytes("R:",USART_RX_Buffer[1],Length);
			return 0;
		}else DeBug("校验失败",Infor_Warning);
	}
	DeBug("返回超时",Infor_Warning);
	return 3;
}
예제 #11
0
/*******************************************************************************
Func:填充文件容器基本信息
Date:2014-7-27
Note:FileSize=0时为不确定文件长度
*******************************************************************************/
void TQFS_FileRoomInfor(File_Infor *FI,void *File,uint32 FileSize,uint8 FileVirtue)
{
	uint8 Buf[14];
	BufferFill(FI,0xff,sizeof(File_Infor));//配置不设置项为不修改状态
	GetFileNameFormat(File,&Buf[0],Null);
	StringCoppy(&Buf[0],&FI->FileName[0]);
	GetFileNameFormat(File,Null,&Buf[0]);
	StringCoppy(&Buf[0],&FI->FileFormat[0]);
	FI->FileType=FT_ReadyRoom;//待分配的文件类型
	BufferCoppy(&NowTime,&FI->CreateDate,sizeof(Date_Time));
	FI->Page_Status=FT_ReadyRoom;//页即将被使用
	if(FileSize)FI->FileSize=FileSize;
	FI->FileID=rand();//文件ID其实就是随机数,但必须保证同一个文件的ID号相同
	FI->FileVirtue=FileVirtue;//可读可写隐藏等属性	
}
예제 #12
0
float MUI_GetValue(float Value,uint8 Size,uint8 InType)
{
	uint8 Buf[10],KeyData,Index=0;
	Size++;
	MUI_ReSetTitle("PutIn");
	BufferFill(&Buf[0],0,sizeof(Buf));
	GetStringByFmt((char *)&Buf[0],"%.3f",Value);
	while(1)
	{
		MUI_SetDrawClear(False);
		Printf_Data(&Buf[0],Size+1,Index);
		KeyData=MUI_GetKey(0);
		if(KeyData==Key_Left)if(Index)Index--;
		if(KeyData==Key_Right)if(Index<Size)Index++;
		if(Index==Size)if(KeyData==Key_Up|KeyData==Key_Down){Value=GetStringToNumber(&Buf[0]);break;}
		if(Index==0)if(KeyData==Key_Up|KeyData==Key_Down)break;
		if(Index<Size)Key_GetASCII(KeyData,&Buf[Index-1],InType);
		Buf[Size-1]=0;
	}
	MUI_SetDrawClear(True);
	Printf_Data(&Buf[0],Size+1,1);
	return Value;
}
예제 #13
0
uint32 MUI_GetColor(uint32 Value,uint8 InType)
{
	uint8 Buf[18],KeyData,Index=0;
	uint8 Size=12;
	MUI_ReSetTitle("PutIn");
	BufferFill(&Buf[0],0,sizeof(Buf));
	GetStringByFmt((char *)&Buf[0],"%03d.%03d.%03d",TFT_RGB(Value).R,TFT_RGB(Value).G,TFT_RGB(Value).B);
	while(1)
	{
		MUI_SetDrawClear(False);
		Printf_Data(&Buf[0],Size+1,Index);
		KeyData=MUI_GetKey(0);
		if(KeyData==Key_Left)if(Index)Index--;
		if(KeyData==Key_Right)if(Index<Size)Index++;
		if(Index==Size)if(KeyData==Key_Up|KeyData==Key_Down){Buf[11]=0;Value=ALL_TFT(StringToIPUint32(&Buf[0]));break;}
		if(Index==0)if(KeyData==Key_Up|KeyData==Key_Down)break;
		if(Index<Size)Key_GetASCII(KeyData,&Buf[Index-1],InType);
		Buf[Size-1]=0;
	}
	MUI_SetDrawClear(True);
	Printf_Data(&Buf[0],Size+1,1);
	return Value;
}
예제 #14
0
파일: buffer.c 프로젝트: Ravenbrook/mps
Res BufferReserve(Addr *pReturn, Buffer buffer, Size size)
{
  Addr next;

  AVER(pReturn != NULL);
  AVERT(Buffer, buffer);
  AVER(size > 0);
  AVER(SizeIsAligned(size, BufferPool(buffer)->alignment));
  AVER(BufferIsReady(buffer)); /* <design/check/#.common> */

  /* Is there enough room in the unallocated portion of the buffer to */
  /* satisfy the request?  If so, just increase the alloc marker and */
  /* return a pointer to the area below it. */
  next = AddrAdd(buffer->ap_s.alloc, size);
  if (next > (Addr)buffer->ap_s.alloc &&
      next <= (Addr)buffer->ap_s.limit) {
    buffer->ap_s.alloc = next;
    *pReturn = buffer->ap_s.init;
    return ResOK;
  }

  /* If the buffer can't accommodate the request, call "fill". */
  return BufferFill(pReturn, buffer, size);
}
예제 #15
0
void Task_CramSnake()
{
	uint16 Buf[2][20];
	uint8 KeyData;
	CramSnakeValue RunValue;
	MUI_ReSetTitle("Snake");
	RunValue.StartX=MenuValue->StartX+2;
	RunValue.StartY=MenuValue->StartY+2;
	RunValue.Row=17;
	RunValue.Rank=16;
	RunValue.Mode=1;
	RunValue.GridSize=11;
	RunValue.Buf=&Buf[0][0];
	RunValue.OldBuf=&Buf[1][0];
	RunValue.Index=0x00;
	RunValue.Found=0x00;
	RunValue.HeadOffset=0x00;
	RunValue.SnakeLength=0x01;
	RunValue.ValueSize=sizeof(RunValue.Value);
	MUI_SetDrawClear(False);
	CS_DrawWords(&RunValue,0xff);
	while(RunValue.Mode)
	{
		switch(RunValue.Mode)
		{
		  case 1:
						BufferFill(&Buf[0],0x00,sizeof(Buf[0]));
						BufferFill(&Buf[1],0xff,sizeof(Buf[0]));
						RunValue.Mode=3;break;
			case 2:	

						break;
			case 3://菜单
						CS_DrawWords(&RunValue,0);
						KeyData=MUI_GetKey(0);
						if(KeyData==Key_Up)if(RunValue.Index==0)RunValue.Index=5;else RunValue.Index--;
						if(KeyData==Key_Down)RunValue.Index++;if(RunValue.Index>=6)RunValue.Index=0;
						if(KeyData==Key_Ctrl){RunValue.Mode=5;RunValue.Index=0;}
						if(KeyData==Key_Right)
						{
							if(RunValue.Index==5)RunValue.Mode=0;
							if(RunValue.Index==0)RunValue.Mode=4;
							if(RunValue.Index==1)RunValue.Mode=5;
							if(RunValue.Index==2)CS_Load(&RunValue);
						}break;
			case 4://运行
						KeyData=MUI_GetKey(0);
					  if(CS_SnakePlan(&RunValue,KeyData));//{CS_JoinNew(&RunValue);RunValue.Y=0;RunValue.X=0;}//新块
						if(KeyData==Key_Ctrl)RunValue.Mode=6;break;
			case 5://游戏初始化
						BufferFill(&Buf[0],0x00,sizeof(Buf[0]));
						BufferFill(&Buf[1],0xff,sizeof(Buf[0]));
						BufferFill(&RunValue.Value[0],0xff,sizeof(RunValue.Value));
						RunValue.Y=0;RunValue.X=0;
						RunValue.Mode=4;
						RunValue.Index=0;
						RunValue.X=RunValue.Rank/2;
						RunValue.X=RunValue.Row/2;
						CS_DrawWords(&RunValue,S0|S1|S2);break;
			case 6://游戏暂停
						CS_DrawWords(&RunValue,S0);
						KeyData=MUI_GetKey(0);
						if(KeyData==Key_Up)if(RunValue.Index==0)RunValue.Index=5;else RunValue.Index--;
						if(KeyData==Key_Down)RunValue.Index++;if(RunValue.Index>=6)RunValue.Index=0;
						if(KeyData==Key_Ctrl){RunValue.Mode=4;RunValue.Index=0;}
						if(KeyData==Key_Right)
						{
							if(RunValue.Index==5)RunValue.Mode=0;
							if(RunValue.Index==0){RunValue.Mode=4;RunValue.Index=0;}
							if(RunValue.Index==1)RunValue.Mode=5;
						}
						CS_DrawWords(&RunValue,S0);break;
			default:break;
		}
		CS_DrawDotArray(&RunValue,1);
		CS_DrawDotArray(&RunValue,2);
	}
	CS_DrawDotArray(&RunValue,0);
	CS_DrawNextForm(&RunValue,0xff);
	MUI_SetDrawClear(True);
	CS_DrawWords(&RunValue,0xff);
}