Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button.
This commit is contained in:
parent
f11f69fd29
commit
63a8f66d92
25 changed files with 163 additions and 131 deletions
|
|
@ -58,7 +58,7 @@ int main(void)
|
|||
/* Hardware Initialization */
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
HWB_Init();
|
||||
Buttons_Init();
|
||||
|
||||
/* Indicate USB not ready */
|
||||
UpdateStatus(Status_USBNotReady);
|
||||
|
|
@ -173,7 +173,7 @@ bool GetNextReport(USB_JoystickReport_Data_t* ReportData)
|
|||
if (JoyStatus_LCL & JOY_PRESS)
|
||||
ReportData->Button = (1 << 1);
|
||||
|
||||
if (HWB_GetStatus())
|
||||
if (Buttons_GetStatus() & BUTTONS_BUTTON1)
|
||||
ReportData->Button |= (1 << 0);
|
||||
|
||||
/* Check if the new report is different to the previous report */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
||||
/* Task Definitions: */
|
||||
|
|
|
|||
|
|
@ -240,8 +240,8 @@ TASK(USB_Keyboard)
|
|||
{
|
||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||
|
||||
/* Check if HWB is not pressed, if so mouse mode enabled */
|
||||
if (!(HWB_GetStatus()))
|
||||
/* Check if board button is not pressed, if so mouse mode enabled */
|
||||
if (!(Buttons_GetStatus() & BUTTONS_BUTTON1))
|
||||
{
|
||||
if (JoyStatus_LCL & JOY_UP)
|
||||
KeyboardReportData.KeyCode[0] = 0x04; // A
|
||||
|
|
@ -311,8 +311,8 @@ TASK(USB_Mouse)
|
|||
{
|
||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||
|
||||
/* Check if HWB is pressed, if so mouse mode enabled */
|
||||
if (HWB_GetStatus())
|
||||
/* Check if board button is pressed, if so mouse mode enabled */
|
||||
if (Buttons_GetStatus() & BUTTONS_BUTTON1)
|
||||
{
|
||||
if (JoyStatus_LCL & JOY_UP)
|
||||
MouseReportData.Y = 1;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
||||
/* Task Definitions: */
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ int main(void)
|
|||
/* Hardware Initialization */
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
HWB_Init();
|
||||
Buttons_Init();
|
||||
|
||||
/* Indicate USB not ready */
|
||||
UpdateStatus(Status_USBNotReady);
|
||||
|
|
@ -134,8 +134,8 @@ TASK(USB_MIDI_Task)
|
|||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||
|
||||
/* Get HWB status - if set use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((HWB_GetStatus()) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
|
||||
if (JoystickChanges & JOY_LEFT)
|
||||
SendMIDINoteChange(0x3C, (JoystickStatus & JOY_LEFT), 0, Channel);
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
||||
/* Macros: */
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ int main(void)
|
|||
/* Hardware Initialization */
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
HWB_Init();
|
||||
Buttons_Init();
|
||||
|
||||
/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */
|
||||
OCR0A = 0x7D;
|
||||
|
|
@ -305,7 +305,7 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
|
|||
if (JoyStatus_LCL & JOY_PRESS)
|
||||
ReportData->Button = (1 << 0);
|
||||
|
||||
if (HWB_GetStatus())
|
||||
if (Buttons_GetStatus() & BUTTONS_BUTTON1)
|
||||
ReportData->Button |= (1 << 1);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
||||
/* Task Definitions: */
|
||||
|
|
|
|||
|
|
@ -63,7 +63,7 @@ int main(void)
|
|||
/* Hardware Initialization */
|
||||
SerialStream_Init(9600, false);
|
||||
LEDs_Init();
|
||||
HWB_Init();
|
||||
Buttons_Init();
|
||||
|
||||
/* Indicate USB not ready */
|
||||
UpdateStatus(Status_USBNotReady);
|
||||
|
|
@ -319,10 +319,10 @@ TASK(USB_MassStore_Host)
|
|||
puts_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
puts_P(PSTR("\r\n\r\nPress HWB to read entire ASCII contents of disk...\r\n\r\n"));
|
||||
puts_P(PSTR("\r\n\r\nPress board button to read entire ASCII contents of disk...\r\n\r\n"));
|
||||
|
||||
/* Wait for HWB to be pressed */
|
||||
while (!(HWB_GetStatus()))
|
||||
/* Wait for the board button to be pressed */
|
||||
while (!(Buttons_GetStatus() & BUTTONS_BUTTON1))
|
||||
{
|
||||
/* Abort if device removed */
|
||||
if (!(USB_IsConnected))
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h> // Serial stream driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
|
||||
|
||||
/* Enums: */
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
TASK_LIST
|
||||
{
|
||||
{ .Task = TestApp_CheckJoystick, .TaskStatus = TASK_RUN },
|
||||
{ .Task = TestApp_CheckHWB , .TaskStatus = TASK_RUN },
|
||||
{ .Task = TestApp_CheckButton , .TaskStatus = TASK_RUN },
|
||||
{ .Task = TestApp_CheckTemp , .TaskStatus = TASK_RUN },
|
||||
{ .Task = USB_USBTask , .TaskStatus = TASK_RUN },
|
||||
};
|
||||
|
|
@ -63,7 +63,7 @@ int main(void)
|
|||
Temperature_Init();
|
||||
Joystick_Init();
|
||||
LEDs_Init();
|
||||
HWB_Init();
|
||||
Buttons_Init();
|
||||
|
||||
/* Millisecond timer initialization, with output compare interrupt enabled */
|
||||
OCR0A = 0x7D;
|
||||
|
|
@ -137,17 +137,17 @@ TASK(TestApp_CheckTemp)
|
|||
}
|
||||
}
|
||||
|
||||
/** Task responsible for checking the HWB button position, and start-stopping other tasks and the USB
|
||||
/** Task responsible for checking the board's first button' position, and start-stopping other tasks and the USB
|
||||
* interface in response to user joystick movements.
|
||||
*/
|
||||
TASK(TestApp_CheckHWB)
|
||||
TASK(TestApp_CheckButton)
|
||||
{
|
||||
static SchedulerDelayCounter_t DelayCounter = 0;
|
||||
static bool IsPressed;
|
||||
static bool BlockingJoystickTask;
|
||||
|
||||
/* Check if HWB pressed (start USB) */
|
||||
if (HWB_GetStatus() == true)
|
||||
/* Check if board button pressed (start USB) */
|
||||
if (Buttons_GetStatus() & BUTTONS_BUTTON1)
|
||||
{
|
||||
/* Debounce - check 100 ticks later to see if button is still being pressed */
|
||||
if ((IsPressed == false) && (Scheduler_HasDelayElapsed(100, &DelayCounter)))
|
||||
|
|
@ -185,7 +185,7 @@ TASK(TestApp_CheckHWB)
|
|||
}
|
||||
else
|
||||
{
|
||||
/* HWB not pressed - reset debounce interval counter and press handled flag */
|
||||
/* Board button not pressed - reset debounce interval counter and press handled flag */
|
||||
Scheduler_ResetDelay(&DelayCounter);
|
||||
IsPressed = false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,12 +51,12 @@
|
|||
#include <LUFA/Drivers/Peripheral/SerialStream.h> // USART Stream driver
|
||||
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
|
||||
#include <LUFA/Drivers/Board/LEDs.h> // LED driver
|
||||
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver
|
||||
#include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
|
||||
#include <LUFA/Drivers/Board/Temperature.h> // Temperature sensor driver
|
||||
|
||||
/* Task Definitions: */
|
||||
TASK(TestApp_CheckJoystick);
|
||||
TASK(TestApp_CheckHWB);
|
||||
TASK(TestApp_CheckButton);
|
||||
TASK(TestApp_CheckTemp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue