summaryrefslogtreecommitdiffstats
path: root/abs/core/system-templates/firefly_gen.py
blob: 1bb00702269051cc58ef4c2f3a9413be2b7b1085 (plain)
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
#!/bin/python2
header='''
begin remote
 name Snapstream_Firefly
 bits 40
 eps 30
 aeps 100
 one 0 0
 zero 0 0
 gap 219964
 toggle_bit 0
 begin codes
'''
middle=[
    'MAXI   0x0000001481AC0000',
    'MAXI   0x00000014012C0000',
    'CLOSE  0x00000014D7020000',
    'CLOSE  0x0000001457820000',
    '1      0x00000014628D0000',
    '1      0x00000014E20D0000',
    '2 0x00000014E30E0000',
    '2 0x00000014638E0000',
    '3 0x00000014648F0000',
    '3 0x00000014E40F0000',
    '4 0x00000014E5100000',
    '4 0x0000001465900000',
    '5 0x0000001466910000',
    '5 0x00000014E6110000',
    '6 0x00000014E7120000',
    '6 0x0000001467920000',
    '7 0x0000001468930000',
    '7 0x00000014E8130000',
    '8 0x00000014E9140000',
    '8 0x0000001469940000',
    '9 0x000000146A950000',
    '9 0x00000014EA150000',
    '0 0x00000014EC170000',
    '0 0x000000146C970000',
    'BACK 0x000000146B960000',
    'BACK 0x00000014EB160000',
    'ENT 0x00000014ED180000',
    'ENT 0x000000146D980000',
    'VOL+ 0x000000145E890000',
    'VOL+ 0x00000014DE090000',
    'VOL- 0x000000145D880000',
    'VOL- 0x00000014DD080000',
    'MUTE 0x000000145F8A0000',
    'MUTE 0x00000014DF0A0000',
    'FIREFLY 0x0000001455800000',
    'FIREFLY 0x00000014D5000000',
    'CH+ 0x00000014608B0000',
    'CH+ 0x00000014E00B0000',
    'CH- 0x00000014618C0000',
    'CH- 0x00000014E10C0000',
    'INFO 0x0000001483AE0000',
    'INFO 0x00000014032E0000',
    'OPTION 0x0000001484AF0000',
    'OPTION 0x00000014042F0000',
    'UP 0x000000146F9A0000',
    'UP 0x00000014EF1A0000',
    'LEFT 0x00000014729D0000',
    'LEFT 0x00000014F21D0000',
    'DOWN 0x0000001477A20000',
    'DOWN 0x00000014F7220000',
    'RIGHT 0x00000014749F0000',
    'RIGHT 0x00000014F41F0000',
    'OK 0x00000014739E0000',
    'OK 0x00000014F31E0000',
    'MENU 0x00000014719C0000',
    'MENU 0x00000014F11C0000',
    'EXIT 0x0000001475A00000',
    'EXIT 0x00000014F5200000',
    'REC 0x00000014FC270000',
    'REC 0x000000147CA70000',
    'PLAY 0x00000014FA250000',
    'PLAY 0x000000147AA50000',
    'STOP 0x00000014FD280000',
    'STOP 0x000000147DA80000',
    'REW 0x00000014F9240000',
    'REW 0x0000001479A40000',
    'FWD 0x00000014FB260000',
    'FWD 0x000000147BA60000',
    'PREV 0x00000014002B0000',
    'PREV 0x0000001480AB0000',
    'PAUSE 0x00000014FE290000',
    'PAUSE 0x000000147EA90000',
    'NEXT 0x00000014FF2A0000',
    'NEXT 0x000000147FAA0000',
    'MUSIC 0x00000014DB060000',
    'MUSIC 0x000000145B860000',
    'PHOTOS 0x00000014DA050000',
    'PHOTOS 0x000000145A850000',
    'DVD 0x00000014D9040000',
    'DVD 0x0000001459840000',
    'TV 0x00000014D8030000',
    'TV 0x0000001458830000',
    'VIDEO 0x00000014DC070000',
    'VIDEO 0x000000145C870000',
    'HELP 0x00000014D6010000',
    'HELP 0x0000001456810000',
    'MOUSE 0x00000014022D0000',
    'MOUSE 0x0000001482AD0000',
    'A 0x00000014EE190000',
    'A 0x000000146E990000',
    'B 0x00000014F01B0000',
    'B 0x00000014709B0000',
    'C 0x00000014F6210000',
    'C 0x0000001476A10000',
    'D 0x00000014F8230000',
    'D 0x0000001478A30000'
]
footer='''
 end codes

end remote
'''

modules_conf='''
#placed here by mv_ir.py
blacklist ati_remote
install ati_remote /bin/false

alias char-major-61 lirc_atiusb
options lirc_atiusb unique=1 mask=%s
'''

mod_mask=[(1, "0x0001") ,
          (2,"0x0002"),
          (3,"0x0004"),
          (4,"0x0008"),
          (5,"0x0010"),
          (6,"0x0020"),
          (7,"0x0040"),
          (8,"0x0080"),
          (9,"0x0100"),
          (10,"0x0200"),
          (11,"0x0400"),
          (12,"0x0800"),
          (13,"0x1000"),
          (14,"0x2000"),
          (15,"0x4000"),
          (16,"0x8000") ]






def hex_lookup(code):

    hcode=str(hex(code)).replace("0x","").upper()
    #print code, hcode
    hcode = hcode[-1]
    return hcode







f = open('/tmp/lircd.conf.ff1', 'w')
f.write("#Snapstream Firefly Default Channel 1")
f.write(header)
for i in middle:
    f.write("    "+ i )
    f.write("\n")
f.write(footer)


loop=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16]
for mask in loop:
    filename="/tmp/lircd.conf.ff%s" %(mask+1)
    f = open(filename, 'w')
    f.write("#Snapstream Firefly Channel %s" %(mask+1))
    f.write(header)
    for i in middle:

        rkey,code=i.split()
        #print code,rkey
        #newkey="%s_chan%s" %(rkey,mask)
        newkey=rkey
        fourth_code = int(code[-4],16)
        eight_code =  int(code[-8],16)

        new_forth = fourth_code + mask
        new_eigth = eight_code + mask

        new_code=list(code)

        new_code[-4] = (hex_lookup(new_forth))
        new_code[-8] = (hex_lookup(new_eigth))

        f.write("    " + newkey +"\t\t" +  ''.join(new_code))
        f.write("\n")
        #print fourth_code
        #print new_forth

    f.write(footer)
    f.close()


#write out modules.conf
for i in mod_mask:
    filename="/tmp/ir.conf.ff%s" %(i[0])
    f = open(filename, 'w')
    f.write("#Snapstream Firefly Channel %s" %(i[0]))
    f.write(modules_conf %i[1])
    f.close()