mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2026-08-10 09:53:41 +00:00
Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 59088071eb | |||
| c76252b79c | |||
| 176579b868 | |||
| 9e5068180b | |||
| 07d746feb5 | |||
| 3e0be7979c | |||
| 3947a0bfea | |||
| 24f060906e | |||
| b98e87284e | |||
| 6a22fbf7a3 | |||
| f4461c4eda | |||
| 018bbdc190 | |||
| 76de12852e | |||
| 444d4f9ff3 | |||
| 31a04f47de |
@@ -30,6 +30,7 @@
|
||||
using namespace portapack;
|
||||
|
||||
#include "string_format.hpp"
|
||||
#include "complex.hpp"
|
||||
|
||||
namespace ui {
|
||||
|
||||
@@ -147,7 +148,7 @@ GeoMap::GeoMap(
|
||||
}
|
||||
|
||||
void GeoMap::paint(Painter& painter) {
|
||||
Coord line;
|
||||
u_int16_t line;
|
||||
std::array<ui::Color, 240> map_line_buffer;
|
||||
const auto r = screen_rect();
|
||||
|
||||
@@ -168,7 +169,7 @@ void GeoMap::paint(Painter& painter) {
|
||||
display.fill_rectangle({ r.center() - Point(16, 1), { 32, 2 } }, Color::red());
|
||||
display.fill_rectangle({ r.center() - Point(1, 16), { 2, 32 } }, Color::red());
|
||||
} else {
|
||||
draw_bearing({ 120, 32 + 144 }, angle_, 16, Color::red());
|
||||
draw_bearing({ 120, 32 + 144 }, angle_, 10, Color::red());
|
||||
painter.draw_string({ 120 - ((int)tag_.length() * 8 / 2), 32 + 144 - 32 }, style(), tag_);
|
||||
}
|
||||
}
|
||||
@@ -191,10 +192,16 @@ void GeoMap::move(const float lon, const float lat) {
|
||||
|
||||
Rect map_rect = screen_rect();
|
||||
|
||||
// Map is in Equidistant "Plate Carrée" projection
|
||||
x_pos = map_center_x - (map_rect.width() / 2) + (lon_ / lon_ratio);
|
||||
y_pos = map_center_y - (map_rect.height() / 2) + (lat_ / lat_ratio) + 16;
|
||||
|
||||
// Using WGS 84/Pseudo-Mercator projection
|
||||
x_pos = map_width * (lon_+180)/360 - (map_rect.width() / 2);
|
||||
|
||||
// Latitude calculation based on https://stackoverflow.com/a/10401734/2278659
|
||||
double map_bottom = sin(-85.05 * pi / 180); // Map bitmap only goes from about -85 to 85 lat
|
||||
double lat_rad = sin(lat * pi / 180);
|
||||
double map_world_lon = map_width / (2 * pi);
|
||||
double map_offset = (map_world_lon / 2 * log((1 + map_bottom) / (1 - map_bottom)));
|
||||
y_pos = map_height - ((map_world_lon / 2 * log((1 + lat_rad) / (1 - lat_rad))) - map_offset) - 128; // Offset added for the GUI
|
||||
|
||||
// Cap position
|
||||
if (x_pos > (map_width - map_rect.width()))
|
||||
x_pos = map_width - map_rect.width();
|
||||
@@ -228,8 +235,8 @@ void GeoMap::draw_bearing(const Point origin, const uint32_t angle, uint32_t siz
|
||||
|
||||
for (size_t thickness = 0; thickness < 3; thickness++) {
|
||||
arrow_a = polar_to_point(angle, size) + origin;
|
||||
arrow_b = polar_to_point(angle + 180 - 30, size) + origin;
|
||||
arrow_c = polar_to_point(angle + 180 + 30, size) + origin;
|
||||
arrow_b = polar_to_point(angle + 180 - 35, size) + origin;
|
||||
arrow_c = polar_to_point(angle + 180 + 35, size) + origin;
|
||||
|
||||
display.draw_line(arrow_a, arrow_b, color);
|
||||
display.draw_line(arrow_b, arrow_c, color);
|
||||
|
||||
Executable → Regular
+1
@@ -23,6 +23,7 @@ import struct
|
||||
|
||||
outfile = open("airlines.db", "w")
|
||||
|
||||
# Download airlines.txt from http://xdeco.org/?page_id=30
|
||||
lines = [line.rstrip('\n') for line in open('../../sdcard/ADSB/airlines.txt', 'r')]
|
||||
n = 0
|
||||
|
||||
Executable → Regular
+10
-4
@@ -23,11 +23,11 @@ import sys
|
||||
import struct
|
||||
from PIL import Image
|
||||
|
||||
outfile = open('../../sdcard/world_map.bin', 'wb')
|
||||
|
||||
# Allow for bigger images
|
||||
Image.MAX_IMAGE_PIXELS = None
|
||||
|
||||
outfile = open('../../sdcard/ADSB/world_map.bin', 'wb')
|
||||
|
||||
im = Image.open("../../sdcard/ADSB/world_map.jpg")
|
||||
im = Image.open("../../sdcard/world_map.jpg")
|
||||
pix = im.load()
|
||||
|
||||
outfile.write(struct.pack('H', im.size[0]))
|
||||
@@ -36,9 +36,15 @@ outfile.write(struct.pack('H', im.size[1]))
|
||||
for y in range (0, im.size[1]):
|
||||
line = ''
|
||||
for x in range (0, im.size[0]):
|
||||
# RRRRRGGGGGGBBBBB
|
||||
pixel_lcd = (pix[x, y][0] >> 3) << 11
|
||||
pixel_lcd |= (pix[x, y][1] >> 2) << 5
|
||||
pixel_lcd |= (pix[x, y][2] >> 3)
|
||||
# RRRGGGBB to
|
||||
# RRR00GGG000BB000
|
||||
# pixel_lcd = (pix[x, y][0] >> 5) << 5
|
||||
# pixel_lcd |= (pix[x, y][1] >> 5) << 2
|
||||
# pixel_lcd |= (pix[x, y][2] >> 6)
|
||||
line += struct.pack('H', pixel_lcd)
|
||||
outfile.write(line)
|
||||
print(str(y) + '/' + str(im.size[1]) + '\r', end="")
|
||||
@@ -1,48 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
# Copyright (C) 2017 Furrtek
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2, or (at your option)
|
||||
# any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; see the file COPYING. If not, write to
|
||||
# the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
# Boston, MA 02110-1301, USA.
|
||||
#
|
||||
|
||||
from __future__ import print_function
|
||||
import sys
|
||||
import struct
|
||||
from PIL import Image
|
||||
|
||||
outfile = open('../../sdcard/world_map.bin', 'wb')
|
||||
|
||||
im = Image.open("../../sdcard/world_map.jpg")
|
||||
pix = im.load()
|
||||
|
||||
outfile.write(struct.pack('H', im.size[0]))
|
||||
outfile.write(struct.pack('H', im.size[1]))
|
||||
|
||||
for y in range (0, im.size[1]):
|
||||
line = ''
|
||||
for x in range (0, im.size[0]):
|
||||
# RRRRRGGGGGGBBBBB
|
||||
#pixel_lcd = (pix[x, y][0] >> 3) << 11
|
||||
#pixel_lcd |= (pix[x, y][1] >> 2) << 5
|
||||
#pixel_lcd |= (pix[x, y][2] >> 3)
|
||||
# RRRGGGBB to
|
||||
# RRR00GGG000BB000
|
||||
pixel_lcd = (pix[x, y][0] >> 5) << 5
|
||||
pixel_lcd |= (pix[x, y][1] >> 5) << 2
|
||||
pixel_lcd |= (pix[x, y][2] >> 6)
|
||||
line += struct.pack('B', pixel_lcd)
|
||||
outfile.write(line)
|
||||
print(str(y) + '/' + str(im.size[1]) + '\r', end="")
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 28 MiB After Width: | Height: | Size: 90 MiB |
Reference in New Issue
Block a user