void ICACHE_FLASH_ATTR plug_object_init() { plug_init(); pando_object plug_object = { 1, plug_object_pack, plug_object_unpack, }; register_pando_object(plug_object); }
void ICACHE_FLASH_ATTR user_plug_init() { uint8 i; for (i=0; i<PLUG_LED_COUNT; i++) { PIN_FUNC_SELECT(plug_led_hardware[i].gpio_name, plug_led_hardware[i].gpio_func); } PIN_FUNC_SELECT(plug_reset_hardware.gpio_name, plug_reset_hardware.gpio_func); plug_init(); plug_wifi_blink_start(); }
t_node *add_pipe(t_context *C) { // NEW BLOCK t_node *node_block = add_block(C,"pipe"); t_block *block = ( t_block *) node_block->data; block->block_state.draw_outline=1; // INT add_part_slider_int(C,block,"state",NULL); // CLONE //t_node *node_brick_clone=add_part_slider_add( C, block, "pipe", NULL); t_node *node_brick_clone = add_part_slider_add_bricks( C, block, "pipe", 2, NULL); t_brick *brick_clone = ( t_brick *) node_brick_clone->data; // re-init to float (old int data used by plug_out) plug_init(&brick_clone->plug_in,dt_float,brick_clone,NULL,0); brick_clone->exe=op_pipe; return node_block; }
int cmd_reply(char *src, char *dest, char *cmd, char *msg) { char buf[IRC_BUF_LENGTH]; struct plug_msg *tmp; char *n; /* pool number (if specified) */ n = strtok(msg, " "); if (strcmp(cmd, RM_POOLS_CMD) == 0) { int i; sprintf(buf, "%s", "Available map pools:"); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); sprintf(buf, "%s", "All pools (don't specify a number)"); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); for (i = 0; i < npools; i++) { sprintf(buf, "%d. %s", i+1, pools[i]->name); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); } } else if (strcmp(cmd, RM_RELOAD_MAPS_CMD) == 0) { plug_close(); plug_init(); sprintf(buf, "%s", "Reloaded map pools"); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); } else if (strcmp(cmd, RM_RANDOM_MAP_CMD) == 0) { int pn, choice; if (n != NULL) { /* pick a map from the specified pool */ pn = atoi(n); if (pn < 1 || pn > npools) return -1; pn--; choice = random() % (pools[pn]->nmaps); sprintf(buf, "Map: %s",pools[pn]->maps[choice]); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); } else { /* pick a map from the union of all pools */ int totalmaps = 0, i; for (i = 0; i < npools; i++) totalmaps += pools[i]->nmaps; choice = random() % totalmaps; i = 0; while (choice >= pools[i]->nmaps) { choice -= pools[i]->nmaps; i++; } sprintf(buf, "Map: %s", pools[i]->maps[choice]); tmp = create_plug_msg(src, buf); send_plug_msg(tmp); free_plug_msg(tmp); } } return 0; }