Compare commits
No commits in common. "577ba83a586ceef83e689a19639deee90cb5ef62" and "cec6bd2c0bd49bdbb362ce68aec4f5a743f31eca" have entirely different histories.
577ba83a58
...
cec6bd2c0b
@ -3,12 +3,11 @@
|
||||
#include <avr/io.h>
|
||||
|
||||
#define ADC_CHANNEL 0
|
||||
#define PORT_ADCC(t) t##C
|
||||
#define PORT_ADCC(t) t##D
|
||||
#define PIN_ADCC (1 << 1)
|
||||
|
||||
// Nominal 3.7V: 195; Full 4.2V: 220
|
||||
#define BAT_THRES_POWER_ON 175 // TODO: Minimum ADC value to allow turning the device on (3.3V)
|
||||
#define BAT_THRES_POWER_OFF 165 // TODO: ADC value to (hard) power off the device. (3.1V)
|
||||
#define BAT_THRES_POWER_ON 60 // TODO: Minimum ADC value to allow turning the device on
|
||||
#define BAT_THRES_POWER_OFF 50 // TODO: ADC value to (hard) power off the device.
|
||||
|
||||
void batmon_init();
|
||||
uint8_t batmon_get_voltage();
|
||||
|
@ -2,15 +2,16 @@
|
||||
#define INPUT_H
|
||||
|
||||
#define PORT_KEYPAD(t) t##D // Keys connected to: 0,1,2(INT0->POWER),5,6,7
|
||||
#define PIN_KEYPAD_MASK 0b11111111
|
||||
#define PIN_KEYPAD_MASK 0b11100111
|
||||
#define PORT_KEYAUX(t) t##B
|
||||
#define PIN_ROTARY_PUSH (1 << 0)
|
||||
|
||||
#define PORT_SBCMON(t) t##C
|
||||
#define PIN_SBCMON (1 << 1)
|
||||
|
||||
#define PORT_ROTARY(t) t##B
|
||||
#define PIN_ROTARY_A (1 << 0)
|
||||
#define PIN_ROTARY_B (1 << 1)
|
||||
#define PORT_ROTARY(t) t##D
|
||||
#define PIN_ROTARY_A (1 << 3) // INT1
|
||||
#define PIN_ROTARY_B (1 << 4)
|
||||
|
||||
void input_init();
|
||||
void input_proc();
|
||||
|
@ -47,9 +47,7 @@ uint8_t spi_proc()
|
||||
x++;
|
||||
if (x == DISPLAY_WIDTH) {
|
||||
x = 0;
|
||||
y = Y_MAX;
|
||||
new_data = 1; // Only update the display if a full frame was received
|
||||
lcd_display();
|
||||
}
|
||||
} else {
|
||||
y--;
|
||||
@ -57,6 +55,7 @@ uint8_t spi_proc()
|
||||
}
|
||||
} else {
|
||||
if (new_data) {
|
||||
lcd_display();
|
||||
new_data = 0;
|
||||
} else if ((y == Y_MAX - 3) && (x == 0)) { // If the last one was a I/O frame
|
||||
input_clear_events();
|
||||
|
@ -2,8 +2,8 @@
|
||||
#define PM_H
|
||||
#include <avr/io.h>
|
||||
|
||||
#define PORT_SBCPOW(t) t##B
|
||||
#define PIN_SBCPOW (1 << 7)
|
||||
#define PORT_SBCPOW(t) t##C
|
||||
#define PIN_SBCPOW (1 << 2)
|
||||
|
||||
void pm_init();
|
||||
void suspend();
|
||||
|
@ -5,9 +5,9 @@ import asyncio
|
||||
from mpd import MPDClient
|
||||
import spidev
|
||||
|
||||
IO_DELAY = (1.0 / 18.0)
|
||||
IO_DELAY = (1.0 / 25.0)
|
||||
MPD_DELAY = 0.5
|
||||
SPI_SPEED = 500000
|
||||
SPI_SPEED = 600000
|
||||
|
||||
class display(object):
|
||||
def __init__(self):
|
||||
@ -129,41 +129,14 @@ class display_manager(object):
|
||||
# TODO: Consider also animating inactive screens... Might resolve some glitches when updating text while a screen is in the background (or pass `tick` to update funcs)
|
||||
|
||||
class radioserv:
|
||||
def handle_rx(self, rdata):
|
||||
# Handle key presses
|
||||
key_id = rdata[0] & 0x0F
|
||||
key_press_short = ((rdata[0] & 0xC0) == 128)
|
||||
if (key_press_short):
|
||||
print("Press key: {}".format(key_id))
|
||||
if (key_id == 0): # Tune-
|
||||
pass
|
||||
elif (key_id == 1): # Tune+
|
||||
self.mpd.previous()
|
||||
elif (key_id == 2): # Power
|
||||
self.kill_event.set()
|
||||
elif (key_id == 4): # Wheel
|
||||
self.mpd.pause()
|
||||
elif (key_id == 5): # Source
|
||||
pass
|
||||
elif (key_id == 6): # Info / Menu
|
||||
self.mpd.next()
|
||||
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)
|
||||
#print("Battery: {}".format(rdata[2]))
|
||||
|
||||
async def io_main(self):
|
||||
while True:
|
||||
self.disp_mgr.animate(1)
|
||||
self.disp_mgr.render()
|
||||
rdata = self.spi.xfer([100, 101, 102], 50000, 1000)
|
||||
self.handle_rx(rdata)
|
||||
rdata = self.spi.xfer([100, 101, 102, 103], 100000, 1)
|
||||
print(rdata)
|
||||
data = list(self.disp_mgr.get_image())
|
||||
rdata = self.spi.xfer(data, SPI_SPEED, 10000)
|
||||
rdata = self.spi.xfer(data, SPI_SPEED, 1)
|
||||
await self.io_event.wait()
|
||||
self.io_event.clear()
|
||||
|
||||
@ -230,7 +203,7 @@ class radioserv:
|
||||
|
||||
# Connect to MPD
|
||||
self.mpd = MPDClient()
|
||||
self.mpd.connect("localhost", 6600)
|
||||
self.mpd.connect("yuki", 6600)
|
||||
|
||||
# Set up displays
|
||||
self.disp_playback = display_playback()
|
||||
@ -241,14 +214,13 @@ class radioserv:
|
||||
|
||||
# Create main tasks
|
||||
self.io_event = asyncio.Event()
|
||||
self.kill_event = asyncio.Event()
|
||||
|
||||
io_task = asyncio.create_task(self.io_main())
|
||||
io_timer_task = asyncio.create_task(self.io_timer_main())
|
||||
mpd_task = asyncio.create_task(self.mpd_main())
|
||||
|
||||
await self.kill_event.wait()
|
||||
self.kill_event.clear()
|
||||
# TODO: Wait for exit condition (shutdown command)
|
||||
await asyncio.sleep(6000)
|
||||
|
||||
io_timer_task.cancel()
|
||||
io_task.cancel()
|
||||
|
Loading…
Reference in New Issue
Block a user