[frame] move setting set LCDbrightness func to mail box, make sure PC compile Qt frame success

This commit is contained in:
lupeng 2019-01-30 11:45:51 +08:00
parent 9e0dc36717
commit f5c57f6d1d
4 changed files with 71 additions and 2 deletions

View File

@ -1,6 +1,20 @@
#include <string>
#include "framelogic.h"
#include <sys/ioctl.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
#include <unistd.h>
#include <linux/fb.h>
#define DISP_DEV "/dev/disp"
#define DISP_LCD_SET_BRIGHTNESS 0x102
#define DISP_LCD_GET_BRIGHTNESS 0x103
#define MAX_BRIGHTNESS_LEVEL 256
#define DEV_CH 0 //显示通道0
void setMailBox(void)
{
extern MailBox *mailbox;
@ -97,5 +111,57 @@ int DbusMailBox::s_wifiDisconnect()
}
float DbusMailBox::getLCDBrightness(void)
{
float lcdBl = -1;
int fbd;
unsigned int arg[3];
unsigned int bl ;
fbd = open (DISP_DEV, O_RDWR);
if (fbd<0)
{
qDebug() << "Error opening framebuffer device:" << fbd;
return lcdBl;
}
arg[0] = DEV_CH;//显示通道0
bl = ioctl(fbd, DISP_LCD_GET_BRIGHTNESS, (void*)arg);
close(fbd);
qDebug() << "Get brightness:" << bl<<"arg:"<<arg[0]<<arg[1]<<arg[2];
lcdBl = ((float)(MAX_BRIGHTNESS_LEVEL - bl))/MAX_BRIGHTNESS_LEVEL;
qDebug() << "lcdBl:" << lcdBl;
return lcdBl;
}
float DbusMailBox::setLCDBrightness(float val)
{
int fbd;
unsigned int arg[3];
unsigned int bl = (unsigned int)(MAX_BRIGHTNESS_LEVEL*(1-val));
qDebug() << "set lcd bl:" << val<<", bl:"<<bl;
if(val>=0){
fbd = open (DISP_DEV, O_RDWR);
if (fbd<0)
{
qDebug() << "Error opening framebuffer device:" << fbd;
return -1;
}
arg[0] = DEV_CH;//显示通道0
arg[1] = bl;
ioctl(fbd, DISP_LCD_SET_BRIGHTNESS, (void*)arg);
close(fbd);
qDebug() << "Set brightness:" << bl<<"arg:"<<arg[0]<<arg[1]<<arg[2];
}
return this->getLCDBrightness();
}

View File

@ -59,5 +59,8 @@ public:
Q_INVOKABLE int s_wifiConnect(QString ssid, QString passwd) override;
Q_INVOKABLE int s_wifiDisconnect() override;
Q_INVOKABLE int s_wifiScan() override;
float getLCDBrightness(void) override;
float setLCDBrightness(float val) override;
};

@ -1 +1 @@
Subproject commit 936bfe741da4840da0ced51a22dd619ece604835
Subproject commit a3dd4b7363cbc2e0bc6f6e2832a76d7f8f2ba4b1

View File

@ -2910,7 +2910,7 @@ CONFIG_PACKAGE_libyunxin=y
CONFIG_PACKAGE_KPlatinum=y
CONFIG_PACKAGE_KPlayer=y
CONFIG_PACKAGE_KPlayerTest=y
# CONFIG_PACKAGE_NeteaseInitScript is not set
CONFIG_PACKAGE_NeteaseInitScript=y
CONFIG_PACKAGE_SPlayer=y
CONFIG_PACKAGE_SPlayer-demo=y
CONFIG_PACKAGE_alarmer=y