// fill tmp region with new content // given input index and foreground color static void render_line(s16 idx, u8 fg) { region_fill(lineRegion, 0x0); if( (idx >= 0) && (idx < files_get_scene_count()) ) { clearln(); appendln((const char*)files_get_scene_name(idx)); // stick a null character at the end... lineBuf[SCENE_NAME_LEN - 1] = '\0'; font_string_region_clip(lineRegion, lineBuf, 2, 0, fg, 0); } }
static void show_foot3(void) { u8 fill = 0; u8 fore = 0xf; if(altMode) { fill = 0xf; fore = 0; } region_fill(footRegion[3], fill); font_string_region_clip(footRegion[3], "ALT", 0, 0, fore, fill); }
static void show_foot1(void) { u8 fill = 0; if(keyPressed == 1) { fill = 0x5; } region_fill(footRegion[1], fill); if(altMode) { if(net_get_in_play(*pageSelect)) { font_string_region_clip(footRegion[1], "HIDE", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[1], "SHOW", 0, 0, 0xf, fill); } } else { if(net_get_in_preset(*pageSelect)) { font_string_region_clip(footRegion[1], "EXC", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[1], "INC", 0, 0, 0xf, fill); } } }
// render new operator type name void render_op_type(void) { const char* name = op_registry[userOpTypes[newOpType]].name; // print_dbg("\r\n new op selection: "); // print_dbg(name); region_fill(headRegion, 0x0); clearln(); appendln_char('+'); appendln(name); endln(); font_string_region_clip(headRegion, lineBuf, 0, 0, 0xa, 0); }
static void show_foot2(void) { u8 fill = 0; if(keyPressed == 2) { fill = 0x5; } region_fill(footRegion[2], fill); if(altMode) { #if 0 if(playFilter) { font_string_region_clip(footRegion[2], "ALL", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[2], "FILT", 0, 0, 0xf, fill); } #endif } else { if(zeroed) { font_string_region_clip(footRegion[2], "MAX", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[2], "ZERO", 0, 0, 0xf, fill); } } }
// display the function key labels according to current state static void show_foot0(void) { u8 fill = 0; if(keyPressed == 0) { fill = 0x5; } region_fill(footRegion[0], fill); if(altMode) { /// TODO // font_string_region_clip(footRegion[0], "GATHER", 0, 0, 0xf, fill); } else { font_string_region_clip(footRegion[0], "STORE", 0, 0, 0xf, fill); } }
// render a given line void render_line(s16 idx) { region_fill(lineRegion, 0x0); if((idx >= 0) && (idx < net_num_ops()) ) { clearln(); appendln_idx_lj((u8)idx); appendln_char('.'); appendln(net_op_name(idx)); endln(); font_string_region_clip(lineRegion, lineBuf, 0, 0, 0xa, 0); // region_fill_part(lineRegion, LINE_UNDERLINE_OFFSET, LINE_UNDERLINE_LEN, 0x1); } }
// select void select_ops(void) { // assign global scroll region pointer // also marks dirty render_set_scroll(¢erScroll); // other regions are static in top-level render, with global handles region_fill(headRegion, 0x0); font_string_region_clip(headRegion, "OPERATORS", 0, 0, 0xf, 0x1); // assign handlers app_event_handlers[ kEventEncoder0 ] = &handle_enc_0 ; app_event_handlers[ kEventEncoder1 ] = &handle_enc_1 ; app_event_handlers[ kEventEncoder2 ] = &handle_enc_2 ; app_event_handlers[ kEventEncoder3 ] = &handle_enc_3 ; app_event_handlers[ kEventSwitch0 ] = &handle_key_0 ; app_event_handlers[ kEventSwitch1 ] = &handle_key_1 ; app_event_handlers[ kEventSwitch2 ] = &handle_key_2 ; app_event_handlers[ kEventSwitch3 ] = &handle_key_3 ; }
// fill tmp region with new content // given input index and foreground color static void render_line(s16 idx, u8 fg) { const s16 opIdx = net_in_op_idx(idx); region_fill(lineRegion, 0x0); if(opIdx >= 0) { // operator input // build descriptor string clearln(); appendln_idx_lj(opIdx); appendln_char('.'); appendln( net_op_name(opIdx) ); appendln_char('/'); appendln( net_in_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, fg, 0); clearln(); op_print(lineBuf, net_get_in_value(idx)); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_SHORT, 0, fg, 0); } else { // parameter input clearln(); appendln_idx_lj( (int)net_param_idx(idx)); appendln_char('.'); appendln( net_in_name(idx)); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xa, 0); clearln(); // op_print(lineBuf, net_get_in_value(idx)); /// FIXME: this is pretty dumb, // params and inputs should just be on separate pages i guess net_get_param_value_string(lineBuf, idx); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_LONG, 0, fg, 0); } // draw something to indicate play mode visibility if(net_get_in_play(idx)) { font_string_region_clip(lineRegion, ".", 0, 0, fg, 0); } // draw something to indicate preset inclusion if(net_get_in_preset(idx)) { font_string_region_clip(lineRegion, ".", 126, 0, fg, 0); } }
// select void select_scenes(void) { // print_dbg("\r\n select SCENES... "); // assign global scroll region pointer // also marks dirty // print_dbg("\r\n set scroll region..."); render_set_scroll(¢erScroll); // print_dbg("\r\n fill head region..."); // other regions are static in top-level render, with global handles region_fill(headRegion, 0x0); font_string_region_clip(headRegion, "SCENES", 0, 0, 0xf, 0x1); show_foot(); // assign handlers // print_dbg("\r\n assign page handlers....."); app_event_handlers[ kEventEncoder0 ] = &handle_enc_0 ; app_event_handlers[ kEventEncoder1 ] = &handle_enc_1 ; app_event_handlers[ kEventEncoder2 ] = &handle_enc_2 ; app_event_handlers[ kEventEncoder3 ] = &handle_enc_3 ; app_event_handlers[ kEventSwitch0 ] = &handle_key_0 ; app_event_handlers[ kEventSwitch1 ] = &handle_key_1 ; app_event_handlers[ kEventSwitch2 ] = &handle_key_2 ; app_event_handlers[ kEventSwitch3 ] = &handle_key_3 ; }
bool screen_refresh_live() { bool screen_dirty = false; if (dirty & D_INPUT) { line_editor_draw(&le, '>', &line[7]); screen_dirty = true; dirty &= ~D_INPUT; } if (dirty & D_MESSAGE) { char s[32]; if (status != E_OK) { strcpy(s, tele_error(status)); if (error_msg[0]) { size_t len = strlen(s); strcat(s, ": "); strncat(s, error_msg, 32 - len - 3); error_msg[0] = 0; } status = E_OK; } else if (output.has_value) { itoa(output.value, s, 10); output.has_value = false; } else if (show_welcome_message) { strcpy(s, TELETYPE_VERSION ": "); strcat(s, git_version); show_welcome_message = false; } else { s[0] = 0; } region_fill(&line[6], 0); font_string_region_clip(&line[6], s, 0, 0, 0x4, 0); screen_dirty = true; dirty &= ~D_MESSAGE; } if (dirty & D_LIST) { for (int i = 0; i < 6; i++) region_fill(&line[i], 0); screen_dirty = true; dirty &= ~D_LIST; } if ((activity != activity_prev)) { region_fill(&line[0], 0); // slew icon uint8_t slew_fg = activity & A_SLEW ? 15 : 1; line[0].data[98 + 0 + 512] = slew_fg; line[0].data[98 + 1 + 384] = slew_fg; line[0].data[98 + 2 + 256] = slew_fg; line[0].data[98 + 3 + 128] = slew_fg; line[0].data[98 + 4 + 0] = slew_fg; // delay icon uint8_t delay_fg = activity & A_DELAY ? 15 : 1; line[0].data[106 + 0 + 0] = delay_fg; line[0].data[106 + 1 + 0] = delay_fg; line[0].data[106 + 2 + 0] = delay_fg; line[0].data[106 + 3 + 0] = delay_fg; line[0].data[106 + 4 + 0] = delay_fg; line[0].data[106 + 0 + 128] = delay_fg; line[0].data[106 + 0 + 256] = delay_fg; line[0].data[106 + 0 + 384] = delay_fg; line[0].data[106 + 0 + 512] = delay_fg; line[0].data[106 + 4 + 128] = delay_fg; line[0].data[106 + 4 + 256] = delay_fg; line[0].data[106 + 4 + 384] = delay_fg; line[0].data[106 + 4 + 512] = delay_fg; // queue icon uint8_t stack_fg = activity & A_STACK ? 15 : 1; line[0].data[114 + 0 + 0] = stack_fg; line[0].data[114 + 1 + 0] = stack_fg; line[0].data[114 + 2 + 0] = stack_fg; line[0].data[114 + 3 + 0] = stack_fg; line[0].data[114 + 4 + 0] = stack_fg; line[0].data[114 + 0 + 256] = stack_fg; line[0].data[114 + 1 + 256] = stack_fg; line[0].data[114 + 2 + 256] = stack_fg; line[0].data[114 + 3 + 256] = stack_fg; line[0].data[114 + 4 + 256] = stack_fg; line[0].data[114 + 0 + 512] = stack_fg; line[0].data[114 + 1 + 512] = stack_fg; line[0].data[114 + 2 + 512] = stack_fg; line[0].data[114 + 3 + 512] = stack_fg; line[0].data[114 + 4 + 512] = stack_fg; // metro icon uint8_t metro_fg = activity & A_METRO ? 15 : 1; line[0].data[122 + 0 + 0] = metro_fg; line[0].data[122 + 0 + 128] = metro_fg; line[0].data[122 + 0 + 256] = metro_fg; line[0].data[122 + 0 + 384] = metro_fg; line[0].data[122 + 0 + 512] = metro_fg; line[0].data[122 + 1 + 128] = metro_fg; line[0].data[122 + 2 + 256] = metro_fg; line[0].data[122 + 3 + 128] = metro_fg; line[0].data[122 + 4 + 0] = metro_fg; line[0].data[122 + 4 + 128] = metro_fg; line[0].data[122 + 4 + 256] = metro_fg; line[0].data[122 + 4 + 384] = metro_fg; line[0].data[122 + 4 + 512] = metro_fg; // mutes for (size_t i = 0; i < 8; i++) { // make it staggered to match how the device looks size_t stagger = i % 2 ? 384 : 128; uint8_t mute_fg = ss_get_mute(&scene_state, i) ? 15 : 1; line[0].data[87 + i + stagger] = mute_fg; } activity_prev = activity; screen_dirty = true; activity &= ~A_MUTES; } return screen_dirty; }
// fill tmp region with new content // given input index and foreground color static void render_line(s16 idx, u8 fg) { // const s16 opIdx = net_in_op_idx(idx); s16 target; s16 targetOpIdx = -1; s16 srcOpIdx; region_fill(lineRegion, 0x0); // print_dbg("\r\n page_outs: render_line"); if(idx >= net_num_outs() ) { return; } if(targetSelect) { // print_dbg(" , in targetSelect"); target = tmpTarget; } else { target = net_get_target(idx); } srcOpIdx = net_out_op_idx(idx); targetOpIdx = net_in_op_idx(target); /* print_dbg(" , target: "); */ /* print_dbg_ulong(target); */ if(target >= 0) { //// output has target // the network doesn't actually execute connections from an op to itself. // reflect this in UI by dimming this line if(targetOpIdx == srcOpIdx) { fg = 0x5; } // render output clearln(); appendln_idx_lj(srcOpIdx); appendln_char('.'); appendln( net_op_name(srcOpIdx)); appendln_char('/'); appendln( net_out_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 2, 0, fg, 0); // render target targetOpIdx = net_in_op_idx(target); clearln(); appendln("-> "); if(targetOpIdx >= 0) { // print_dbg(" , target is op in"); // target is operator input appendln_idx_lj(net_in_op_idx(target)); appendln_char('.'); appendln( net_op_name(net_in_op_idx(target)) ); appendln_char('/'); appendln( net_in_name(target) ); } else { // print_dbg(" , target is param in"); // target is parameter input appendln_idx_lj( (int)net_param_idx(target)); appendln_char('.'); appendln( net_in_name(target)); } endln(); font_string_region_clip(lineRegion, lineBuf, 60, 0, fg, 0); clearln(); } else { //// no target // render output clearln(); appendln_idx_lj(net_out_op_idx(idx)); appendln_char('.'); appendln( net_op_name(net_out_op_idx(idx))); appendln_char('/'); appendln( net_out_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 2, 0, fg, 0); } // draw something to indicate preset inclusion if(net_get_out_preset(idx)) { font_string_region_clip(lineRegion, ".", 125, 0, fg, 0); } // underline // region_fill_part(lineRegion, LINE_UNDERLINE_FSET, LINE_UNDERLINE_LEN, 0x1); }
// redraw based on provisional preset seleciton void redraw_ins_preset ( void ) { s32 max = net_num_ins() - 1; u8 i=0; u8 n = *pageSelect - 3; u8 enabled; io_t opVal; s32 paramVal; s16 opIdx; print_dbg("\r\n redraw_ins_preset() "); while(i<8) { region_fill(lineRegion, 0x0); opIdx = net_in_op_idx(n); if(n <= max) { enabled = net_get_in_preset(n); if(opIdx < 0 ) { // parameter... clearln(); appendln_idx_lj( (int)net_param_idx(n)); appendln_char('.'); appendln( net_in_name(n)) ; endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xf, 0); clearln(); if(enabled) { paramVal = preset_get_selected()->ins[n].value; net_get_param_value_string_conversion(lineBuf, net_param_idx(n), paramVal); } else { net_get_param_value_string(lineBuf, n); } font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_LONG, 0, 0xf, 0); } else { // op input clearln(); appendln_idx_lj(opIdx); appendln_char('.'); appendln( net_op_name(opIdx) ); appendln_char('/'); appendln( net_in_name(n) ); endln(); font_string_region_clip(lineRegion, lineBuf, 4, 0, 0xf, 0); if(enabled) { opVal = preset_get_selected()->ins[n].value; } else { opVal = net_get_in_value(n); } op_print(lineBuf, opVal); font_string_region_clip(lineRegion, lineBuf, LINE_VAL_POS_SHORT, 0, 0xf, 0); } // draw something to indicate preset inclusion if(enabled) { font_string_region_clip(lineRegion, ".", 126, 0, 0xf, 0); } } render_to_scroll_line(i, 0); ++i; ++n; } // print_dbg("\r\n\r\n"); draw_preset_name(); }
// redraw based on provisional preset seleciton void redraw_outs_preset (void) { // s32 max = net_num_outs() - 1; u8 i=0; u8 idx = *pageSelect - 3; u8 fg; u8 enabled; s16 target; s16 targetOpIdx = -1; s16 srcOpIdx; s32 preSel = preset_get_select(); // print_dbg("\r\n redraw_outs_preset()"); while(i<8) { region_fill(lineRegion, 0x0); if(idx >= net_num_outs() ) { return; } enabled = preset_out_enabled(preSel, idx); if(enabled) { // if it's enabled, show the preset's target (including if blank) target = preset_get_selected()->outs[idx].target; srcOpIdx = net_out_op_idx(idx); targetOpIdx = net_in_op_idx(target); if(target >= 0) { //// output has target // the network doesn't actually execute connections from an op to itself. // reflect this in UI by dimming this line if(targetOpIdx == srcOpIdx) { fg = 0x5; } // render output clearln(); appendln_idx_lj(srcOpIdx); appendln_char('.'); appendln( net_op_name(srcOpIdx)); appendln_char('/'); appendln( net_out_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 2, 0, fg, 0); // render target targetOpIdx = net_in_op_idx(target); clearln(); appendln("-> "); if(targetOpIdx >= 0) { // target is operator input appendln_idx_lj(net_in_op_idx(target)); appendln_char('.'); appendln( net_op_name(net_in_op_idx(target)) ); appendln_char('/'); appendln( net_in_name(target) ); } else { // target is parameter input appendln_idx_lj( (int)net_param_idx(target)); appendln_char('.'); appendln( net_in_name(target)); } endln(); font_string_region_clip(lineRegion, lineBuf, 60, 0, fg, 0); clearln(); } else { //// no target // render output clearln(); appendln_idx_lj(net_out_op_idx(idx)); appendln_char('.'); appendln( net_op_name(net_out_op_idx(idx))); appendln_char('/'); appendln( net_out_name(idx) ); endln(); font_string_region_clip(lineRegion, lineBuf, 2, 0, fg, 0); } // draw something to indicate preset inclusion if(net_get_out_preset(idx)) { font_string_region_clip(lineRegion, ".", 126, 0, fg, 0); } } else { // not enabled, draw as normal with dim coloring render_line(idx, 0x5); } render_to_scroll_line(i, 0); ++i; ++idx; } draw_preset_name(); }
// draw to the head region void notify(const char* str) { region_fill(headRegion, 0x0); font_string_region_clip(headRegion, str, 0, 0, 0xa, 0); headRegion->dirty = 1; render_update(); }
// draw preset name in header void draw_preset_name(void) { font_string_region_clip(headRegion, " ", 64, 0, 0, 0); font_string_region_clip(headRegion, preset_name((u8)preset_get_select()), 64, 0, 0x5, 0); headRegion->dirty = 1; }