#include "system.h" #include #include #include #include void System::setIP(System::IPData &data) { QString ifconfig = QString("ifconfig eth0 %1 netmask %2 up").arg(data.address, data.netmask); QString route = QString("route del default; route add default gw %1").arg(data.gateway); system(ifconfig.toLocal8Bit().constData()); system(route.toLocal8Bit().constData()); } void System::setBacklight(int level) { QString command = QString("echo %1 > /sys/class/backlight/backlight_lvds.19/brightness").arg(level); system(command.toLocal8Bit().constData()); } void System::setVolume(int percentage) { static int last = -1; if (percentage == last) return; last = percentage; QString command = QString("/usr/bin/amixer -c 0 sset 'PCM',0 %1% %1% on").arg(percentage); system(command.toLocal8Bit().constData()); } bool System::setRtcTime(QDateTime dt_tm){ int fd; rtc_time rt; rt.tm_year = dt_tm.date().year() - 1900; rt.tm_mon = dt_tm.date().month()-1; rt.tm_mday = dt_tm.date().day(); rt.tm_hour = dt_tm.time().hour(); rt.tm_min = dt_tm.time().minute(); rt.tm_sec = 0; fd = open("/dev/rtc0", O_WRONLY); if(fd <0){ return false; }{ ioctl(fd, RTC_SET_TIME, &rt); close(fd); return true; } }