Design of embedded keyboard based on Murphypinyin

Publisher:qq8174350Latest update time:2013-03-06 Source: dzscKeywords:S3C2440 Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere
    Introduction

  With the rapid development of embedded systems, in embedded handheld devices, human-computer interaction devices are the part that contacts the user the most, and can most directly and quickly reflect the performance of the device. Therefore, whether there is a friendly, fast, and reliable human-computer interaction device has become an important indicator for measuring a handheld device. In embedded human-computer interaction devices, keyboards are widely used because of their high accuracy and reliability, ability to adapt to various harsh working environments, and long service life.

  According to the characteristics of handheld terminals, this paper designs a matrix keyboard and develops the keyboard driver under the Linux platform. Qt/Embedded is used to build the graphical interface. By analyzing the input method provided by Qt/Embedded and combining the Murphpinyin Chinese input method software package, an embedded keyboard that can input numbers, Chinese/English is built.

  1 Hardware Design

  The hardware part of this system is mainly a matrix keyboard with 4 columns and 5 rows, as shown in Figure 1. The column lines COL0~COL3 use the 4 interrupt pins of S3C2440 - EINT10, ENIT13, EINT15, EINT20, and each column line has a 4.7 kΩ pull-up circuit to pull the interrupt pin level high to ensure that the key will not trigger an interrupt when it is idle; the row lines ROW0~ROW4 use the 5 common I/O ports of S3C2440 - GPE11, GPE13, GPG3, GPG6, GPG11. The problem that needs to be paid attention to here is to ensure that the interrupts used by the column lines have not been used in various Linux devices, otherwise the driver initialization will fail in the subsequent driver.


  Considering the convenience of handheld terminal operation, all buttons are re-arranged, as shown in Figure 2. In order to extend the service life of the handheld device and improve reliability, a power button Power is added. In addition, considering the low power consumption requirements of handheld devices, a backlight control button Back-Light is added to control the switch of the LCD backlight by controlling the high and low levels of the LCD_PWREN pin. The power button Power and the backlight control button BackLight are separate buttons, which are directly connected to the interrupt pin of S3C2440. This article focuses on a detailed introduction to the matrix keyboard. The processing mechanism of the power button and the backlight control button is similar to that of the matrix keyboard, so it will not be introduced here.


  2 Software Design

  2.1 Linux driver design for matrix keyboard

  The matrix keyboard is registered in the system as a character device of Linux. In order to reduce the loss of system resources, the interrupt processing function is used to process the keys; at the same time, considering the jitter problem of the keys, a timer is used to eliminate the jitter.

  The process of the driver is shown in Figure 3. First, use the S3C2440_Kb_init() function to register the keyboard as a character device, initialize the row line pins as output, non-pull-up, and set all row outputs to low level; register the keyboard device. Initialize the interrupt pins connected to the column lines as input, falling edge trigger interrupt, and establish a connection between the interrupt and the interrupt processing function Key_interrupt().

[page]


  When a key is pressed, since all the lines are low, there must be a row and a column line turned on, which will pull the corresponding column line low and trigger an interrupt. Then, the interrupt processing function Key_interrupt() records the corresponding interrupt number. Due to the jitter of the key, it is unreliable to determine that the corresponding key is pressed based on the triggering of an interrupt. Therefore, after the interrupt is triggered, the timer kb_timer is started to determine the key status again.

  The upper application uses S3C2440_Kb_open() to open the keyboard device, enable the column line interrupt, and initialize the timer. When the interrupt is triggered, the timer is turned on. When the timer timing is up, the timer interrupt kb_timer_handler() is triggered. kb_timer_handler() will first call the keyboard scanning function Scan_keyboard() to scan the key status. The Scan_keyboard() process is shown in Figure 4. If the same key value is scanned as pressed each time after three keyboard scans, it proves that a key is indeed pressed, and the Scan_keyboard() function returns: KEYDOWN. If the key value pressed this time is different from the previous key value, the key value is saved in the circular queue, so that duplicate data is not saved in the buffer queue. If the key status is not KEY_DOWN for 10 consecutive scans, it proves that the key has been popped up and the timer kb_timer is turned off.


  The S3C2440_Kb_read() function is responsible for reading the key value from the circular queue and feeding it back to the upper-level application.

  2.2 Qt/Embedded Keyboard Mapping

  Qt/Embedded is a comprehensive application platform developed by Trolltech for electronic devices using embedded Linux. Qt/Embedded includes a complete application layer, a flexible user interface, a window operating system, application programs, and a development framework.

  Qt/Embedded itself provides support for keystrokes. It provides a QWSKeyboardHandler class in the file qkeyboard_qws.cpp to handle keystroke events. This system creates a subclass of the QWSKeyboardHandler class, QWSKEYMATRIXHandler. In the constructor of the QWSKEYMATRIXHandler class, the matrix keyboard key_matrix is ​​opened through the open() function, and a QscoketNotifer is created for the opened keyboard device to monitor the keystroke device. Through the signal and slot mechanism, the connection between the QscoketNotifer and the keyboard reading function ReadKeyboardData() is established. When key_matrix is ​​activated, the keyboard reading function ReadKeyboardData() is triggered. The code is as follows:

  notifier=new QSocketNotifier(key_matrix, QSock-etNotifier::Read, this);

  connect(notifier, SIGNAL(activated(int)), this, SLOT(ReadKeyboardData()));

  In the keyboard reading function ReadKeyboardData(), call the matrix keyboard driver's reading function Read() to obtain the key value. In order to transmit the key value to the application, use the member function processKeyEvent(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat) of the QWSKeyboardHandler class. The functions of each parameter are as follows:

  ①Unicode: Unicode code of the key, such as the Unicode code of the number 1 is 1, and the Unicode code of the letter A is A. If this item is 0, it is a function key such as Shift, Left, Right, etc.; if this item is 0xFFFF, only the key value keycode is transmitted, and the code is not printed.

  ②Keycode: The key name used in Qt, such as Qt::Key_Backspace, Qt::Key_Enter, etc.

  ③Modifiers: Keyboard key combinations supported by Qt.

  ④isPress: Determine whether the button is "pressed" or "up".

  ⑤autoRepeat: Determine whether this event is generated by an automatic repeat mechanism or by a real button.

  Numbers, lowercase English, and uppercase English can be sent through the processKeyEvent() function, but there is currently no Chinese input method on Qt/Embedded, so Chinese cannot be input.

  2.3 Transplantation of Murphpinyin Pinyin Input Method

  Murphypinyin is a relatively good open source Chinese input method based on Qt/Embedded so far, and Murphypinyin has a soft keyboard, and users can input Chinese, English, numbers and symbols through the touch screen. There are many reference materials on the Internet about the transplantation of Murphypinyin to Qt/Embedded, which will not be introduced here.

  However, there is still a problem in applying Murphypinyin to handheld terminals: the soft keyboard of Murphypinyin is a standard PC101 keyboard with a large number of keys. On handheld terminals with strict requirements on volume and weight, the size of the touch screen itself is severely restricted. The PC101 keyboard will occupy most of the display area of ​​the touch screen; and the area occupied by a single key is very small, so the positioning accuracy of the touch screen is very high. However, the touch screen itself is greatly affected by the surrounding environment, which can easily cause inaccurate positioning. This system maps the matrix keyboard to Murphypinyin, and inputs Chinese, English and numbers through the matrix keyboard. In this way, ordinary LCDs can be used on handheld terminals, thereby reducing system costs and improving system reliability. [page]

  The first question to consider is: How to open the Murphypinyin input method with the keyboard? Here you can modify the PinyinFrame.cpp file in the Murphypinyin software package:

  boot QPinyinFrame: :filter(int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat)

  Among them: if(!isHidden()&& isPress) statement is used to determine whether the Murphypinyin input method has been opened and a key has been pressed. If so, it is determined whether the current mode is Chinese or English. In Chinese mode, the GetKey(unicode, keycode) function is called to search for Chinese characters based on the input pinyin; in English mode, the SendKey(unicode, keycode) function is called to send uppercase or lowercase English letters. If unicode==9&&keycode==Qt::Key_Tab, Chinese and English are switched. Here you can add a judgment statement: if(keycode==Qt::Key NumLock). When the NumLock key is pressed, the two functions: QPinyinFrame::sizeHint() and QPinyinFrame::show() are called to open the Murphypinyin input method interface. If the NumLock key is pressed again, QPinyinFrame::hide() is called to hide the input method interface.

  After opening the Murphypinyin input method with the keyboard, you can input Chinese characters by sending pinyin letters through the keyboard. You can switch between Chinese and English by sending unicode=9&&keycode==Qt::Key_Tab.


  2.4 Button Multiplexing

  Since handheld terminal devices have strict requirements on their own size, in order to reduce the size of the keyboard, this system imitates the layout of the mobile phone keyboard and uses key reuse to reduce the size of the keyboard. The 26 English letters are arranged in groups of 3 or 4 in alphabetical order on the 8 numeric keys 2 to 9, and reused with Arabic numerals (see Figure 2).

  The simplification of hardware will inevitably lead to the increase of software complexity. In order to enable the system to automatically identify whether it is a number, uppercase English letter, lowercase English letter or pinyin letter after pressing a key, it is necessary to modify the QWSKEYMATRIXHandler::ReadKeyboardData() function in qkeyboard_qws.cpp in Qt/Embedded.

  When a key is pressed, the first thing to do is to determine the current mode: digital, pinyin, lowercase English, or uppercase English. The implementation process is shown in Figure 5. The NumLock key and the status flag English-Mode are used to switch between the digital state and several other states. The Tab key is used to switch between the Chinese and English modes, and the CapsLock key is used to switch between uppercase and lowercase English letters.

  In order to enable a key to input different characters, the system uses different key_ID values ​​to identify each character, so that each key press is different. Figure 6 shows the multiplexing process for key 2. According to different key_IDs combined with the current input mode, the corresponding numbers, lowercase English or uppercase English characters are sent.

  3. Conclusion

  This paper introduces the hardware design method and software driver development method of matrix keyboard based on S3C2440. By integrating Murphpinyin open source software package with Qt/Embeded built-in input method, using key reuse strategy and fewer keys, an embedded keyboard capable of inputting numbers, Chinese/English is constructed and implemented on S3C2440. This provides an embedded keyboard solution for handheld terminals.

References:

[1]. S3C2440 datasheet http://www.dzsc.com/datasheet/S3C2440_589562.html.
[2]. Power datasheet http://www.dzsc.com/datasheet/Power_1093617.html.
[3]. PC101 datasheet http://www.dzsc.com/datasheet/PC101_1147923.html.

Keywords:S3C2440 Reference address:Design of embedded keyboard based on Murphypinyin

Previous article:Design of smart home embedded system based on S3C44B0X and μC/OS-Ⅱ
Next article:Construction of wind power generation monitoring system development platform based on embedded Linux

Recommended ReadingLatest update time:2024-11-16 15:40

Compilation and configuration of u-boot-2011.06 based on s3c2440 development board
Before porting, we also need to install and configure eldk for compiling u-boot. Below we will introduce the installation and configuration of eldk: 1. Download eldk Select any version of eldk here and download it. I chose the arm-2008-11-24.iso file of eldk4.2 version. Download the file to the /home/zhaoc
[Microcontroller]
Boa Web server transplanted on PC and S3C2440 development board
boa is a very small web server with only about 60KB of executable code. It is a single-task web server that can only complete user requests one by one, and will not fork a new process to handle concurrent connection requests. However, Boa supports CGI and can fork a process for CGI programs to execute. Below we expl
[Microcontroller]
s3c2440 bare metal - i2c programming - 3 - i2c program framework
1. Functions of iiC devices Obviously, the IIC controller provides the ability to transmit data, but the IIC controller does not know what the data means. The meaning of the data is from the external I2C slave device. We need to read the chip manual to know what data the IIC controller should send. The fol
[Microcontroller]
s3c2440 bare metal - i2c programming - 3 - i2c program framework
s3c2440 learning path-003 assembly to C pass parameters to light up different LED lights
Hardware platform: jz2440 Software platform: Ubuntu16.04 arm-linux-gcc-3.4.5 Source code location: https://github.com/lian494362816/C/tree/master/2440/004_led_parma 1 Principle Analysis When using assembly to call a C function, if you need to pass parameters, you can use R0-R3 to pass parameters. R0 represents the f
[Microcontroller]
S3C2440 development board bare metal program series 05 - timer PWM
1. PWM Overview Timers 0, 1, 2, and 3 have PWM functions. TCNTBn is the initial count value. After the timer is turned on, it counts down by 1. The value of TCMPBn is used for comparison. The initial value is 0, so when TCNTBn counts down by 1 to 0, it is equal to TCMPBn, and TOUTn will flip. Therefore, the value
[Microcontroller]
S3C2440 development board bare metal program series 05 - timer PWM
S3C2440 bare metal --- touch screen _ resistive touch screen hardware principle
1. Principle of resistive touch screen 2. Resistive touch screen equivalent circuit 2.1 Touch screen idle state When the touch screen is not pressed, the equivalent circuit is shown in Figure 14.5. S4 and S5 are closed, S1, S2, and S3 are open, that is, YM is grounded, XP is pulled up, XP is used as analog inpu
[Microcontroller]
S3C2440 bare metal --- touch screen _ resistive touch screen hardware principle
S3C2440 bare metal -------NandFlash programming_chip id reading
1. Chip ID reading timing diagram Let's first look at the timing diagram for reading the ID in the NandFlash chip manual. Later we will write the code based on this timing diagram. 2. Enable chip From the previous timing diagram, we can see that we must first send out the chip select signal. We set it by setting the
[Microcontroller]
S3C2440 bare metal -------NandFlash programming_chip id reading
The whole process of SPI transplantation based on S3C2440 processor
environment Hardware: S3C2440 (ARM920T) Embedded operating system: Linux 2.6.24 kernel File system: Yaffs2 file system Server: SuSe10.0 Linux server Step 1: Kernel Configuration  You need to select the above options in the kernel: Many netizens have emailed to say that the Linux 2.6.24 kernel does not h
[Microcontroller]
The whole process of SPI transplantation based on S3C2440 processor
Latest Microcontroller Articles
  • Download from the Internet--ARM Getting Started Notes
    A brief introduction: From today on, the ARM notebook of the rookie is open, and it can be regarded as a place to store these notes. Why publish it? Maybe you are interested in it. In fact, the reason for these notes is ...
  • Learn ARM development(22)
    Turning off and on interrupts Interrupts are an efficient dialogue mechanism, but sometimes you don't want to interrupt the program while it is running. For example, when you are printing something, the program suddenly interrupts and another ...
  • Learn ARM development(21)
    First, declare the task pointer, because it will be used later. Task pointer volatile TASK_TCB* volatile g_pCurrentTask = NULL;volatile TASK_TCB* vol ...
  • Learn ARM development(20)
    With the previous Tick interrupt, the basic task switching conditions are ready. However, this "easterly" is also difficult to understand. Only through continuous practice can we understand it. ...
  • Learn ARM development(19)
    After many days of hard work, I finally got the interrupt working. But in order to allow RTOS to use timer interrupts, what kind of interrupts can be implemented in S3C44B0? There are two methods in S3C44B0. ...
  • Learn ARM development(14)
  • Learn ARM development(15)
  • Learn ARM development(16)
  • Learn ARM development(17)
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号