This commit is contained in:
Zakary Timson 2019-07-11 18:54:44 -04:00
parent 3153d94c3d
commit 187d937958
3 changed files with 16 additions and 9 deletions

View File

@ -1,9 +1,18 @@
<div> <div>
<div> <div class="row">
<mat-form-field appearance="fill"> <div class="col-5 pr-0">
<mat-label>Calibrate</mat-label> <mat-form-field appearance="fill" class="w-100">
<input matInput type="number" min="-180" max="180" [(ngModel)]="calibration"> <mat-label>Shift +/-</mat-label>
</mat-form-field> <input matInput type="number" min="-180" max="180" [(ngModel)]="calibration">
</mat-form-field>
</div>
<div class="col-2 text-center"><h1> = </h1></div>
<div class="col-5 pl-0">
<mat-form-field appearance="fill" class="w-100">
<mat-label>Heading</mat-label>
<input matInput type="number" [ngModel]="(physicsService.info | async)?.heading" readonly>
</mat-form-field>
</div>
</div> </div>
<div> <div>
<mat-slider class="w-100" [max]="180" [min]="-180" [step]="1" [tickInterval]="90" [thumbLabel]="true" [(ngModel)]="calibration" (input)="calibration = $event.value"></mat-slider> <mat-slider class="w-100" [max]="180" [min]="-180" [step]="1" [tickInterval]="90" [thumbLabel]="true" [(ngModel)]="calibration" (input)="calibration = $event.value"></mat-slider>

View File

@ -25,9 +25,9 @@ export class CalibrateComponent {
setN() { setN() {
let currentHeading = this.physicsService.orientation.value.alpha; let currentHeading = this.physicsService.orientation.value.alpha;
if(currentHeading <= 180) { if(currentHeading <= 180) {
this.calibration = -currentHeading; this.calibration = 360 - Math.round(currentHeading);
} else { } else {
this.calibration = 360 - currentHeading; this.calibration = -Math.round(currentHeading);
} }
} }
} }

View File

@ -64,8 +64,6 @@ export class PhysicsService {
} }
info.heading = -data[1].alpha + (data[2] == Infinity ? 0 : data[2]); info.heading = -data[1].alpha + (data[2] == Infinity ? 0 : data[2]);
if(info.heading > 360) info.heading -= 360;
if(info.heading < 0) info.heading += 360;
} }
if(info.speed == null && !!data[3]) info.speed = Math.sqrt(data[3].x**2 + data[3].y**2 + data[3].z**2); if(info.speed == null && !!data[3]) info.speed = Math.sqrt(data[3].x**2 + data[3].y**2 + data[3].z**2);