Difference between revisions of "Matrix - Button"
From FriendlyELEC WiKi
Line 1: | Line 1: | ||
[[Matrix - Button/zh|查看中文]] | [[Matrix - Button/zh|查看中文]] | ||
− | == | + | ==Introduction== |
[[File:Btn.png|thumb|按键]] | [[File:Btn.png|thumb|按键]] | ||
Matrix-Button主要器件是一个瞬时(非自锁)按钮开关,通过3-Pin 2.54mm排针中的S信号输出按钮开关的状态。平时没有按下按钮时触点断开,S输出高电平;当按下按钮时触点导通,S输出低电平,直到松开才恢复高电平。 | Matrix-Button主要器件是一个瞬时(非自锁)按钮开关,通过3-Pin 2.54mm排针中的S信号输出按钮开关的状态。平时没有按下按钮时触点断开,S输出高电平;当按下按钮时触点导通,S输出低电平,直到松开才恢复高电平。 | ||
+ | The Matrix-Button is an instant(non self locked) button. The button's status can be read from pin S in the 3-pin 2.54 mm spacing pin header. If the button is not pressed S will output high otherwise S will output low. | ||
==特性== | ==特性== |
Revision as of 07:00, 7 August 2015
1 Introduction
Matrix-Button主要器件是一个瞬时(非自锁)按钮开关,通过3-Pin 2.54mm排针中的S信号输出按钮开关的状态。平时没有按下按钮时触点断开,S输出高电平;当按下按钮时触点导通,S输出低电平,直到松开才恢复高电平。 The Matrix-Button is an instant(non self locked) button. The button's status can be read from pin S in the 3-pin 2.54 mm spacing pin header. If the button is not pressed S will output high otherwise S will output low.
2 特性
- 瞬时响应,非自锁
- 体积小巧, 带固定孔,方便嵌入到外壳
- 2.54mm排针,接线方便,通用性强
3 使用方法
3.1 连接
- 连接到Tiny4412 SDK (1506)
- 将配件S针脚连接到GPIO PIN1, V接5V,G接地
3.2 Linux下的C示例
#include <stdio.h> #include "libfahw.h" static struct sensor button[] = { { TINY4412_GPIO_PIN1, IRQ_TYPE_EDGE_FALLING, } }; int main(void) { int i; int retSize = -1; char value[ARRAY_SIZE(button)]; int devFD = -1; if ((devFD =sensorInit(button, ARRAY_SIZE(button))) == -1) { printf("Fail to init sensor\n"); return -1; } printf("Press the button...\n"); if (( retSize = sensorRead(devFD, value, ARRAY_SIZE(button)) ) == -1) { printf("Fail to read sensors\n"); } if (retSize > 0) { i = 0; for (i=0; i<retSize; i++) { printf("Button[%d]:%d\n", i, value[i]); } } sensorDeinit(devFD); return 0; }
3.3 编译并运行示例
git clone http://github.com/friendlyarm/fa-hardware.git cd fa-hardware cd demo cd matrix-button make
将编译生成的button通过ftp上传到开发板上运行即可测试。