aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-08-06 14:30:53 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-08-06 14:30:53 +0000
commit33a5715e91d7fe2c0c58351a4a973352ae0e01c9 (patch)
treef75e3726c93546ad6874b140c8769eabf192934d /Demos/Device
parentc830fcb0e1d42c1300ebe78a8b33924054b63a87 (diff)
downloadlufa-33a5715e91d7fe2c0c58351a4a973352ae0e01c9.tar.gz
lufa-33a5715e91d7fe2c0c58351a4a973352ae0e01c9.tar.bz2
lufa-33a5715e91d7fe2c0c58351a4a973352ae0e01c9.zip
Simplify CDC device demos, by directly assigning the string to transmit to the pointer, rather than using an intermediatary table to hold all the possible transmit strings.
Diffstat (limited to 'Demos/Device')
-rw-r--r--Demos/Device/ClassDriver/CDC/CDC.c19
-rw-r--r--Demos/Device/ClassDriver/DualCDC/DualCDC.c19
-rw-r--r--Demos/Device/LowLevel/CDC/CDC.c26
-rw-r--r--Demos/Device/LowLevel/DualCDC/DualCDC.c26
4 files changed, 26 insertions, 64 deletions
diff --git a/Demos/Device/ClassDriver/CDC/CDC.c b/Demos/Device/ClassDriver/CDC/CDC.c
index 4f64646ea..f09d3f136 100644
--- a/Demos/Device/ClassDriver/CDC/CDC.c
+++ b/Demos/Device/ClassDriver/CDC/CDC.c
@@ -124,25 +124,16 @@ void CheckJoystickMovement(void)
char* ReportString = NULL;
static bool ActionSent = false;
- char* const JoystickStrings[] =
- {
- "Joystick Up\r\n",
- "Joystick Down\r\n",
- "Joystick Left\r\n",
- "Joystick Right\r\n",
- "Joystick Pressed\r\n",
- };
-
if (JoyStatus_LCL & JOY_UP)
- ReportString = JoystickStrings[0];
+ ReportString = "Joystick Up\r\n";
else if (JoyStatus_LCL & JOY_DOWN)
- ReportString = JoystickStrings[1];
+ ReportString = "Joystick Down\r\n";
else if (JoyStatus_LCL & JOY_LEFT)
- ReportString = JoystickStrings[2];
+ ReportString = "Joystick Left\r\n";
else if (JoyStatus_LCL & JOY_RIGHT)
- ReportString = JoystickStrings[3];
+ ReportString = "Joystick Right\r\n";
else if (JoyStatus_LCL & JOY_PRESS)
- ReportString = JoystickStrings[4];
+ ReportString = "Joystick Pressed\r\n";
else
ActionSent = false;
diff --git a/Demos/Device/ClassDriver/DualCDC/DualCDC.c b/Demos/Device/ClassDriver/DualCDC/DualCDC.c
index e5406a4ba..5ee3c4d05 100644
--- a/Demos/Device/ClassDriver/DualCDC/DualCDC.c
+++ b/Demos/Device/ClassDriver/DualCDC/DualCDC.c
@@ -132,25 +132,16 @@ void CheckJoystickMovement(void)
char* ReportString = NULL;
static bool ActionSent = false;
- char* const JoystickStrings[] =
- {
- "Joystick Up\r\n",
- "Joystick Down\r\n",
- "Joystick Left\r\n",
- "Joystick Right\r\n",
- "Joystick Pressed\r\n",
- };
-
if (JoyStatus_LCL & JOY_UP)
- ReportString = JoystickStrings[0];
+ ReportString = "Joystick Up\r\n";
else if (JoyStatus_LCL & JOY_DOWN)
- ReportString = JoystickStrings[1];
+ ReportString = "Joystick Down\r\n";
else if (JoyStatus_LCL & JOY_LEFT)
- ReportString = JoystickStrings[2];
+ ReportString = "Joystick Left\r\n";
else if (JoyStatus_LCL & JOY_RIGHT)
- ReportString = JoystickStrings[3];
+ ReportString = "Joystick Right\r\n";
else if (JoyStatus_LCL & JOY_PRESS)
- ReportString = JoystickStrings[4];
+ ReportString = "Joystick Pressed\r\n";
else
ActionSent = false;
diff --git a/Demos/Device/LowLevel/CDC/CDC.c b/Demos/Device/LowLevel/CDC/CDC.c
index 12cd8c40f..0c98c11af 100644
--- a/Demos/Device/LowLevel/CDC/CDC.c
+++ b/Demos/Device/LowLevel/CDC/CDC.c
@@ -247,14 +247,6 @@ void CDC_Task(void)
char* ReportString = NULL;
uint8_t JoyStatus_LCL = Joystick_GetStatus();
static bool ActionSent = false;
- char* JoystickStrings[] =
- {
- "Joystick Up\r\n",
- "Joystick Down\r\n",
- "Joystick Left\r\n",
- "Joystick Right\r\n",
- "Joystick Pressed\r\n",
- };
/* Device must be connected and configured for the task to run */
if (USB_DeviceState != DEVICE_STATE_Configured)
@@ -285,22 +277,20 @@ void CDC_Task(void)
/* Determine if a joystick action has occurred */
if (JoyStatus_LCL & JOY_UP)
- ReportString = JoystickStrings[0];
+ ReportString = "Joystick Up\r\n";
else if (JoyStatus_LCL & JOY_DOWN)
- ReportString = JoystickStrings[1];
+ ReportString = "Joystick Down\r\n";
else if (JoyStatus_LCL & JOY_LEFT)
- ReportString = JoystickStrings[2];
+ ReportString = "Joystick Left\r\n";
else if (JoyStatus_LCL & JOY_RIGHT)
- ReportString = JoystickStrings[3];
+ ReportString = "Joystick Right\r\n";
else if (JoyStatus_LCL & JOY_PRESS)
- ReportString = JoystickStrings[4];
+ ReportString = "Joystick Pressed\r\n";
+ else
+ ActionSent = false;
/* Flag management - Only allow one string to be sent per action */
- if (ReportString == NULL)
- {
- ActionSent = false;
- }
- else if ((ActionSent == false) && LineEncoding.BaudRateBPS)
+ if ((ReportString != NULL) && (ActionSent == false) && LineEncoding.BaudRateBPS)
{
ActionSent = true;
diff --git a/Demos/Device/LowLevel/DualCDC/DualCDC.c b/Demos/Device/LowLevel/DualCDC/DualCDC.c
index 7a84c8dcd..efbecd6cf 100644
--- a/Demos/Device/LowLevel/DualCDC/DualCDC.c
+++ b/Demos/Device/LowLevel/DualCDC/DualCDC.c
@@ -230,14 +230,6 @@ void CDC1_Task(void)
char* ReportString = NULL;
uint8_t JoyStatus_LCL = Joystick_GetStatus();
static bool ActionSent = false;
- char* JoystickStrings[] =
- {
- "Joystick Up\r\n",
- "Joystick Down\r\n",
- "Joystick Left\r\n",
- "Joystick Right\r\n",
- "Joystick Pressed\r\n",
- };
/* Device must be connected and configured for the task to run */
if (USB_DeviceState != DEVICE_STATE_Configured)
@@ -245,22 +237,20 @@ void CDC1_Task(void)
/* Determine if a joystick action has occurred */
if (JoyStatus_LCL & JOY_UP)
- ReportString = JoystickStrings[0];
+ ReportString = "Joystick Up\r\n";
else if (JoyStatus_LCL & JOY_DOWN)
- ReportString = JoystickStrings[1];
+ ReportString = "Joystick Down\r\n";
else if (JoyStatus_LCL & JOY_LEFT)
- ReportString = JoystickStrings[2];
+ ReportString = "Joystick Left\r\n";
else if (JoyStatus_LCL & JOY_RIGHT)
- ReportString = JoystickStrings[3];
+ ReportString = "Joystick Right\r\n";
else if (JoyStatus_LCL & JOY_PRESS)
- ReportString = JoystickStrings[4];
+ ReportString = "Joystick Pressed\r\n";
+ else
+ ActionSent = false;
/* Flag management - Only allow one string to be sent per action */
- if (ReportString == NULL)
- {
- ActionSent = false;
- }
- else if ((ActionSent == false) && LineEncoding1.BaudRateBPS)
+ if ((ReportString != NULL) && (ActionSent == false) && LineEncoding1.BaudRateBPS)
{
ActionSent = true;