/elec/audio-switcher

To get this branch, use:
bzr branch http://bzr.ed.am/elec/audio-switcher

« back to all changes in this revision

Viewing changes to src/VirtualSerial.c

  • Committer: Tim Marston
  • Date: 2012-11-22 18:45:43 UTC
  • Revision ID: tim@ed.am-20121122184543-ysse46aabr0akflw
wrote README and renamed NOTES

Show diffs side-by-side

added added

removed removed

1
1
/*
2
 
 
3
 
  AUDIO SWITCHER
4
 
 
5
 
  Based on a serial device demonstration from the LUFA project
6
 
  (www.lufa-lib.org).  LUFA is Copyright (C) Dean Camera, 2012.
7
 
 
8
 
  Changes made to the serial device demonstration program are
9
 
  Copyright (C) Tim Marston, 2012.
10
 
 
11
 
  For more information:
12
 
    * see README, or
13
 
    * visit http://ed.am/
14
 
 
 
2
             LUFA Library
 
3
     Copyright (C) Dean Camera, 2012.
 
4
 
 
5
  dean [at] fourwalledcubicle [dot] com
 
6
           www.lufa-lib.org
15
7
*/
16
8
 
17
9
/*
43
35
 */
44
36
 
45
37
#include "VirtualSerial.h"
46
 
#include "wiring.h"
47
38
 
48
39
/** LUFA CDC Class driver interface configuration and state information. This structure is
49
40
 *  passed to all CDC Class driver functions, so that multiple instances of the same class
106
97
                if( !sent )
107
98
                {
108
99
                        sent = true;
109
 
                        fprintf( &USBSerialStream, "%lu\r\n", millis() );
110
 
//                      fputs( "press\r\n", &USBSerialStream );
 
100
                        fputs( "press\r\n", &USBSerialStream );
111
101
                }
112
102
 
113
103
                // set led
162
152
        LEDs_Init();
163
153
        USB_Init();
164
154
 
165
 
        // do my init
166
 
        init();
167
 
 
168
 
        // set up arduino wiring.c
169
 
        init_wiring_c();
170
 
}
 
155
        init(); 
 
156
}
 
157
 
 
158
/** Checks for changes in the position of the board joystick, sending strings to the host upon each change. */
 
159
#if 0
 
160
void CheckJoystickMovement(void)
 
161
{
 
162
        uint8_t     JoyStatus_LCL = Joystick_GetStatus();
 
163
        char*       ReportString  = NULL;
 
164
        static bool ActionSent    = false;
 
165
 
 
166
        if (JoyStatus_LCL & JOY_UP)
 
167
          ReportString = "Joystick Up\r\n";
 
168
        else if (JoyStatus_LCL & JOY_DOWN)
 
169
          ReportString = "Joystick Down\r\n";
 
170
        else if (JoyStatus_LCL & JOY_LEFT)
 
171
          ReportString = "Joystick Left\r\n";
 
172
        else if (JoyStatus_LCL & JOY_RIGHT)
 
173
          ReportString = "Joystick Right\r\n";
 
174
        else if (JoyStatus_LCL & JOY_PRESS)
 
175
          ReportString = "Joystick Pressed\r\n";
 
176
        else
 
177
          ActionSent = false;
 
178
 
 
179
        if ((ReportString != NULL) && (ActionSent == false))
 
180
        {
 
181
                ActionSent = true;
 
182
 
 
183
                /* Write the string to the virtual COM port via the created character stream */
 
184
                fputs(ReportString, &USBSerialStream);
 
185
 
 
186
                /* Alternatively, without the stream: */
 
187
                // CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString);
 
188
        }
 
189
}
 
190
#endif
171
191
 
172
192
/** Event handler for the library USB Connection event. */
173
193
void EVENT_USB_Device_Connect(void)