summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Makefile3
-rwxr-xr-xsrc/__main__.py1
-rw-r--r--src/aux.py56
-rw-r--r--src/monitor.py38
4 files changed, 60 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index 3d308eb..d35c941 100644
--- a/Makefile
+++ b/Makefile
@@ -62,7 +62,8 @@ FLAGS = $$($(PKGCONFIG) --cflags $(LIBS)) -std=$(STD) $(WARN) $(OPTIMISE) -fPIC
# Resource files
DATAFILES = 2deg 10deg redshift redshift_old
# Python source files
-PYFILES = __main__.py colour.py curve.py monitor.py solar.py icc.py adhoc.py backlight.py blackbody.py
+PYFILES = __main__.py colour.py curve.py monitor.py solar.py icc.py adhoc.py \
+ backlight.py blackbody.py aux.py
# Library files
CBINDINGS = $(foreach B,$(SERVER_BINDINGS),blueshift_$(B).so)
# Configuration script example files
diff --git a/src/__main__.py b/src/__main__.py
index ad256c3..4197963 100755
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -36,6 +36,7 @@ global monitor_controller, running, continuous_run, panic, _globals_, conf_stora
global signal_SIGTERM, signal_SIGUSR1, signal_SIGUSR2
+from aux import *
from icc import *
from solar import *
from curve import *
diff --git a/src/aux.py b/src/aux.py
new file mode 100644
index 0000000..ec94549
--- /dev/null
+++ b/src/aux.py
@@ -0,0 +1,56 @@
+#!/usr/bin/env python3
+
+# Copyright © 2014 Mattias Andrée (maandree@member.fsf.org)
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+from curve import *
+
+
+def translate_to_integers():
+ '''
+ Translate the curves from float to integer
+
+ @param :(list<int>, list<int>, list<int>) The red curve, the green curve and,
+ the blue curve mapped to integers
+ '''
+ R_curve, G_curve, B_curve = [0] * i_size, [0] * i_size, [0] * i_size
+ for i_curve, o_curve in ((r_curve, R_curve), (g_curve, G_curve), (b_curve, B_curve)):
+ for i in range(i_size):
+ o_curve[i] = int(i_curve[i] * (o_size - 1) + 0.5)
+ if clip_result:
+ o_curve[i] = min(max(0, o_curve[i]), (o_size - 1))
+ return (R_curve, G_curve, B_curve)
+
+
+def ramps_to_function(r, g, b):
+ '''
+ Convert a three colour curves to a function that applies those adjustments
+
+ @param r:int The red colour curves as [0, 65535] integers
+ @param g:int The green colour curves as [0, 65535] integers
+ @param b:int The blue colour curves as [0, 65535] integers
+ @return :()→void Function to invoke to apply the curves that the parameters [r, g and b] represents
+ '''
+ r = [y / 65535 for y in r]
+ g = [y / 65535 for y in g]
+ b = [y / 65535 for y in b]
+ def fcurve(R_curve, G_curve, B_curve):
+ for curve, cur in curves(R_curve, G_curve, B_curve):
+ for i in range(i_size):
+ y = int(curve[i] * (len(cur) - 1) + 0.5)
+ y = min(max(0, y), len(cur) - 1)
+ curve[i] = cur[y]
+ return lambda : fcurve(r, g, b)
+
diff --git a/src/monitor.py b/src/monitor.py
index 90ae603..499864f 100644
--- a/src/monitor.py
+++ b/src/monitor.py
@@ -18,6 +18,7 @@
import sys
from subprocess import Popen, PIPE
+from aux import *
from curve import *
# /usr/lib
@@ -36,22 +37,6 @@ except:
pass ## Not compiled with DRM support
-def translate_to_integers():
- '''
- Translate the curves from float to integer
-
- @param :(list<int>, list<int>, list<int>) The red curve, the green curve and,
- the blue curve mapped to integers
- '''
- R_curve, G_curve, B_curve = [0] * i_size, [0] * i_size, [0] * i_size
- for i_curve, o_curve in ((r_curve, R_curve), (g_curve, G_curve), (b_curve, B_curve)):
- for i in range(i_size):
- o_curve[i] = int(i_curve[i] * (o_size - 1) + 0.5)
- if clip_result:
- o_curve[i] = min(max(0, o_curve[i]), (o_size - 1))
- return (R_curve, G_curve, B_curve)
-
-
def close_c_bindings():
'''
Close all C bindings and let them free resources and close connections
@@ -68,27 +53,6 @@ def close_c_bindings():
drm_manager.close()
-def ramps_to_function(r, g, b):
- '''
- Convert a three colour curves to a function that applies those adjustments
-
- @param r:int The red colour curves as [0, 65535] integers
- @param g:int The green colour curves as [0, 65535] integers
- @param b:int The blue colour curves as [0, 65535] integers
- @return :()→void Function to invoke to apply the curves that the parameters [r, g and b] represents
- '''
- r = [y / 65535 for y in r]
- g = [y / 65535 for y in g]
- b = [y / 65535 for y in b]
- def fcurve(R_curve, G_curve, B_curve):
- for curve, cur in curves(R_curve, G_curve, B_curve):
- for i in range(i_size):
- y = int(curve[i] * (len(cur) - 1) + 0.5)
- y = min(max(0, y), len(cur) - 1)
- curve[i] = cur[y]
- return lambda : fcurve(r, g, b)
-
-
def randr_get(crtc = 0, screen = 0):
'''
Gets the current colour curves using the X11 extension RandR