本文整理汇总了C++中BSP_JOY_GetState函数的典型用法代码示例。如果您正苦于以下问题:C++ BSP_JOY_GetState函数的具体用法?C++ BSP_JOY_GetState怎么用?C++ BSP_JOY_GetState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BSP_JOY_GetState函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Joystick_exti_demo
/**
* @brief Joystick Exti demo
* @param None
* @retval None
*/
void Joystick_exti_demo (void)
{
uint8_t status = 0;
uint32_t ITstatus = 0;
Joystick_SetHint(1);
status = BSP_JOY_Init(JOY_MODE_EXTI);
if (status != IO_OK)
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 95, (uint8_t *)"ERROR", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 80, (uint8_t *)"Joystick cannot be initialized", CENTER_MODE);
}
if (status == IO_OK)
{
Joystick_SetCursorPosition();
}
while (1) /* pull for USER button in GPIO mode */
{
if (status == IO_OK)
{
if (MfxExtiReceived == 1)
{
MfxExtiReceived = 0;
ITstatus = BSP_IO_ITGetStatus(JOY_ALL_PINS);
if (ITstatus)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
Joystick_SetCursorPosition();
}
BSP_IO_ITClear();
/* poll if joystick is still pressed until it is released*/
while ( BSP_JOY_GetState() != JOY_NONE)
{
Joystick_SetCursorPosition();
HAL_Delay(5);
}
}
}
if(CheckForUserInput() > 0)
{
return;
}
HAL_Delay(5);
}
}
示例2: Joystick_MscMenu
/**
* @brief Joystick Msc menu
* @param None
* @retval None
*/
void Joystick_MscMenu(void)
{
static JOYState_TypeDef JoyState = JOY_NONE;
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
MSC_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
osSemaphoreRelease(MenuEvent);
}
示例3: Joystick_demo
/**
* @brief Joystick Gpio demo
* @param None
* @retval None
*/
void Joystick_demo (void)
{
uint8_t status = 0;
Joystick_SetHint();
status = BSP_JOY_Init();
if (status != HAL_OK)
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 70, (uint8_t *)"ERROR", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 55, (uint8_t *)"Joystick cannot", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 40, (uint8_t *)"be initialized", CENTER_MODE);
}
while (1)
{
if (status == HAL_OK)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
Joystick_SetCursorPosition();
}
if(CheckForUserInput() > 0)
{
return;
}
HAL_Delay(6);
}
}
示例4: GetPointerData
/**
* @brief Gets Pointer Data.
* @param pbuf: Pointer to report
* @retval None
*/
static void GetPointerData(uint8_t *pbuf)
{
int8_t x = 0, y = 0 ;
switch (BSP_JOY_GetState())
{
case JOY_LEFT:
x -= CURSOR_STEP;
break;
case JOY_RIGHT:
x += CURSOR_STEP;
break;
case JOY_UP:
y -= CURSOR_STEP;
break;
case JOY_DOWN:
y += CURSOR_STEP;
break;
default:
break;
}
pbuf[0] = 0;
pbuf[1] = x;
pbuf[2] = y;
pbuf[3] = 0;
}
示例5: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
__IO JOYState_TypeDef JoyState = JOY_NONE;
if(GPIO_Pin == GPIO_PIN_8)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
HID_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear();
osSemaphoreRelease(MenuEvent);
}
}
示例6: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
static JOYState_TypeDef JoyState = JOY_NONE;
if(GPIO_Pin == GPIO_PIN_2)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
MSC_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear(JOY_ALL_PINS);
}
}
示例7: Joystick_AudioMenu
/**
* @brief Joystick audio menu
* @param None
* @retval None
*/
void Joystick_AudioMenu(void)
{
static JOYState_TypeDef JoyState = JOY_NONE;
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
if(AudioSelectMode == AUDIO_SELECT_MENU)
{
AUDIO_MenuProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
}
else if(AudioSelectMode == AUDIO_PLAYBACK_CONTROL)
{
AUDIO_PlaybackProbeKey(JoyState);
}
}
示例8: Log_demo
/**
* @brief LCD Log demo
* @param None
* @retval None
*/
void Log_demo(void)
{
JOYState_TypeDef JoyState = JOY_NONE;
uint8_t i = 0;
/* Wait For User inputs */
while(CheckForUserInput() == 0);
BSP_JOY_Init(JOY_MODE_GPIO);
/* Initialize LCD Log module */
LCD_LOG_Init();
/* Show Header and Footer texts */
LCD_LOG_SetHeader((uint8_t *)"Log Example");
LCD_LOG_SetFooter((uint8_t *)"Use Joystick to scroll up/down");
/* Output User logs */
for (i = 0; i < 10; i++)
{
LCD_UsrLog ("This is Line %d \n", i);
}
HAL_Delay(2000);
/* Clear Old logs */
LCD_LOG_ClearTextZone();
/* Output new user logs */
for (i = 0; i < 30; i++)
{
LCD_UsrLog ("This is Line %d \n", i);
}
/* Check for joystick user input for scroll (back and forward) */
while (1)
{
JoyState = BSP_JOY_GetState();
switch(JoyState)
{
case JOY_UP:
LCD_LOG_ScrollBack();
break;
case JOY_DOWN:
LCD_LOG_ScrollForward();
break;
default:
break;
}
if(CheckForUserInput() > 0)
{
return;
}
HAL_Delay (10);
}
}
示例9: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
/* If the interruption comes from the Joystick, check which
Joystick button has been pressed */
JoyState = BSP_JOY_GetState();
if(JoyState == JOY_SEL)
{
/* SEL is used to pause and resume the audio playback */
if (PressCount == 1)
{
/* Resume playing Wave status */
PauseResumeStatus = RESUME_STATUS;
PressCount = 0;
}
else
{
/* Pause playing Wave status */
PauseResumeStatus = PAUSE_STATUS;
PressCount = 1;
}
}
else if(JoyState == JOY_UP)
{
/* UP is used to increment the volume of the audio playback */
volume ++;
if (volume > 100)
{
volume = 100;
}
VolumeChange = 1;
}
else if(JoyState == JOY_DOWN)
{
/* DOWN is used to decrement the volume of the audio playback */
volume --;
if ((int8_t)volume < 50)
{
volume = 50;
}
VolumeChange = 1;
}
/* Clear MFX IT */
BSP_IO_ITClear();
}
示例10: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
static JOYState_TypeDef JoyState = JOY_NONE;
if(GPIO_Pin == MFX_IRQOUT_PIN)
{
/* The different functionalities of MFX (TS, Joystick, SD detection, etc. )
can be configured in exti mode to generate an IRQ on given events.
The MFX IRQ_OUT pin is unique and common to all functionalities, so if several
functionalities are configured in exit mode, the MCU has to enquire MFX about
the IRQ source (see BSP_IO_ITGetStatus). Communication with Mfx is done by I2C.
Often the sw requires ISRs (irq service routines) to be quick while communication
with I2C can be considered relatively long (hundreds of usec depending on I2C clk).
Considering that the features for human interaction like TS, Joystick, SD detection
don’t need immediate reaction, it is suggested to use POLLING instead of EXTI mode,
in order to avoid "blocking I2C communication" on interrupt service routines */
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
HAL_Delay(200);
MSC_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear();
}
}
示例11: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
__IO JOYState_TypeDef JoyState = JOY_NONE;
if(GPIO_Pin == MFX_IRQOUT_PIN)
{
/* The different functionalities of MFX (TS, Joystick, SD detection, etc. )
can be configured in exti mode to generate an IRQ on given events.
The MFX IRQ_OUT pin is unique and common to all functionalities, so if several
functionalities are configured in exit mode, the MCU has to enquire MFX about
the IRQ source (see BSP_IO_ITGetStatus). Communication with Mfx is done by I2C.
Often the sw requires ISRs (irq service routines) to be quick while communication
with I2C can be considered relatively long (hundreds of usec depending on I2C clk).
In order to avoid to use "blocking I2C communication" on interrupt service routines
it's suggested (as alternative to this implementation) to use dedicated semaphore*/
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
HID_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear();
osSemaphoreRelease(MenuEvent);
}
}
示例12: HdmiCec_SelectDevice
/**
* @brief Select the type of device
* @param None
* @retval None
*/
static void HdmiCec_SelectDevice(void)
{
JOYState_TypeDef JoyKey;
BSP_LCD_DisplayStringAt(20, 100, (uint8_t *)"Select your CEC Device Type", LEFT_MODE);
BSP_LCD_DisplayStringAt(20, 130, (uint8_t *)"RIGHT --> Recording", LEFT_MODE);
BSP_LCD_DisplayStringAt(20, 145, (uint8_t *)"LEFT --> Tuner", LEFT_MODE);
BSP_LCD_DisplayStringAt(20, 160, (uint8_t *)"UP --> Playback", LEFT_MODE);
BSP_LCD_DisplayStringAt(20, 175, (uint8_t *)"DOWN --> AudioSystem", LEFT_MODE);
do
{
JoyKey = BSP_JOY_GetState();
} while(JoyKey == JOY_NONE);
switch(JoyKey)
{
case JOY_DOWN :
DeviceType = HDMI_CEC_AUDIOSYSTEM;
BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Device selected : AudioSystem", LEFT_MODE);
break;
case JOY_LEFT :
DeviceType = HDMI_CEC_TUNER;
BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Device selected : Tuner", LEFT_MODE);
break;
case JOY_RIGHT :
DeviceType = HDMI_CEC_RECORDING;
BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Device selected : Recording", LEFT_MODE);
break;
case JOY_UP :
DeviceType = HDMI_CEC_PLAYBACK;
BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"Device selected : Playback", LEFT_MODE);
break;
default :
DeviceType = HDMI_CEC_TV;
BSP_LCD_DisplayStringAt(20, BSP_LCD_GetYSize()-30, (uint8_t *)"No device selected (TV by default)", LEFT_MODE);
}
}
示例13: HID_Joysticky
void HID_Joysticky(void)
{
static JOYState_TypeDef JoyState = JOY_NONE;
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
HID_DEMO_ProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
}
示例14: HAL_GPIO_EXTI_Callback
/**
* @brief EXTI line detection callbacks.
* @param GPIO_Pin: Specifies the pins connected EXTI line
* @retval None
*/
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
static JOYState_TypeDef JoyState = JOY_NONE;
static uint32_t debounce_time = 0;
if(GPIO_Pin == GPIO_PIN_2)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear(JOY_ALL_PINS);
if(mtp_select_mode == MTP_SELECT_MENU)
{
MTP_MenuProbeKey(JoyState);
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
}
else if(mtp_select_mode == MTP_PLAYBACK_CONTROL)
{
AUDIO_PlaybackProbeKey(JoyState);
}
}
if(mtp_demo.state == MTP_DEMO_PLAYBACK)
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
/* Prevent debounce effect for user key */
if((HAL_GetTick() - debounce_time) > 50)
{
debounce_time = HAL_GetTick();
}
else
{
return;
}
/* Change the selection type */
if(mtp_select_mode == MTP_SELECT_MENU)
{
MTP_ChangeSelectMode(MTP_PLAYBACK_CONTROL);
}
else if(mtp_select_mode == MTP_PLAYBACK_CONTROL)
{
AUDIO_Stop();
}
}
}
}
示例15: Calibration_Menu
/**
* @brief Enter Calibration menu to correct ICError and Capacitance55RH values
* @param None
* @retval None
*/
static void Calibration_Menu(void)
{
uint8_t exitmenu = 0;
uint8_t LCDstr[20] = {0};
/*##-1- Display messages on LCD ############################################*/
/* Set the LCD Text Color */
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
/* Display Calibration Screen */
BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Calibration steps: ", CENTER_MODE);
BSP_LCD_DisplayStringAt(60, 145, (uint8_t *)"1. Set JP19 to REF ", LEFT_MODE);
BSP_LCD_DisplayStringAt(60, 160, (uint8_t *)"2. Press Joystick Sel push-button ", LEFT_MODE);
/*##-2- Calibration Phases #################################################*/
/* ------------- First step calibration using reference capacitance ----- */
while (exitmenu != 1)
{
if (BSP_JOY_GetState() == JOY_SEL)
{
/* Get ICError for reference capacitance */
/* TriggerTime = (AvrgICReadValue - ICError)/SystemCoreClock
* TriggerTime = RES * REFCAP * ln(VDD/(VDD - VREF))
* @VREF = 2.086V (generated by DAC), ln(VDD/(VDD - VREF)) is ~ 1
* ==> TriggerTime = RES * REFCAP
* Then RES * REFCAP = (AvrgICReadValue - ICError)/SystemCoreClock
* ==> ICError = AvrgICReadValue - REFCAP * RES * SystemCoreClock
*/
ICError = (uint16_t) (AvrgICReadValue-REFCAP*RES*SystemCoreClock);
/* Set exitmenu to 1 */
exitmenu = 1;
}
}
/* --------------- Second step calibration using reference humidity ------- */
exitmenu = 0;
/* Clear Calibration Screen */
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_WHITE);
BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize()- 24, BSP_LCD_GetYSize() - 104);
/* Set the LCD Text Color */
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
BSP_LCD_DisplayStringAt(0, 100, (uint8_t *)"Now set JP19 to HUM ", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"and set current humidity value", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, 130, (uint8_t *)"using Up/Down keys", CENTER_MODE);
BSP_LCD_DisplayStringAt(14, 190, (uint8_t *)"Joystick Sel push-button: Apply ", LEFT_MODE);
BSP_LCD_DisplayStringAt(14, 205, (uint8_t *)"Key push-button: Cancel ", LEFT_MODE);
/* Set the LCD Text Color for Humidity value */
BSP_LCD_SetTextColor(LCD_COLOR_RED);
/* Wait for SEL button to be released */
while (BSP_JOY_GetState() != JOY_NONE);
while (exitmenu != 1)
{
if ((BSP_JOY_GetState() == JOY_UP) && (DisplayValue<99))
{
/* Wait for UP button to be released */
while (BSP_JOY_GetState() != JOY_NONE);
DisplayValue++;
UpdateDisplayValue = 1;
}
if ((BSP_JOY_GetState() == JOY_DOWN) && (DisplayValue>0))
{
/* Wait for DOWN button to be released */
while (BSP_JOY_GetState() != JOY_NONE);
DisplayValue--;
UpdateDisplayValue = 1;
}
if (UpdateDisplayValue)
{
UpdateDisplayValue = 0;
/* Display humidity value on LCD Line 4 */
sprintf((char*)LCDstr, " %lu %% ", DisplayValue);
BSP_LCD_DisplayStringAt(0, 160, (uint8_t*) LCDstr, CENTER_MODE);
}
if (BSP_JOY_GetState() == JOY_SEL)
{
/* Calculate Trigger Time Value */
TriggerTime = (float) (AvrgICReadValue-ICError)/SystemCoreClock;
/* Calculate Capacitance Value */
Capacitance = (float) TriggerTime/RES;
/* Update Capacitance55RH value: capacitance @ 55% Relative Humidity */
Capacitance55RH= Capacitance/(P3 * pow(DisplayValue,3) +
P2 * pow(DisplayValue,2) +
P1 * DisplayValue +
//.........这里部分代码省略.........