-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsync24.c
111 lines (78 loc) · 2.13 KB
/
sync24.c
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
unsigned char nbpulse;
unsigned char nbpulse24;
unsigned char nbtik;//LSDJ TIK (or equivalent)
unsigned char nbstep;//LSDJ STEPS
unsigned char nbpat;//LSDJ PAT NUM
unsigned int timer = 0;
unsigned int timer24 = 0;
unsigned char play = 0;//BOOL IS PLAYING
unsigned char midiplay = 0;//BOOL midi realtime message -> play/stop
/**
* Send a lsdj sync bute on RD4 (j6 or j9?)
*/
void SEND_PULSE(void){
// LSDJ SYNC !!!
/*
for(int i=0;i<8,i++){
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
}
*/
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
PORTDbits.RD4 = 1; PORTDbits.RD4 = 0;
return;
}
void SYNC24_PUSH(void){
nbpulse++;
nbpulse24++;
//if(nbpulse24>=2){
if( (play == 1 && nbpulse24>=1) || (midiplay == 1 && nbpulse24>=1) ){
nbpulse24=0;
timer24=4;//SYNC 24 Pulse length (ms) :)
//MIOS_DOUT_PinSet1(1);//SYNC24 CLOCK PIN
//PORTCbits.RC0=1;//new SYNC24 CLOCK PIN
PORTAbits.RA3 = 1;
}
if( (play == 1 && nbpulse>=3) || (midiplay == 1 && nbpulse>=3) ){
nbpulse=0;
nbtik++;
if(nbtik>=8){
nbtik=0;
nbstep++;
PORTAbits.RA1 = 1;//LEDS
}
if(nbstep>=4){
nbstep=0;
nbpat++;
PORTAbits.RA0 = 1;//LEDS
}
if(nbtik>1){
PORTAbits.RA0 = 0;//LEDS
PORTAbits.RA1 = 0;//LEDS
}
//DISPLAY POSITION (based on 4/4)
MIOS_LCD_CursorSet(0x00);
MIOS_LCD_PrintCString("[");
MIOS_LCD_PrintBCD1(nbtik+1);//
MIOS_LCD_PrintCString("][");
MIOS_LCD_PrintBCD1(nbstep+1);//
MIOS_LCD_PrintCString("][");
MIOS_LCD_PrintBCD2(nbpat);//
MIOS_LCD_PrintCString("]");
}
// INIT DELAY //
if(play==0){
play=1;// PLAY
PORTAbits.RA0 = 1;//LEDS
PORTAbits.RA2 = 1;//new SYNC24 startstop PIN
MIOS_MIDI_TxBufferPut(0xFA); // MIDI START
}
timer=100;// millisec
//MIOS_MIDI_TxBufferPut(0xF8); // SEND MIDI REALTIME CLOCK
SEND_PULSE();
}