Skip to content

Commit

Permalink
chore: renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Julusian committed Jul 16, 2024
1 parent 3b48d32 commit 13ac55d
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
30 changes: 15 additions & 15 deletions packages/core/src/models/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import type {
StreamDeck,
StreamDeckEvents,
} from '../types'
import type { ButtonsLcdService } from '../services/buttonsLcd'
import type { ButtonsLcdDisplayService } from '../services/buttonsLcdDisplay'
import type { StreamDeckButtonControlDefinition, StreamDeckControlDefinition } from '../controlDefinition'
import type { LcdStripService } from '../services/lcdStrip'
import type { LcdStripDisplayService } from '../services/lcdStripDisplay'

export type EncodeJPEGHelper = (buffer: Buffer, width: number, height: number) => Promise<Buffer>

Expand Down Expand Up @@ -72,24 +72,24 @@ export abstract class StreamDeckBase extends EventEmitter<StreamDeckEvents> impl

protected readonly device: HIDDevice
protected readonly deviceProperties: Readonly<StreamDeckProperties>
private readonly buttonsLcdService: ButtonsLcdService
private readonly lcdStripService: LcdStripService | null
private readonly buttonsLcdService: ButtonsLcdDisplayService
private readonly lcdStripDisplayService: LcdStripDisplayService | null
// private readonly options: Readonly<OpenStreamDeckOptions>
private readonly keyState: boolean[]

constructor(
device: HIDDevice,
_options: OpenStreamDeckOptions,
properties: StreamDeckProperties,
buttonsLcdService: ButtonsLcdService,
lcdStripService: LcdStripService | null
buttonsLcdService: ButtonsLcdDisplayService,
lcdStripDisplayService: LcdStripDisplayService | null
) {
super()

this.deviceProperties = properties
this.device = device
this.buttonsLcdService = buttonsLcdService
this.lcdStripService = lcdStripService
this.lcdStripDisplayService = lcdStripDisplayService

const maxButtonIndex = properties.CONTROLS.filter(
(control): control is StreamDeckButtonControlDefinition => control.type === 'button'
Expand Down Expand Up @@ -186,20 +186,20 @@ export abstract class StreamDeckBase extends EventEmitter<StreamDeckEvents> impl

ps.push(this.buttonsLcdService.clearPanel())

if (this.lcdStripService) {
if (this.lcdStripDisplayService) {
for (const control of this.deviceProperties.CONTROLS) {
if (control.type !== 'lcd-strip') continue
ps.push(this.lcdStripService.clearLcdStrip(control.id))
ps.push(this.lcdStripDisplayService.clearLcdStrip(control.id))
}
}

await Promise.all(ps)
}

public async fillLcd(...args: Parameters<StreamDeck['fillLcd']>): ReturnType<StreamDeck['fillLcd']> {
if (!this.lcdStripService) throw new Error('Not supported for this model')
if (!this.lcdStripDisplayService) throw new Error('Not supported for this model')

return this.lcdStripService.fillLcd(...args)
return this.lcdStripDisplayService.fillLcd(...args)
}

// public async fillEncoderLcd(
Expand All @@ -211,16 +211,16 @@ export abstract class StreamDeckBase extends EventEmitter<StreamDeckEvents> impl
public async fillLcdRegion(
...args: Parameters<StreamDeck['fillLcdRegion']>
): ReturnType<StreamDeck['fillLcdRegion']> {
if (!this.lcdStripService) throw new Error('Not supported for this model')
if (!this.lcdStripDisplayService) throw new Error('Not supported for this model')

return this.lcdStripService.fillLcdRegion(...args)
return this.lcdStripDisplayService.fillLcdRegion(...args)
}

public async clearLcdStrip(
...args: Parameters<StreamDeck['clearLcdStrip']>
): ReturnType<StreamDeck['clearLcdStrip']> {
if (!this.lcdStripService) throw new Error('Not supported for this model')
if (!this.lcdStripDisplayService) throw new Error('Not supported for this model')

return this.lcdStripService.clearLcdStrip(...args)
return this.lcdStripDisplayService.clearLcdStrip(...args)
}
}
2 changes: 1 addition & 1 deletion packages/core/src/models/generic-gen1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { HIDDevice } from '../hid-device'
import { OpenStreamDeckOptions, StreamDeckBase, StreamDeckProperties } from './base'
import { StreamdeckImageWriter } from '../services/imageWriter/types'
import { BMP_HEADER_LENGTH, FillImageTargetOptions, transformImageBuffer, writeBMPHeader } from '../util'
import { ButtonLcdImagePacker, DefaultButtonsLcdService, InternalFillImageOptions } from '../services/buttonsLcd'
import { ButtonLcdImagePacker, DefaultButtonsLcdService, InternalFillImageOptions } from '../services/buttonsLcdDisplay'

function extendDevicePropertiesForGen1(rawProps: StreamDeckGen1Properties): StreamDeckProperties {
return {
Expand Down
16 changes: 8 additions & 8 deletions packages/core/src/models/generic-gen2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { transformImageBuffer } from '../util'
import { EncodeJPEGHelper, OpenStreamDeckOptions, StreamDeckBase, StreamDeckProperties } from './base'
import { StreamdeckDefaultImageWriter } from '../services/imageWriter/imageWriter'
import { StreamdeckGen2ImageHeaderGenerator } from '../services/imageWriter/headerGenerator'
import { EncoderInputService } from '../services/encoder'
import { ButtonLcdImagePacker, DefaultButtonsLcdService, InternalFillImageOptions } from '../services/buttonsLcd'
import { LcdInputService } from '../services/lcdInputService'
import { LcdStripService } from '../services/lcdStrip'
import { EncoderInputService } from '../services/encoderInput'
import { ButtonLcdImagePacker, DefaultButtonsLcdService, InternalFillImageOptions } from '../services/buttonsLcdDisplay'
import { LcdStripInputService } from '../services/lcdStripInput'
import { LcdStripDisplayService } from '../services/lcdStripDisplay'

function extendDevicePropertiesForGen2(rawProps: StreamDeckGen2Properties): StreamDeckProperties {
return {
Expand All @@ -22,15 +22,15 @@ export type StreamDeckGen2Properties = Omit<StreamDeckProperties, 'KEY_DATA_OFFS
* Class for generation 2 hardware (starting with the xl)
*/
export class StreamDeckGen2 extends StreamDeckBase {
readonly #lcdStripInputService: LcdInputService | null
readonly #lcdStripInputService: LcdStripInputService | null
protected readonly encoderService: EncoderInputService

constructor(
device: HIDDevice,
options: Required<OpenStreamDeckOptions>,
properties: StreamDeckGen2Properties,
lcdStripService: LcdStripService | null,
lcdStripInputService: LcdInputService | null,
lcdStripDisplayService: LcdStripDisplayService | null,
lcdStripInputService: LcdStripInputService | null,
disableXYFlip?: boolean
) {
const fullProperties = extendDevicePropertiesForGen2(properties)
Expand All @@ -50,7 +50,7 @@ export class StreamDeckGen2 extends StreamDeckBase {
device,
fullProperties
),
lcdStripService
lcdStripDisplayService
)

this.#lcdStripInputService = lcdStripInputService
Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/models/neo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import { StreamdeckDefaultImageWriter } from '../services/imageWriter/imageWrite
import { StreamdeckNeoLcdImageHeaderGenerator } from '../services/imageWriter/headerGenerator'
import { FillImageOptions, FillLcdImageOptions } from '../types'
import { transformImageBuffer } from '../util'
import { InternalFillImageOptions } from '../services/buttonsLcd'
import { InternalFillImageOptions } from '../services/buttonsLcdDisplay'
import { freezeDefinitions, generateButtonsGrid } from '../controlsGenerator'
import { StreamDeckControlDefinition, StreamDeckLcdStripControlDefinition } from '../controlDefinition'
import { LcdStripService } from '../services/lcdStrip'
import { LcdStripDisplayService } from '../services/lcdStripDisplay'

const neoControls: StreamDeckControlDefinition[] = generateButtonsGrid(4, 2)
neoControls.push(
Expand Down Expand Up @@ -69,7 +69,7 @@ export function StreamDeckNeoFactory(device: HIDDevice, options: Required<OpenSt
)
}

class StreamDeckNeoLcdService implements LcdStripService {
class StreamDeckNeoLcdService implements LcdStripDisplayService {
readonly #encodeJPEG: EncodeJPEGHelper
readonly #device: HIDDevice
readonly #lcdControls: Readonly<StreamDeckLcdStripControlDefinition[]>
Expand Down
4 changes: 2 additions & 2 deletions packages/core/src/models/pedal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { DeviceModelId, Dimension } from '../id'
import { FillImageOptions, FillPanelDimensionsOptions, FillPanelOptions } from '../types'
import { StreamDeckControlDefinition } from '../controlDefinition'
import { freezeDefinitions } from '../controlsGenerator'
import type { ButtonsLcdService } from '../services/buttonsLcd'
import type { ButtonsLcdDisplayService } from '../services/buttonsLcdDisplay'

const pedalControls: StreamDeckControlDefinition[] = [
{
Expand Down Expand Up @@ -77,7 +77,7 @@ class StreamDeckPedal extends StreamDeckBase {
}
}

class PedalLcdService implements ButtonsLcdService {
class PedalLcdService implements ButtonsLcdDisplayService {
public calculateFillPanelDimensions(_options?: FillPanelDimensionsOptions): Dimension | null {
// Not supported
return null
Expand Down
10 changes: 5 additions & 5 deletions packages/core/src/models/plus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import { StreamDeckGen2, StreamDeckGen2Properties } from './generic-gen2'
import { DeviceModelId } from '../id'
import { StreamdeckDefaultImageWriter } from '../services/imageWriter/imageWriter'
import { StreamdeckPlusLcdImageHeaderGenerator } from '../services/imageWriter/headerGenerator'
import { InternalFillImageOptions } from '../services/buttonsLcd'
import { InternalFillImageOptions } from '../services/buttonsLcdDisplay'
import { freezeDefinitions, generateButtonsGrid } from '../controlsGenerator'
import { StreamDeckControlDefinition, StreamDeckLcdStripControlDefinition } from '../controlDefinition'
import { LcdInputService } from '../services/lcdInputService'
import { LcdStripService } from '../services/lcdStrip'
import { LcdStripInputService } from '../services/lcdStripInput'
import { LcdStripDisplayService } from '../services/lcdStripDisplay'

const plusControls: StreamDeckControlDefinition[] = generateButtonsGrid(4, 2)
plusControls.push(
Expand Down Expand Up @@ -79,7 +79,7 @@ class StreamDeckPlus extends StreamDeckGen2 {
options,
plusProperties,
new StreamDeckPlusLcdService(options.encodeJPEG, device, lcdStripControls),
new LcdInputService(lcdStripControls, (key, ...args) => this.emit(key, ...args)),
new LcdStripInputService(lcdStripControls, (key, ...args) => this.emit(key, ...args)),
true
)
}
Expand All @@ -90,7 +90,7 @@ export function StreamDeckPlusFactory(device: HIDDevice, options: Required<OpenS
return new StreamDeckPlus(device, options)
}

class StreamDeckPlusLcdService implements LcdStripService {
class StreamDeckPlusLcdService implements LcdStripDisplayService {
readonly #encodeJPEG: EncodeJPEGHelper
readonly #device: HIDDevice
readonly #lcdControls: Readonly<StreamDeckLcdStripControlDefinition[]>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface GridSpan {
maxCol: number
}

export interface ButtonsLcdService {
export interface ButtonsLcdDisplayService {
calculateFillPanelDimensions(options: FillPanelDimensionsOptions | undefined): Dimension | null

clearPanel(): Promise<void>
Expand All @@ -35,7 +35,7 @@ export interface ButtonsLcdService {
fillPanelBuffer(imageBuffer: Buffer, options: FillPanelOptions | undefined): Promise<void>
}

export class DefaultButtonsLcdService implements ButtonsLcdService {
export class DefaultButtonsLcdService implements ButtonsLcdDisplayService {
readonly #imageWriter: StreamdeckImageWriter
readonly #imagePacker: ButtonLcdImagePacker
readonly #device: HIDDevice
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FillImageOptions, FillLcdImageOptions } from '../types'

export interface LcdStripService {
export interface LcdStripDisplayService {
/**
* Fill the whole lcd strip
* @param {number} lcdIndex The id of the lcd strip to draw to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { LcdPosition } from '../types'
import { StreamDeckLcdStripControlDefinition } from '../controlDefinition'
import { SomeEmitEventFn } from '../models/plus'

export class LcdInputService {
export class LcdStripInputService {
readonly #lcdStripControls: Readonly<StreamDeckLcdStripControlDefinition[]>
readonly #emitEvent: SomeEmitEventFn

Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { InternalFillImageOptions } from './services/buttonsLcd'
import type { InternalFillImageOptions } from './services/buttonsLcdDisplay'

export interface FillImageTargetOptions {
colorMode: 'bgr' | 'rgba'
Expand Down

0 comments on commit 13ac55d

Please sign in to comment.