本文整理汇总了C++中BSP_JOY_GetState函数的典型用法代码示例。如果您正苦于以下问题:C++ BSP_JOY_GetState函数的具体用法?C++ BSP_JOY_GetState怎么用?C++ BSP_JOY_GetState使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BSP_JOY_GetState函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
}
开发者ID:eemei,项目名称:library-stm32f4,代码行数:57,代码来源:joystick.c
示例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);
}
开发者ID:z80,项目名称:stm32f429,代码行数:30,代码来源:menu.c
示例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);
}
}
开发者ID:PaxInstruments,项目名称:STM32CubeF2,代码行数:38,代码来源:joystick.c
示例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;
}
开发者ID:dazuo78,项目名称:TBall,代码行数:36,代码来源:stm32f1xx_it.c
示例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);
}
}
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:34,代码来源:menu.c
示例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);
}
}
开发者ID:451506709,项目名称:automated_machine,代码行数:33,代码来源:menu.c
示例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);
}
}
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:37,代码来源:menu.c
示例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);
}
}
开发者ID:451506709,项目名称:automated_machine,代码行数:63,代码来源:log.c
示例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();
}
开发者ID:RadMie,项目名称:STM32F7DiscoveryBase,代码行数:51,代码来源:main.c
示例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();
}
}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:45,代码来源:menu.c
示例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);
}
}
开发者ID:nguyenvuhung,项目名称:STM32Cube_FW_F4,代码行数:44,代码来源:menu.c
示例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);
}
}
开发者ID:NjordCZ,项目名称:stm32cubef0,代码行数:44,代码来源:hdmi_cec.c
示例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;
}
}
开发者ID:z80,项目名称:stm32f429,代码行数:23,代码来源:menu.c
示例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();
}
}
}
}
开发者ID:chsigi,项目名称:blindschleiche,代码行数:68,代码来源:menu.c
示例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 +
//.........这里部分代码省略.........
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:101,代码来源:main.c
示例16: 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_8)
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
CDC_DEMO_ProbeKey(JoyState);
/* Clear joystick interrupt pending bits */
BSP_IO_ITClear();
if((CdcSelectMode == CDC_SELECT_MENU) && (CdcDemo.state != CDC_DEMO_RECEIVE))
{
switch(JoyState)
{
case JOY_LEFT:
LCD_LOG_ScrollBack();
break;
case JOY_RIGHT:
LCD_LOG_ScrollForward();
break;
default:
break;
}
}
}
if(CdcDemo.state == CDC_DEMO_CONFIGURATION)
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
/* Prevent debounce effect for user key */
if((HAL_GetTick() - debounce_time) > 50)
{
debounce_time = HAL_GetTick();
}
else
{
return;
}
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
/* Change the selection type */
if(CdcSelectMode == CDC_SELECT_MENU)
{
CDC_ChangeSelectMode(CDC_SELECT_CONFIG);
}
else if(CdcSelectMode == CDC_SELECT_CONFIG)
{
CDC_ChangeSelectMode(CDC_SELECT_MENU);
}
else if(CdcSelectMode == CDC_SELECT_FILE)
{
CDC_ChangeSelectMode(CDC_SELECT_FILE);
}
}
}
if(CdcDemo.state == CDC_DEMO_SEND)
{
if(GPIO_Pin == KEY_BUTTON_PIN)
{
/* Prevent debounce effect for user key */
if((HAL_GetTick() - debounce_time) > 50)
{
debounce_time = HAL_GetTick();
}
else
{
return;
}
if(CdcDemo.Send_state == CDC_SEND_SELECT_FILE)
{
BSP_LCD_SetBackColor(LCD_COLOR_BLACK);
/* Change the selection type */
if(CdcSelectMode == CDC_SELECT_MENU)
{
CDC_ChangeSelectMode(CDC_SELECT_FILE);
}
else if(CdcSelectMode == CDC_SELECT_FILE)
{
LCD_ClearTextZone();
LCD_LOG_UpdateDisplay();
CDC_ChangeSelectMode(CDC_SELECT_MENU);
CdcDemo.Send_state = CDC_SEND_WAIT;
}
}
}
//.........这里部分代码省略.........
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:101,代码来源:menu.c
示例17: AudioPlay_demo
/**
* @brief Audio Play demo
* @param None
* @retval None
*/
void AudioPlay_demo (void)
{
uint32_t *AudioFreq_ptr;
uint8_t status = 0;
uint8_t FreqStr[256] = {0};
AudioFreq_ptr = AudioFreq+6; /*AF_48K*/
uwPauseEnabledStatus = 1; /* 0 when audio is running, 1 when Pause is on */
uwVolume = 50;
Audio_SetHint();
status = BSP_JOY_Init(JOY_MODE_GPIO);
if (status != IO_OK)
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 100, (uint8_t *)"ERROR", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 85, (uint8_t *)"Joystick cannot be initialized", CENTER_MODE);
}
if(BSP_AUDIO_OUT_Init(OUTPUT_DEVICE_BOTH, uwVolume, *AudioFreq_ptr) == 0)
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 100, (uint8_t *)" AUDIO CODEC OK ", CENTER_MODE);
}
else
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_RED);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 100, (uint8_t *)" AUDIO CODEC FAIL ", CENTER_MODE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 85, (uint8_t *)" Try to reset board ", CENTER_MODE);
}
/*
Start playing the file from a circular buffer, once the DMA is enabled, it is
always in running state. Application has to fill the buffer with the audio data
using Transfer complete and/or half transfer complete interrupts callbacks
(EVAL_AUDIO_TransferComplete_CallBack() or EVAL_AUDIO_HalfTransfer_CallBack()...
*/
AUDIO_Start();
/* Display the state on the screen */
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 85, (uint8_t *)" PLAYING... ", CENTER_MODE);
sprintf((char*)FreqStr," VOL: %lu ",uwVolume);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 55, (uint8_t *)FreqStr, CENTER_MODE);
sprintf((char*)FreqStr," FREQ: %lu ",*AudioFreq_ptr);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 40, (uint8_t *)FreqStr, CENTER_MODE);
/* IMPORTANT:
AUDIO_Process() is called by the SysTick Handler, as it should be called
within a periodic process */
/* Infinite loop */
while(1)
{
BSP_LCD_SetBackColor(LCD_COLOR_WHITE);
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
switch(JoyState)
{
case JOY_UP:
/* Increase volume by 5% */
if (uwVolume < 95)
uwVolume += 5;
else
uwVolume = 100;
sprintf((char*)FreqStr," VOL: %lu ",uwVolume);
BSP_AUDIO_OUT_SetVolume(uwVolume);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 55, (uint8_t *)FreqStr, CENTER_MODE);
BSP_LCD_DisplayStringAt(0, LINE(14), (uint8_t *)" ", CENTER_MODE);
break;
case JOY_DOWN:
/* Decrease volume by 5% */
if (uwVolume > 5)
uwVolume -= 5;
else
uwVolume = 0;
sprintf((char*)FreqStr," VOL: %lu ",uwVolume);
BSP_AUDIO_OUT_SetVolume(uwVolume);
BSP_LCD_DisplayStringAt(0, BSP_LCD_GetYSize()- 55, (uint8_t *)FreqStr, CENTER_MODE);
BSP_LCD_DisplayStringAt(0, LINE(14), (uint8_t *)" ", CENTER_MODE);
break;
case JOY_LEFT:
/*Decrease Frequency */
//.........这里部分代码省略.........
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:101,代码来源:audio.c
示例18: TFT_DisplayImages
/**
* @brief Displays on TFT Images or error messages when error occurred.
* @param None
* @retval None
*/
static void TFT_DisplayImages(void)
{
uint32_t bmplen = 0x00;
uint32_t checkstatus = 0x00;
uint32_t filesnumbers = 0x00;
uint32_t joystickstatus = JOY_NONE;
uint32_t bmpcounter = 0x00;
DIR directory;
FRESULT res;
/* Initialize the Joystick available on adafruit 1.8" TFT shield */
BSP_JOY_Init();
/* Welcome message */
TFT_DisplayMenu();
/* Open directory */
res = f_opendir(&directory, "/");
if((res != FR_OK))
{
if(res == FR_NO_FILESYSTEM)
{
/* Display message: SD card not FAT formated */
TFT_DisplayErrorMessage(SD_CARD_NOT_FORMATTED);
}
else
{
/* Display message: Fail to open directory */
TFT_DisplayErrorMessage(SD_CARD_OPEN_FAIL);
}
}
/* Get number of bitmap files */
filesnumbers = Storage_GetDirectoryBitmapFiles ("/", pDirectoryFiles);
/* Set bitmap counter to display first image */
bmpcounter = 1;
while (1)
{
/* Get JoyStick status */
joystickstatus = BSP_JOY_GetState();
if(joystickstatus == JOY_SEL)
{
JoystickValue++;
if (JoystickValue > 2)
{
JoystickValue = 1;
}
joystickstatus = JOY_NONE;
}
/*## Display BMP pictures in Automatic mode ##############################*/
if(JoystickValue == 1)
{
sprintf((char*)str, "%-11.11s", pDirectoryFiles[bmpcounter -1]);
checkstatus = Storage_CheckBitmapFile((const char*)str, &bmplen);
if(checkstatus == 0)
{
/* Format the string */
checkstatus = Storage_OpenReadFile(POSITION_X_BITMAP, POSITION_Y_BITMAP, (const char*)str);
}
if (checkstatus == 1)
{
/* Display message: File not supported */
TFT_DisplayErrorMessage(SD_CARD_FILE_NOT_SUPPORTED);
}
bmpcounter++;
if(bmpcounter > filesnumbers)
{
bmpcounter = 1;
}
}
/*## Display BMP pictures in Manual mode #################################*/
if(JoystickValue == 2)
{
if(joystickstatus == JOY_RIGHT)
{
if((bmpcounter + 1) > filesnumbers)
{
bmpcounter = 1;
}
else
{
bmpcounter++;
}
sprintf ((char*)str, "%-11.11s", pDirectoryFiles[bmpcounter - 1]);
checkstatus = Storage_CheckBitmapFile((const char*)str, &bmplen);
//.........这里部分代码省略.........
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:101,代码来源:main.c
示例19: TFT_DisplayMenu
/**
* @brief Displays demonstration menu.
* @param None
* @retval None
*/
static void TFT_DisplayMenu(void)
{
JOYState_TypeDef tmp;
/* Set Menu font */
BSP_LCD_SetFont(&Font12);
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_RED);
/* Display message */
BSP_LCD_DisplayStringAtLine(1, (uint8_t*)" NUCLEO-STM32F1xx ");
BSP_LCD_DisplayStringAtLine(2, (uint8_t*)" DEMO ");
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
/* Display message */
BSP_LCD_DisplayStringAtLine(4, (uint8_t*)" Display images ");
BSP_LCD_DisplayStringAtLine(6, (uint8_t*)" stored under uSD ");
BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" on TFT LCD ");
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
/* Display message */
BSP_LCD_DisplayStringAtLine(11, (uint8_t*)" Press JOY DOWN ");
BSP_LCD_DisplayStringAtLine(12, (uint8_t*)" to continue... ");
/* Wait for JOY_DOWN is pressed */
while (BSP_JOY_GetState() != JOY_DOWN)
{
}
/* Wait for JOY_DOWN is released */
while (BSP_JOY_GetState() == JOY_DOWN)
{
}
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_BLACK);
/* Display message */
BSP_LCD_DisplayStringAtLine(4, (uint8_t*)" ");
BSP_LCD_DisplayStringAtLine(6, (uint8_t*)" Press Joystick ");
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
/* Display message */
BSP_LCD_DisplayStringAtLine(8, (uint8_t*)" UP for: ");
BSP_LCD_DisplayStringAtLine(9, (uint8_t*)" Manual Mode ");
BSP_LCD_DisplayStringAtLine(11, (uint8_t*)" DOWN for: ");
BSP_LCD_DisplayStringAtLine(12, (uint8_t*)" Automatic Mode ");
/* Wait for JOY_DOWN or JOY_UP is pressed */
tmp = JOY_RIGHT;
while ((tmp != JOY_DOWN) && (tmp != JOY_UP))
{
tmp = BSP_JOY_GetState();
}
/* LCD Clear */
BSP_LCD_Clear(LCD_COLOR_WHITE);
/* JOY_UP is pressed: Display Manual mode menu #############################*/
if(tmp == JOY_UP)
{
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_RED);
/* Display message */
BSP_LCD_DisplayStringAtLine(3, (uint8_t*)" Manual Mode ");
BSP_LCD_DisplayStringAtLine(5, (uint8_t*)" Selected ");
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_BLUE);
/* Display message */
BSP_LCD_DisplayStringAtLine(9, (uint8_t*)" RIGHT: Next image");
BSP_LCD_DisplayStringAtLine(10, (uint8_t*)" LEFT : Previous ");
BSP_LCD_DisplayStringAtLine(11, (uint8_t*)" SEL : Switch to ");
BSP_LCD_DisplayStringAtLine(12, (uint8_t*)" automatic mode ");
JoystickValue = 2;
}
/* JOY_DOWN is pressed: Display Automatic mode menu ########################*/
else if (tmp == JOY_DOWN)
{
/* Set Text color */
BSP_LCD_SetTextColor(LCD_COLOR_RED);
/* Display message */
BSP_LCD_DisplayStringAtLine(3, (uint8_t*)" Automatic Mode ");
BSP_LCD_DisplayStringAtLine(5, (uint8_t*)" Selected ");
JoystickValue = 1;
HAL_Delay(200);
}
}
开发者ID:Lembed,项目名称:STM32CubeF1-mirrors,代码行数:97,代码来源:main.c
示例20: 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)
{
uint32_t ITstatus = 0;
JOYState_TypeDef JoyState = JOY_NONE;
if(GPIO_Pin == TAMPER_BUTTON_PIN)
{
/* Toggle GREEN LED1 */
BSP_LED_Toggle(LED1);
DestinationAddress = MyFollowerAddress1;
TxSize = 0x0; /* no payload, ping only */
StartSending = 1;
}
if(GPIO_Pin == MFX_IRQOUT_PIN) /* Interrupt received from MFX */
{
/* 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 */
ITstatus = BSP_IO_ITGetStatus(JOY_ALL_PINS);
if (ITstatus) /* Checks if interrupt comes from joystick */
{
/* Get the Joystick State */
JoyState = BSP_JOY_GetState();
if(JoyState == JOY_UP)
{
/* Toggle RED LED3 */
BSP_LED_Toggle(LED3);
}
if(JoyState == JOY_DOWN)
{
/* Toggle BLUE LED4 */
BSP_LED_Toggle(LED4);
#if defined (DEVICE_1)
DestinationAddress = MyFollowerAddress2;
#elif defined (DEVICE_2)
DestinationAddress = MyFollowerAddress1;
#endif /* DEVICE_1 */
TxSize = 0x0; /* no payload, ping only */
StartSending = 1;
}
if(JoyState == JOY_SEL)
{
/* Toggle ORANGE LED2 */
BSP_LED_Toggle(LED2);
DestinationAddress = 0xF; /* broadcast message indicator */
TxSize = 0x0; /* no payload, ping only */
StartSending = 1;
}
}
BSP_IO_ITClear();
}
}
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:69,代码来源:main.c
注:本文中的BSP_JOY_GetState函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论