feat: Add serial compass support #0

This commit is contained in:
Janez T
2026-03-19 21:38:54 +01:00
parent 5a58e45e13
commit 721fb7e7a2
26 changed files with 1014 additions and 217 deletions

View File

@@ -0,0 +1,36 @@
import 'dart:math';
import 'package:flutter_test/flutter_test.dart';
import 'package:meshcore_sar_app/widgets/map/compass/compass_math.dart';
void main() {
group('compass dial math', () {
test('rotates the rose opposite the heading', () {
expect(compassRoseRotationRadians(0), closeTo(0, 1e-10));
expect(compassRoseRotationRadians(90), closeTo(-pi / 2, 1e-10));
expect(compassRoseRotationRadians(450), closeTo(-pi / 2, 1e-10));
});
test('places east at the top when heading east', () {
expect(
compassDialAngleRadians(markerDegrees: 90, headingDegrees: 90),
closeTo(-pi / 2, 1e-10),
);
expect(
compassDialAngleRadians(markerDegrees: 270, headingDegrees: 90),
closeTo(pi / 2, 1e-10),
);
});
test('places west at the top when heading west', () {
expect(
compassDialAngleRadians(markerDegrees: 270, headingDegrees: 270),
closeTo(-pi / 2, 1e-10),
);
expect(
compassDialAngleRadians(markerDegrees: 90, headingDegrees: 270),
closeTo(pi / 2, 1e-10),
);
});
});
}