Exemple #1
0
void Key()
{
	char keyvalue;
	keyvalue=ReadKey();
	if(keyvalue!=0x00)
	{
		keyvalue=ReadKey();
		while(ReadKey()!=0x00){}
	}
	if(keyvalue!=0x00)
	{
		switch(keyvalue)	//只处理单个键按下的情况,多个键按下不识别,当作没有键按下
		{
			case 0x01:KeyNum=1;break;
			case 0x02:KeyNum=2;break;
			case 0x04:KeyNum=3;break;
			case 0x08:KeyNum=4;break;
			case 0x10:KeyNum=5;break;
			case 0x20:KeyNum=6;break;
			case 0x40:KeyNum=7;break;
			case 0x80:KeyNum=8;break;
			default:KeyNum=0;break;
		}
	}
	else KeyNum=0;
	if(KeyNum==3) Count++;
	else if(KeyNum==7) Count--;
	else{}
}
Exemple #2
0
void CSTMInput::ReadKeys()
{
  ReadKey(KEY_JOYSTICK_SEL);
  ReadKey(KEY_JOYSTICK_UP);
  ReadKey(KEY_JOYSTICK_DOWN);
  ReadKey(KEY_JOYSTICK_LEFT);
  ReadKey(KEY_JOYSTICK_RIGHT);
}
/*******************************************************************************
* Function Name  : Mass_Storage_Start
* Description    : Starts the mass storage demo.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Mass_Storage_Start (void)
{
  /* Disble the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);

  /* Clear the LCD screen */
  LCD_Clear(White);

  LCD_SetDisplayWindow(160, 223, 128, 128);
 
  LCD_DrawBMP(0x00647C00);

  /* Disable LCD Window mode */
  LCD_WindowModeDisable();
  
  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White); 

  if(MSD_Init() != 0x00)
  {
    LCD_DisplayStringLine(Line8, " No MSD Card Present");
    LCD_DisplayStringLine(Line9, "  To exit Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }
  }
  else
  {
    Get_Medium_Characteristics();

    /* Display the "  Plug the USB   " message */
    LCD_DisplayStringLine(Line8, " Plug the USB Cable ");
    LCD_DisplayStringLine(Line9, "Exit:  Push JoyStick");
    
    /* Intialize the USB cell */
    USB_Init();
  
    LCD_ClearLine(Line9);
    /* Display the "To stop Press SEL" message */
    LCD_DisplayStringLine(Line8, "  To stop Press SEL ");

    /* Loop until SEL key pressed */
    while(ReadKey() != SEL)
    {
    }

    PowerOff();
  }
  LCD_Clear(White);
  DisplayMenu();
  IntExtOnOffConfig(ENABLE);
  /* Flush SPI1 Data Register */
  SPI_I2S_ReceiveData(SPI1);
}
Exemple #4
0
// read configuration either from INI file (if it exists) or from the registry
int DHCPReadConfig ( )
{
int   Ark;
char szBuf[128];

   memset (& sParamDHCP, 0, sizeof sParamDHCP);
   sParamDHCP.nLease = DHCP_DEFAULT_LEASE_TIME;

   for (Ark=0 ; Ark<SizeOfTab (tDHCPd32Entry) ; Ark++)
        ReadKey (  TFTPD32_DHCP_KEY, 
                   tDHCPd32Entry [Ark].szEntry,
                   tDHCPd32Entry [Ark].pValue,
                   tDHCPd32Entry [Ark].nBufSize,
                   tDHCPd32Entry [Ark].nType,
                   szTftpd32IniFile );
    // custom items
   for (Ark=0 ; Ark < SizeOfTab (sParamDHCP.t) ; Ark++)
   {
      wsprintf (szBuf, "%s%d", KEY_DHCP_USER_OPTION_NB, Ark+1);
      ReadKey  (TFTPD32_DHCP_KEY, szBuf, & sParamDHCP.t[Ark].nAddOption, 
                sizeof sParamDHCP.t[Ark].nAddOption, REG_DWORD, szTftpd32IniFile);

       wsprintf (szBuf, "%s%d", KEY_DHCP_USER_OPTION_VALUE, Ark+1);
       ReadKey  (TFTPD32_DHCP_KEY,  szBuf, sParamDHCP.t[Ark].szAddOption, 
                 sizeof sParamDHCP.t[Ark].szAddOption, REG_SZ, szTftpd32IniFile);
   }

   if ( sParamDHCP.nPoolSize!=0 )
   {
	  tFirstIP = malloc (sParamDHCP.nPoolSize * sizeof *tFirstIP[0]) ;
	  tMAC = malloc (sParamDHCP.nPoolSize * sizeof *tMAC[0]) ; 
	  if (tFirstIP == NULL  ||  tMAC == NULL ) 
	   {
			SVC_ERROR ("Can not allocate memory");
			return FALSE;
	   }
	   LoadLeases ();
   }

   if (sParamDHCP.nLease==0)
   {  
      sParamDHCP.nLease=DHCP_DEFAULT_LEASE_TIME;
      LOG (12, "%d, Lease time not specified, set to 2 days", GetCurrentThreadId ());
   }
   // compatability 3 -> 4
   if (sParamDHCP.szWins[0]==0  && sParamDHCP.szDns1[0]!=0)
   {
      lstrcpy (sParamDHCP.szWins, sParamDHCP.szDns1);
      LOG (0, "WINS server copied from DNS servers");
   }

return TRUE;
} // DHCPReadConfig
Exemple #5
0
char Proc_TP_Adj(char *NC)
{
  unsigned int temp[8]                               ;
  Color     = Green                                  ;
  Color_BK  = Black                                  ;
  TP_Init()                                          ;
  Clear_LCD(Color_BK)                                ; 
  PutStringCN24(58,120,"触摸屏校正")                 ;
  Color     = Cyan                                   ;
  PutStringCN16(30,165,"请用触控笔点测试点中心")     ;
  for(;;)
  {
    Draw_Test_Point(20,20,Yellow)                    ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[0],&temp[1]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,0,40,40,Color_BK)                 ;
    Wait_Pen_Up()                                    ;
  
    Draw_Test_Point(220,20,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[2],&temp[3]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,0,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(20,300,Yellow)                   ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[4],&temp[5]))  break    ;
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(0,280,40,40,Color_BK)               ;
    Wait_Pen_Up()                                    ;
    
    Draw_Test_Point(220,300,Yellow)                  ;
    for(;;)
    {
      if(Read_TP_Twice(&temp[6],&temp[7]))  break    ;       
      if(ReadKey()==Cancel)  return 0x00             ;
    }
    DrawRectFill(200,280,40,40,Color_BK)             ;
    Wait_Pen_Up()                                    ;
    if(TP_Adjust(temp))         break                ;
  }
  return 0x00                                        ;
}
/*******************************************************************************
* Function Name  : MASS_init
* Description    : Mass Storage init routine.
* Input          : None.
* Output         : None.
* Return         : None.
*******************************************************************************/
void MASS_init()
{
  pInformation->Current_Configuration = 0;

  /* Connect the device */
  PowerOn();

  /* USB interrupts initialization */
  /* clear pending interrupts */
  _SetISTR(0);
  wInterrupt_Mask = IMR_MSK;
  /* set interrupts mask */
  _SetCNTR(wInterrupt_Mask);
  pInformation->Current_Feature = MASS_ConfigDescriptor[7];

  /* Wait until device is configured */
  while (pInformation->Current_Configuration == 0)
  {
    NOP_Process();
    if(ReadKey() != NOKEY)
    {
      return;
    }
  }
  bDeviceState = CONFIGURED;
}
Exemple #7
0
/////////////////////////////////////////////////////////
// Read settings :
// Parse the settings table and call ReadKey
/////////////////////////////////////////////////////////
BOOL Tftpd32ReadSettings (void)
{
int Ark, Rc=TRUE;
char szCurDir[_MAX_PATH];
   for (Ark=0 ;   Ark< SizeOfTab (tTftpd32Entry) ;   Ark++)
     ReadKey (   TFTPD32_MAIN_KEY, 
                 tTftpd32Entry[Ark].szEntry,
                 tTftpd32Entry[Ark].pValue,
                 tTftpd32Entry[Ark].nBufSize,
                 tTftpd32Entry[Ark].nType,
                 szTftpd32IniFile );
  if (sSettings.uServices == TFTPD32_NONE)  sSettings.uServices = TFTPD32_ALL_SERVICES;
  
    // field WorkingDirectory : 
    // try env variable then szBaseDir and current dir
    if (    GetEnvironmentVariable (TFTP_DIR, szCurDir, sizeof szCurDir) != 0 
         && IsValidDirectory ( szCurDir ) )
                GetFullPathName ( szCurDir, 
                                  sizeof sSettings.szWorkingDirectory,
                                  sSettings.szWorkingDirectory, 
                                  NULL );
    else if ( IsValidDirectory ( sSettings.szBaseDirectory ) )
                GetFullPathName ( sSettings.szBaseDirectory, 
                                  sizeof sSettings.szWorkingDirectory,
                                  sSettings.szWorkingDirectory, 
                                  NULL );
    else        GetCurrentDirectory ( sizeof sSettings.szWorkingDirectory,
                                       sSettings.szWorkingDirectory );
// release for the Australian Department of defence
#ifdef BAE_SYSTEMS_LEN_WHITE
  sSettings.uServices = TFTPD32_TFTP_SERVER;
#endif
return Rc;
} // Tftpd32ReadSettings
int main(int argc, char **argv)
{
	FILE *f;
	double atk,def;
	int t=0;
	
	InitSystem();
	
	Bpp=4;
	XRes=800+XR; YRes=400; 

	ScreenBuf=(unsigned char*)malloc(XRes*YRes*Bpp);
	memset(ScreenBuf,0,XRes*YRes*Bpp);
	InitSDL();	
	
	while (1)
	{
		int Ch=ReadKey();
		
		if (Ch=='q') exit(0);
		Iterate();
		Survey(&atk,&def);
		
		f=fopen("output.txt","a");
		fprintf(f,"%d %.6g %.6g\n",t,atk,def);
		fclose(f);
		t++;
	}
}
Exemple #9
0
/*******************************************************************************
* Function Name  : Alarm_Adjust
* Description    : Adjusts an alarm event to occurs within the current day.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Alarm_Adjust(void)
{
  /* Disable the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);

  while(ReadKey() != NOKEY)
  {
  }
  
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  /* Clear the LCD screen */
  LCD_Clear(White);

  LCD_SetDisplayWindow(160, 223, 128, 128);
 
  LCD_NORDisplay(ALARM_ICON);
  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  /* Disable LCD Window mode */
  LCD_WindowModeDisable();
  
  Alarm_PreAdjust();

  /* Clear the LCD */
  LCD_Clear(White);
  /* Display the menu */
  DisplayMenu();
  /* Enable the JoyStick interrupts */
  IntExtOnOffConfig(ENABLE);  
}
std::string
GetVisItInstallationDirectory(const char *version)
{
#if defined(_WIN32)
    // Get the installation dir for the specified from the registry.
    char *visitHome = 0;
    std::string installDir("C:\\");
    if(ReadKey(version, "VISITHOME", &visitHome) == 1)
    {
        installDir = visitHome;
    }
    else
    {
        // try the environment
        const std::string idir = Environment::get("VISITHOME");
        if (!idir.empty())
        {
            installDir = idir;
        }
        else
        {
            // get the path for this process
            char tmpdir[MAX_PATH];
            if (GetModuleFileName(NULL, tmpdir, MAX_PATH) != 0)
            {
                std::string visitpath(tmpdir);
                size_t lastSlash = visitpath.rfind("\\");
                if(lastSlash != std::string::npos)
                    installDir = visitpath.substr(0, lastSlash);
                else
                    installDir = visitpath;
            }
        }
    }
    if (visitHome != 0)
        free(visitHome);
    return installDir;
#else
    // Get the installation dir for the version that's running. They all use
    // the same "visit" script so it's okay to do this.
    std::string installDir("/usr/local/visit");
    const std::string idir = Environment::get("VISITHOME");
    if(!idir.empty())
    {
        if(isDevelopmentVersion)
            installDir = idir;
        else
        {
            // The directory often has a "/bin" on the end. Strip it off.
            std::string home(idir);
            int lastSlash = home.rfind("/");
            if(lastSlash != -1)
                installDir = home.substr(0, lastSlash);
            else
                installDir = idir;
        }
    }
    return installDir;
#endif
}
Exemple #11
0
bool CDVDSession::GetDiscKey()
{
    if (m_session == DVD_END_ALL_SESSIONS) {
        return false;
    }

    BYTE DiscKeys[2048];
    if (!ReadKey(DvdDiskKey, DiscKeys)) {
        return false;
    }

    for (int i = 0; i < g_nPlayerKeys; i++) {
        for (int j = 1; j < 409; j++) {
            BYTE DiscKey[6];
            memcpy(DiscKey, &DiscKeys[j * 5], 5);
            DiscKey[5] = 0;

            CSSdisckey(DiscKey, g_PlayerKeys[i]);

            BYTE Hash[6];
            memcpy(Hash, &DiscKeys[0], 5);
            Hash[5] = 0;

            CSSdisckey(Hash, DiscKey);

            if (!memcmp(Hash, DiscKey, 6)) {
                memcpy(m_DiscKey, DiscKey, 6);
                return true;
            }
        }
    }

    return false;
}
Exemple #12
0
STATIC int _QuerySaveState(void)
{
     _UpdateInterfaceState();
     
     while (KeyPressed())
     {
        if (ReadKey() == STOPKEY)
        {
           UnLockMouse();
           DrawFunctionKey(1, "help");
           if (QueryUserStop())
           {
              StopDefragmentationProcess(); /* Just sets a variable in
                                               main\actions.c           */
              LockMouse(1, 1, 80, 25);
              DrawFunctionKey(3, "stop");
              return TRUE;
           }
           else
           {
              LockMouse(1, 1, 80, 25);
              DrawFunctionKey(3, "stop");
              return FALSE;
           }
        }
     }

     return FALSE;
}
Exemple #13
0
int Bitmaps::ReadData()
{
	this->GetSquareSize();
	int start = this->_squareSize / 2;

	if (!ReadKey())
	{
		printf("invalid key\n");
		return 0;
	}
	ReadOne();

	int i = start*4;
	int a;
	int r;
	int b;
	int g;
	r = b = g = -1;
	for(a=0;a<this->_n_squares;a++)
	{
		r = this->_data[i+2];
		g = this->_data[i+1];
		b = this->_data[i];
		//printf("Read data = R:%d G:%d B:%d\n",r,g,b);
		i = i + this->_squareSize *4;
	}
	return a;
}
Exemple #14
0
int GTIFImport(GTIF *gtif, GTIFReadMethod scan,void *aux)
{
    int status;
    char message[1024];

    if (!scan) scan = (GTIFReadMethod) &DefaultRead;
    if (!aux) aux=stdin;

    scan(message,aux);
    if (strncmp(message,FMT_GEOTIFF,8)) return 0;
    scan(message,aux);
    if (!sscanf(message,FMT_VERSION,(short int*)&gtif->gt_version)) return 0;
    scan(message,aux);
    if (sscanf(message,FMT_REV,(short int*)&gtif->gt_rev_major,
               (short int*)&gtif->gt_rev_minor) !=2) return 0;

    scan(message,aux);
    if (strncmp(message,FMT_TAGS,8)) return 0;
    while ((status=ReadTag(gtif,scan,aux))>0);
    if (status < 0) return 0;

    scan(message,aux);
    if (strncmp(message,FMT_KEYS,8)) return 0;
    while ((status=ReadKey(gtif,scan,aux))>0);

    return (status==0); /* success */
}
/**
  * @brief  Calibration of External crystal oscillator manually
  * @param  None
  * @retval : None
  */
void ManualClockCalibration(void)
{
  UpDownIntOnOffConfig(ENABLE);
  RightLeftIntExtOnOffConfig(ENABLE);
  SelIntExtOnOffConfig(DISABLE);
  LCD_Clear(Blue2);
  BKP_TamperPinCmd(DISABLE);
  BKP_RTCOutputConfig(BKP_RTCOutputSource_CalibClock);
  LCD_DisplayString(Line1,Column5,"Calibration");
  LCD_DisplayString(Line3,Column0,"LSE/64 is available");
  LCD_DisplayString(Line4,Column0,"on PC13.Measure the");
  LCD_DisplayString(Line5,Column0,"the frequency and");
  LCD_DisplayString(Line6,Column0,"press Sel to proceed");
  
  while(ReadKey()!=SEL)
  {
  }
  
  LCD_Clear(Blue2);
  BKP_RTCOutputConfig(BKP_RTCOutputSource_None);
  LCD_DisplayString(Line1,Column4,"Please enter");
  LCD_DisplayString(Line2,Column2,"Calibration Value");
  LCD_DisplayCount(Line4,Column6,1,ArrayTime[0]+0x30);
  LCD_DisplayCount(Line4,Column7,0,ArrayTime[1]+0x30);
  LCD_DisplayCount(Line4,Column8,0,ArrayTime[2]+0x30);
  LCD_DisplayString(Line6,Column6,"(0-121)");
  LCD_SetBackColor(Green);
  SelIntExtOnOffConfig(ENABLE);
}
Exemple #16
0
/**
  * @brief  Reads digit entered by user, using menu navigation keys.
  * @param  None
  * @retval Digit value
  */
uint8_t ReadDigit(uint16_t LineBegin, uint16_t ColBegin, uint8_t CountBegin, uint8_t ValueMax, uint8_t ValueMin)
{
  uint8_t tmpValue = 0;
  Button_TypeDef keystate = (Button_TypeDef)10;

  /* Set the Back Color */
  LCD_SetBackColor(LCD_COLOR_RED);

  /* Set the Text Color */
  LCD_SetTextColor(LCD_COLOR_WHITE);

  /* Initialize tmpValue */
  tmpValue = CountBegin;

  /* Display  */
  LCD_DisplayChar(LineBegin, ColBegin, (tmpValue + 0x30));

  /* Endless loop */
  while(1)
  {
    /* Get the Joytick State */
    keystate = ReadKey();

    /* If "BUTTON_TAMPER" push button is pressed */
    if(keystate == BUTTON_TAMPER)
    {
      /* Increase the value of the digit */
      if(tmpValue == ValueMax)
      {
        tmpValue = (ValueMin - 1);
      }
      /* Display new value */
      LCD_DisplayChar(LineBegin, ColBegin,((++tmpValue) + 0x30));
    }
    /* If "BUTTON_WAKEUP" push button is pressed */
    if(keystate == BUTTON_WAKEUP)
    {
      /* Decrease the value of the digit */
      if(tmpValue == ValueMin)
      {
        tmpValue = (ValueMax + 1);
      }
      /* Display new value */
      LCD_DisplayChar(LineBegin, ColBegin,((--tmpValue) + 0x30));
    }
    /* If "BUTTON_KEY" push button is pressed */
    if(keystate == BUTTON_KEY)
    {
      /* Set the Back Color */
      LCD_SetBackColor(LCD_COLOR_WHITE);
      /* Set the Text Color */
      LCD_SetTextColor(LCD_COLOR_RED);
      /* Display new value */
      LCD_DisplayChar(LineBegin, ColBegin, (tmpValue + 0x30));
      /* Return the digit value and exit */
      return tmpValue;
    }
  }
}
unsigned int GetKey(void) {
 unsigned int c;
 unsigned int r;
 c=(unsigned int)ReadKey();
 if (!c) return 0;
 r=(c&0x80)?0x80000000:0;
 c&=~0x80;
 if (c>=2 && c<=11)
   c=keys0[c-2];
 else if (c>=15 && c<=27) 
   c=keys1[c-15];
 else if (c>=30 && c<=40) 
   c=keys2[c-30];
 else if (c>=44 && c<=53) 
   c=keys3[c-44];
 else 
  switch (c) {
   case 57: c=' '; break;
   case 77: c=KEY_RIGHTARROW; break;
   case 75: c=KEY_LEFTARROW; break;
   case 72: c=KEY_UPARROW; break;
   case 80: c=KEY_DOWNARROW; break;
   case 1: c=KEY_ESCAPE; break;
   case 28: c=KEY_ENTER; break;
   case 9: c=KEY_TAB; break;
   case 58: c=KEY_CAPSLOCK; break;
   case 59: c=KEY_F1; break;
   case 60: c=KEY_F2; break;
   case 61: c=KEY_F3; break;
   case 62: c=KEY_F4; break;
   case 63: c=KEY_F5; break;
   case 64: c=KEY_F6; break;
   case 65: c=KEY_F7; break;
   case 66: c=KEY_F8; break;
   case 67: c=KEY_F9; break;
   case 68: c=KEY_F10; break;
   case 87: c=KEY_F11; break;
   case 88: c=KEY_F12; break;
   case 14: c=KEY_BACKSPACE; break;
   case 69: c=KEY_PAUSE; break;
   case 13: c=KEY_EQUALS; break;
   case 12: c=KEY_MINUS; break;
   case 42: c=KEY_RSHIFT; break;
   case 29: c=KEY_RCTRL; break;
   case 56: c=KEY_RALT; break;
   case 0x35: c=KEY_FIVE; break;
   case 0x36: c=KEY_SIX; break;
   case 0x37: c=KEY_SEVEN; break;
//   case 0x38: c=KEY_EIGHT; break;
//   case 0x39: c=KEY_NINE; break;
   case 0x30: c=KEY_ZERO; break;
   case 0x5C: c=KEY_BACKSLASH; break;
   case 71: c=KEY_HOME; break;
   case 79: c=KEY_END; break;
   case 73: c=KEY_PGUP; break;
   case 81: c=KEY_PGDN; break;
  }
 return (c|r);   
}
Exemple #18
0
bool CDVDSession::Authenticate()
{
    if (m_session == DVD_END_ALL_SESSIONS) {
        return false;
    }

    BYTE Challenge[10], Key[10];

    for (BYTE i = 0; i < 10; i++) {
        Challenge[i] = i;
    }

    if (!SendKey(DvdChallengeKey, Challenge)) {
        return false;
    }

    if (!ReadKey(DvdBusKey1, Key)) {
        return false;
    }

    int varient = -1;

    for (int i = 31; i >= 0; i--) {
        BYTE KeyCheck[5];
        CSSkey1(i, Challenge, KeyCheck);
        if (!memcmp(KeyCheck, Key, 5)) {
            varient = i;
        }
    }

    if (!ReadKey(DvdChallengeKey, Challenge)) {
        return false;
    }

    CSSkey2(varient, Challenge, &Key[5]);

    if (!SendKey(DvdBusKey2, &Key[5])) {
        return false;
    }

    CSSbuskey(varient, Key, m_SessionKey);

    return true;
}
Exemple #19
0
/*******************************************************************************
* Function Name  : ReadDigit
* Description    : Reads digit entered by user, using menu navigation keys.
* Input          : None
* Output         : None
* Return         : Digit value
*******************************************************************************/
uint8_t ReadDigit(uint8_t ColBegin, uint8_t CountBegin, uint8_t ValueMax, uint8_t ValueMin)
{
  uint32_t MyKey = 0, tmpValue = 0;

  /* Set the Back Color */
  LCD_SetBackColor(Red);
  /* Set the Text Color */
  LCD_SetTextColor(White);

  /* Initialize tmpValue */
  tmpValue = CountBegin;
  /* Display  */
  LCD_DisplayChar(Line8, ColBegin, (tmpValue + 0x30));

  /* Endless loop */
  while(1)
  {
    /* Check which key is pressed */
    MyKey = ReadKey();

    /* If "UP" pushbutton is pressed */
    if(MyKey == UP)
    {
      /* Increase the value of the digit */
      if(tmpValue == ValueMax)
      {
        tmpValue = (ValueMin - 1);
      }
      /* Display new value */
      LCD_DisplayChar(Line8, ColBegin,((++tmpValue) + 0x30));
    }
    /* If "DOWN" pushbutton is pressed */
    if(MyKey == DOWN)
    {
      /* Decrease the value of the digit */
      if(tmpValue == ValueMin)
      {
        tmpValue = (ValueMax + 1);
      }
      /* Display new value */
      LCD_DisplayChar(Line8, ColBegin,((--tmpValue) + 0x30));
    }
    /* If "SEL" pushbutton is pressed */
    if(MyKey == SEL)
    {
      /* Set the Back Color */
      LCD_SetBackColor(White);
      /* Set the Text Color */
      LCD_SetTextColor(Red);
      /* Display new value */
      LCD_DisplayChar(Line8, ColBegin, (tmpValue + 0x30));
      /* Return the digit value and exit */
      return tmpValue;
    }
  } 
}
int KeyUp(ALLEGRO_EVENT *toEvent)
{
    int nTecla = 0;

    if (toEvent->type == ALLEGRO_EVENT_KEY_UP)
    {
        nTecla = ReadKey(toEvent->keyboard.keycode);
    }
    return nTecla;
}
Exemple #21
0
 int Shortcut::IsHit() {
     unsigned int s = 0;
     for( unsigned int i = 0; i < keys.size(); ++i ) {
         s += ReadKey( keys[i] );
     }
     if( s > keys.size() ) {
         return true;
     }
     return false;
 }
Exemple #22
0
/*******************************************************************************
* Function Name  : RegulateMonth
* Description    : Regulates month.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
static void RegulateMonth(void)
{
  uint32_t tmpValue = 0;
  uint32_t MyKey = 0;

  /* Initialize tmpValue */
  tmpValue = date_s.month;

  /* Endless loop */
  while(1)
  {
    /* Check which key is pressed */
    MyKey = ReadKey();

    /* If "UP" pushbutton is pressed */
    if(MyKey == UP)
    {
      /* Increase the value of the digit */
      if(tmpValue == 12)
      {
        tmpValue = 0;
      }
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);
      Date_Display(date_s.year, ++tmpValue, date_s.day);
    }
    /* If "DOWN" pushbutton is pressed */
    if(MyKey == DOWN)
    {
      /* Decrease the value of the digit */
      if(tmpValue == 1)
      {
        tmpValue = 13;
      }
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);     
      /* Display new value */
      Date_Display(date_s.year, --tmpValue, date_s.day);
    }
    /* If "SEL" pushbutton is pressed */
    if(MyKey == SEL)
    {
      LCD_ClearLine(Line3);
      LCD_ClearLine(Line7);
      LCD_ClearLine(Line8);     
      /* Display new value */
      Date_Display(date_s.year, tmpValue, date_s.day);
      /* Return the digit value and exit */
      date_s.month = tmpValue;
      return;
    }
  }
}
Exemple #23
0
void CLFE_Input::CaptureKeyboard()
{
    if(m_bBuffered)
    {
        ReadKeyBuffered();
    }
    else
    {
        ReadKey();
    }
}
Exemple #24
0
uint64_t cKbdRemote::ReadKeySequence(void)
{
  uint64_t k = 0;
  int key1;

  if ((key1 = ReadKey()) >= 0) {
     k = key1;
     if (key1 == 0x1B) {
         // Start of escape sequence
         if ((key1 = ReadKey()) >= 0) {
            k <<= 8;
            k |= key1 & 0xFF;
            switch (key1) {
              case 0x4F: // 3-byte sequence
                   if ((key1 = ReadKey()) >= 0) {
                      k <<= 8;
                      k |= key1 & 0xFF;
                      }
                   break;
              case 0x5B: // 3- or more-byte sequence
                   if ((key1 = ReadKey()) >= 0) {
                      k <<= 8;
                      k |= key1 & 0xFF;
                      switch (key1) {
                        case 0x31 ... 0x3F: // more-byte sequence
                        case 0x5B: // strange, may apparently occur
                             do {
                                if ((key1 = ReadKey()) < 0)
                                   break; // Sequence ends here
                                k <<= 8;
                                k |= key1 & 0xFF;
                                } while (key1 != 0x7E);
                             break;
                        default: ;
                        }
                      }
                   break;
              default: ;
              }
            }
/*******************************************************************************
* Function Name  : Mass_Storage_Recovery
* Description    : Erases the NAND Flash Content.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void Mass_Storage_Recovery (void)
{
  /* Disble the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);


  while(ReadKey() != NOKEY)
  {
  }

  LCD_Clear(White);

  RCC_AHBPeriphClockCmd(RCC_AHBPeriph_FSMC, ENABLE);
  
  /* Set the Back Color */
  LCD_SetBackColor(Blue);
  /* Set the Text Color */
  LCD_SetTextColor(White); 

  LCD_DisplayStringLine(Line4, " Erase NAND Content ");
  LCD_DisplayStringLine(Line5, "Please wait...      ");
 
  /* FSMC Initialization */
  FSMC_NAND_Init();

  NAND_Format();

  /* Display the "To stop Press SEL" message */
  LCD_DisplayStringLine(Line4, "     NAND Erased    ");
  LCD_DisplayStringLine(Line5, "  To exit Press SEL ");

  /* Loop until SEL key pressed */
  while(ReadKey() != SEL)
  {
  }
  
  LCD_Clear(White);
  DisplayMenu();
  IntExtOnOffConfig(ENABLE);
}
Exemple #26
0
TMemberIndex CObjectIStreamJson::BeginClassMember(const CClassTypeInfo* classType,
                                      TMemberIndex pos)
{
    TMemberIndex first = classType->GetMembers().FirstIndex();
    TMemberIndex last = classType->GetMembers().LastIndex();
    if (m_RejectedTag.empty()) {
        if (pos == first) {
            if (classType->GetMemberInfo(first)->GetId().IsAttlist()) {
                TopFrame().SetNotag();
                return first;
            }
        }
    }

    if ( !NextElement() ) {
        if (pos == last &&
            classType->GetMemberInfo(pos)->GetId().HasNotag() &&
            classType->GetMemberInfo(pos)->GetTypeInfo()->GetTypeFamily() == eTypeFamilyPrimitive) {
            TopFrame().SetNotag();
            return pos;
        }
        return kInvalidMember;
    }
    char c = PeekChar();
    if (m_RejectedTag.empty() && (c == '[' || c == '{')) {
        for (TMemberIndex i = pos; i <= last; ++i) {
            if (classType->GetMemberInfo(i)->GetId().HasNotag()) {
                TopFrame().SetNotag();
                return i;
            }
        }
    }
    string tagName = ReadKey();
    if (tagName[0] == '#') {
        tagName = tagName.substr(1);
        TopFrame().SetNotag();
    }
    bool deep = false;
    TMemberIndex ind = FindDeep(classType->GetMembers(), tagName, deep);
    if (deep) {
        if (ind != kInvalidMember) {
            TopFrame().SetNotag();
        }
        UndoClassMember();
    } else if (ind != kInvalidMember) {
        if (classType->GetMembers().GetItemInfo(ind)->GetId().HasAnyContent()) {
            UndoClassMember();
        }
    }
    return ind;
}
Exemple #27
0
// Assignation by MAC Address
DWORD DHCP_StaticAssignation (struct dhcp_packet *pPkt)
{
char          szIP[20];

return ( pPkt->htype==HTYPE_ETHER || pPkt->htype==HTYPE_IEEE802 )
        && pPkt->hlen==6
        && ReadKey ( TFTPD32_DHCP_KEY, 
                     haddrtoa(pPkt->chaddr, pPkt->hlen,':'), 
                     szIP, sizeof szIP, 
                     REG_SZ, 
                     szTftpd32IniFile )
        ?  inet_addr (szIP) : INADDR_NONE;

} // DHCP_StaticAssignation
Exemple #28
0
void CObjectIStreamJson::ReadAnyContentObject(CAnyContentObject& obj)
{
    obj.Reset();
    string value;
    string name = ReadKey();
    obj.SetName(name);
    if (PeekChar(true) == '{') {
        StartBlock('{');        
        while (NextElement()) {
            name = ReadKey();
            value = ReadValue();
            if (name[0] != '#') {
                obj.AddAttribute(name,kEmptyStr,value);
            } else {
                obj.SetValue(value);
            }
        }
        EndBlock('}');
        return;
    }
    value = ReadValue();
    obj.SetValue(value);
}
Exemple #29
0
int dutyCycle(){
    int keypadData;
    int keypadData1;
    int keypadData2;
    int keypadData3;
    DDRB = 0xFF;
    DDRJ = 0x02;

        keypadData1 = ReadKey();
        keypadData1 = keypadData1*100;

        keypadData2 = ReadKey();
        keypadData2 = keypadData2*10;

        keypadData3 = ReadKey();
        keypadData = keypadData1+keypadData2+keypadData3;

        PWMDTY1 = keypadData; //DTY/PER


    return keypadData;

}
/*******************************************************************************
* Function Name  : EnterSTANDBYMode_RTCAlarm
* Description    : Enters MCU in STANDBY mode. The wake-up from STANDBY mode is 
*                  performed by an RTC Alarm event.
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void EnterSTANDBYMode_RTCAlarm(void)
{
  uint32_t tmp = 0;

  LCD_Clear(White);
  /* Set the LCD Back Color */
  LCD_SetBackColor(Blue);

  /* Set the LCD Text Color */
  LCD_SetTextColor(White);

  /* Disable the JoyStick interrupts */
  IntExtOnOffConfig(DISABLE);
  if(BKP_ReadBackupRegister(BKP_DR1) != 0xA5A5)
  {
    LCD_DisplayStringLine(Line1, "Time and Date are   ");
    LCD_DisplayStringLine(Line2, "not configured,     ");
    LCD_DisplayStringLine(Line3, "please go to the    ");
    LCD_DisplayStringLine(Line4, "calendar menu and   ");
    LCD_DisplayStringLine(Line5, "set the time and    ");
    LCD_DisplayStringLine(Line6, "date parameters.    ");
    LCD_DisplayStringLine(Line7, "Press JoyStick to   ");
    LCD_DisplayStringLine(Line8, "continue...         ");
    while(ReadKey() == NOKEY)
    {
    }
    /* Clear the LCD */
    LCD_Clear(White);
    /* Display the previous menu */
    DisplayMenu();
    /* Enable the JoyStick interrupts */
    IntExtOnOffConfig(ENABLE);
    return;
  }
  
  tmp = RTC_GetCounter();

  /* Save the Alarm value in the Backup register */
  BKP_WriteBackupRegister(BKP_DR6, (tmp & 0x0000FFFF));
  BKP_WriteBackupRegister(BKP_DR7, (tmp >> 16));

  Alarm_PreAdjust();

  LCD_DisplayStringLine(Line7, " MCU in STANDBY Mode");
  LCD_DisplayStringLine(Line8, " Wait For RTC Alarm ");

  /* Request to enter STANDBY mode (Wake Up flag is cleared in PWR_EnterSTANDBYMode function) */
  PWR_EnterSTANDBYMode();
}