From 36251d0b5eabc70772e0b2ca3dda5f28a1a87567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Mo=C5=84?= Date: Fri, 30 Jan 2009 11:01:16 +0100 Subject: [PATCH] add switch_user_preset and switch_system_preset --- gdigi.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/gdigi.c b/gdigi.c index 2411033..49ee57f 100644 --- a/gdigi.c +++ b/gdigi.c @@ -30,8 +30,9 @@ static char magic[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x7F, 0x7F, 0x04, 0x7 static char presets_user[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x21, 0x00, 0x07, 0x01, 0x6C, 0xF7}; /* this command seems to query user presets? */ static char presets_system[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x21, 0x00, 0x07, 0x00, 0x6D, 0xF7}; /* this command seems to query system presets? */ -static char magic3[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x2A, 0x00, 0x04, 0x04, 0x00, 0x62, 0x05, 0xF7, 0x00, 0x00}; -static char magic4[] = {0x0B, 0xB0, 0x40, 0x00}; +static char magic3[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x2A, 0x00, 0x04, 0x04, 0x00, 0x62, 0x05, 0xF7, 0x00, 0x00}; /* seems to query active preset name */ +static char magic4[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x2B, 0x00, 0x04, 0x00, 0x01, 0x77, 0x05, 0xF7, 0x00, 0x00}; +static char magic5[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x3A, 0x00, 0x04, 0x00, 0x01, 0x77, 0x05, 0xF7, 0x00, 0x00}; int read_device(struct usb_dev_handle *handle, int bytes) { @@ -355,6 +356,43 @@ void set_comp_on_off(struct usb_dev_handle *handle, gboolean val) printf("wrote: %d\n", i); } +/* x = 0 to 60 */ +void switch_user_preset(struct usb_dev_handle *handle, int x) +{ + static char switch_preset[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x39, 0x00, 0x04, 0x01 /* bank = user */, 0x00 /* no */, 0x04, 0x04, 0x00, 0x00, 0x01, 0x06, 0x00 /* confirm */, 0xF7, 0x00, 0x00}; + int val; + + switch_preset[14] = x; + val = (7 - ((x & 0xf0) >> 4)) << 4; + val += (x & 0x0f); + if (((x & 0x0f) % 2) == 1) { + val -= 1; + } else { + val += 1; + } + switch_preset[21] = val; + + int i; + i = usb_bulk_write(handle, 4, switch_preset, sizeof(switch_preset), TIMEOUT); + printf("wrote: %d\n", i); +} + +/* x = 0 to 60 */ +void switch_system_preset(struct usb_dev_handle *handle, int x) +{ + static char switch_preset[] = {0x04, 0xF0, 0x00, 0x00, 0x04, 0x10, 0x00, 0x5E, 0x04, 0x02, 0x39, 0x00, 0x04, 0x00 /* bank = system */, 0x00 /* no */, 0x04, 0x04, 0x00, 0x00, 0x01, 0x06, 0x00 /* confirm */, 0xF7, 0x00, 0x00}; + int val; + + switch_preset[14] = x; + val = (7 - ((x & 0xf0) >> 4)) << 4; + val += (x & 0x0f); + switch_preset[21] = val; + + int i; + i = usb_bulk_write(handle, 4, switch_preset, sizeof(switch_preset), TIMEOUT); + printf("wrote: %d\n", i); +} + void value_changed_cb(GtkSpinButton *spinbutton, void (*callback)(struct usb_dev_handle*, int)) { int val = gtk_spin_button_get_value_as_int(spinbutton);