Skip to content

Commit

Permalink
SUKU led color preview report enabled FW-3
Browse files Browse the repository at this point in the history
  • Loading branch information
sukuwc committed Apr 26, 2022
1 parent c62b262 commit f127549
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 31 deletions.
Binary file modified binary/grid_nightly.uf2
Binary file not shown.
3 changes: 2 additions & 1 deletion grid_make/.vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"grid_buf.h": "c",
"grid_module_en16.h": "c",
"grid_hardwaretest.h": "c",
"grid_usb.h": "c"
"grid_usb.h": "c",
"grid_protocol.h": "c"
}
}
35 changes: 10 additions & 25 deletions grid_make/grid/grid_buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1738,28 +1738,8 @@ uint8_t grid_port_process_outbound_ui(struct grid_port* por){
//printf("254\r\n");
}

uint8_t led_report_valid = 0;
uint8_t ui_report_valid = 0;

if (1 && 0){

for(uint8_t j=0; j<grid_led_state.led_count; j++){

if (grid_led_state.led_lowlevel_changed[j]){

uint8_t led_num = j;
uint8_t led_red = grid_led_state.led_lowlevel_red[j];
uint8_t led_gre = grid_led_state.led_lowlevel_gre[j];
uint8_t led_blu = grid_led_state.led_lowlevel_blu[j];

printf("Led %d: %d %d %d\r\n", led_num, led_red, led_gre, led_blu);

//grid_led_state.led_lowlevel_changed[j] = 0;
led_report_valid = 1;
}

}
}

if (1 && 0){

Expand Down Expand Up @@ -1822,7 +1802,10 @@ uint8_t grid_port_process_outbound_ui(struct grid_port* por){
printf("\r\n");
}

if (led_report_valid && 0){

// Report the state of the changed leds

if (grid_led_lowlevel_change_report_length(&grid_led_state)){

struct grid_msg response;

Expand All @@ -1838,19 +1821,21 @@ uint8_t grid_port_process_outbound_ui(struct grid_port* por){
len += strlen(&response_payload[len]);

grid_msg_body_append_text(&response, response_payload);



grid_msg_body_append_printf(&response, GRID_CLASS_LEDPREVIEW_frame_end);

grid_msg_text_set_parameter(&response, 0, GRID_INSTR_offset, GRID_INSTR_length, GRID_INSTR_REPORT_code);
grid_msg_text_set_parameter(&response, 0, GRID_CLASS_LEDPREVIEW_LENGTH_offset, GRID_CLASS_LEDPREVIEW_LENGTH_length, report_length);

grid_msg_packet_close(&response);
grid_msg_packet_send_everywhere(&response);

printf(response.body);
printf("\r\n");

}




// from editor

}
Expand Down
1 change: 1 addition & 0 deletions grid_make/grid/grid_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -877,6 +877,7 @@ enum grid_ui_event_t
#define GRID_CLASS_EVENTPREVIEW_VALUE_offset 11
#define GRID_CLASS_EVENTPREVIEW_VALUE_length 2


// CONFIG STORE Fetch(Read) Configure(Overwrite) Append(Write)
#define GRID_CLASS_CONFIG_code 0x060
#define GRID_CLASS_CONFIG_frame "%c%03x_................%c", GRID_CONST_STX, GRID_CLASS_CONFIG_code, GRID_CONST_ETX
Expand Down
41 changes: 36 additions & 5 deletions grid_make/grid/grid_ui.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ void grid_port_process_ui(struct grid_ui_model* ui, struct grid_port* por){
}

grid_msg_body_append_text(&message, payload);


grid_msg_packet_close(&message);

uint32_t message_length = grid_msg_packet_get_length(&message);
Expand Down Expand Up @@ -179,7 +181,6 @@ void grid_port_process_ui(struct grid_ui_model* ui, struct grid_port* por){
}

}

}

}
Expand All @@ -190,9 +191,7 @@ void grid_port_process_ui(struct grid_ui_model* ui, struct grid_port* por){

//por->cooldown += (2+por->cooldown/2);
por->cooldown += 2;
//por->cooldown = 3;


//por->cooldown = 3;

grid_msg_packet_close(&message);
uint32_t length = grid_msg_packet_get_length(&message);
Expand All @@ -213,9 +212,41 @@ void grid_port_process_ui(struct grid_ui_model* ui, struct grid_port* por){
else{
// LOG UNABLE TO WRITE EVENT
}



}

// LEDREPORT
if (ui_available && grid_led_lowlevel_change_report_length(&grid_led_state) && grid_sys_state.editor_connected){

struct grid_msg response;

grid_msg_init_header(&response, GRID_SYS_GLOBAL_POSITION, GRID_SYS_GLOBAL_POSITION);

uint8_t response_payload[300] = {0};
uint16_t len = 0;
snprintf(response_payload, 299, GRID_CLASS_LEDPREVIEW_frame_start);
len += strlen(&response_payload[len]);

uint16_t report_length = grid_led_lowlevel_change_report(&grid_led_state, -1, &response_payload[len]);

len += strlen(&response_payload[len]);

grid_msg_body_append_text(&response, response_payload);


grid_msg_body_append_printf(&response, GRID_CLASS_LEDPREVIEW_frame_end);

grid_msg_text_set_parameter(&response, 0, GRID_INSTR_offset, GRID_INSTR_length, GRID_INSTR_REPORT_code);
grid_msg_text_set_parameter(&response, 0, GRID_CLASS_LEDPREVIEW_LENGTH_offset, GRID_CLASS_LEDPREVIEW_LENGTH_length, report_length);

grid_msg_packet_close(&response);
grid_msg_packet_send_everywhere(&response);

}




}

Expand Down

0 comments on commit f127549

Please sign in to comment.