本文整理匯總了TypeScript中@amnisio/arduino-uno.createSinks函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript createSinks函數的具體用法?TypeScript createSinks怎麽用?TypeScript createSinks使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了createSinks函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.D2$ = periodic(100).sample(arduino.D2$).map(invert);
sinks.D3$ = periodic(250).sample(arduino.D3$).map(invert);
sinks.LED$ = periodic(500).sample(arduino.LED$).map(invert);
return sinks;
};
示例2: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ =
periodic(500)
.sample(arduino.LED$)
.map(led => led == LOW ? HIGH : LOW);
return sinks;
};
示例3: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ =
periodic(20)
.sample(arduino.D2$)
.map(value => value == LOW ? HIGH : LOW);
return sinks;
};
示例4: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
// We do some maths in order to get a stream of brightnesses that allows fading
sinks.D10$ =
// Create a stream that emits an event every 30 ms
periodic(30)
// fold it onto a stream that repeats 0 to 101 forever
// 0-1-2-3-...-100-101-0-1-2-3-4-...->
.fold((brightness, event) => brightness == 101 ? 0 : ++brightness, 0)
// map it to a triangular stream that rises and falls, peaking at 51, forever
// 0-1-2-3-...-50-51-50-...-3-2-1-0-1-2-3-...->
.map(brightness => {
const x = brightness % 51;
return brightness > x ? 51 - x : x;
})
// map it to a stream that multiplies the value by 5, to get increments of 5, peaking at 255
// 0-5-10-15-...-250-255-250-...-15-10-5-0-5-10-15-...->
.map(brightness => 5 * brightness);
return sinks;
};
示例5: createSinks
const application = (arduino: Sources) => {
const sinks = createSinks();
sinks.LED$ = periodic(20).sample(arduino.D2$);
return sinks;
};