2020-07-11 12:41:08 +02:00
|
|
|
#include <avr/io.h>
|
2020-07-19 18:40:44 +02:00
|
|
|
#include <avr/pgmspace.h>
|
|
|
|
#include <avr/delay.h>
|
|
|
|
#include "oled-display/lcd.h"
|
2020-07-11 12:41:08 +02:00
|
|
|
|
2020-07-19 18:40:44 +02:00
|
|
|
#define PORT_SPI(t) t##B
|
|
|
|
#define PIN_SPI_CS (1 << 2)
|
|
|
|
|
|
|
|
void spi_proc()
|
2020-07-11 12:41:08 +02:00
|
|
|
{
|
2020-07-19 18:40:44 +02:00
|
|
|
static uint8_t spi_cs_last = 0;
|
|
|
|
static uint8_t x = 0;
|
|
|
|
static uint8_t y = DISPLAY_HEIGHT / 8 - 1;
|
|
|
|
uint8_t spi_cs;
|
|
|
|
|
|
|
|
spi_cs = !(PORT_SPI(PIN) & PIN_SPI_CS);
|
|
|
|
|
|
|
|
if (spi_cs) {
|
|
|
|
if (SPSR & (1 << SPIF)) {
|
|
|
|
lcd_set_buffer(x, y, SPDR);
|
|
|
|
if (y == 0) {
|
|
|
|
y = DISPLAY_HEIGHT / 8 - 1;
|
|
|
|
x++;
|
|
|
|
if (x == DISPLAY_WIDTH)
|
|
|
|
x = 0;
|
|
|
|
} else {
|
|
|
|
y--;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (spi_cs_last) {
|
|
|
|
lcd_display();
|
|
|
|
}
|
|
|
|
x = 0;
|
|
|
|
y = DISPLAY_HEIGHT / 8 - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
spi_cs_last = spi_cs;
|
|
|
|
}
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
lcd_init(LCD_DISP_ON);
|
|
|
|
lcd_gotoxy(0, 0);
|
|
|
|
lcd_puts_p(PSTR("== Internet Radio =="));
|
|
|
|
lcd_drawLine(0, 9, 120, 9, WHITE);
|
|
|
|
lcd_gotoxy(0, 2);
|
|
|
|
lcd_puts_p(PSTR("Starting up."));
|
|
|
|
lcd_gotoxy(0, 3);
|
|
|
|
lcd_puts_p(PSTR("Please wait..."));
|
|
|
|
lcd_display();
|
|
|
|
|
|
|
|
SPCR = (1 << SPE);
|
|
|
|
|
|
|
|
_delay_ms(10);
|
2020-07-11 12:41:08 +02:00
|
|
|
|
2020-07-19 18:40:44 +02:00
|
|
|
while (1) {
|
|
|
|
spi_proc();
|
|
|
|
}
|
|
|
|
return 0;
|
2020-07-11 12:41:08 +02:00
|
|
|
}
|