-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtestatmodriver.py
85 lines (61 loc) · 2 KB
/
testatmodriver.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import os, sys, threading, time
import atmodriver
logLevel = atmodriver.LOG_DEBUG
def log(level, msg):
if level <= logLevel:
print "DFAtmo: %s" % msg
class Logger:
def __init__(self):
self.LOG_NONE = atmodriver.LOG_NONE
self.LOG_ERROR = atmodriver.LOG_ERROR
self.LOG_INFO = atmodriver.LOG_INFO
self.LOG_DEBUG = atmodriver.LOG_DEBUG
def log(self, level, msg):
global log
log(level, msg)
class CustomDriverCallbacks:
def __init__(self, atmoDriver):
self.atmoDriver = atmoDriver
def getParm(self, name):
return self.atmoDriver.getParm(name)
def setParm(self, name, value):
self.atmoDriver.setParm(name, value)
def driverError(self, msg):
return atmodriver.error(str(msg))
atmodriver.setLogLevel(logLevel)
ad = atmodriver.AtmoDriver()
customDriver = None
# Uncomment the output driver you want to use
# Script custom drivers should be set with customDriver
# Native output drivers should be set with ad.driver
customDriver = "mydriver"
#ad.driver = "file"
ad.driver_param = "/tmp/atmo.out"
ad.driver_path = "."
ad.left = 1
ad.right = 1
ad.top = 1
ad.bottom = 1
ad.filter = atmodriver.FILTER_NONE
od = ad
if customDriver:
customDriverModule = __import__(customDriver)
od = customDriverModule.newOutputDriver(CustomDriverCallbacks(ad), Logger())
log(atmodriver.LOG_INFO, "Custom driver interface version is %d" % od.getInterfaceVersion())
od.openOutputDriver()
od.turnLightsOff()
ad.configure()
ad.resetFilters()
img = bytearray(range(256) * 64)
analyzedColors = ad.analyzeImage(64,64,atmodriver.IMAGE_FORMAT_RGBA,img)
outputColors = ad.filterAnalyzedColors(analyzedColors)
filteredOutputColors = ad.filterOutputColors(outputColors)
od.outputColors(filteredOutputColors)
ad.gamma = 25
if ad != od:
od.instantConfigure()
ad.instantConfigure()
filteredOutputColors = ad.filterOutputColors(outputColors)
od.outputColors(filteredOutputColors)
od.turnLightsOff()
od.closeOutputDriver()