Merge branch 'antirez:master' into master

This commit is contained in:
bdejean 2022-08-21 19:21:09 +02:00 committed by GitHub
commit 17416856d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 84 additions and 42 deletions

View File

@ -158,6 +158,7 @@ struct {
/* Configuration */
char *filename; /* Input form file, --ifile option. */
int loop; /* Read input file again and again. */
int fix_errors; /* Single bit error correction if true. */
int check_crc; /* Only display messages with good CRC. */
int raw; /* Raw output format. */
@ -277,6 +278,7 @@ void modesInitConfig(void) {
Modes.interactive_ttl = MODES_INTERACTIVE_TTL;
Modes.aggressive = 0;
Modes.interactive_rows = getTermRows();
Modes.loop = 0;
}
void modesInit(void) {
@ -436,6 +438,16 @@ void readDataFromFile(void) {
p = Modes.data+(MODES_FULL_LEN-1)*4;
while(toread) {
nread = read(Modes.fd, p, toread);
/* In --file mode, seek the file again from the start
* and re-play it if --loop was given. */
if (nread == 0 &&
Modes.filename != NULL &&
Modes.fd != STDIN_FILENO &&
Modes.loop)
{
if (lseek(Modes.fd,0,SEEK_SET) != -1) continue;
}
if (nread <= 0) {
Modes.exit = 1; /* Signal the other thread to exit. */
break;
@ -493,10 +505,18 @@ void dumpMagnitudeBar(int index, int magnitude) {
buf[div] = set[rem];
buf[div+1] = '\0';
if (index >= 0)
printf("[%.3d] |%-66s %d\n", index, buf, magnitude);
else
if (index >= 0) {
int markchar = ']';
/* preamble peaks are marked with ">" */
if (index == 0 || index == 2 || index == 7 || index == 9)
markchar = '>';
/* Data peaks are marked to distinguish pairs of bits. */
if (index >= 16) markchar = ((index-16)/2 & 1) ? '|' : ')';
printf("[%.3d%c |%-66s %d\n", index, markchar, buf, magnitude);
} else {
printf("[%.2d] |%-66s %d\n", index, buf, magnitude);
}
}
/* Display an ASCII-art alike graphical representation of the undecoded
@ -2413,6 +2433,7 @@ void showHelp(void) {
"--enable-agc Enable the Automatic Gain Control (default: off).\n"
"--freq <hz> Set frequency (default: 1090 Mhz).\n"
"--ifile <filename> Read data from file (use '-' for stdin).\n"
"--loop With --ifile, read the same file in a loop.\n"
"--interactive Interactive mode refreshing data on screen.\n"
"--interactive-rows <num> Max number of rows in interactive mode (default: 15).\n"
"--interactive-ttl <sec> Remove from list if idle for <sec> (default: 60).\n"
@ -2484,6 +2505,8 @@ int main(int argc, char **argv) {
Modes.freq = strtoll(argv[++j],NULL,10);
} else if (!strcmp(argv[j],"--ifile") && more) {
Modes.filename = strdup(argv[++j]);
} else if (!strcmp(argv[j],"--loop")) {
Modes.loop = 1;
} else if (!strcmp(argv[j],"--no-fix")) {
Modes.fix_errors = 0;
} else if (!strcmp(argv[j],"--no-crc-check")) {

View File

@ -3,9 +3,14 @@
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ==" crossorigin=""/>
<style type="text/css">
html { height: 100% }
body { height: 100%; margin: 0; padding: 0 }
.plane-icon {
padding:0px;
margin:0px;
}
#map_canvas { height: 100% }
#info {
position: absolute;
@ -32,11 +37,8 @@
color:#333;
}
</style>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">
</script>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?sensor=true">
</script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" integrity="sha512-gZwIG9x3wUXg2hdXF6+rVkLF/0Vi9U8D2Ntg4Ga5I5BZpVkVxlJWbSQtXPSiUTtC0TjtGOmxa1AJPuV0CPthew==" crossorigin=""></script>
<script type="text/javascript">
Map=null;
CenterLat=45.0;
@ -53,20 +55,31 @@
if (invalt < 0) invalt = 0;
b = parseInt(255/maxalt*invalt);
return {
strokeWeight: (selected ? 2 : 1),
path: google.maps.SymbolPath.FORWARD_CLOSED_ARROW,
scale: 5,
fillColor: 'rgb('+r+','+g+','+b+')',
fillOpacity: 0.9,
rotation: plane.track
};
/* As Icon we use the plane emoji, this is a simple solution but
is definitely a compromise: we expect the icon to be rotated
45 degrees facing north-east by default, this is true in most
systems but not all. */
var he = document.createElement("P");
he.innerHTML = '>';
var rotation = 45+360-plane.track;
var selhtml = '';
/* Give a border to the selected plane. */
if (Selected == plane.hex) {
selhtml = 'border:1px dotted #0000aa; border-radius:10px;';
} else {
selhtml = '';
}
he = '<div style="transform: rotate(-'+rotation+'deg); '+selhtml+'">✈️</div>';
var icon = L.divIcon({html: he, className: 'plane-icon'});
return icon;
}
function selectPlane() {
if (!Planes[this.planehex]) return;
function selectPlane(planehex) {
if (!Planes[planehex]) return;
var old = Selected;
Selected = this.planehex;
Selected = planehex;
if (Planes[old]) {
/* Remove the highlight in the previously selected plane. */
Planes[old].marker.setIcon(getIconForPlane(Planes[old]));
@ -74,6 +87,14 @@
Planes[Selected].marker.setIcon(getIconForPlane(Planes[Selected]));
refreshSelectedInfo();
}
/* Return a closure to caputure the 'hex' argument. This way we don't
have to care about how Leaflet passes the object to the callback. */
function selectPlaneCallback(hex) {
return function() {
return selectPlane(hex);
}
}
function refreshGeneralInfo() {
var i = document.getElementById('geninfo');
@ -108,9 +129,7 @@
if (Planes[plane.hex]) {
var myplane = Planes[plane.hex];
marker = myplane.marker;
var icon = marker.getIcon();
var newpos = new google.maps.LatLng(plane.lat, plane.lon);
marker.setPosition(newpos);
marker.setLatLng([plane.lat,plane.lon]);
marker.setIcon(getIconForPlane(plane));
myplane.altitude = plane.altitude;
myplane.speed = plane.speed;
@ -121,29 +140,27 @@
if (myplane.hex == Selected)
refreshSelectedInfo();
} else {
marker = new google.maps.Marker({
position: new google.maps.LatLng(plane.lat, plane.lon),
map: Map,
icon: getIconForPlane(plane)
});
var icon = getIconForPlane(plane);
var marker = L.marker([plane.lat, plane.lon], {icon: icon}).addTo(Map);
var hex = plane.hex;
marker.on('click',selectPlaneCallback(plane.hex));
plane.marker = marker;
marker.planehex = plane.hex;
Planes[plane.hex] = plane;
/* Trap clicks for this marker. */
google.maps.event.addListener(marker, 'click', selectPlane);
}
if (plane.flight.length == 0)
marker.setTitle(plane.hex)
else
marker.setTitle(plane.flight+' ('+plane.hex+')')
// FIXME: Set the title
// if (plane.flight.length == 0)
// marker.setTitle(plane.hex)
// else
// marker.setTitle(plane.flight+' ('+plane.hex+')')
}
NumPlanes = data.length;
/* Remove idle planes. */
for (var p in Planes) {
if (!stillhere[p]) {
Planes[p].marker.setMap(null);
Map.removeLayer(Planes[p].marker);
delete Planes[p];
}
}
@ -151,18 +168,20 @@
}
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(CenterLat, CenterLon),
zoom: 5,
mapTypeId: google.maps.MapTypeId.ROADMAP
};
Map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
Map = L.map('map_canvas').setView([37.0, 13.0], 8);
L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data &copy; <a href="https://www.openstreetmap.org/">OpenStreetMap</a> contributors, <a href="https://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>, Imagery © <a href="https://www.mapbox.com/">Mapbox</a>',
maxZoom: 18,
id: 'mapbox/streets-v11',
accessToken: 'your.mapbox.access.token'
}).addTo(Map);
/* Setup our timer to poll from the server. */
window.setInterval(function() {
fetchData();
refreshGeneralInfo();
}, 1000);
}, 100);
}
</script>