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