Compare commits

..

No commits in common. "1eaa9c3c38779b23a7a704d4cf0ebf7681ce026d" and "09bc6979e9316fe19feef7effbdd54be60d214ed" have entirely different histories.

5 changed files with 17 additions and 32 deletions

View File

@ -16,9 +16,11 @@ void input_init()
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()
@ -81,15 +83,11 @@ void input_proc_switches()
}
}
inline uint8_t get_switch_event()
uint8_t get_switch_event()
{
return sw_event;
}
inline void input_clear_events()
{
rotary_delta = 0;
uint8_t temp = sw_event;
sw_event = 0;
return temp;
}
// Need to call timer_proc() before calling this function!

View File

@ -14,7 +14,6 @@ void input_init();
void input_proc();
int8_t get_rotary_delta();
uint8_t get_switch_event();
void input_clear_events();
extern uint8_t ctime;
#endif // INPUT_H

View File

@ -18,28 +18,23 @@ void spi_init()
DDRB |= (1 << 4);
}
#define Y_MAX (DISPLAY_HEIGHT / 8 - 1)
uint8_t spi_proc()
{
static uint8_t new_data = 0;
static uint8_t x = 0;
static uint8_t y = Y_MAX;
static uint8_t y = DISPLAY_HEIGHT / 8 - 1;
uint8_t spi_cs;
static uint8_t spdr_next = 0;
spi_cs = !(PORT_SPI(PIN) & PIN_SPI_CS);
if (spi_cs) {
if (SPSR & (1 << SPIF)) {
SPDR = spdr_next;
switch (y) {
case Y_MAX:
spdr_next = 55; // TODO: Vbat
break;
}
//SPDR = get_rotary_delta();
SPDR = get_switch_event();
//SPDR = dbg;
lcd_set_buffer(x, y, SPDR);
if (y == 0) {
y = Y_MAX;
y = DISPLAY_HEIGHT / 8 - 1;
x++;
if (x == DISPLAY_WIDTH) {
x = 0;
@ -53,13 +48,9 @@ uint8_t spi_proc()
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();
}
x = 0;
y = Y_MAX;
SPDR = get_switch_event();
spdr_next = get_rotary_delta();
y = DISPLAY_HEIGHT / 8 - 1;
}
return spi_cs;

View File

@ -174,7 +174,7 @@ void lcd_goto_xpix_y(uint8_t x, uint8_t y){
#endif
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;
}
void lcd_clrscr(void){

View File

@ -7,7 +7,6 @@ import spidev
IO_DELAY = (1.0 / 25.0)
MPD_DELAY = 0.5
SPI_SPEED = 600000
class display(object):
def __init__(self):
@ -133,10 +132,8 @@ class radioserv:
while True:
self.disp_mgr.animate(1)
self.disp_mgr.render()
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, 1)
self.spi.xfer(data)
await self.io_event.wait()
self.io_event.clear()
@ -198,7 +195,7 @@ class radioserv:
# Connect to SPI
self.spi = spidev.SpiDev()
self.spi.open(0, 0)
self.spi.max_speed_hz = SPI_SPEED
self.spi.max_speed_hz = 500000
self.spi.mode = 0b00
# Connect to MPD
@ -220,7 +217,7 @@ class radioserv:
mpd_task = asyncio.create_task(self.mpd_main())
# TODO: Wait for exit condition (shutdown command)
await asyncio.sleep(6000)
await asyncio.sleep(60)
io_timer_task.cancel()
io_task.cancel()