src/gmenu2x.cpp |
243 | 243 | |
244 | 244 | void GMenu2X::init() { |
245 | 245 | batteryHandle = 0; |
246 | | backlightHandle = 0; |
247 | 246 | usbHandle = 0; |
248 | 247 | acHandle = 0; |
249 | 248 | |
250 | 249 | batteryHandle = fopen("/sys/class/power_supply/battery/capacity", "r"); |
251 | 250 | usbHandle = fopen("/sys/class/power_supply/usb/online", "r"); |
252 | 251 | acHandle = fopen("/sys/class/power_supply/ac/online", "r"); |
253 | | #if defined(PLATFORM_NANONOTE) |
254 | | backlightHandle = fopen("/sys/class/lcd/ili8960-lcd/contrast", "w+"); |
255 | | #elif defined(PLATFORM_DINGUX) |
256 | | backlightHandle = fopen("/sys/class/backlight/pwm-backlight/brightness", "w+"); |
257 | | #endif |
258 | 252 | } |
259 | 253 | |
260 | 254 | void GMenu2X::deinit() { |
261 | 255 | if (batteryHandle) fclose(batteryHandle); |
262 | | if (backlightHandle) fclose(backlightHandle); |
263 | 256 | if (usbHandle) fclose(usbHandle); |
264 | 257 | if (acHandle) fclose(acHandle); |
265 | 258 | } |
... | ... | |
652 | 645 | } |
653 | 646 | } |
654 | 647 | |
655 | | void GMenu2X::setBacklight(int val) |
656 | | { |
657 | | if (backlightHandle) { |
658 | | fprintf(backlightHandle, "%d", (val * 255) / 100); |
659 | | fflush(backlightHandle); |
660 | | rewind(backlightHandle); |
661 | | } |
662 | | } |
663 | | |
664 | | int GMenu2X::getBackLight() |
665 | | { |
666 | | int val = 255; |
667 | | if (backlightHandle) { |
668 | | fscanf(backlightHandle, "%d", &val); |
669 | | rewind(backlightHandle); |
670 | | val = (val * 100) / 255; |
671 | | if (val < 0) val = 0; else if (val > 100) val = 100; |
672 | | } |
673 | | return val; |
674 | | } |
675 | | |
676 | 648 | void GMenu2X::main() { |
677 | 649 | uint linksPerPage = linkColumns*linkRows; |
678 | 650 | int linkSpacingX = (resX-10 - linkColumns*skinConfInt["linkWidth"])/linkColumns; |
... | ... | |
904 | 876 | |
905 | 877 | void GMenu2X::options() { |
906 | 878 | int curMenuClock = confInt["menuClock"]; |
907 | | int oldBacklight = getBackLight(); |
908 | | int newBacklight = oldBacklight; |
909 | 879 | bool showRootFolder = fileExists(CARD_ROOT); |
910 | 880 | |
911 | 881 | FileLister fl_tr(getHome() + "/translations"); |
... | ... | |
926 | 896 | sd.addSetting(new MenuSettingInt(this, ts, tr["Clock for GMenu2X"], tr["Set the cpu working frequency when running GMenu2X"], &confInt["menuClock"], cpuFreqMin, cpuFreqSafeMax, cpuFreqMultiple)); |
927 | 897 | sd.addSetting(new MenuSettingInt(this, ts, tr["Maximum overclock"], tr["Set the maximum overclock for launching links"], &confInt["maxClock"], cpuFreqMin, cpuFreqMax, cpuFreqMultiple)); |
928 | 898 | sd.addSetting(new MenuSettingBool(this, ts, tr["Output logs"], tr["Logs the output of the links. Use the Log Viewer to read them."], &confInt["outputLogs"])); |
929 | | sd.addSetting(new MenuSettingInt(this, ts, tr["Lcd Backlight"], tr["Set Lcd Backlight value (default: 100)"], &newBacklight, 5, 100)); |
930 | 899 | sd.addSetting(new MenuSettingInt(this, ts, tr["Screen Timeout"], tr["Set screen's backlight timeout in seconds"], &confInt["backlightTimeout"], 0, 120)); |
931 | 900 | // sd.addSetting(new MenuSettingMultiString(this, ts, tr["Tv-Out encoding"], tr["Encoding of the tv-out signal"], &confStr["tvoutEncoding"], &encodings)); |
932 | 901 | sd.addSetting(new MenuSettingBool(this, ts, tr["Show root"], tr["Show root folder in the file selection dialogs"], &showRootFolder)); |
933 | 902 | |
934 | 903 | if (sd.exec() && sd.edited()) { |
935 | | if (newBacklight != oldBacklight) setBacklight(newBacklight); |
936 | 904 | if (curMenuClock != confInt["menuClock"]) setClock(confInt["menuClock"]); |
937 | 905 | |
938 | 906 | if (confInt["backlightTimeout"] == 0) { |
src/gmenu2x.h |
85 | 85 | @return A number representing battery charge. 0 means fully discharged. 5 means fully charged. 6 represents a gp2x using AC power. |
86 | 86 | */ |
87 | 87 | unsigned short getBatteryLevel(); |
88 | | FILE* batteryHandle, *backlightHandle, *usbHandle, *acHandle; |
| 88 | FILE* batteryHandle, *usbHandle, *acHandle; |
89 | 89 | void browsePath(const std::string &path, std::vector<std::string>* directories, std::vector<std::string>* files); |
90 | 90 | /*! |
91 | 91 | Starts the scanning of the nand and sd filesystems, searching for dge and gpu files and creating the links in 2 dedicated sections. |
... | ... | |
173 | 173 | |
174 | 174 | void setClock(unsigned mhz); |
175 | 175 | |
176 | | void setBacklight(int val); |
177 | | int getBackLight(); |
178 | | |
179 | 176 | void setInputSpeed(); |
180 | 177 | |
181 | 178 | void writeConfig(); |