Skip to content

Commit

Permalink
feat: timer negative variable (#57)
Browse files Browse the repository at this point in the history
* feat: timer negative variable

* bump to v4.0.2 and rename artifact on build

* rename to `time_sign`

* Update variables.ts name
  • Loading branch information
alex-Arc authored May 21, 2024
1 parent 9a31a84 commit 74a03ef
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ jobs:
uses: actions/upload-artifact@v4
with:
path: './pkg'
name: 'getontime-ontime'
2 changes: 1 addition & 1 deletion companion/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "getontime-ontime",
"shortname": "ontime",
"description": "Companion module for ontime",
"version": "4.0.1",
"version": "4.0.2",
"license": "MIT",
"repository": "git+https://github.com/bitfocus/companion-module-getontime-ontime.git",
"bugs": "https://github.com/bitfocus/companion-module-getontime-ontime/issues",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "getontime-ontime",
"version": "4.0.1",
"version": "4.0.2",
"main": "/dist/index.js",
"license": "MIT",
"prettier": "@companion-module/tools/.prettierrc.json",
Expand Down
1 change: 1 addition & 0 deletions src/enums.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ export enum variableId {
TimeH = 'time_h',
TimeM = 'time_m',
TimeS = 'time_s',
TimeN = 'time_sign',

IdNow = 'idNow',
TitleNow = 'titleNow',
Expand Down
13 changes: 8 additions & 5 deletions src/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const defaultTimerObject = {
hoursMinutes: '--:--',
hoursMinutesSeconds: '--:--:--',
delayString: '0',
negative: '',
}

type SplitTime = typeof defaultTimerObject
Expand All @@ -35,19 +36,20 @@ export function msToSplitTime(time: number | null): SplitTime {

const seconds = padTo2Digits(s)
const minutes = padTo2Digits(m)
const hours = (negative ? '-' : '') + padTo2Digits(h)
const hours = padTo2Digits(h)
const negativeSign = negative ? '-' : ''

const hoursMinutes = `${hours}:${minutes}`
const hoursMinutesSeconds = `${hoursMinutes}:${seconds}`
const hoursMinutesSeconds = `${negativeSign}${hoursMinutes}:${seconds}`

let delayString = '00'

if (h && !m && !s) {
delayString = `${negative ? '-' : '+'}${h}h`
delayString = `${negativeSign}${h}h`
} else if (!h && m && !s) {
delayString = `${negative ? '-' : '+'}${m}m`
delayString = `${negativeSign}${m}m`
} else if (!h && !m && s) {
delayString = `${negative ? '-' : '+'}${s}s`
delayString = `${negativeSign}${s}s`
}

return {
Expand All @@ -57,6 +59,7 @@ export function msToSplitTime(time: number | null): SplitTime {
hoursMinutes,
hoursMinutesSeconds,
delayString,
negative: negativeSign,
}
}

Expand Down
1 change: 1 addition & 0 deletions src/v3/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ export function connect(self: OnTimeInstance, ontime: OntimeV3): void {
ontime.state.companionSpecific.timerZone = timerZone
self.setVariableValues({
[variableId.TimerTotalMs]: val.current ?? 0,
[variableId.TimeN]: timer.negative,
[variableId.Time]: timer.hoursMinutesSeconds,
[variableId.TimeHM]: timer.hoursMinutes,
[variableId.TimeH]: timer.hours,
Expand Down
4 changes: 4 additions & 0 deletions src/v3/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ export function variables(): CompanionVariableDefinition[] {
name: 'Current event state Seconds',
variableId: variableId.TimeS,
},
{
name: 'Current event timer Sign',
variableId: variableId.TimeN,
},
//timer.duration
//timer.elapsed
//timer.expectedFinish
Expand Down

0 comments on commit 74a03ef

Please sign in to comment.