blinkstick-ts
Version:
BlinkStick TypeScript implementation
39 lines (38 loc) • 2.03 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.wait = exports.getColors = exports.getColor = exports.setColors = exports.setColor = exports.blinkStick = void 0;
const promises_1 = require("timers/promises");
const simulation_1 = require("./simulation/simulation");
//export const blinkStick = new BlinkSticks().findFirst();
exports.blinkStick = simulation_1.Simulation.createBlinkStickWithLedLine(32);
function setColor(position, color) {
exports.blinkStick === null || exports.blinkStick === void 0 ? void 0 : exports.blinkStick.setColor(color, position);
}
exports.setColor = setColor;
function setColors(colors) {
exports.blinkStick === null || exports.blinkStick === void 0 ? void 0 : exports.blinkStick.setColors(colors);
}
exports.setColors = setColors;
function getColor(position) {
return exports.blinkStick === null || exports.blinkStick === void 0 ? void 0 : exports.blinkStick.getColor(position);
}
exports.getColor = getColor;
function getColors(count) {
return exports.blinkStick === null || exports.blinkStick === void 0 ? void 0 : exports.blinkStick.getColors(count);
}
exports.getColors = getColors;
function wait(milliseconds) {
return __awaiter(this, void 0, void 0, function* () {
yield (0, promises_1.setTimeout)(milliseconds);
});
}
exports.wait = wait;