mirror of
https://gitlab1.ptb.de/waltem01/Matrix
synced 2024-12-25 11:31:46 +00:00
dynamically import optional env variables
This commit is contained in:
parent
fc8c2d292d
commit
04f905a841
@ -1,9 +1,4 @@
|
||||
import {
|
||||
PUBLIC_LED_CHAIN,
|
||||
PUBLIC_LED_HEIGHT,
|
||||
PUBLIC_LED_PARALLEL,
|
||||
PUBLIC_LED_WIDTH
|
||||
} from '$env/static/public';
|
||||
import * as env from '$env/static/public';
|
||||
|
||||
// Interface to represent the entire matrix data
|
||||
export interface Matrix {
|
||||
@ -27,16 +22,19 @@ export interface MatrixCell {
|
||||
}
|
||||
|
||||
// Initialize matrix object based on environment variables
|
||||
// These variables might appear to throw an error if they are not set
|
||||
// in the project-wide .env file. This is intentional. The optional-
|
||||
// chaining operator will catch these errors.
|
||||
export function initializeMatrix(): Matrix {
|
||||
const led_width = Number(PUBLIC_LED_WIDTH ?? '64');
|
||||
const led_height = Number(PUBLIC_LED_HEIGHT ?? '64');
|
||||
const led_width = Number(env?.PUBLIC_LED_WIDTH ?? '64');
|
||||
const led_height = Number(env?.PUBLIC_LED_HEIGHT ?? '64');
|
||||
|
||||
const led_chain = Number(PUBLIC_LED_CHAIN ?? '1');
|
||||
const led_parallel = Number(PUBLIC_LED_PARALLEL ?? '1');
|
||||
const led_chain = Number(env?.PUBLIC_LED_CHAIN ?? '1');
|
||||
const led_parallel = Number(env?.PUBLIC_LED_PARALLEL ?? '1');
|
||||
|
||||
return {
|
||||
width: led_width * led_parallel,
|
||||
height: led_height * led_chain,
|
||||
height: led_height * led_chain
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user