コード例 #1
0
ファイル: xtft.c プロジェクト: USN-Norway/VHDL-SmartWatch
/**
*
* This function performs one of the following three operations based on the
* CharValue passed :
* - Move the position to the next line at the same position.
* - Move the position to the next line.
* - Write a particular character and update the column position by the
*   width of the character.
*
* @param	InstancePtr is a pointer to the XTft instance.
* @param	CharValue is the ASCII code value of the character to be
*		written.
*
* @return	None.
*
* @note		As the character bitmap array does not support some of the
*		ASCII values, to support some of those which carry
*		significance in display are added in the switch case. If
*		there is a necessity for any other characters, it can be
*		added here.
*
****************************************************************************/
void XTft_Write(XTft *InstancePtr, u8 CharValue)
{
	/*
	 * Assert validates the input arguments.
	 */
	Xil_AssertVoid(InstancePtr != NULL);
	Xil_AssertVoid(InstancePtr->IsReady == XIL_COMPONENT_IS_READY);

	/*
	 * First two cases handle the special input values
	 * and default case performs a character write operation
	 * and it updates the column position in the instance structure.
	 */
	switch (CharValue) {
		case 0xd:
			/*
			 * Action to be taken for carriage return.
			 */
			XTft_SetPos(InstancePtr, XTFT_DEF_COLVAL,
					InstancePtr->RowVal);
			break;
		case 0xa:
			/*
			 * Action to be taken for line feed.
			 */
			XTft_SetPos(InstancePtr, XTFT_DEF_COLVAL,
				InstancePtr->RowVal + XTFT_CHAR_HEIGHT);
			break;
		default:
			/*
			 * Set the position and write the character and
			 * update the column position by width of
			 * character.
			 */
			XTft_SetPosChar(InstancePtr, InstancePtr->ColVal,
					InstancePtr->RowVal);
			XTft_WriteChar(
				InstancePtr, CharValue,
				InstancePtr->ColVal, InstancePtr->RowVal,
				InstancePtr->FgColor, InstancePtr->BgColor);

			InstancePtr->ColVal += XTFT_CHAR_WIDTH;
			break;
	}

}
コード例 #2
0
ファイル: xtft.c プロジェクト: eugenecartwright/hthreads
XStatus XTft_Write(XTft *InstancePtr, Xint8 val)
{
  XASSERT_NONVOID(InstancePtr != XNULL);
  XASSERT_NONVOID(InstancePtr->IsReady == XCOMPONENT_IS_READY);

  switch (val)
  {
  case 0xd:  /* carriage return */
    XTft_SetPos(InstancePtr, 0, InstancePtr->Y);
    break;
  case 0xa:  /* line feed */
    XTft_SetPos(InstancePtr, 0, InstancePtr->Y+XTFT_CHAR_HEIGHT);
    break;
  default:
    XTft_SetPos(InstancePtr, InstancePtr->X, InstancePtr->Y);
    XTft_WriteChar(*(Xuint32 *)InstancePtr->BaseAddress, val,
                   InstancePtr->X, InstancePtr->Y,
                   InstancePtr->FgColor, InstancePtr->BgColor);
    InstancePtr->X += XTFT_CHAR_WIDTH;
    break;
  }
  return XST_SUCCESS;
}