Compare commits
2 Commits
09bc6979e9
...
1eaa9c3c38
Author | SHA1 | Date | |
---|---|---|---|
1eaa9c3c38 | |||
c618e058dd |
@ -16,11 +16,9 @@ void input_init()
|
|||||||
PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups
|
PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups
|
||||||
}
|
}
|
||||||
|
|
||||||
int8_t get_rotary_delta()
|
inline int8_t get_rotary_delta()
|
||||||
{
|
{
|
||||||
int8_t temp = rotary_delta;
|
return rotary_delta;
|
||||||
//rotary_delta = 0;
|
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void input_proc_rotary()
|
static inline void input_proc_rotary()
|
||||||
@ -83,11 +81,15 @@ void input_proc_switches()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t get_switch_event()
|
inline uint8_t get_switch_event()
|
||||||
{
|
{
|
||||||
uint8_t temp = sw_event;
|
return sw_event;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void input_clear_events()
|
||||||
|
{
|
||||||
|
rotary_delta = 0;
|
||||||
sw_event = 0;
|
sw_event = 0;
|
||||||
return temp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Need to call timer_proc() before calling this function!
|
// Need to call timer_proc() before calling this function!
|
||||||
|
@ -14,6 +14,7 @@ void input_init();
|
|||||||
void input_proc();
|
void input_proc();
|
||||||
int8_t get_rotary_delta();
|
int8_t get_rotary_delta();
|
||||||
uint8_t get_switch_event();
|
uint8_t get_switch_event();
|
||||||
|
void input_clear_events();
|
||||||
extern uint8_t ctime;
|
extern uint8_t ctime;
|
||||||
|
|
||||||
#endif // INPUT_H
|
#endif // INPUT_H
|
||||||
|
@ -18,23 +18,28 @@ void spi_init()
|
|||||||
DDRB |= (1 << 4);
|
DDRB |= (1 << 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define Y_MAX (DISPLAY_HEIGHT / 8 - 1)
|
||||||
uint8_t spi_proc()
|
uint8_t spi_proc()
|
||||||
{
|
{
|
||||||
static uint8_t new_data = 0;
|
static uint8_t new_data = 0;
|
||||||
static uint8_t x = 0;
|
static uint8_t x = 0;
|
||||||
static uint8_t y = DISPLAY_HEIGHT / 8 - 1;
|
static uint8_t y = Y_MAX;
|
||||||
uint8_t spi_cs;
|
uint8_t spi_cs;
|
||||||
|
static uint8_t spdr_next = 0;
|
||||||
|
|
||||||
spi_cs = !(PORT_SPI(PIN) & PIN_SPI_CS);
|
spi_cs = !(PORT_SPI(PIN) & PIN_SPI_CS);
|
||||||
|
|
||||||
if (spi_cs) {
|
if (spi_cs) {
|
||||||
if (SPSR & (1 << SPIF)) {
|
if (SPSR & (1 << SPIF)) {
|
||||||
//SPDR = get_rotary_delta();
|
SPDR = spdr_next;
|
||||||
SPDR = get_switch_event();
|
switch (y) {
|
||||||
//SPDR = dbg;
|
case Y_MAX:
|
||||||
|
spdr_next = 55; // TODO: Vbat
|
||||||
|
break;
|
||||||
|
}
|
||||||
lcd_set_buffer(x, y, SPDR);
|
lcd_set_buffer(x, y, SPDR);
|
||||||
if (y == 0) {
|
if (y == 0) {
|
||||||
y = DISPLAY_HEIGHT / 8 - 1;
|
y = Y_MAX;
|
||||||
x++;
|
x++;
|
||||||
if (x == DISPLAY_WIDTH) {
|
if (x == DISPLAY_WIDTH) {
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -48,9 +53,13 @@ uint8_t spi_proc()
|
|||||||
if (new_data) {
|
if (new_data) {
|
||||||
lcd_display();
|
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
|
||||||
|
input_clear_events();
|
||||||
}
|
}
|
||||||
x = 0;
|
x = 0;
|
||||||
y = DISPLAY_HEIGHT / 8 - 1;
|
y = Y_MAX;
|
||||||
|
SPDR = get_switch_event();
|
||||||
|
spdr_next = get_rotary_delta();
|
||||||
}
|
}
|
||||||
|
|
||||||
return spi_cs;
|
return spi_cs;
|
||||||
|
@ -174,7 +174,7 @@ void lcd_goto_xpix_y(uint8_t x, uint8_t y){
|
|||||||
#endif
|
#endif
|
||||||
lcd_command(commandSequence, sizeof(commandSequence));
|
lcd_command(commandSequence, sizeof(commandSequence));
|
||||||
}
|
}
|
||||||
void lcd_set_buffer(uint8_t x, uint8_t y, uint8_t value) {
|
inline void lcd_set_buffer(uint8_t x, uint8_t y, uint8_t value) {
|
||||||
displayBuffer[y][x] = value;
|
displayBuffer[y][x] = value;
|
||||||
}
|
}
|
||||||
void lcd_clrscr(void){
|
void lcd_clrscr(void){
|
||||||
|
@ -7,6 +7,7 @@ import spidev
|
|||||||
|
|
||||||
IO_DELAY = (1.0 / 25.0)
|
IO_DELAY = (1.0 / 25.0)
|
||||||
MPD_DELAY = 0.5
|
MPD_DELAY = 0.5
|
||||||
|
SPI_SPEED = 600000
|
||||||
|
|
||||||
class display(object):
|
class display(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -132,8 +133,10 @@ class radioserv:
|
|||||||
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, 103], 100000, 1)
|
||||||
|
print(rdata)
|
||||||
data = list(self.disp_mgr.get_image())
|
data = list(self.disp_mgr.get_image())
|
||||||
self.spi.xfer(data)
|
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()
|
||||||
|
|
||||||
@ -195,7 +198,7 @@ class radioserv:
|
|||||||
# Connect to SPI
|
# Connect to SPI
|
||||||
self.spi = spidev.SpiDev()
|
self.spi = spidev.SpiDev()
|
||||||
self.spi.open(0, 0)
|
self.spi.open(0, 0)
|
||||||
self.spi.max_speed_hz = 500000
|
self.spi.max_speed_hz = SPI_SPEED
|
||||||
self.spi.mode = 0b00
|
self.spi.mode = 0b00
|
||||||
|
|
||||||
# Connect to MPD
|
# Connect to MPD
|
||||||
@ -217,7 +220,7 @@ class radioserv:
|
|||||||
mpd_task = asyncio.create_task(self.mpd_main())
|
mpd_task = asyncio.create_task(self.mpd_main())
|
||||||
|
|
||||||
# TODO: Wait for exit condition (shutdown command)
|
# TODO: Wait for exit condition (shutdown command)
|
||||||
await asyncio.sleep(60)
|
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