sw: Implement rotary encoder for volume
This commit is contained in:
parent
577ba83a58
commit
c4c6446d16
@ -150,10 +150,17 @@ class radioserv:
|
||||
elif (key_id == 7): # PRESET
|
||||
pass
|
||||
# Handle rotary input
|
||||
rotary_delta = int(rdata[1])# - 128
|
||||
if (rotary_delta > 0):
|
||||
print("Rotary: {}".format(rdata[2]))
|
||||
# self.mpd.volume(rotary_delta)
|
||||
rotary_delta = int(rdata[1])
|
||||
if (rotary_delta > 127):
|
||||
rotary_delta -= 256
|
||||
if (rotary_delta != 0):
|
||||
print("Rotary: {}".format(rotary_delta))
|
||||
nvol = int(self.mpd.status()['volume']) + (rotary_delta * 4)
|
||||
if (nvol < 0):
|
||||
nvol = 0;
|
||||
elif (nvol > 100):
|
||||
nvol = 100
|
||||
self.mpd.setvol(nvol)
|
||||
#print("Battery: {}".format(rdata[2]))
|
||||
|
||||
async def io_main(self):
|
||||
|
Loading…
Reference in New Issue
Block a user