Skip to content

Commit

Permalink
fix(control schemes): fix profile add/dec default timing
Browse files Browse the repository at this point in the history
  • Loading branch information
nvsukhanov committed Aug 31, 2023
1 parent 4211162 commit 21aa282
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChangeDetectionStrategy, Component, Inject, OnDestroy, OnInit } from '@angular/core';
import { ChangeDetectionStrategy, Component, OnDestroy, OnInit } from '@angular/core';
import { Store } from '@ngrx/store';
import { JsonPipe, NgIf } from '@angular/common';
import { PushPipe } from '@ngrx/component';
Expand All @@ -9,8 +9,8 @@ import { MatInputModule } from '@angular/material/input';
import { TranslocoModule } from '@ngneat/transloco';
import { MatButtonModule } from '@angular/material/button';
import { Router } from '@angular/router';
import { APP_CONFIG, HintComponent, IAppConfig } from '@app/shared';
import { CONTROL_SCHEME_ACTIONS } from '@app/store';
import { HintComponent } from '@app/shared';
import { CONTROL_SCHEME_ACTIONS, DEFAULT_ACC_DEC_PROFILE_TIME_MS } from '@app/store';

import { PORT_CONFIG_EDIT_PAGE_SELECTORS } from './port-config-edit-page.selectors';
import { RoutesBuilderService } from '../../routing';
Expand Down Expand Up @@ -38,11 +38,11 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy {

public readonly minAccDecProfileTimeMs = 0;

public readonly maxAccDecProfileTimeMs = this.config.maxAccDecProfileTimeMs;
public readonly maxAccDecProfileTimeMs = 10000;

public readonly formGroup = this.formBuilder.group({
accelerationTimeMs: this.formBuilder.control<number>(
this.config.defaultAccDecProfileTimeMs,
DEFAULT_ACC_DEC_PROFILE_TIME_MS,
{
nonNullable: true,
validators: [
Expand All @@ -53,7 +53,7 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy {
}
),
decelerationTimeMs: this.formBuilder.control<number>(
this.config.defaultAccDecProfileTimeMs,
DEFAULT_ACC_DEC_PROFILE_TIME_MS,
{
nonNullable: true,
validators: [
Expand All @@ -70,7 +70,6 @@ export class PortConfigEditPageComponent implements OnInit, OnDestroy {
constructor(
private readonly store: Store,
private readonly formBuilder: FormBuilder,
@Inject(APP_CONFIG) private readonly config: IAppConfig,
private readonly routesBuilder: RoutesBuilderService,
private readonly router: Router
) {
Expand Down
4 changes: 0 additions & 4 deletions src/app/shared/i-app-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ export interface IAppConfig {
readonly hubBatteryPollInterval: number;
readonly hubRssiPollInterval: number;
readonly logLevel: LogLevel;
readonly defaultAccDecProfileTimeMs: number;
readonly maxAccDecProfileTimeMs: number;
}

export const APP_CONFIG = new InjectionToken<IAppConfig>('APP_CONFIG', {
Expand All @@ -18,8 +16,6 @@ export const APP_CONFIG = new InjectionToken<IAppConfig>('APP_CONFIG', {
hubBatteryPollInterval: 20000,
hubRssiPollInterval: 10000,
logLevel: isDevMode() ? LogLevel.Debug : LogLevel.Warning,
defaultAccDecProfileTimeMs: 100,
maxAccDecProfileTimeMs: 10000,
}),
providedIn: 'root'
});
10 changes: 4 additions & 6 deletions src/app/store/reducers/control-scheme.reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,14 @@ import { ControlSchemeBinding, ControlSchemeModel, ControlSchemePortConfig } fro
import { CONTROL_SCHEME_ACTIONS } from '../actions';
import { attachedIosIdFn } from './attached-ios.reducer';

const DEFAULT_ACCELERATION_PROFILE_TIME_MS = 1000;

const DEFAULT_DECELERATION_PROFILE_TIME_MS = 1000;

function createDefaultPortConfig(
{ hubId, portId }: { hubId: string; portId: number },
): ControlSchemePortConfig {
return {
hubId,
portId,
accelerationTimeMs: DEFAULT_ACCELERATION_PROFILE_TIME_MS,
decelerationTimeMs: DEFAULT_DECELERATION_PROFILE_TIME_MS,
accelerationTimeMs: DEFAULT_ACC_DEC_PROFILE_TIME_MS,
decelerationTimeMs: DEFAULT_ACC_DEC_PROFILE_TIME_MS,
};
}

Expand Down Expand Up @@ -46,6 +42,8 @@ function ensurePortConfigsAreUpToDate(
return portConfigs;
}

export const DEFAULT_ACC_DEC_PROFILE_TIME_MS = 100;

export enum ControlSchemeRunState {
Idle,
Starting,
Expand Down

0 comments on commit 21aa282

Please sign in to comment.