/
aiwa-lx-110.ino
219 lines (185 loc) · 4.56 KB
/
aiwa-lx-110.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
// https://www.arduino.cc/en/Reference/AttachInterrupt
// https://www.arduino.cc/en/Reference/Volatile
/**************************************
* Constants
***************************************/
int const clock = 2;
int const latch = 3;
int const data = 4;
/**************************************
* Variables
***************************************/
int running = 0;
int tracks = 6; // Amount of tracks on LP
boolean trackList[7] = {false, false, false, false, false, false, false};
/**************************************
* Setup
***************************************/
void setup() {
// I/O init
Serial.println('I/O init');
Serial.begin(9600);
pinMode(clock,OUTPUT);
pinMode(latch,OUTPUT);
pinMode(data,OUTPUT);
// Read Sensors
// Serial.println('Read sensors');
// needlePosition = digitalRead(needleSensor) == HIGH ? true : false;
// Ignition
// Serial.println('Ignition');
}
/**************************************
* Loop
***************************************/
void loop() {
// Processa a seleção das tracks
processTrackButtons();
updateTrackInterface();
// Processa os comandos
processCommandButtons();
}
/**************************************
* Interface - Tracks Functions
***************************************/
// Process track selection
void processTrackButtons() {
// ler porta com entrada do Key das Tracks
float value = 0.1;
int track_button = 0;
// montar tabela de conversao de tensão para track
switch( (int) value ) {
case 1:
track_button = 1;
break;
case 2:
track_button = 2;
break;
case 3:
track_button = 3;
break;
case 4:
track_button = 4;
break;
case 5:
track_button = 5;
break;
case 6:
track_button = 6;
break;
case 7:
track_button = 7;
break;
case 8:
track_button = 8;
break; // clear all
default:
return;
}
if(track_button == 8) {
// deseleciona todos
for(int i = 0; i < 7; i++) { trackList[i] = false; }
} else if(track_button >= tracks) { // tem que ser menor ou igual a quantidades de faixas do disco
// inverte o conteudo do selecionado
trackList[track_button] = !trackList[track_button];
}
}
// Process commands
void processCommandButtons() {
float value;
if (running == 0) {
value = 0.1;
} else {
value = (float) running;
}
switch((int) value) {
case 1:
playCue();
break;
case 2:
repeat();
break;
case 3:
intro();
break;
case 4:
forward();
break;
case 5:
rewind();
break;
case 6:
needle();
break;
case 7:
nextTrack();
break;
case 8:
previousTrack();
break;
case 9:
scanTracks();
break;
default:
break;
}
}
/**************************************
* Player Functions
***************************************/
void intro() {
// toca cada uma dela por x segundos
}
void repeat() {
// repete infinitas vezes as musicas selecionadas
// se não possuir musicas selecionadas repete o disco todo
}
void nextTrack() {
// próxima musica
}
void forward() {
// adianta um pouco a música
}
void previousTrack() {
// musica anterior
}
void rewind() {
// volta um pouco a música
}
void playCue() {
// começa a tocar
// caso tenha musicas selecionadas na playlist toca somente elas
// caso não tenha, toca o disco todo
}
/**************************************
* Engine Functions
***************************************/
void needle() {
// levanta a agulha ou abaixa a agulha
}
void fowardNeedle() {
// anda com o carrinho pra frente
}
void rewindNeedle() {
// anda com o carrinho pra trás
}
void directDrive(boolean status) {
// controla o direct drive
}
int scanTracks() {
// send needle to 0
// upNeedle();
return 5;
}
void updateTrackInterface() {
digitalWrite(latch,LOW);
for (int x = 0; x <= 7; x++) {
digitalWrite(clock,LOW);
if (trackList[x]) {
digitalWrite(data,HIGH);
} else {
digitalWrite(data,LOW);
}
digitalWrite(clock,HIGH);
}
digitalWrite(latch,HIGH);
}