//Starts a data input session //Read characters from keyboard //Ends with ESC (cancelled) or ENTER (confirmed) uint8_t input_password() { uint8_t cnt = 0; uchar c; lcd_clrscr(); kb_clear_buff(); c = kb_get_char(); while (c != '\r') { if (c == ESC) { return 0; } else if (c == BACKSPACE) { cnt = lcd_backspace(cnt); } else if ((c < 0x80) && (cnt < LCD_LINES * LCD_DISP_LENGTH)) { //If ASCII character is printable lcd_putc(c); stringBuffer[cnt++] = c; } c = kb_get_char(); } return cnt; }
// //********************************** // M B A C K S P A C E // // eingegebenes Zeichen l�schen // void m_backspace () { m_reset_timer(); lcd_backspace(); f_in_buf[cpos]=0; }
static int lcd_write(struct tty_struct *tty, const unsigned char *buf, int count) { struct lcd *lcd_data = tty->driver_data; int buf_i = 0, left; char val; #ifdef DEBUG char *dbgbuf = kzalloc(count + 1, GFP_KERNEL); strncpy(dbgbuf, buf, count); pr_debug("\n%s: count=%d buf[0]=%02x --->%s<---\n", __func__, count, buf[0], dbgbuf); #endif /* DEBUG */ if (count == 0) { #ifdef DEBUG kfree(dbgbuf); #endif /* DEBUG */ return 0; } while (buf_i < count) { left = count - buf_i; /* process displayable chars */ if ((0x20 <= buf[buf_i]) && (buf[buf_i] <= 0x7f)) { while ((buf_i < count) && ((0x20 <= buf[buf_i]) && (buf[buf_i] <= 0x7f))) { val = lcd_translate_printable_char(buf[buf_i]); lcd_add_char_at_cursor(lcd_data, val); buf_i++; } /* flush the line out to the display when we get to eol */ lcd_reprint_one_line(lcd_data, lcd_data->cursor_line); /* * ECMA-48 CSI sequences (from console_codes man page) * * ESC [ 2 J : erase whole display. * ESC [ 2 K : erase whole line. */ } else if (buf[buf_i] == ASCII_ESC) { if ((left >= 4) && (buf[buf_i + 1] == '[') && (buf[buf_i + 2] == '2') && (buf[buf_i + 3] == 'J')) { pr_debug("ESC [2J = clear screan\n"); lcd_clear_buffer(lcd_data); lcd_cmd_clear_screen(lcd_data); buf_i += 4; } else if ((left >= 4) && (buf[buf_i + 1] == '[') && (buf[buf_i + 2] == '2') && (buf[buf_i + 3] == 'K')) { pr_debug("ESC [2K = clear line\n"); lcd_clear_buffer_line(lcd_data, lcd_data->cursor_line); lcd_reprint_one_line(lcd_data, lcd_data->cursor_line); lcd_cmd_set_cursor(lcd_data, lcd_data->cursor_line, 0); lcd_data->cursor_col = 0; buf_i += 4; } else { pr_debug("Unsupported escape sequence\n"); buf_i++; } } else if ((left >= 2) && (buf[buf_i] == ASCII_CR) && (buf[buf_i + 1] == ASCII_LF)) { pr_debug("ASCII_CR/LF\n"); lcd_crlf(lcd_data); buf_i += 2; } else if ((left >= 1) && (buf[buf_i] == ASCII_CR)) { pr_debug("ASCII_CR\n"); lcd_crlf(lcd_data); buf_i++; } else if ((left >= 1) && (buf[buf_i] == ASCII_LF)) { pr_debug("ASCII_LF\n"); lcd_crlf(lcd_data); buf_i++; } else if ((left >= 1) && (buf[buf_i] == ASCII_BS)) { pr_debug("ASCII_BS\n"); lcd_backspace(lcd_data); buf_i++; } else { pr_debug("%s - Unsupported command 0x%02x\n", __func__, buf[buf_i]); buf_i++; } } #ifdef DEBUG kfree(dbgbuf); #endif /* DEBUG */ return count; }