Example #1
0
/**
 * Rendering of a variable number/char (single digit with
 * up/down arrows above/below it).
 *
 * @param item should be an ITEM_TYPE_VARNUM
 * @param selected if cursor should be on that particular digit
 */
void render_item_varnum(screen_item &item, bool selected) {

  // Position on screen where to draw the digit
  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  // Text can be with this format:
  // "NAME:char1,char2,char..." to let user select
  // non-numeric values, we detect this below:
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }

  bool nonnumeric = false;
  char selitem[10][10];
  // We have a non-numeric variable, initialize the
  // possible values (comma-separated string following ":"
  // in the item.text. For instance: "SIGN:-,+,"
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {

      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  // Retrieve the current value of this VARNUM
  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Example #2
0
void GUI::process_key_up() {
	if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_VARNUM) {
		uint8_t current = get_item_state_varnum(screens_layout[current_screen].items[selected_item]);

		int8_t val[1];
		val[0] = current+1;
		if(val[0] > 9) val[0] = 9;
		update_item(screens_layout[current_screen].items[selected_item],val);
		receive_gui_events.receive_gui_event("varnumchange",screens_layout[current_screen].items[selected_item].text);
		return;
	}


	if(selected_item == 1) return;
  last_selected_item = selected_item;
	selected_item--;
}
Example #3
0
void render_item_varnum(screen_item &item, bool selected) {

  uint8_t x = item.val1;
  uint8_t y = item.val2;

  int len = strlen(item.text);
  int colon_pos=-1;
  for(int n=0;n<len;n++) {
    if(item.text[n] == ':') colon_pos=n;
  }
  
  bool nonnumeric = false;
  char selitem[10][10];
  if(colon_pos != -1) {
    nonnumeric=true;

    char current[10];
    int  current_pos=0;
    int  cselitem=0;
    for(int n=colon_pos+1;n<len;n++) {
 
      if(item.text[n] != ',') {
        current[current_pos  ] = item.text[n];
        current[current_pos+1] = 0;
        current_pos++;
      } else {
        strcpy(selitem[cselitem],current);
        current_pos=0;
        current[0]=0;
        cselitem++;
      }
    }
  }

  uint8_t val = get_item_state_varnum(item.text);

  uint16_t color;
  if(selected) color = 0xcccc; else color = FOREGROUND_COLOR;
  display_draw_equtriangle(x,y,9,color);
  display_draw_equtriangle_inv(x,y+33,9,color);
  if(nonnumeric == false) {
    display_draw_number(x-4,y+9,val,1,FOREGROUND_COLOR);
  } else {
    display_draw_text(x-4,y+9,selitem[val],FOREGROUND_COLOR);
  }
}
Example #4
0
void GUI::process_key_down() {
	if(screens_layout[current_screen].items[selected_item].type == ITEM_TYPE_VARNUM) {
		uint8_t current = get_item_state_varnum(screens_layout[current_screen].items[selected_item]);

		int8_t val[1];
		val[0] = current-1;
		if(val[0] < 0) val[0] = 0;
		update_item(screens_layout[current_screen].items[selected_item],val);

		receive_gui_events.receive_gui_event("varnumchange",screens_layout[current_screen].items[selected_item].text);
		return;
	}

	if((selected_item+1) < screens_layout[current_screen].item_count) {
    last_selected_item = selected_item;
	  selected_item++;
	}
}
Example #5
0
uint8_t get_item_state_varnum(screen_item &item) {
  return get_item_state_varnum(item.text);
}
Example #6
0
uint8_t GUI::get_item_state_uint8(const char *tag) {
  // should check item type and repsond appropriately, however only varnum currently returns uint8_t
  return get_item_state_varnum(tag);
}