This repository has been archived by the owner on Dec 31, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 53
/
display800x480.py
73 lines (66 loc) · 2.33 KB
/
display800x480.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
#!/usr/bin/env python
# This file is part of Openplotter.
# Copyright (C) 2015 by sailoog <https://github.com/sailoog/openplotter>
# e-sailing <https://github.com/e-sailing/openplotter>
# Openplotter 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 2 of the License, or
# any later version.
# Openplotter 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 Openplotter. If not, see <http://www.gnu.org/licenses/>.
import subprocess, platform
if platform.machine()[0:3]!='arm':
print 'this is not a raspberry pi -> no RPI display settings'
else:
output = subprocess.check_output(['tvservice', '-d', '/dev/stdout'])
output = output[:128]
try:
editfile = open('edid.dat', 'r', 5000)
bak = editfile.read()
editfile.close()
except:
bak = ''
if output != bak:
subprocess.check_output(['tvservice', '-d', 'edid.dat'])
output = subprocess.check_output(['edidparser', 'edid.dat'])
DisplayResolution = ''
if '800x480' in output:
DisplayResolution = '800 480'
#DisplayResolution = '1024 600'
#DisplayResolution = '1120 630'
elif '1024:600' in output:
DisplayResolution = '1024 600'
elif '1280:800' in output:
DisplayResolution = '1280 800'
if DisplayResolution != '':
configfile = open('/boot/config.txt', 'r', 5000)
data = configfile.read()
configfile.close()
output = subprocess.check_output(['tvservice', '-n'])
output = output[12:-1]
if ('[EDID=' + output) in data: pass
else:
if '[all]' in data:
line = data.split('\n')
data = ''
for l in line:
if '[all]' in l:
data += '[EDID=' + output + ']\n'
data += 'hdmi_group=2\n'
data += 'hdmi_mode=87\n'
data += 'hdmi_cvt='+ DisplayResolution +' 60 6 0 0 0\n'
data += l+'\n'
else:
data += '[EDID=' + output + ']\n'
data += 'hdmi_group=2\n'
data += 'hdmi_mode=87\n'
data += 'hdmi_cvt='+ DisplayResolution +' 60 6 0 0 0\n'
data += '[all]\n'
configfile = open('/boot/config.txt', 'w')
configfile.write(data)
configfile.close()