Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(control schemes): fix profile add/dec default timing #239

Merged
merged 1 commit into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading