-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcvconv.ino
145 lines (122 loc) · 2.28 KB
/
cvconv.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// Simple I2C test for ebay 128x64 oled.
#include <Wire.h>
#include <SoftwareSerial.h>
#include "SSD1306Ascii.h"
#include "SSD1306AsciiWire.h"
#define I2C_ADDRESS 0x3C
SSD1306AsciiWire oled;
SoftwareSerial midi (1, 3); // Rx, Tx
int dataByte;
int velocityByte;
int result;
int isRealTimeCategory(int b)
{
if(b >= 0xF8)
{
return 1;
}
else
{
return 0;
}
}
/**********************
//function declarations
**********************/
int isStatus(int b)
{
if( (b & 0x80) == 0x80)
{
return 1;
}
else if( (b & 0x80) == 0)
{
return 0;
}
}
int isAftertouch(int b)
{
if( (b & 0xf0) == 0xa0)
{
return 1;
}
else //if( (b & 0xf0) != 0xa0)
{
return 0;
}
}
const byte LED = 4; // pin 5 on ATtiny85
//------------------------------------------------------------------------------
void setup() {
analogWrite(LED, 128);
delay(500);
analogWrite(LED, 0);
delay(500);
Wire.begin();
oled.begin(&Adafruit128x64, I2C_ADDRESS);
oled.clear();
oled.setFont(Adafruit5x7);
oled.setScroll(true);
oled.println("Started up!");
oled.println("Attempting midi serial");
midi.begin(31250);
}
void loop()
{
while(midi.available())
{
//This is the protocol for reading new stuff
byte myByte = midi.read();
if(isRealTimeCategory(myByte))
{
;
}
else
{
if(isStatus(myByte))
{
result = (myByte | 0x80); //0b10000000
switch(result)
{
case 0b10000000:
oled.println("0b10000000");
break;
case 0b10010000:
oled.println("0b10010000");
break;
case 0b10100000:
break;
case 0b10110000:
break;
case 0b11000000:
break;
case 0b11010000:
break;
case 0b11100000:
break;
case 0b11110000:
break;
}
}
else
{
byte myByte = midi.read(); //This is the protocol for reading new stuff
if(isRealTimeCategory(myByte))
{
;
}
else
{
if(myByte > 0)
{
oled.println("SMOKAN!!");
}
else
{
oled.println("-------");
}
}
}
}
}
} //END