Compare commits
No commits in common. "1eaa9c3c38779b23a7a704d4cf0ebf7681ce026d" and "09bc6979e9316fe19feef7effbdd54be60d214ed" have entirely different histories.
1eaa9c3c38
...
09bc6979e9
@ -16,9 +16,11 @@ void input_init()
|
|||||||
PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups
|
PORT_KEYPAD(PORT) |= PIN_KEYPAD_MASK; // Key pullups
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int8_t get_rotary_delta()
|
int8_t get_rotary_delta()
|
||||||
{
|
{
|
||||||
return rotary_delta;
|
int8_t temp = rotary_delta;
|
||||||
|
//rotary_delta = 0;
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void input_proc_rotary()
|
static inline void input_proc_rotary()
|
||||||
@ -81,15 +83,11 @@ void input_proc_switches()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t get_switch_event()
|
uint8_t get_switch_event()
|
||||||
{
|
{
|
||||||
return sw_event;
|
uint8_t temp = 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,7 +14,6 @@ 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,28 +18,23 @@ 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 = Y_MAX;
|
static uint8_t y = DISPLAY_HEIGHT / 8 - 1;
|
||||||
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 = spdr_next;
|
//SPDR = get_rotary_delta();
|
||||||
switch (y) {
|
SPDR = get_switch_event();
|
||||||
case Y_MAX:
|
//SPDR = dbg;
|
||||||
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 = Y_MAX;
|
y = DISPLAY_HEIGHT / 8 - 1;
|
||||||
x++;
|
x++;
|
||||||
if (x == DISPLAY_WIDTH) {
|
if (x == DISPLAY_WIDTH) {
|
||||||
x = 0;
|
x = 0;
|
||||||
@ -53,13 +48,9 @@ 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 = Y_MAX;
|
y = DISPLAY_HEIGHT / 8 - 1;
|
||||||
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));
|
||||||
}
|
}
|
||||||
inline void lcd_set_buffer(uint8_t x, uint8_t y, uint8_t value) {
|
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,7 +7,6 @@ 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):
|
||||||
@ -133,10 +132,8 @@ 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())
|
||||||
rdata = self.spi.xfer(data, SPI_SPEED, 1)
|
self.spi.xfer(data)
|
||||||
await self.io_event.wait()
|
await self.io_event.wait()
|
||||||
self.io_event.clear()
|
self.io_event.clear()
|
||||||
|
|
||||||
@ -198,7 +195,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 = SPI_SPEED
|
self.spi.max_speed_hz = 500000
|
||||||
self.spi.mode = 0b00
|
self.spi.mode = 0b00
|
||||||
|
|
||||||
# Connect to MPD
|
# Connect to MPD
|
||||||
@ -220,7 +217,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(6000)
|
await asyncio.sleep(60)
|
||||||
|
|
||||||
io_timer_task.cancel()
|
io_timer_task.cancel()
|
||||||
io_task.cancel()
|
io_task.cancel()
|
||||||
|
Loading…
Reference in New Issue
Block a user