Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adaption for Asus UX303LN #18

Closed
jv-barsuk opened this issue Jun 12, 2015 · 5 comments
Closed

Adaption for Asus UX303LN #18

jv-barsuk opened this issue Jun 12, 2015 · 5 comments

Comments

@jv-barsuk
Copy link

I adapted the programm for the Asus UX303LN. There were the following issues

  • path to the max_brightness file
  • number format of the brightness (dec instead of hex)
  • I replaced the case with if and ranges
  • I adapted the brightness a bit

Can you somehow include this in your project or should I fork it for the UX303LN?

@@ -105,9 +106,9 @@

 int getScreenBacklightMax()
 {
-    int fd = open("/sys/class/backlight/intel_backlight/max_brightness", O_RDONLY);
+    int fd = open("/sys/class/backlight/acpi_video0/max_brightness", O_RDONLY);
     if(fd == -1) {
-        syslog(LOG_ERR, "Error opening /sys/class/backlight/intel_backlight/max_brightness");
+        syslog(LOG_ERR, "Error opening /sys/class/backlight/acpi_video0/max_brightness");
         return 0;
     }

@@ -125,7 +126,7 @@
     char cmd[100];
     int maxScreenBacklight=getScreenBacklightMax(); // could be static if we are sure if it will not be changed at program lifetime
     if (!maxScreenBacklight) maxScreenBacklight=15; // 15 is a default value
-    snprintf(cmd, sizeof(cmd), "echo %d | tee /sys/class/backlight/intel_backlight/brightness", maxScreenBacklight*percent/100);
+    snprintf(cmd, sizeof(cmd), "echo %d | tee /sys/class/backlight/acpi_video0/brightness", maxScreenBacklight*percent/100);
     ret = system(cmd);
     if (ret < 0) {
         syslog(LOG_ERR, "Failed to set screen backlight.");
@@ -189,26 +190,28 @@

     // 0x32 (min illuminance), 0xC8, 0x190, 0x258, 0x320 (max illuminance).
     int als = atoi(strals);
-    syslog(LOG_ERR,"\"%s\"\n", strals);
-    syslog(LOG_ERR,"Illuminance detected: %d\n", als);
+    //printf("\"%s\"\n", strals);
+    //printf("Illuminance detected: %d\n", als);

     float percent = 0;

-    if (50 > als) {
+    switch(als) {
+    case 0x32:
         percent = 10;
-       } else
-    if (200 > als) {
+        break;
+    case 0xC8:
         percent = 25;
-   } else
-    if (400 > als) {
+        break;
+    case 0x190:
         percent = 50;
-   } else
-    if (600 > als) {
+        break;
+    case 0x258:
         percent = 75;
-   } else
-    if (800 > als) {
+        break;
+    case 0x320:
         percent = 100;
-       }
+        break;
+    }

     return percent;
 }
@@ -294,16 +297,16 @@
             //printf("Illuminance percent: %f\n", als);

             if(als <= 10) {
-                setScreenBacklight(30);
+                setScreenBacklight(40);
                 setKeyboardBacklight(100);
             } else if(als <= 25) {
-                setScreenBacklight(50);
+                setScreenBacklight(60);
                 setKeyboardBacklight(0);
             } else if(als <= 50) {
-                setScreenBacklight(65);
+                setScreenBacklight(75);
                 setKeyboardBacklight(0);
             } else if(als <= 75) {
-                setScreenBacklight(80);
+                setScreenBacklight(90);
                 setKeyboardBacklight(0);
             } else if(als <= 100) {
                 setScreenBacklight(100);

@danieleds
Copy link
Owner

Thanks! I can adapt it.
Can you confirm that /sys/class/backlight/intel_backlight/max_brightness is missing on your PC?

@jv-barsuk
Copy link
Author

/sys/class/backlight/intel_backlight/max_brightness is there but /sys/class/backlight/acpi_video0/max_brightness which you are using in your programm is missing on my system.

@danieleds
Copy link
Owner

Ok!

@nitroxx92
Copy link

What about Asus ZenBook UX305?

@Perlover
Copy link

If you have Asus UX305 may be my branch of this repo will work at you:
https://github.com/Perlover/Asus-Zenbook-Ambient-Light-Sensor-Controller/tree/asus-ux305

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants