mini2440之--leds程序
来源:互联网 发布:squid软件 编辑:程序博客网 时间:2024/06/06 02:35
如图所示,图中用到了PushButton,GroupBox,SpinBox,PixmapLabel,TextLabel组件
led.h
#ifndef MYHELLOFORM_H
#define MYHELLOFORM_H
#include "led_base.h"
#include <qpixmap.h>
class MyLEDForm : public LEDBaseForm
{
Q_OBJECT
public:
MyLEDForm( QWidget* parent = 0, const char* name = 0, WFlags fl = 0 );
virtual ~MyLEDForm();
//const QPixmap *eddy;
private slots:
void startSys();
void stopSys();
void OnLED();
void OffLED();
void blink1();
void blink2();
};
#endif // MYHELLOFORM_H
led.cpp
#include "led.h"
#include <qlabel.h>
#include <qpushbutton.h>
#include <qspinbox.h>
#include <qtopia/qpeapplication.h>
#include <unistd.h>
#include <sys/types.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#include <fcntl.h>
MyLEDForm::MyLEDForm( QWidget* parent, const char* name, WFlags fl)
:LEDBaseForm(parent, name, fl)
{
connect(PushButton1,SIGNAL(clicked()),this,SLOT(stopSys()));
connect(PushButton2,SIGNAL(clicked()),this,SLOT(startSys()));
connect(PushButton3,SIGNAL(clicked()),this,SLOT(OnLED()));
connect(PushButton4,SIGNAL(clicked()),this,SLOT(OffLED()));
connect(PushButton5,SIGNAL(clicked()),this,SLOT(blink1()));
connect(PushButton6,SIGNAL(clicked()),this,SLOT(blink2()));
}
MyLEDForm::~MyLEDForm()
{
system("/etc/rc.d/init.d/leds start");
}
void MyLEDForm::stopSys()
{
system("/etc/rc.d/init.d/leds stop");
TextLabel1->setText("System Led is Stoped");
}
void MyLEDForm::startSys()
{
system("/etc/rc.d/init.d/leds start");
TextLabel1->setText("System Led is Started");
}void MyLEDForm::OnLED()
{
int iData=SpinBox1->text().toFloat();
int fd = ::open("/dev/leds", 0);
::ioctl(fd, 1, iData);
::close(fd); // 关闭设备
}
void MyLEDForm::OffLED()
{
int iData=SpinBox1->text().toFloat();//取得SpinBox1上的数字
int fd = ::open("/dev/leds", 0);
::ioctl(fd, 0, iData);
::close(fd); // 关闭设备
}
void MyLEDForm::blink1()
{
volatile int k;
int fd=::open("/dev/leds", 0); // 打开设备
for (k=0; k<4; k++)
{
::ioctl(fd, 1, k);
usleep(500000);
::ioctl(fd, 0, k);
usleep(500000);
}
::close(fd); // 关闭设备
}
void MyLEDForm::blink2()
{
// transfer codes from the demostration.
// " :: "is added before each function.
int fd = ::open("/dev/leds0", 0);
if (fd < 0) {
fd = ::open("/dev/leds", 0);
}
if (fd < 0) {
::perror("open device leds");
::exit(1);
}
for (int k=0; k<4; k++)
{
::ioctl(fd, 0, 3-k);
usleep(500000);
::ioctl(fd, 1, 3-k);
usleep(500000);
}
::close(fd);
}
0 0
- mini2440之--leds程序
- mini2440的LEDS驱动程序和测试程序详解
- mini2440的LEDS驱动程序和测试程序详解
- mini2440的LEDS驱动程序和测试程序详解 .
- mini2440 的 leds的驱动程序
- Eclipse+JLink GDB Sever在mini2440开发板leds点灯程序调试过程
- mini2440之--hello程序
- mini2440之--pwm程序
- mini2440之--button程序
- mini2440之--adc程序
- OK6410裸机程序---leds
- OK6410裸机程序---leds
- 树莓派之 Dancing Leds
- contiki学习笔记之leds
- Jlink v8 gdbserver + eclipse cdt+ yagarto gcc 调试 mini2440 leds 代码
- Mini2440 裸机实验之LED程序、按键、中断
- mini2440裸机程序之二--点亮LED灯
- mini2440 iis 程序分析
- C++/C博客记录
- [BZOJ1041][HAOI2008][数学乱搞]圆上的整点
- android中intent带Uri传输时中文的乱码问题
- Nginx自定义模块编写:根据post参数路由到不同服务器
- codechef The Ball And Cups题解
- mini2440之--leds程序
- maven项目添加jar包.
- the msi failed
- IIS防盗链:ISAPI Rewrite图片防盗链规则写法
- undone有关链表
- db2日期和时间常用汇总
- uva 11578 - Situp Benches(dp+输出路径)
- SVN标准目录结构 的一些网文
- POJ 1050 To the Max(枚举+动规)