Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jam improvements, USB fixes and 7 segment AVTKA support #66

Merged
merged 14 commits into from Dec 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions ctlra/ctlra.c
Expand Up @@ -163,8 +163,10 @@ CTLRA_DEVICE_DECL(avtka);
info->vendor, info->device);
struct ctlra_dev_t *dev = ctlra_dev_connect(c, ctlra_avtka_connect,
0x0, 0x0, info);
if(!dev)
CTLRA_WARN(c, "avtka dev returned %p\n", dev);
if(!dev) {
CTLRA_ERROR(c, "avtka dev returned %p\n", dev);
return -EINVAL;
}

/* assuming info setup is ok, call accept dev callback in app */
int accepted = c->accept_dev_func(&dev->info,
Expand Down
1 change: 1 addition & 0 deletions ctlra/ctlra.h
Expand Up @@ -127,6 +127,7 @@ typedef const char *(*ctlra_info_get_name_func)(enum ctlra_event_type_t type,

#define CTLRA_ITEM_FB_LED_STRIP (1<< 7)
#define CTLRA_ITEM_FB_SCREEN (1<< 8)
#define CTLRA_ITEM_FB_7_SEGMENT (1<< 9)

#define CTLRA_ITEM_HAS_FB_ID (1<<31)
struct ctlra_item_info_t {
Expand Down
13 changes: 12 additions & 1 deletion ctlra/devices/avtka.c
Expand Up @@ -101,6 +101,12 @@ avtka_light_set(struct ctlra_dev_t *base, uint32_t light_id,
avtka_redraw(a);
}

void
avtka_feedback_digits(struct ctlra_dev_t *base, uint32_t feedback_id,
float value)
{
}

void
avtka_light_flush(struct ctlra_dev_t *base, uint32_t force)
{
Expand Down Expand Up @@ -470,6 +476,11 @@ ctlra_build_avtka_ui(struct cavtka_t *dev,
ai.draw = AVTKA_DRAW_BUTTON;
}

if(item->flags & CTLRA_ITEM_FB_7_SEGMENT) {
ai.draw = AVTKA_DRAW_7_SEG;
ai.params[0] = item->params[0];
}

ai.interact = 0;

//snprintf(ai.name, sizeof(ai.name), "%s", name);
Expand All @@ -480,7 +491,7 @@ ctlra_build_avtka_ui(struct cavtka_t *dev,
return 0;
}
dev->id_to_ctlra[idx].type = CTLRA_FEEDBACK_ITEM;
dev->id_to_ctlra[idx].id = 6;
dev->id_to_ctlra[idx].id = i;
}

/* return the pointer to the new UI instance */
Expand Down
33 changes: 31 additions & 2 deletions ctlra/devices/ni_kontrol_x1_mk2.c
Expand Up @@ -262,6 +262,33 @@ static const struct ni_kontrol_x1_mk2_ctlra_t buttons[] = {

#define CONTROLS_SIZE (SLIDERS_SIZE + BUTTONS_SIZE)


static struct ctlra_item_info_t feedback_info[] = {
/* horizontal LED strip */
{ .x = 10, .y = 180, .w = 100, .h = 3,
.flags = CTLRA_ITEM_FB_LED_STRIP,
.params = {0, 1, 1, 0},
},
/* Left 7 segs */
{ .x = 10, .y = 141, .w = (3 * 7) + 2, .h = 10,
.flags = CTLRA_ITEM_FB_7_SEGMENT,
.params = {3, 0, 0, 0},
},
/* Right 7 segs */
{ .x = 88, .y = 141, .w = (3 * 7) + 2, .h = 10,
.flags = CTLRA_ITEM_FB_7_SEGMENT,
.params = {3, 0, 0, 0},
},
};
#define FEEDBACK_SIZE (sizeof(feedback_info) / sizeof(feedback_info[0]))

static const char *ni_kontrol_x1_mk2_feedback_names[] = {
/* Encoders */
"LED Strip",
"7-seg L",
"7-seg R",
};

/* Multi-colour lights take multiple bytes for colour, but only one
* enum value - hence lights size is > led count */
#define LIGHTS_SIZE (NI_KONTROL_X1_MK2_LED_COUNT+16)
Expand Down Expand Up @@ -292,6 +319,7 @@ ni_kontrol_x1_mk2_control_get_name(enum ctlra_event_type_t type,
num_of_type[CTLRA_EVENT_SLIDER] = SLIDER_SIZE;
num_of_type[CTLRA_EVENT_BUTTON] = BUTTON_SIZE;
num_of_type[CTLRA_EVENT_ENCODER] = ENCODER_SIZE;
num_of_type[CTLRA_FEEDBACK_ITEM] = FEEDBACK_SIZE;

uint16_t n = num_of_type[type];
if(control >= n)
Expand All @@ -301,6 +329,7 @@ ni_kontrol_x1_mk2_control_get_name(enum ctlra_event_type_t type,
name_by_type[CTLRA_EVENT_SLIDER] = ni_kontrol_x1_mk2_slider_names;
name_by_type[CTLRA_EVENT_BUTTON] = ni_kontrol_x1_mk2_button_names;
name_by_type[CTLRA_EVENT_ENCODER] = ni_kontrol_x1_mk2_encoder_names;
name_by_type[CTLRA_FEEDBACK_ITEM] = ni_kontrol_x1_mk2_feedback_names;

return name_by_type[type][control];
}
Expand Down Expand Up @@ -632,10 +661,10 @@ struct ctlra_dev_info_t ctlra_ni_kontrol_x1_mk2_info = {
.control_info[CTLRA_EVENT_SLIDER] = sliders_info,
.control_count[CTLRA_EVENT_BUTTON] = BUTTON_SIZE,
.control_info[CTLRA_EVENT_BUTTON] = buttons_info,
.control_count[CTLRA_FEEDBACK_ITEM] = FEEDBACK_SIZE,
.control_info[CTLRA_FEEDBACK_ITEM] = feedback_info,
#if 0
.control_count[CTLRA_EVENT_ENCODER] = ENCODER_SIZE,
//.control_count[CTLRA_FEEDBACK_ITEM] = FEEDBACK_SIZE,
.control_info[CTLRA_FEEDBACK_ITEM] = feedback_info,
#endif

.get_name = ni_kontrol_x1_mk2_control_get_name,
Expand Down