//--- network input functions static void op_step_in_focus(op_step_t* op, const io_t v) { if((v) > 0) { op->focus = OP_ONE; } else { // if(op->focus>0) { net_monome_grid_clear(); } op->focus = 0; } net_monome_set_focus( &(op->monome), op->focus > 0); }
const u8* op_step_unpickle(op_step_t* mgrid, const u8* src) { src = unpickle_io(src, (u32*)&(mgrid->focus)); src = unpickle_io(src, (u32*)&(mgrid->size)); /* probably shouldn't call this here... if we assume that network monome device focus is null during unpickling, it will be ok. that assumption should hold true, but if it doesn't, or if we change something and forget to update this, the result is both and hard to track (dereferencing a garbage pointer.) we should just explicitly check for focused grid ops after scene recall, last one wins... */ net_monome_set_focus( &(mgrid->monome), mgrid->focus > 0); return src; }
//------------------------------------------------- //----- extern function definition void op_step_init(void* mem) { u8 i; // print_dbg("\r\n op_step_init "); op_step_t* op = (op_step_t*)mem; // superclass functions //--- op op->super.in_fn = op_step_in_fn; op->super.pickle = (op_pickle_fn) (&op_step_pickle); op->super.unpickle = (op_unpickle_fn) (&op_step_unpickle); //--- monome op->monome.handler = (monome_handler_t)&op_step_handler; op->monome.op = op; // superclass state op->super.type = eOpStep; op->super.flags |= (1 << eOpFlagMonomeGrid); op->super.numInputs = 3; op->super.numOutputs = 8; op->super.in_val = op->in_val; op->super.out = op->outs; op->super.opString = op_step_opstring; op->super.inString = op_step_instring; op->super.outString = op_step_outstring; op->in_val[0] = &(op->focus); op->in_val[1] = &(op->size); op->outs[0] = -1; op->outs[1] = -1; op->outs[2] = -1; op->outs[3] = -1; op->outs[4] = -1; op->outs[5] = -1; op->outs[6] = -1; op->outs[7] = -1; op->s_start = 0; op->s_end = 7; op->s_length = 7; op->s_now = 0; op->s_cut = 0; op->s_start2 = 0; op->s_end2 = 7; op->s_length2 = 7; op->s_now2 = 0; op->s_cut2 = 0; op->size = monome_size_x(); op->focus = OP_ONE; net_monome_set_focus(&(op->monome), 1); // init monome drawing, maybe should clear first monomeLedBuffer[monome_xy_idx(0, 0)] = 15; monomeLedBuffer[monome_xy_idx(0, 2)] = 15; for(i=0;i<op->size;i++) { monomeLedBuffer[monome_xy_idx(i, 1)] = 15; monomeLedBuffer[monome_xy_idx(i, 3)] = 15; } monome_set_quadrant_flag(0); }
// de-init void op_step_deinit(void* op) { // release focus net_monome_set_focus(&(((op_step_t*)op)->monome), 0); }
const u8* op_step_unpickle(op_step_t* mgrid, const u8* src) { src = unpickle_io(src, (u32*)&(mgrid->focus)); src = unpickle_io(src, (u32*)&(mgrid->size)); net_monome_set_focus( &(mgrid->monome), mgrid->focus > 0); return src; }