本文整理匯總了C++中GetChar函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetChar函數的具體用法?C++ GetChar怎麽用?C++ GetChar使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了GetChar函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: CommHandler
void CommHandler(void) //UART4 Interrupt handler implementation
{
int c = GetChar();
if (c >= 0)
{
//ConfigMode = 1;
LEDon();
//print("got char %02X\r\n", c);
switch (c)
{
case 'b':
print("rebooting into boot loader ...\r\n");
Delay_ms(1000);
bootloader();
break;
case 'c':
debugCnt ^= 1;
print("counter messages %s\r\n", debugCnt ? "on" : "off");
break;
case 'd':
debugPrint ^= 1;
print("debug messages %s\r\n", debugPrint ? "on" : "off");
break;
case 'g':
Delay_ms(100);
PutChar('x');
for (int i = 0; i < CONFIGDATASIZE; i++)
{
uint8_t data = configData[i];
PutChar(data);
}
break;
case 'G':
printConfig();
break;
#if 0
case 'H':
if (CharAvailable() >= CONFIGDATASIZE)
{
for (int i = 0; i < CONFIGDATASIZE; i++)
{
uint8_t data = GetChar();
if (data <= LARGEST_CONFIGDATA)
{
configData[i] = data;
}
}
configSave();
}
else
{
UnGetChar(c); // try again in next loop
}
break;
#endif
case 'h':
for (int i = 0; i < CONFIGDATASIZE; i++)
{
int data;
while ((data = GetChar()) < 0)
;
if (data <= LARGEST_CONFIGDATA)
{
configData[i] = data;
}
}
configSave();
break;
case 'i':
ConfigMode = 1;
break;
case 'j':
ConfigMode = 0;
break;
case 'o':
debugOrient ^= 1;
print("Orientation messages %s\r\n", debugOrient ? "on" : "off");
break;
case 'p':
//.........這裏部分代碼省略.........
示例2: GetLeadingChar
//------------------------------------------------------------------------------
bool FBasicTokenParser::GetToken(FBasicToken& Token, bool bNoConsts/* = false*/)
{
// if the parser is in a bad state, then don't continue parsing (who
// knows what will happen!?)
if (!IsValid())
{
return false;
}
Token.TokenName = NAME_None;
TCHAR c = GetLeadingChar();
TCHAR p = PeekChar();
if( c == 0 )
{
UngetChar();
return 0;
}
Token.StartPos = PrevPos;
Token.StartLine = PrevLine;
if( (c>='A' && c<='Z') || (c>='a' && c<='z') || (c=='_') )
{
// Alphanumeric token.
int32 Length=0;
do
{
Token.Identifier[Length++] = c;
if( Length >= NAME_SIZE )
{
Length = ((int32)NAME_SIZE) - 1;
Token.Identifier[Length]=0; // need this for the error description
FText ErrorDesc = FText::Format(LOCTEXT("IdTooLong", "Identifer ({0}...) exceeds maximum length of {1}"), FText::FromString(Token.Identifier), FText::AsNumber((int32)NAME_SIZE));
SetError(FErrorState::ParseError, ErrorDesc);
break;
}
c = GetChar();
} while( ((c>='A')&&(c<='Z')) || ((c>='a')&&(c<='z')) || ((c>='0')&&(c<='9')) || (c=='_') );
UngetChar();
Token.Identifier[Length]=0;
// Assume this is an identifier unless we find otherwise.
Token.TokenType = FBasicToken::TOKEN_Identifier;
// Lookup the token's global name.
Token.TokenName = FName( Token.Identifier, FNAME_Find, true );
// If const values are allowed, determine whether the identifier represents a constant
if ( !bNoConsts )
{
// See if the identifier is part of a vector, rotation or other struct constant.
// boolean true/false
if( Token.Matches(TEXT("true")) )
{
Token.SetConstBool(true);
return true;
}
else if( Token.Matches(TEXT("false")) )
{
Token.SetConstBool(false);
return true;
}
}
return IsValid();
}
// if const values are allowed, determine whether the non-identifier token represents a const
else if ( !bNoConsts && ((c>='0' && c<='9') || ((c=='+' || c=='-') && (p>='0' && p<='9'))) )
{
// Integer or floating point constant.
bool bIsFloat = 0;
int32 Length = 0;
bool bIsHex = 0;
do
{
if( c==TEXT('.') )
{
bIsFloat = true;
}
if( c==TEXT('X') || c == TEXT('x') )
{
bIsHex = true;
}
Token.Identifier[Length++] = c;
if( Length >= NAME_SIZE )
{
Length = ((int32)NAME_SIZE) - 1;
Token.Identifier[Length]=0; // need this for the error description
FText ErrorDesc = FText::Format(LOCTEXT("IdTooLong", "Identifer ({0}...) exceeds maximum length of {1}"), FText::FromString(Token.Identifier), FText::AsNumber((int32)NAME_SIZE));
SetError(FErrorState::ParseError, ErrorDesc);
break;
}
c = FChar::ToUpper(GetChar());
} while ((c >= TEXT('0') && c <= TEXT('9')) || (!bIsFloat && c == TEXT('.')) || (!bIsHex && c == TEXT('X')) || (bIsHex && c >= TEXT('A') && c <= TEXT('F')));
Token.Identifier[Length]=0;
//.........這裏部分代碼省略.........
示例3: GetChar
const Number FloatLiteralParser::Parse()
{
// Assert( NotAtEnd() && InClass(CharClass::NUMBER_HEAD) )
char c = GetChar();
NumberBuilder numberBuilder;
if (c == '0')
{
Advance();
if (AtEnd())
{
return Number::ZERO();
}
switch (GetChar())
{
case '.' : return ParseFractional(numberBuilder);
case 'e' :
case 'E' : return ParseExponent(numberBuilder);
case 'b' : return config_.parse_binary ? ParseBinary() : Number::ZERO();
case 'x' : return config_.parse_hexadecimal ? ParseHexadecimal() : Number::ZERO();
}
if (NotInClass(CharClass::DECIMAL))
{
return Number::ZERO();
}
if (config_.parse_octal)
{
return ParseOctal();
}
}
else if (c == '-')
{
numberBuilder.SetNegative();
Advance();
if (AtEnd() || NotInClass(CharClass::DECIMAL))
{
ThrowError("Decimal digit expected");
}
}
// Assert( NotAtEnd() && InClass(CharClass::DECIMAL) )
do
{
numberBuilder.OnIntegerDigit(GetChar() - '0');
Advance();
if (AtEnd())
{
return numberBuilder.Release();
}
}
while (InClass(CharClass::DECIMAL));
if (GetChar() == '.')
{
return ParseFractional(numberBuilder);
}
else if (GetChar() == 'e' || GetChar() == 'E')
{
return ParseExponent(numberBuilder);
}
return numberBuilder.Release();
}
示例4: assert
void kGUIText::DrawSectionRot(int sstart,int slen,float x,float y,float angle,kGUIColor color,float alpha)
{
kGUIFace *face=kGUIFont::GetFace(GetFontID());
int glyph_index;
int font_height,font_above,font_below;
FT_Face ftface;
int size;
FT_Glyph glyph2;
FT_Matrix matrix;
FT_BitmapGlyph bit;
float dx,dy,adv;
float advsin,advcos;
float fax,fay; /* rotated font above */
unsigned int ch; /* current character */
unsigned int nb; /* number of bytes for current character */
ftface=face->GetFace();
size=GetFontSize();
if(!size)
return;
assert(size>0,"Cannot print size 0\n");
font_height=face->GetPixHeight(size);
font_above = face->GetPixAscHeight(size);
font_below = face->GetPixDescHeight(size);
kGUI::SelectFont(face,size);
matrix.xx = (FT_Fixed)( cos( angle ) * 0x10000L );
matrix.xy = (FT_Fixed)(-sin( angle ) * 0x10000L );
matrix.yx = (FT_Fixed)( sin( angle ) * 0x10000L );
matrix.yy = (FT_Fixed)( cos( angle ) * 0x10000L );
adv=0;
advsin=sin(angle);
advcos=cos(angle);
fax=sin(angle-(2*PI)*0.025f)*font_above;
fay=-(cos(angle-(2*PI)*0.025f)*font_above);
/* todo, handle underline */
while(slen>0)
{
ch=GetChar(sstart,&nb);
if(!ch)
return;
sstart+=nb;
slen-=nb;
/* todo, handle tabs, handle encoding */
glyph_index = FT_Get_Char_Index( ftface, ch );
if(glyph_index>0)
{
FT_Load_Glyph(ftface,glyph_index,FT_LOAD_DEFAULT);
FT_Get_Glyph( ftface->glyph, &glyph2 );
FT_Glyph_Transform( glyph2, &matrix, 0 );
FT_Glyph_To_Bitmap( &glyph2, ft_render_mode_normal,0, 1);
/* draw to screen using writepixel */
bit = (FT_BitmapGlyph)glyph2;
dx=x+((advcos*adv)+fax);
dy=y-((advsin*adv)+fay);
DrawChar( (char *)bit->bitmap.buffer,
dx + bit->left,
dy -bit->top,
bit->bitmap.width, bit->bitmap.rows,
color,alpha);
adv+=ftface->glyph->advance.x/64.0f;
adv+=m_letterspacing;
FT_Done_Glyph(glyph2);
}
}
if(m_underline)
kGUI::DrawLine(x+fax,y-fay,x+((advcos*adv)+fax),y-((advsin*adv)+fay),color,alpha);
}
示例5: OnValReadStart
CFSVar CJSONReader::ReadVal(const CFSAString &szKeyPath)
{
OnValReadStart(szKeyPath);
CFSVar Data;
if (m_cCh=='[') {
Data.Cast(CFSVar::VAR_ARRAY);
GetChar(true);
INTPTR ipPos=0;
for (;;) {
if (m_cCh==0) {
throw CJSONException(FSTSTR("Unexpetcted EOF"));
} else if (m_cCh==']') {
GetChar(true);
break;
} else if (ipPos>0) {
if (m_cCh==',') {
GetChar(true);
} else {
throw CJSONException(FSTSTR("Missing ',' in array"));
}
}
CFSAString szKey;
szKey.Format("%zd", ipPos);
CFSVar Data1=ReadVal(szKeyPath+"/"+szKey);
if (m_iCollectData>0) {
Data[ipPos]=Data1;
}
ipPos++;
}
} else if (m_cCh=='{') {
Data.Cast(CFSVar::VAR_MAP);
GetChar(true);
INTPTR ipPos=0;
for (;;) {
if (m_cCh==0) {
throw CJSONException(FSTSTR("Unexpetcted EOF"));
} else if (m_cCh=='}') {
GetChar(true);
break;
} else if (ipPos>0) {
if (m_cCh==',') {
GetChar(true);
} else {
throw CJSONException(FSTSTR("Missing ',' in map"));
}
}
CFSAString szKey;
if (m_cCh=='\"' || m_cCh=='\'') {
szKey=ReadString();
} else if (FSIsLetter(m_cCh)) {
szKey=ReadText();
} else {
throw CJSONException(FSTSTR("Expected key"));
}
if (m_cCh==':') {
GetChar(true);
} else {
throw CJSONException(FSTSTR("Expected ':'"));
}
CFSVar Data1=ReadVal(szKeyPath+"/"+szKey);
if (m_iCollectData>0) {
Data[szKey]=Data1;
}
ipPos++;
}
} else if (m_cCh=='\"' || m_cCh=='\'') {
Data=ReadString();
} else if ((m_cCh>='0' && m_cCh<='9') || FSStrChr("-+.", m_cCh)) {
Data=ReadNumber();
} else if (FSIsLetter(m_cCh)) {
Data=ReadConst();
} else if (!m_cCh) {
} else {
throw CJSONException(FSTSTR("Unknown value type"));
}
OnValReadEnd(szKeyPath, Data);
return Data;
}
示例6: tchar
inline CField::operator tchar() const
{
return GetChar();
}
示例7: TK_Device2PC
void TK_Device2PC(void)
{
int count=0,i=0;
uint16_t len=0;
uint8_t test;
TK_CNANNEL_CONFIG tk_channel_config;
TK_CNANNEL_CONFIG *tkchconfig;
len=sizeof(TK_CNANNEL_CONFIG);
//get magic id
i=0;
count=0;
while(1)
{
if(kbhit())
{
test=GetChar();
if(test!=MagicId[i++])
{
return;
}
if(i==sizeof(MagicId)) break;
}
else
{
count++;
}
if(count > DELAY_TIME_OUT) return;
}
i=0;
count=0;
while(i<2)
{
if(kbhit())
{
((uint8_t *)&reclen)[i]=GetChar();
i++;
}
}
i=0;
count=0;
while(i<reclen)
{
if(kbhit())
{
ReceiveBuf[i]=GetChar();
i++;
}
}
SendChars(MagicIdR,sizeof(MagicIdR));
count=0;
switch(ReceiveBuf[0])
{
case OP_AUTO_CHANNEL_CONFIG:
/*Send : MagicidR | len(16) | "START" | progess (5 time) |len<NEXT> (16) */
len=5+sizeof(len);
memcpy(SendBuf+count,&len,sizeof(len));
count+=sizeof(len);
memcpy(SendBuf+count,(uint8_t *)"START",5);
count+=5;
len=sizeof(TK_CNANNEL_CONFIG)+5 /*Used by Progress */;
memcpy(SendBuf+count,&len,2);
count+=sizeof(len);
SendChars((uint8_t *)SendBuf,count);
AutoChannelConfig(ReceiveBuf[1],&final_result);
tk_channel_config.channel=ReceiveBuf[1];
tk_channel_config.base=final_result.base;
tk_channel_config.diff=final_result.diff;
tk_channel_config.current=final_result.current;
tk_channel_config.div=final_result.div;
SendChars((uint8_t *)&tk_channel_config,sizeof(TK_CNANNEL_CONFIG));
break;
case OP_GET_CONFIG:
len=TK_CH_NUM*sizeof(TK_CNANNEL_CONFIG);
memcpy( SendBuf+count,(uint8_t *)&len,sizeof(len));
count+=sizeof(len);
for(i=0;i<TK_CH_NUM;i++)
{
tk_channel_config.channel=i;
tk_channel_config.base=cfg[i].base;
tk_channel_config.diff=cfg[i].diff;
tk_channel_config.current=cfg[i].current;
tk_channel_config.div=cfg[i].div;
memcpy(SendBuf+count,(uint8_t *)(&tk_channel_config),sizeof(TK_CNANNEL_CONFIG));
count+=sizeof(TK_CNANNEL_CONFIG);
//.........這裏部分代碼省略.........
示例8: NotInClass
bool NotInClass(const CharClass & charClass) const { return !charClass.Contains(GetChar()); }
示例9: Set_Channel_Config
/*! \brief Extract the data packet from QTouch Studio and set channel config.
* \note Should only be called from the command handler.
*/
void Set_Channel_Config(void)
{
touch_ret_t touch_ret = TOUCH_SUCCESS;
#if ((DEF_TOUCH_QDEBUG_ENABLE_QM == 1) ||\
(DEF_TOUCH_QDEBUG_ENABLE_QTA == 1) ||\
(DEF_TOUCH_QDEBUG_ENABLE_QTB == 1))
sensor_id_t sensor_id;
uint8_t type_aks_pos_hyst;
#if (DEF_TOUCH_QDEBUG_ENABLE_QM == 1)
touch_qm_param_t touch_sensor_param;
#endif
#if ((DEF_TOUCH_QDEBUG_ENABLE_QTA == 1) || (DEF_TOUCH_QDEBUG_ENABLE_QTB == 1))
touch_qt_param_t touch_sensor_param;
#endif
sensor_id = GetChar();
/* Read back and initialize the touch_sensor_param structure.
* This is because not all the touch_sensor_param members are
* updated by this API. */
touch_ret
= QDEBUG_GET_SENSOR_CONFIG_FUNC(sensor_id,
&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
/* Update the necessary members of the touch_sensor_param structure
* and write back. */
touch_sensor_param.detect_threshold = GetChar();
type_aks_pos_hyst = GetChar();
touch_sensor_param.aks_group
= (aks_group_t)((uint8_t)((type_aks_pos_hyst & 0x38u) >> 3u));
touch_sensor_param.detect_hysteresis
= (hysteresis_t)((uint8_t)(type_aks_pos_hyst & 0x03u));
touch_ret
= QDEBUG_UPDATE_SENSOR_CONFIG_FUNC(sensor_id,
&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
#endif
#if DEF_TOUCH_QDEBUG_ENABLE_AT == 1
sensor_id_t sensor_id;
touch_at_param_t touch_sensor_param;
sensor_id = GetChar(); /* Dummy. To skip sensor_id. */
UNUSED(sensor_id); /* Dummy. To avoid warning. */
/* Read back and initialize the touch_sensor_param structure.
* This is because not all the touch_sensor_param members are
* updated by this API. */
touch_ret = QDEBUG_GET_SENSOR_CONFIG_FUNC(&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
/* Update the necessary members of the touch_sensor_param structure
* and write back. */
touch_sensor_param.sense = GetChar(); /* Sense level (Detect
*Threshold). */
touch_ret = QDEBUG_UPDATE_SENSOR_CONFIG_FUNC(&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
#endif
}
示例10: AutoChannelConfig
void AutoChannelConfig(uint8_t ch,best_cfg* final_result)
{
uint16_t div, i;
uint16_t current = 1;
S_TK_CH_CFG ch_cfg = {1, 0, 0xFFFF, 0x0000};
uint8_t sen_level, sen_state,tmp_div;
uint16_t sen_data;
int8_t tmp_score;
uint8_t tmp_cur;
uint8_t progress=0;
final_result->current = 1;
final_result->div = 0;
final_result->base = 0;
final_result->diff = 0;
base_rank[0].val = 0xFFFF;
base_rank[0].div = 0;
base_rank[0].current = 1;
diff_rank[0].val = 0;
diff_rank[0].div = 0;
diff_rank[0].current = 1;
progress=20;
SendChars((uint8_t *)&progress,sizeof(progress));
for(div = 1; div < 12; div++) {
for(current = 1; current <= 15; current++) {
ch_cfg.u8Level = current;
ch_cfg.u8Div = div;
TK_ConfigChannel(ch, &ch_cfg);
result[div][current - 1].level_off = 0;
result[div][current - 1].data_off = 0;
for(i = 0; i < 2; i++) {
complete = 0;
TK_Start(1 << ch);
while(complete != 1);
TK_ReadStatus(&sen_level, &sen_state, NULL);
sen_data = TK_ReadData(ch);
if(sen_state != 0 || sen_data == 0 || sen_data == 0xFFFF) {
result[div][current - 1].level_off = 0;
result[div][current - 1].data_off = 0;
break;
} else {
result[div][current - 1].level_off += sen_level;
result[div][current - 1].data_off += (sen_data >> 1);
}
}
result[div][current - 1].level_off >>= 1;
}
}
progress=40;
SendChars((uint8_t *)&progress,sizeof(progress));
while(1)
{
if(kbhit())
if(GetChar()==progress)
break;
}
for(div = 1; div < 12; div++) {
for(current = 1; current <= 15; current++) {
ch_cfg.u8Level = current;
ch_cfg.u8Div = div;
TK_ConfigChannel(ch, &ch_cfg);
result[div][current - 1].level_on = 0;
result[div][current - 1].data_on = 0;
if(result[div][current - 1].level_off == 0)
continue;
for(i = 0; i < 2; i++) {
complete = 0;
TK_Start(1 << ch);
while(complete != 1);
TK_ReadStatus(&sen_level, &sen_state, NULL);
sen_data = TK_ReadData(ch);
if(sen_state != 0 || sen_data == 0 || sen_data == 0xFFFF) {
result[div][current - 1].level_on = 0;
result[div][current - 1].data_on = 0;
break;
} else {
result[div][current - 1].level_on += sen_level;
result[div][current - 1].data_on += (sen_data >> 1);
}
}
result[div][current - 1].level_on >>= 1;
}
}
// calculate sense level, timer divider, and change current score
for(div = 1; div < 12; div++) {
for(current = 1; current <= 15; current++) {
result[div][current - 1].score = 0;
//.........這裏部分代碼省略.........
示例11: Set_Global_Config
/*! \brief Extract the data packet from QTouch Studio and set global config.
* \note Should only be called from the command handler.
*/
void Set_Global_Config(void)
{
touch_ret_t touch_ret = TOUCH_SUCCESS;
#if ((DEF_TOUCH_QDEBUG_ENABLE_QM == 1) ||\
(DEF_TOUCH_QDEBUG_ENABLE_QTA == 1) ||\
(DEF_TOUCH_QDEBUG_ENABLE_QTB == 1))
touch_global_param_t global_params;
global_params.recal_threshold = (recal_threshold_t)GetChar();
global_params.di = GetChar();
global_params.drift_hold_time = GetChar();
global_params.max_on_duration = GetChar();
global_params.neg_drift_rate = GetChar();
global_params.pos_drift_rate = GetChar();
global_params.pos_recal_delay = GetChar();
/* update the global parameter value inside the uc3l library */
touch_ret = QDEBUG_UPDATE_GLOBAL_PARAM_FUNC(&global_params);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
#endif
#if DEF_TOUCH_QDEBUG_ENABLE_AT == 1
touch_at_param_t touch_sensor_param;
uint8_t dummy_var;
/* Fill touch_sensor_param structure with default values.
* This is because QTouch Studio does not provide sense and outsense
* values. So these values should not be overwritten by the update API.
* */
touch_ret = QDEBUG_GET_GLOBAL_PARAM_FUNC(&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
/* Update data from QTouch Studio. */
touch_sensor_param.pthr = (recal_threshold_t)GetChar();
touch_sensor_param.filter = GetChar();
dummy_var = GetChar(); /* Skip drift_hold_time. */
dummy_var = GetChar(); /* Skip max_on_duration. */
touch_sensor_param.ndrift = GetChar();
touch_sensor_param.pdrift = GetChar();
UNUSED(dummy_var); /* Dummy. Avoid compiler warning. */
/* update the global parameter value inside the uc3l library */
touch_ret = QDEBUG_UPDATE_GLOBAL_PARAM_FUNC(&touch_sensor_param);
if (touch_ret != TOUCH_SUCCESS) {
while (1) {
}
}
#endif
}
示例12: AutoFlow_FunctionRxTest
/*---------------------------------------------------------------------------------------------------------*/
void AutoFlow_FunctionRxTest()
{
uint32_t u32i;
printf("\n");
printf("+-----------------------------------------------------------+\n");
printf("| Pin Configure |\n");
printf("+-----------------------------------------------------------+\n");
printf("| ______ _____ |\n");
printf("| | | | | |\n");
printf("| |Master|--UART1_TXD(PB.5) <==> UART1_RXD(PB.4)--|Slave| |\n");
printf("| | |--UART1_nCTS(PB.7) <==> UART1_nRTS(PB.6)--| | |\n");
printf("| |______| |_____| |\n");
printf("| |\n");
printf("+-----------------------------------------------------------+\n");
printf("\n");
printf("+-----------------------------------------------------------+\n");
printf("| AutoFlow Function Test (Slave) |\n");
printf("+-----------------------------------------------------------+\n");
printf("| Description : |\n");
printf("| The sample code needs two boards. One is Master and |\n");
printf("| the other is slave. Master will send 1k bytes data |\n");
printf("| to slave.Slave will check if received data is correct |\n");
printf("| after getting 1k bytes data. |\n");
printf("| Press any key to start... |\n");
printf("+-----------------------------------------------------------+\n");
GetChar();
/* Enable RTS and CTS autoflow control */
UART_EnableFlowCtrl(UART1);
/* Set RTS Trigger Level as 8 bytes */
UART1->FCR &= ~UART_FCR_RTS_TRI_LEV_Msk;
UART1->FCR |= UART_FCR_RTS_TRI_LEV_8BYTES;
/* Set RX Trigger Level as 8 bytes */
UART1->FCR &= ~UART_FCR_RFITL_Msk;
UART1->FCR |= UART_FCR_RFITL_8BYTES;
/* Set Timeout time 0x3E bit-time and time-out counter enable */
UART_SetTimeoutCnt(UART1, 0x3E);
/* Enable RDA\RLS\RTO Interrupt */
UART_EnableInt(UART1, (UART_IER_RDA_IEN_Msk | UART_IER_RLS_IEN_Msk | UART_IER_TOUT_IEN_Msk));
printf("\n Starting to receive data...\n");
/* Wait for receive 1k bytes data */
while(g_i32pointer < RXBUFSIZE);
/* Compare Data */
for(u32i = 0; u32i < RXBUFSIZE; u32i++) {
if(g_u8RecData[u32i] != (u32i & 0xFF)) {
printf("Compare Data Failed\n");
while(1);
}
}
printf("\n Receive OK & Check OK\n");
/* Disable RDA\RLS\RTO Interrupt */
UART_DisableInt(UART1, (UART_IER_RDA_IEN_Msk | UART_IER_RLS_IEN_Msk | UART_IER_TOUT_IEN_Msk));
}
示例13: while
bool wxSimpleHtmlParser::EatWhitespace()
{
while (!Eof() && IsWhitespace(GetChar(m_pos)))
m_pos ++;
return TRUE;
}
示例14: skapmot
int skapmot(void) {
struct ShortUser *shortUser;
int mad, setPermission, changed, ch, i, fidoDomainId, highestId;
struct FidoDomain *fidoDomain;
BPTR lock;
struct User user;
struct Mote tmpConf,*searchConf,*newConf;
memset(&tmpConf, 0, sizeof(struct Mote));
if(argument[0] == '\0') {
SendString("\r\n\nNamn på mötet: ");
if(GetString(40,NULL)) {
return 1;
}
strcpy(tmpConf.namn, inmat);
} else {
strcpy(tmpConf.namn, argument);
}
if(parsemot(tmpConf.namn) != -1) {
SendString("\r\n\nFinns redan ett sådant möte!\r\n");
return 0;
}
tmpConf.skapat_tid = time(NULL);;
tmpConf.skapat_av = inloggad;
for(;;) {
SendString("\r\nMötesAdministratör (MAD) : ");
if(GetString(5,NULL)) {
return 1;
}
if(inmat[0]) {
if((mad = parsenamn(inmat)) == -1) {
SendString("\r\nFinns ingen sådan användare!");
} else {
tmpConf.mad = mad;
break;
}
}
}
SendString("\n\rSorteringsvärde: ");
tmpConf.sortpri = GetNumber(0, LONG_MAX, NULL);
if(EditBitFlagShort("\r\nSka mötet vara slutet?", 'j', 'n', "Slutet", "Öppet",
&tmpConf.status, SLUTET)) {
return 1;
}
if(tmpConf.status & SLUTET) {
SendString("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n");
if(editgrupp((char *)&tmpConf.grupper)) {
return 1;
}
}
if(EditBitFlagShort("\r\nSka mötet vara skrivskyddat?", 'j', 'n',
"Skyddat", "Oskyddat", &tmpConf.status, SKRIVSKYDD)) {
return 1;
}
if(EditBitFlagShort("\r\nSka mötet vara kommentarsskyddat?", 'j', 'n',
"Skyddat", "Oskyddat", &tmpConf.status, KOMSKYDD)) {
return 1;
}
if(EditBitFlagShort("\r\nSka mötet vara hemligt?", 'j', 'n',
"Hemligt", "Ej hemligt", &tmpConf.status, HEMLIGT)) {
return 1;
}
if(!(tmpConf.status & SLUTET)) {
if(EditBitFlagShort("\r\nSka alla användare bli medlemmar automagiskt?", 'j', 'n',
"Ja", "Nej", &tmpConf.status, AUTOMEDLEM)) {
return 1;
}
if(EditBitFlagShort("\r\nSka rättigheterna styra skrivmöjlighet?", 'j', 'n',
"Ja", "Nej", &tmpConf.status, SKRIVSTYRT)) {
return 1;
}
if(tmpConf.status & SKRIVSTYRT) {
SendString("\r\nVilka grupper ska ha tillgång till mötet? (? för lista)\r\n");
if(editgrupp((char *)&tmpConf.grupper)) {
return 1;
}
}
}
if(EditBitFlagShort("\r\nSka mötet enbart kommas åt från ARexx?", 'j', 'n',
"Ja", "Nej", &tmpConf.status, SUPERHEMLIGT)) {
return 1;
}
SendString("\n\n\rVilken typ av möte ska det vara?\n\r");
SendString("1: Lokalt möte\n\r");
SendString("2: Fido-möte\n\n\r");
SendString("Val: ");
for(;;) {
ch = GetChar();
if(ch == GETCHAR_LOGOUT) {
return 1;
}
if(ch == '1' || ch == '2') {
break;
}
}
if(ch == '1') {
SendString("Lokalt möte\n\n\r");
tmpConf.type = MOTE_ORGINAL;
//.........這裏部分代碼省略.........
示例15: W
void MSA::ToAlnFile(TextFile &File) const
{
if (getMuscleContext()->params.g_bClwStrict)
File.PutString("CLUSTAL W (1.81) multiple sequence alignment\n");
else
{
File.PutString("MUSCLE ("
MUSCLE_MAJOR_VERSION "." MUSCLE_MINOR_VERSION ")"
" multiple sequence alignment\n");
File.PutString("\n");
}
int iLongestNameLength = 0;
for (unsigned uSeqIndex = 0; uSeqIndex < GetSeqCount(); ++uSeqIndex)
{
const char *ptrName = GetSeqName(uSeqIndex);
const char *ptrBlank = strchr(ptrName, ' ');
int iLength;
if (0 != ptrBlank)
iLength = (int) (ptrBlank - ptrName);
else
iLength = (int) strlen(ptrName);
if (iLength > iLongestNameLength)
iLongestNameLength = iLength;
}
if (iLongestNameLength > MAX_NAME)
iLongestNameLength = MAX_NAME;
if (iLongestNameLength < MIN_NAME)
iLongestNameLength = MIN_NAME;
unsigned uLineCount = (GetColCount() - 1)/uCharsPerLine + 1;
for (unsigned uLineIndex = 0; uLineIndex < uLineCount; ++uLineIndex)
{
File.PutString("\n");
unsigned uStartColIndex = uLineIndex*uCharsPerLine;
unsigned uEndColIndex = uStartColIndex + uCharsPerLine - 1;
if (uEndColIndex >= GetColCount())
uEndColIndex = GetColCount() - 1;
char Name[MAX_NAME+1];
for (unsigned uSeqIndex = 0; uSeqIndex < GetSeqCount(); ++uSeqIndex)
{
const char *ptrName = GetSeqName(uSeqIndex);
const char *ptrBlank = strchr(ptrName, ' ');
int iLength;
if (0 != ptrBlank)
iLength = (int) (ptrBlank - ptrName);
else
iLength = (int) strlen(ptrName);
if (iLength > MAX_NAME)
iLength = MAX_NAME;
memset(Name, ' ', MAX_NAME);
memcpy(Name, ptrName, iLength);
Name[iLongestNameLength] = 0;
File.PutFormat("%s ", Name);
for (unsigned uColIndex = uStartColIndex; uColIndex <= uEndColIndex;
++uColIndex)
{
const char c = GetChar(uSeqIndex, uColIndex);
File.PutFormat("%c", toupper(c));
}
File.PutString("\n");
}
memset(Name, ' ', MAX_NAME);
Name[iLongestNameLength] = 0;
File.PutFormat("%s ", Name);
for (unsigned uColIndex = uStartColIndex; uColIndex <= uEndColIndex;
++uColIndex)
{
const char c = GetAlnConsensusChar(*this, uColIndex);
File.PutChar(c);
}
File.PutString("\n");
}
}