-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathxfm2.cpp
65 lines (59 loc) · 1.69 KB
/
xfm2.cpp
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
#include <Arduino.h>
#include "xfm2.h"
#include "XFM2_vars.h"
int program=0;
void change_unit() {
// Default to unit 1
if (active_unit == 1) {
active_unit = 2;
//swap unit params
//or do 2 memcpy's
for(int i=0;i<n_params;i++) {
unit1_params[i]=params[i];
params[i]=unit2_params[i];
}
} else {
active_unit = 1;
//swap unit params
//or do 2 memcpy's
for(int i=0;i<n_params;i++) {
unit2_params[i]=params[i];
params[i]=unit1_params[i];
}
}
Serial1.write(active_unit);
// Serial.print("Active Unit Changed:");
// Serial.println(active_unit);
delay(30);
}
// Code for setting the parameter on the XFM2
void set_parameter( int param, int value ) {
Serial1.write( 's' ); // 's' = Set Parameter
if( param > 255 ) {
// Parameters above 255 have a two-byte format: b1 = 255, b2 = x-256
Serial1.write( 255 );
Serial1.write( param - 256 );
Serial1.write( value );
}
else {
Serial1.write( param );
Serial1.write( value );
}
}
// Code for getting a selected parameter on the XFM2
int get_parameter( int param) {
Serial1.write( 'g' ); // 'g' = Get Parameter
if( param > 255 ) {
// Parameters above 255 have a two-byte format: b1 = 255, b2 = x-256
Serial1.write( 255 );
Serial1.write( param - 256 );
} else Serial1.write( param );
while(!Serial1.available());//wait for it
return Serial1.read();
}
// Code for getting all parameters on the XFM2
void get_all_parameter() {
Serial1.write( '2' );
for (int i = 0; i < n_params; i++)
params[i]=get_parameter(i);
}