Beispiel #1
0
static void draw_settings_menu() {
    uint8_t x;

    for(x=0; x < NUM_LIVECTRL_CMDS; x++) {
        show_name(x);
        show_parameter(x);
    }
}
Beispiel #2
0
static void handle_setting(uint8_t cmd) {
    livectrl_cmd_t  * livectrl_cmd = &livectrl_cmds[cmd];

    uint16_t var = livectrl_cmd->current_value;
    uint16_t step = livectrl_cmd->step;
    uint16_t min_val = livectrl_cmd->min_val;
    uint16_t max_val = livectrl_cmd->max_val;

    show_parameter(cmd);

    while(1) {
        uint8_t key;
        if((key = terminal_get_key_nb()) != 0) {
            switch(key) {
            case KEY_UP:
                if(var > min_val) {
                    var -= step;
                    rfm12_livectrl(cmd, var);
                    show_parameter(cmd);
                }
                break;
            case KEY_DOWN:
                if(var < max_val) {
                    var += step;
                    rfm12_livectrl(cmd, var);
                    show_parameter(cmd);
                }
                break;
            case KEY_ENTER:
                rfm12_save_settings();
            case KEY_EXIT:
                return;
                break;
            }
        }

        run_statemachines();
    }
}
Beispiel #3
0
/* Format one line of the "format" string based on the module contents. */
static void format_query_line(struct obj_file *f, const char *format,
			      char *key, char *value, const char *desc)
{
	int c;
	const char *in_str = format;

	while (*in_str) {
		/* Just copy normal characters into the output. */
		if (*in_str != '%')
		  {
		    if (*in_str == '\\')
		      c = convert_escape(*++in_str);
		    else
		      c = *in_str;

		    ++in_str;

		    putchar (c);
		    if (c == '\n')
			    break;
		    continue;
		  }
		++in_str;
		/* Process the replacement as required. */
		switch (*in_str++) {

		case '%':
			putchar ('%');
			break;

		case 'a':
			append_modinfo_tag(f, "author", "<none>", 1);
			break;

		case 'd':
			append_modinfo_tag(f, "description", "<none>", 1);
			break;

		case 'n':
			append_modinfo_tag(f, "filename", "<none>", 0);
			break;

		case 'l':
			append_modinfo_tag(f, "license", "<none>", 1);
			break;

		case 'p':
			show_parameter(f, key, value, desc);
			break;

		case '{':{
				char tag[MAX_TAG_LEN];
				char *end = strchr(in_str, '}');
				int multi_line;

				/* Copy out the tag name. */
				memset(tag, 0, sizeof(tag));
				strncpy(tag, in_str, end - in_str);
				tag[end - in_str] = '\0';
				multi_line = strcmp(tag, "author") == 0 ||
					     strcmp(tag, "description") == 0 ||
					     strcmp(tag, "license") == 0;

				if (strcmp (tag, "parm") != 0)
				        /* Append the tag's value if it exists. */
					append_modinfo_tag(f, tag, "<none>", multi_line);
				else
					show_parameter(f, key, value, desc);

				/* Advance past the end of the replacement. */
				in_str = end + 1;
				break;
			}
		}		/* switch */
	}			/* while */
}
Beispiel #4
0
static int show_scope(ivl_scope_t net, void*x)
{
      unsigned idx;
      const char *is_auto;

      fprintf(out, "scope: %s (%u parameters, %u signals, %u logic)",
	      ivl_scope_name(net), ivl_scope_params(net),
	      ivl_scope_sigs(net), ivl_scope_logs(net));

      is_auto = ivl_scope_is_auto(net) ? "automatic " : "";
      switch (ivl_scope_type(net)) {
	  case IVL_SCT_MODULE:
	    fprintf(out, " module %s%s", ivl_scope_tname(net),
                    ivl_scope_is_cell(net) ? " (cell)" : "");
	    break;
	  case IVL_SCT_FUNCTION:
	    fprintf(out, " function %s%s", is_auto, ivl_scope_tname(net));
	    break;
	  case IVL_SCT_BEGIN:
	    fprintf(out, " begin : %s", ivl_scope_tname(net));
	    break;
	  case IVL_SCT_FORK:
	    fprintf(out, " fork : %s", ivl_scope_tname(net));
	    break;
	  case IVL_SCT_TASK:
	    fprintf(out, " task %s%s", is_auto, ivl_scope_tname(net));
	    break;
	  default:
	    fprintf(out, " type(%u) %s", ivl_scope_type(net),
		    ivl_scope_tname(net));
	    break;
      }

      fprintf(out, " time units = 1e%d\n", ivl_scope_time_units(net));
      fprintf(out, " time precision = 1e%d\n", ivl_scope_time_precision(net));

      for (idx = 0 ;  idx < ivl_scope_attr_cnt(net) ;  idx += 1) {
	    ivl_attribute_t attr = ivl_scope_attr_val(net, idx);
	    switch (attr->type) {
		case IVL_ATT_VOID:
		  fprintf(out, "  (* %s *)\n", attr->key);
		  break;
		case IVL_ATT_STR:
		  fprintf(out, "  (* %s = \"%s\" *)\n", attr->key,
			  attr->val.str);
		  break;
		case IVL_ATT_NUM:
		  fprintf(out, "  (* %s = %ld *)\n", attr->key,
			  attr->val.num);
		  break;
	    }
      }

      for (idx = 0 ;  idx < ivl_scope_params(net) ;  idx += 1)
	    show_parameter(ivl_scope_param(net, idx));

      for (idx = 0 ; idx < ivl_scope_enumerates(net) ; idx += 1)
	    show_enumerate(ivl_scope_enumerate(net, idx));

      for (idx = 0 ;  idx < ivl_scope_sigs(net) ;  idx += 1)
	    show_signal(ivl_scope_sig(net, idx));

      for (idx = 0 ;  idx < ivl_scope_events(net) ;  idx += 1)
	    show_event(ivl_scope_event(net, idx));

      for (idx = 0 ;  idx < ivl_scope_logs(net) ;  idx += 1)
	    show_logic(ivl_scope_log(net, idx));

      for (idx = 0 ;  idx < ivl_scope_lpms(net) ;  idx += 1)
	    show_lpm(ivl_scope_lpm(net, idx));

      for (idx = 0 ; idx < ivl_scope_switches(net) ; idx += 1)
	    show_switch(ivl_scope_switch(net, idx));

      switch (ivl_scope_type(net)) {
	  case IVL_SCT_FUNCTION:
	  case IVL_SCT_TASK:
	    fprintf(out, "  scope function/task definition\n");
	    if (ivl_scope_def(net) == 0) {
		  fprintf(out, "  ERROR: scope missing required task definition\n");
		  stub_errors += 1;
	    } else {
		  show_statement(ivl_scope_def(net), 6);
	    }
	    break;

	  default:
	    if (ivl_scope_def(net)) {
		  fprintf(out, "  ERROR: scope has an attached task definition:\n");
		  show_statement(ivl_scope_def(net), 6);
		  stub_errors += 1;
	    }
	    break;
      }

      fprintf(out, "end scope %s\n", ivl_scope_name(net));
      return ivl_scope_children(net, show_scope, 0);
}