Compare commits

..

2 Commits

Author SHA1 Message Date
8fec7fbc8b fw: Fix rotary input
Accidentally disabled pull-ups instead of enabling them.
2020-08-08 17:27:49 +02:00
c4c6446d16 sw: Implement rotary encoder for volume 2020-08-08 17:27:17 +02:00
2 changed files with 12 additions and 5 deletions

View File

@ -10,7 +10,7 @@ static volatile uint8_t sw_event = 0;
void input_init() void input_init()
{ {
PORT_ROTARY(DDR) &= ~(PIN_ROTARY_A | PIN_ROTARY_B); // Configure as input PORT_ROTARY(DDR) &= ~(PIN_ROTARY_A | PIN_ROTARY_B); // Configure as input
PORT_ROTARY(PORT) &= ~(PIN_ROTARY_A | PIN_ROTARY_B); // Set pullups PORT_ROTARY(PORT) |= (PIN_ROTARY_A | PIN_ROTARY_B); // Set pullups
PORT_KEYPAD(DDR) &= ~(PIN_KEYPAD_MASK); // Key inputs PORT_KEYPAD(DDR) &= ~(PIN_KEYPAD_MASK); // Key inputs
PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups

View File

@ -150,10 +150,17 @@ class radioserv:
elif (key_id == 7): # PRESET elif (key_id == 7): # PRESET
pass pass
# Handle rotary input # Handle rotary input
rotary_delta = int(rdata[1])# - 128 rotary_delta = int(rdata[1])
if (rotary_delta > 0): if (rotary_delta > 127):
print("Rotary: {}".format(rdata[2])) rotary_delta -= 256
# self.mpd.volume(rotary_delta) 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])) #print("Battery: {}".format(rdata[2]))
async def io_main(self): async def io_main(self):