Notice: This forum has been recovered from an old backup, so some content, links, and dates may be outdated. The forum is currently read-only while we restore sign-in and registration functionality. Details
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
If you find this forum valuable and would like to help keep it online, donations to help cover hosting and domain costs are greatly appreciated, but never expected. You can support the forum through Buy Me a Coffee or Ko-fi. Thank you for helping preserve the EventGhost community.
Serial Plugin
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
Code: Select all
device = "AV2"
serial = eg.Plugin.Serial2
def printhex(bytes):
print " ".join([("%0.2X" % ord(x)) for x in bytes])
serial.Write("*")
serial.Read()
eg.Wait(0.025)
serial.Write("*" + device + " \x69\xFF")
response_length = len(device) + 8
response = serial.Read(response_length, 1.0)
printhex(response)
if response.startswith("#" + device + " \x69"):
val = ord(response[response_length - 3]) & 0x7F
val += 1
print val
val = max(0, min(val, 99))
print val
eg.Wait(0.1)
serial.Write("*")
eg.Wait(0.025)
cmd = "*" + device + " \x23" + chr(val) + "\xFF"
printhex(cmd)
serial.Write(cmd)
response = serial.Read(len(cmd), 1.0)
printhex(response)
Last edited by Bitmonster on Mon Feb 13, 2006 11:22 pm, edited 1 time in total.
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
Mach mal ein Python-Script direkt hinter dem Serial-Plugin f├╝r den naim im Autostart-Makro und f├╝ge da folgendes ein:
Weiter einstellen brauchst du da nichts. Dann startest du EG neu und f├╝gst noch diese Befehle in deinen Baum ein:
Jetzt noch die Tasten der FB zuweisen und dann sollte er zucken.
Code: Select all
device = "AV2"
serial = result
from time import sleep, clock
class naim:
def __init__(self):
self.last_cmd_time = 0
self.volume = None
#self.GetVolume()
def SendCommand(self, cmd):
time_diff = clock() - self.last_cmd_time
if time_diff < 0.1:
sleep(0.1 - time_diff)
serial.Write("*")
serial.Read()
sleep(0.025)
serial.Write("*" + device + " " + cmd + "\xFF")
self.last_cmd_time = clock()
def GetVolume(self):
self.SendCommand("\x69")
response_length = len(device) + 8
response = serial.Read(response_length, 1.0)
if (response.startswith("#" + device + " \x69")
and len(response) == response_length):
self.volume = ord(response[response_length - 3]) & 0x7F
else:
eg.PrintError("can't get volume from naim!")
self.volume = None
return self.volume
def SetVolume(self, volume):
if volume > 99:
volume = 99
elif volume < 0:
volume = 0
self.SendCommand("\x23" + chr(volume))
self.volume = volume
def ChangeVolume(self, offset):
if self.volume is None:
self.GetVolume()
if self.volume is not None:
self.SetVolume(self.volume + offset)
eg.Global.naim = naim()
Code: Select all
<?xml version="1.0" encoding="UTF-8" ?>
<EventGhost Version="442">
<Macro Name="Increment naim AV2 volume">
<Action>
EventGhost.PythonCommand(u'naim.ChangeVolume(1)')
</Action>
<Action>
EventGhost.AutoRepeat(0.59999999999999998, 0.29999999999999999, 0.01, 3.0)
</Action>
</Macro>
<Macro Name="Decrement naim AV2 volume">
<Action>
EventGhost.PythonCommand(u'naim.ChangeVolume(-1)')
</Action>
<Action>
EventGhost.AutoRepeat(0.59999999999999998, 0.29999999999999999, 0.01, 3.0)
</Action>
</Macro>
</EventGhost>
Last edited by Bitmonster on Fri Feb 17, 2006 1:11 pm, edited 3 times in total.
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm
- Bitmonster
- Site Admin
- Posts: 2239
- Joined: Mon Feb 06, 2006 10:28 pm