init
This commit is contained in:
@@ -0,0 +1,56 @@
|
||||
#include "../res/station.h"
|
||||
#include "core/const.hpp"
|
||||
#include "hal/draw.hpp"
|
||||
#include "hal/hal.hpp"
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
int main() {
|
||||
if (hal::init() != 0) {
|
||||
return 1;
|
||||
}
|
||||
const auto [screen_w, screen_h] = hal::get_screen_size();
|
||||
|
||||
const float pixels_per_km = static_cast<float>(screen_h > screen_w ? screen_w : screen_h) / (max_range*2);
|
||||
bool odd_even = true;
|
||||
|
||||
const uint16_t middle_x = (screen_w / 2);
|
||||
const uint16_t middle_y = (screen_h / 2);
|
||||
|
||||
while (true) {
|
||||
hal::start_frame();
|
||||
|
||||
{ // sing of life
|
||||
draw::rect_t rect = {10, 10, static_cast<uint16_t>(screen_w - 10), 0};
|
||||
draw::filled_rect(&rect,
|
||||
{static_cast<uint8_t>(odd_even ? 0x0 : 0xff), 0, 0xff});
|
||||
odd_even = !odd_even;
|
||||
}
|
||||
|
||||
{ // draw station
|
||||
|
||||
uint16_t y = middle_y - STATION_HEIGHT / 2;
|
||||
for (uint8_t i = 0; i < STATION_HEIGHT; i++) {
|
||||
uint16_t x = middle_x - STATION_WIDTH / 2;
|
||||
for (uint8_t j = 0; j < STATION_WIDTH; j++) {
|
||||
uint8_t byte = station[i * STATION_BYTES_PER_ROW + j / 8];
|
||||
|
||||
if((byte >> (7 - (j % 8))) & 1) {
|
||||
draw::pixel(x, y, {0xff,0xff,0xff});
|
||||
}
|
||||
x++;
|
||||
}
|
||||
y++;
|
||||
}
|
||||
}
|
||||
|
||||
{ // draw rings
|
||||
for(uint16_t r = first_ring_distance; r <= max_range; r *=2) {
|
||||
draw::circle(middle_x, middle_y, r*pixels_per_km, {0xff,0xff,0xff});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
hal::end_frame();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user