Autoformat all MIDI examples

This commit is contained in:
Kristian Sloth Lauszus 2016-04-18 18:04:08 +02:00
parent 45eddcf2db
commit ce7c93a281
5 changed files with 118 additions and 118 deletions

60
examples/USBH_MIDI/USBH_MIDI_dump/USBH_MIDI_dump.ino Executable file → Normal file
View file

@ -36,7 +36,7 @@ void setup()
Serial.begin(115200);
if (Usb.Init() == -1) {
while(1); //halt
while (1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
@ -47,7 +47,7 @@ void loop()
Usb.Task();
t1 = micros();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
}
@ -58,41 +58,41 @@ void loop()
// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
char buf[20];
uint8_t bufMidi[64];
uint16_t rcvd;
char buf[20];
uint8_t bufMidi[64];
uint16_t rcvd;
if(Midi.vid != vid || Midi.pid != pid){
sprintf(buf, "VID:%04X, PID:%04X", Midi.vid, Midi.pid);
Serial.println(buf);
vid = Midi.vid;
pid = Midi.pid;
}
if(Midi.RecvData( &rcvd, bufMidi) == 0 ){
sprintf(buf, "%08X: ", millis());
Serial.print(buf);
Serial.print(rcvd);
Serial.print(':');
for(int i=0; i<64; i++){
sprintf(buf, " %02X", bufMidi[i]);
Serial.print(buf);
}
Serial.println("");
if (Midi.vid != vid || Midi.pid != pid) {
sprintf(buf, "VID:%04X, PID:%04X", Midi.vid, Midi.pid);
Serial.println(buf);
vid = Midi.vid;
pid = Midi.pid;
}
if (Midi.RecvData( &rcvd, bufMidi) == 0 ) {
sprintf(buf, "%08X: ", millis());
Serial.print(buf);
Serial.print(rcvd);
Serial.print(':');
for (int i = 0; i < 64; i++) {
sprintf(buf, " %02X", bufMidi[i]);
Serial.print(buf);
}
Serial.println("");
}
}
// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
unsigned long t3;
unsigned long t3;
if( t1 > t2 ){
t3 = (4294967295 - t1 + t2);
}else{
t3 = t2 - t1;
}
if ( t1 > t2 ) {
t3 = (4294967295 - t1 + t2);
} else {
t3 = t2 - t1;
}
if( t3 < delayTime ){
delayMicroseconds(delayTime - t3);
}
if ( t3 < delayTime ) {
delayMicroseconds(delayTime - t3);
}
}

View file

@ -42,7 +42,7 @@ void setup()
_MIDI_SERIAL_PORT.begin(31250);
if (Usb.Init() == -1) {
while(1); //halt
while (1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
@ -53,7 +53,7 @@ void loop()
Usb.Task();
t1 = micros();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
}
@ -64,29 +64,29 @@ void loop()
// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
byte outBuf[ 3 ];
uint8_t size;
byte outBuf[ 3 ];
uint8_t size;
do {
if( (size=Midi.RecvData(outBuf)) > 0 ){
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
}while(size>0);
do {
if ( (size = Midi.RecvData(outBuf)) > 0 ) {
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
} while (size > 0);
}
// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
unsigned long t3;
unsigned long t3;
if( t1 > t2 ){
t3 = (4294967295 - t1 + t2);
}else{
t3 = t2 - t1;
}
if ( t1 > t2 ) {
t3 = (4294967295 - t1 + t2);
} else {
t3 = t2 - t1;
}
if( t3 < delayTime ){
delayMicroseconds(delayTime - t3);
}
if ( t3 < delayTime ) {
delayMicroseconds(delayTime - t3);
}
}

View file

@ -44,7 +44,7 @@ void setup()
_MIDI_SERIAL_PORT.begin(31250);
if (Usb.Init() == -1) {
while(1); //halt
while (1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
@ -55,7 +55,7 @@ void loop()
Usb.Task();
t1 = micros();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
}
@ -66,35 +66,35 @@ void loop()
// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
byte outBuf[ 3 ];
uint8_t size;
byte outBuf[ 3 ];
uint8_t size;
do {
if( (size=Midi1.RecvData(outBuf)) > 0 ){
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
}while(size>0);
do {
if( (size=Midi2.RecvData(outBuf)) > 0 ){
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
}while(size>0);
do {
if ( (size = Midi1.RecvData(outBuf)) > 0 ) {
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
} while (size > 0);
do {
if ( (size = Midi2.RecvData(outBuf)) > 0 ) {
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
} while (size > 0);
}
// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
unsigned long t3;
unsigned long t3;
if( t1 > t2 ){
t3 = (4294967295 - t1 + t2);
}else{
t3 = t2 - t1;
}
if ( t1 > t2 ) {
t3 = (4294967295 - t1 + t2);
} else {
t3 = t2 - t1;
}
if( t3 < delayTime ){
delayMicroseconds(delayTime - t3);
}
if ( t3 < delayTime ) {
delayMicroseconds(delayTime - t3);
}
}

View file

@ -50,7 +50,7 @@ void setup()
MIDI.begin(MIDI_CHANNEL_OMNI);
if (Usb.Init() == -1) {
while(1); //halt
while (1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
@ -62,19 +62,19 @@ void loop()
Usb.Task();
t1 = micros();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
if (MIDI.read()) {
msg[0] = MIDI.getType();
if( msg[0] == 0xf0 ) { //SysEX
//TODO
//SysEx implementation is not yet.
}else{
msg[1] = MIDI.getData1();
msg[2] = MIDI.getData2();
Midi.SendData(msg, 0);
}
msg[0] = MIDI.getType();
if ( msg[0] == 0xf0 ) { //SysEX
//TODO
//SysEx implementation is not yet.
} else {
msg[1] = MIDI.getData1();
msg[2] = MIDI.getData2();
Midi.SendData(msg, 0);
}
}
}
//delay(1ms)
@ -84,27 +84,27 @@ void loop()
// Poll USB MIDI Controler and send to serial MIDI
void MIDI_poll()
{
byte outBuf[ 3 ];
uint8_t size;
byte outBuf[ 3 ];
uint8_t size;
if( (size=Midi.RecvData(outBuf)) > 0 ){
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
if ( (size = Midi.RecvData(outBuf)) > 0 ) {
//MIDI Output
_MIDI_SERIAL_PORT.write(outBuf, size);
}
}
// Delay time (max 16383 us)
void doDelay(unsigned long t1, unsigned long t2, unsigned long delayTime)
{
unsigned long t3;
unsigned long t3;
if( t1 > t2 ){
t3 = (4294967295 - t1 + t2);
}else{
t3 = t2 - t1;
}
if ( t1 > t2 ) {
t3 = (4294967295 - t1 + t2);
} else {
t3 = t2 - t1;
}
if( t3 < delayTime ){
delayMicroseconds(delayTime - t3);
}
if ( t3 < delayTime ) {
delayMicroseconds(delayTime - t3);
}
}

36
examples/USBH_MIDI/eVY1_sample/eVY1_sample.ino Executable file → Normal file
View file

@ -24,13 +24,13 @@ void noteOn(uint8_t note);
void noteOff(uint8_t note);
uint16_t pid, vid;
uint8_t exdata[] ={
0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10,
'k',' ','o',',', //Ko
'N','\\',',', //N
'J',' ', 'i', ',', //Ni
't','S',' ','i',',',//Chi
'w',' ','a', //Wa
uint8_t exdata[] = {
0xf0, 0x43, 0x79, 0x09, 0x00, 0x50, 0x10,
'k', ' ', 'o', ',', //Ko
'N', '\\', ',', //N
'J', ' ', 'i', ',', //Ni
't', 'S', ' ', 'i', ',', //Chi
'w', ' ', 'a', //Wa
0x00, 0xf7
};
@ -40,7 +40,7 @@ void setup()
Serial.begin(115200);
if (Usb.Init() == -1) {
while(1); //halt
while (1); //halt
}//if (Usb.Init() == -1...
delay( 200 );
}
@ -48,7 +48,7 @@ void setup()
void loop()
{
Usb.Task();
if( Usb.getUsbTaskState() == USB_STATE_RUNNING )
if ( Usb.getUsbTaskState() == USB_STATE_RUNNING )
{
MIDI_poll();
noteOn(0x3f);
@ -61,15 +61,15 @@ void loop()
// Poll USB MIDI Controler
void MIDI_poll()
{
byte inBuf[ 3 ];
//first call?
if(Midi.vid != vid || Midi.pid != pid){
vid = Midi.vid; pid = Midi.pid;
Midi.SendSysEx(exdata, sizeof(exdata));
delay(500);
}
uint8_t size = Midi.RecvData(inBuf);
byte inBuf[ 3 ];
//first call?
if (Midi.vid != vid || Midi.pid != pid) {
vid = Midi.vid; pid = Midi.pid;
Midi.SendSysEx(exdata, sizeof(exdata));
delay(500);
}
uint8_t size = Midi.RecvData(inBuf);
}
//note On