TA的每日心情 | 奋斗 2016-4-14 10:16 |
---|
签到天数: 9 天 连续签到: 1 天 [LV.3]偶尔看看II
|
本帖最后由 小.易 于 2019-1-9 13:08 编辑
需要之前看过 “SinlinxA33搭建Qt App开发环境编写helloworld” “芯灵思Sinlinx A33实现linux led驱动” 这两篇帖子,了解QT编程
主要代码:
- #include "widget.h"
- #include "led.h"
- #include <qpushbutton.h>
- Widget::Widget(QWidget *parent)
- : QWidget(parent)
- {
- Led *led = new Led(); //led对象
- QPushButton *led_off = new QPushButton("LED_OFF",this);
- QPushButton *led_on = new QPushButton("LED ON",this);
- led_on->setGeometry(75, 50, 75, 40); //设置按钮位置
- led_off->setGeometry(300, 50, 75, 40);
-
- connect(led_off,SIGNAL(clicked(bool)),led,SLOT(led_off()));//消息函数
- connect(led_on,SIGNAL(clicked(bool)),led,SLOT(led_on()));
- }
复制代码- <p>#include "led.h"
- Led::Led()
- {
- }
- int Led::led_on(void)
- {
- int fd;
- int val = 1;
- fd = open("/dev/ledzzzzzzzz", O_RDWR);
- if (fd < 0)
- {
- return -1;
- }
- else
- write(fd, &val, 1);
- return 0;
- }
- int Led::led_off(void)
- {
- int fd;
- int val = 0;
- fd = open("/dev/ledzzzzzzzz", O_RDWR);
- if (fd < 0)
- {
- return -1;
- }
- else
- write(fd, &val, 1);
- return 0;
- }
- Led::~Led(void)
- {
- }</p><p>
- </p>
复制代码
|
|