2020-05-18 03:29:45 +00:00
|
|
|
#include "odroid/display.h"
|
2020-05-15 01:44:56 +00:00
|
|
|
#include "odroid/input.h"
|
2020-05-18 03:29:45 +00:00
|
|
|
#include "macros.h"
|
2020-05-15 01:44:56 +00:00
|
|
|
#include <esp_log.h>
|
2020-05-10 02:07:57 +00:00
|
|
|
#include <freertos/FreeRTOS.h>
|
|
|
|
#include <freertos/task.h>
|
2020-05-18 03:29:45 +00:00
|
|
|
#include <string.h>
|
2020-05-15 01:44:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
static const char* LOG_TAG = "Main";
|
2020-05-18 03:29:45 +00:00
|
|
|
static uint16_t gFramebuffer[LCD_WIDTH * LCD_HEIGHT];
|
2020-05-10 02:07:57 +00:00
|
|
|
|
|
|
|
void app_main(void)
|
|
|
|
{
|
2020-05-15 01:44:56 +00:00
|
|
|
Odroid_InitializeInput();
|
2020-05-18 03:29:45 +00:00
|
|
|
Odroid_InitializeDisplay();
|
2020-05-15 01:44:56 +00:00
|
|
|
|
|
|
|
ESP_LOGI(LOG_TAG, "Odroid initialization complete - entering main loop");
|
|
|
|
|
2020-05-18 03:29:45 +00:00
|
|
|
int x = 0;
|
|
|
|
int y = 0;
|
|
|
|
|
|
|
|
uint16_t color = 0xffff;
|
|
|
|
|
2020-05-10 02:07:57 +00:00
|
|
|
for (;;)
|
|
|
|
{
|
2020-05-18 03:29:45 +00:00
|
|
|
memset(gFramebuffer, 0, 320 * 240 * 2);
|
|
|
|
|
2020-05-15 01:44:56 +00:00
|
|
|
Odroid_Input input = Odroid_PollInput();
|
|
|
|
|
2020-05-18 03:29:45 +00:00
|
|
|
if (input.left) { x -= 20; }
|
|
|
|
else if (input.right) { x += 20; }
|
|
|
|
|
|
|
|
if (input.up) { y -= 20; }
|
|
|
|
else if (input.down) { y += 20; }
|
|
|
|
|
|
|
|
if (input.a) { color = SWAP_ENDIAN_16(RGB565(0xff, 0, 0)); }
|
|
|
|
else if (input.b) { color = SWAP_ENDIAN_16(RGB565(0, 0xff, 0)); }
|
|
|
|
else if (input.start) { color = SWAP_ENDIAN_16(RGB565(0, 0, 0xff)); }
|
|
|
|
else if (input.select) { color = SWAP_ENDIAN_16(RGB565(0xff, 0xff, 0xff)); }
|
2020-05-15 01:44:56 +00:00
|
|
|
|
2020-05-18 03:29:45 +00:00
|
|
|
for (int row = y; row < y + 50; ++row)
|
|
|
|
{
|
|
|
|
for (int col = x; col < x + 50; ++col)
|
|
|
|
{
|
|
|
|
gFramebuffer[LCD_WIDTH * row + col] = color;
|
|
|
|
}
|
|
|
|
}
|
2020-05-15 01:44:56 +00:00
|
|
|
|
2020-05-18 03:29:45 +00:00
|
|
|
Odroid_DrawFrame(gFramebuffer);
|
2020-05-10 02:07:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Should never get here
|
|
|
|
esp_restart();
|
|
|
|
}
|
2020-05-15 01:44:56 +00:00
|
|
|
|