参照“Mini6410 Qt4和Qtopia编程开发指南-20110112”学习Qtopia
1.开发板:Tiny6410;RAM: 256M;NAND Flash:MLC、2G;LCD:H43
2.用本论坛提供的虚拟机系统(见帖子“搭建好Linux/Qt4/Qtopia2开发环镜的Fedora9虚拟机”),按指南移植了Qtopia2.2.0
3.前面几个例程“mycalc、串口助手、PWM、按键、ADC”在开发板上都成功运行,但是“LED”例程就不行,
运行现象是:
在显示屏右下角状态栏出现运行状态(沙漏状态),但没有led测试界面显示,
一会(30秒内)运行状态也消失
开机运行的走马灯一直没停止(正常运行,led-testing程序会先停止走马灯)
反复看了程序,与文档中的例程一直呀。
main_form.cpp程序:
#include "main_form.h"
#include <qcheckbox.h>
#include <unistd.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/ioctl.h>
#include <fcntl.h>
TMainForm::TMainForm(QWidget* parent,const char* name,WFlags f):TMainFormBase(parent,name,f)
{
::system("kill -s STOP `pidof led-player`");
m_fd = ::open("/dev/leds0",O_RDONLY);
if(m_fd<0){
m_fd = ::open("/dev/leds",O_RDONLY);
}
connect(m_led1,SIGNAL(clicked()),this,SLOT(checkBoxClicked()));
connect(m_led2,SIGNAL(clicked()),this,SLOT(checkBoxClicked()));
connect(m_led3,SIGNAL(clicked()),this,SLOT(checkBoxClicked()));
connect(m_led4,SIGNAL(clicked()),this,SLOT(checkBoxClicked()));
checkBoxClicked();
}
TMainForm::~TMainForm()
{
::close(m_fd);
}
void TMainForm::checkBoxClicked()
{
ioctl(m_fd,int(m_led1->isChecked()),0);
ioctl(m_fd,int(m_led2->isChecked()),1);
ioctl(m_fd,int(m_led3->isChecked()),2);
ioctl(m_fd,int(m_led4->isChecked()),3);
}