示例#1
0
void make_service(uint8_t symbol){
	if(symbol == EdConf.clean_char_symb){
        if(resp_ptr > 0){
        	cursor_shift(LEFT);
        	lcd_putc(' ');
        	cursor_shift(LEFT);
        	if(btn_old && !is_service_symbol(symbol))return; //if btn not pushed in response yet
        	response_rm_char();
        }
        if(resp_ptr >= disp_line_length){
            lcd_init_first();
            for(uint8_t i=(resp_ptr-disp_line_length); i<resp_ptr; i++){
                lcd_putc(response[i]);
            }
        }
        exit_status=ExitContinue;
	}
	if(symbol == EdConf.exit_symb_ok){
        turn_off_cursor();
        response_push('\0');
        exit_status=ExitOk;
	}
	if(symbol == EdConf.exit_symb_discard){
        turn_off_cursor();
        response_init(EdConf.old_response, EdConf.resp_size);
        exit_status=ExitDiscard;
	}
}
示例#2
0
文件: newline.c 项目: imuli/prompt
static void
redraw_line(void){
	cursor_shift(-cursor);
	render(stderr, line->buf, display_utf8_of_rune);
	cursor += display_width(line, 0, line->buf->c);
	erase_line();
	cursor_shift(-display_width(line, line->off, line->buf->c));
}
示例#3
0
/*!	\details	Writes ANSI-C string to LCD (DDRAM memory space). */
void lcd_puts(const uint8_t *str)
{
	/* Send a ANSI-C string to LCD. */
	while ('\0' != *str)
	{
#if ( USE_FORMATTED_OUTPUT )
		if(('\n' == *str))
		{/*New line */
			lcd_goto(LCD_2nd_LINE, 0u);
		}
		else if(('\r' == *str))
		{/* Return home */
			lcd_return();
		}
		else if(('\t' == *str))
		{/* Tab space */
			uint8_t i;

			for(i=0u; i<TAB_SPACE; i++)
			{/* Shift cursor to the right. */
				cursor_shift(RIGHT);
			}
		}
		else
#endif
		{
			/* Display a symbol. */
			lcd_putc(*str);
		}
		/* Get the next symbol. */
		str++;
	}
}
示例#4
0
void acept_btn(uint8_t btn, uint8_t duration, uint8_t press_cnt){
	uint8_t symbol;
	symbol = get_symbol(btn, duration, press_counter);

	if(is_service_symbol(symbol)){
		make_service(symbol);
        clean_flags();
		return;
	}

	if(is_max_response()){
		if(EdConf.do_exit_on_max_resp){
			response_push(symbol);
            turn_off_cursor();
            exit_status=ExitMaxResp;
		}
        response_rm_char();
        response_push(symbol);
        clean_flags();
	}
	else{
        response_push(symbol);
        cursor_shift(RIGHT);
        clean_flags();
	}
}
示例#5
0
void add_phone(void){
	button *btn;
	uint8_t btn_val;
	uint8_t symbol;

	keyboard my_kb =
			{CURSOR_BLINK,
			12,
			3,
			{{'0', 0 , 0 , 0 , 0 ,' '},
			{'1','_', 0 , 0 , 0 , 0 },
			{'2','a','b','c', 0 , 0 },
			{'3','d','e','f', 0 , 0 },
			{'4','g','h','i', 0 , 0 },
			{'5','j','k','l', 0 , 0 },
			{'6','m','n','o', 0 , 0 },
			{'7','p','q','r','s', 0 },
			{'8','t','u','v', 0 , 0 },
			{'9','w','x','y','z', 0 },
			{'<', 0 , 0 , 0 , 0 ,'#'},
			{'*','+', 0 , 0 , 0 ,'^'}},
			"Type text",
			"012345678"};

	text_editor_init(&my_kb);
	do{
		btn = get_btn();
		btn_val = btn->button;
		if(btn_val){
			key_controller(btn_val, btn->duration);
		}
		symbol = read_tmp_symbol();
		if(symbol){
			lcd_putc(symbol);
		}
		symbol = read_symbol();
		if(symbol){
			cursor_shift(RIGHT);
		}

/*
		switch (btn_val){
		case '2':

			break;
		case '1':

			break;
		case '3':

			break;
		case '*':

		}
*/
	}while (btn_val != '2');
	text_editor_close();
}
示例#6
0
文件: newline.c 项目: imuli/prompt
static void
set_echo(Rune c, void* v, int enable){
	if(!enable){
		redraw_func = redraw_line_noecho;
		cursor_shift(-cursor);
		erase_line();
	}else{
		redraw_func = redraw_line;
	}
}
示例#7
0
void lcd_show_btn(uint8_t btn, uint8_t duration, uint8_t pressed_cnt){
    if(resp_ptr >= disp_line_length){
    	lcd_init_first();
    	for(uint8_t i=(resp_ptr-disp_line_length+1); i<resp_ptr; i++){
    		lcd_putc(response[i]);
    	}
            //shift_display(LEFT);
    }
	if(EdConf.mask) lcd_putc(EdConf.mask); //If mask set than show mask instesd of symbol
	else lcd_putc(get_symbol(btn, duration, pressed_cnt));
	cursor_shift(LEFT);
}
示例#8
0
//-------------------------------
void lcd_drawbar(int8u_t next_bar_load)
{
 int8u_t i = current_bar_load;
 int8u_t cell = (current_bar_load/FULL_ELEMENT); // find current cell position in progress bar
 if(next_bar_load > NUMBER_OF_BAR_ELEMENTS ) next_bar_load = NUMBER_OF_BAR_ELEMENTS;
 if( next_bar_load > current_bar_load )
 {
//-------------------------------
// increment progress bar code //
//-------------------------------
  lcd_goto(DRAW_PROGRESS_BAR_ON_LINE, cell); // goto current cell position
  while( i != next_bar_load )
  {
   i++;
   if( CELL_RATIO(i) == 0 ) lcd_putc( FULL_ELEMENT );
    else lcd_putc( CELL_RATIO(i) );
   if( CELL_RATIO(i) ) cursor_shift(LEFT);
  }
 }
 else
 {
//-------------------------------
// decrement progress bar code //
//-------------------------------
  if(CELL_RATIO(i) == 0) cell--;
  lcd_goto(DRAW_PROGRESS_BAR_ON_LINE, cell); // goto current cell position
  lcd_cmd(ENTRY_MODE_DEC_NO_SHIFT,0); // decrement lcd cursor
  while( i != next_bar_load )
  {
   i--;
   lcd_putc( CELL_RATIO(i) );
   if( CELL_RATIO(i) ) cursor_shift(RIGHT);
  }
  lcd_cmd(ENTRY_MODE_INC_NO_SHIFT,0); // increment lcd cursor
 }
//-------------------------------
//       store new value       //
//-------------------------------
 current_bar_load = next_bar_load;
}
示例#9
0
文件: input.cpp 项目: orlv/fos
void mouse_thread() {
	struct mouse_pos pos;
	int hndl = -1;
	do {
		hndl = open("/dev/psaux", 0);
	} while(hndl == -1);

	while(1) {
		read(hndl, &pos, sizeof(mouse_pos));
		if(pos.dx || pos.dy) {
			cursor_shift(pos.dx, pos.dy);
			RequestRedraw(REDRAW_CURSOR, 0);
		}
	}

}
示例#10
0
文件: newline.c 项目: imuli/prompt
static void
flush_line(Rune c, void* f, int v){
	if(pty_mode || f == NULL){
		append_character(v);
	}else{
		(*(void(*)(int)) f)(v);
	}
	cursor_shift(-cursor);
	erase_line();
	fflush(stderr);
	render(stdout, line->buf, utf8_of_rune);
	fflush(stdout);
	if(pty_mode || f == NULL) line->buf->c--; /* FIXME! store history without the flushing character! */
	hist_cur = hist_len - 1;
	history_save();
	if(--lines <= 0) exit(0);
	history_add();
	history_load();
}
示例#11
0
/*!	\brief	Draw progress bar. */
void lcd_drawbar(uint8_t next_bar_pixel)
{
	/* Go to the current cell position in the progress bar. */
	lcd_goto(PROGRESS_BAR_LINE, (current_bar_pixel / FONT_WIDTH));

	if (next_bar_pixel > current_bar_pixel)
	{
		/* Increment LCD cursor */
		lcd_setmode(ENTRY_MODE_INC_NO_SHIFT);

		/* Prevent the progress bar overflow */
		if (next_bar_pixel > PROGRESS_BAR_MAX_LOAD)
		{
			next_bar_pixel = PROGRESS_BAR_MAX_LOAD;
		}

		while (current_bar_pixel != next_bar_pixel)
		{
			/* Go to the next pixel. */
			current_bar_pixel++;
			current_cell_load++;
			/* Display the load of the current cell. */
			lcd_putc(current_cell_load);

			if (current_cell_load < FULL_LOAD)
			{/* Return the cursor to the current cell. */
				cursor_shift(LEFT);
			}
			else
			{/* Go to the next cell. */
				current_cell_load = EMPTY_LOAD;
			}
		}
	 }
#if (USE_REGRESS_BAR)
	 else if (next_bar_pixel < current_bar_pixel)
	 {
		 /* Decrement LCD cursor */
		lcd_setmode(ENTRY_MODE_DEC_NO_SHIFT);

		do
		{
			if (EMPTY_LOAD == current_cell_load)
			{/* Go to the next cell. */
				cursor_shift(LEFT);
				current_cell_load = FULL_LOAD;
			}
			/* Go to the next pixel. */
			current_bar_pixel--;
			current_cell_load--;
			/* Display the load of the current cell. */
			lcd_putc(current_cell_load);
			/* Return the cursor to the current cell. */
			cursor_shift(RIGHT);
		}
		while (current_bar_pixel != next_bar_pixel);
	 }
#endif /* USE_REGRESS_BAR */
	 else
	 {
		 /* Nothing to do. */
	 }

	/* Restore the default entry mode. */
	lcd_setmode(DEFAULT_ENTRY_MODE);
	/* Return home. */
	lcd_goto(LCD_1st_LINE, 0u);
}
示例#12
0
/*!	\details	Erase a symbol from the left of the cursor. */
void lcd_backspace(void)
{
	cursor_shift(LEFT);		// Сдвигаем курсор на одну позицию влево
	lcd_putc(' ');			// Очищаем, после чего происходит автоинкремент вправо
	cursor_shift(LEFT);		// Сдвигаем курсор на одну позицию влево
}
示例#13
0
文件: newline.c 项目: imuli/prompt
static void
redraw_line_noecho(void){
	cursor_shift(line->off - cursor); /* invisible characters are all one space */
}