Skip to content

Commit

Permalink
Various fixes for CCT & Brightness control
Browse files Browse the repository at this point in the history
  • Loading branch information
Raphiiko committed Jul 5, 2024
1 parent b30d452 commit 1b6760b
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, DestroyRef, OnInit } from '@angular/core';
import { fadeUp, vshrink } from '../../utils/animations';
import { fadeUp, hshrink, vshrink } from '../../utils/animations';
import { BaseModalComponent } from '../base-modal/base-modal.component';
import { ModalOptions } from '../../services/modal.service';
import { HardwareBrightnessControlService } from '../../services/brightness-control/hardware-brightness-control.service';
Expand All @@ -14,7 +14,7 @@ import { Router } from '@angular/router';
selector: 'app-brightness-control-modal',
templateUrl: './brightness-control-modal.component.html',
styleUrls: ['./brightness-control-modal.component.scss'],
animations: [fadeUp(), vshrink()],
animations: [fadeUp(), vshrink(), hshrink()],
})
export class BrightnessControlModalComponent
extends BaseModalComponent<void, void>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, DestroyRef, OnInit } from '@angular/core';
import { fadeUp, vshrink } from '../../utils/animations';
import { fadeUp, hshrink, vshrink } from '../../utils/animations';
import { BaseModalComponent } from '../base-modal/base-modal.component';
import { ModalOptions } from '../../services/modal.service';
import { AutomationConfigService } from '../../services/automation-config.service';
Expand All @@ -12,7 +12,7 @@ import { BigscreenBeyondFanAutomationService } from '../../services/hmd-specific
selector: 'app-bsb-fan-speed-control-modal',
templateUrl: './bsb-fan-speed-control-modal.component.html',
styleUrls: ['./bsb-fan-speed-control-modal.component.scss'],
animations: [fadeUp(), vshrink()],
animations: [fadeUp(), vshrink(), hshrink()],
})
export class BSBFanSpeedControlModalComponent
extends BaseModalComponent<void, void>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import 'effects';
@import '@fontsource/fira-code/index.css';

$decoration-top: 1em;
$background-color: var(--color-surface-2);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
@import '@fontsource/fira-code/index.css';

.modal-inner-wrapper {
margin-top: 16px;
Expand Down
28 changes: 20 additions & 8 deletions src-ui/app/services/cct-control/cct-control.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject, combineLatest, distinctUntilChanged, Observable } from 'rxjs';
import {
BehaviorSubject,
combineLatest,
debounceTime,
distinctUntilChanged,
Observable,
} from 'rxjs';
import { CCTTransitionTask } from './cct-transition';
import { listen } from '@tauri-apps/api/event';
import {
Expand Down Expand Up @@ -39,14 +45,20 @@ export class CCTControlService {
this.cctControlEnabled = settings.cctControlEnabled;
if (!this.initialized) {
this.setCCT(this.cct);
combineLatest([this.openvr.status, this.openvr.devices]).subscribe(([status, devices]) => {
const ready = status === 'INITIALIZED' && !!devices.length && devices[0]?.class === 'HMD';
if (ready && !this.hardwareReady) {
combineLatest([this.openvr.status, this.openvr.devices])
.pipe(debounceTime(100))
.subscribe(([status, devices]) => {
const ready =
status === 'INITIALIZED' &&
!!devices.length &&
devices.find((d) => d.index === 0)?.class === 'HMD';
if (ready && !this.hardwareReady) {
console.log({ ready, hardwareReady: this.hardwareReady });
this.hardwareReady = ready;
this.setCCT(this.cct, SET_BRIGHTNESS_OR_CCT_OPTIONS_DEFAULTS, true);
}
this.hardwareReady = ready;
this.setCCT(this.cct, SET_BRIGHTNESS_OR_CCT_OPTIONS_DEFAULTS, true);
}
this.hardwareReady = ready;
});
});
}
this.initialized = true;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<div class="label" *ngIf="config">
<div class="colortemp-container" @hshrink *ngIf="config?.changeColorTemperature && cctControlEnabled">
<div class="colortemp-icon" [style.background-color]="getCSSColorForCCT(config.colorTemperature)"></div>
<span>{{ config.colorTemperature }} K</span>
<span class="monospace">{{ config.colorTemperature }}K</span>
</div>
<div class="brightness-container" *ngIf="config?.changeBrightness" @hshrink>
<div class="brightness-value" *ngIf="!advancedMode" @vshrink>
<span>{{ config.brightness }}%</span>
<span class="monospace">{{ config.brightness }}%</span>
<i class="material-icons">brightness_6</i>
</div>
<div class="brightness-value" *ngIf="advancedMode" @vshrink>
<span>{{ config.softwareBrightness }}%</span>
<span class="monospace">{{ config.softwareBrightness }}%</span>
<i class="material-symbols-outlined icon-filled">image</i>
</div>
<div class="brightness-value" *ngIf="advancedMode" @vshrink>
<span>{{ config.hardwareBrightness }}%</span>
<span class="monospace">{{ config.hardwareBrightness }}%</span>
<i class="material-symbols-outlined">monitor</i>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,7 @@
}
}
}

.monospace {
font-family: 'Fira Code', monospace !important;
}
2 changes: 2 additions & 0 deletions src-ui/styles/typography.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import '@fontsource/fira-code/index.css';

* {
font-family: 'Poppins', 'Noto Sans JP', 'Noto Sans KR', 'Noto Sans TC', 'Noto Sans SC', sans-serif;
letter-spacing: 0.025em;
Expand Down

0 comments on commit 1b6760b

Please sign in to comment.