当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript rivulet.periodic函数代码示例

本文整理汇总了TypeScript中@amnisio/rivulet.periodic函数的典型用法代码示例。如果您正苦于以下问题:TypeScript periodic函数的具体用法?TypeScript periodic怎么用?TypeScript periodic使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了periodic函数的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;
};
开发者ID:artfuldev,项目名称:RIoT,代码行数:7,代码来源:multiple-blinks.ts

示例2: createSinks

const application = (arduino: Sources) => {
  const sinks = createSinks();
  sinks.LED$ =
    periodic(500)
      .sample(arduino.LED$)
      .map(led => led == LOW ? HIGH : LOW);
  return sinks;
};
开发者ID:artfuldev,项目名称:RIoT,代码行数:8,代码来源:blink.ts

示例3: createSinks

const application = (arduino: Sources) => {
  const sinks = createSinks();
  sinks.LED$ =
    periodic(20)
      .sample(arduino.D2$)
      .map(value => value == LOW ? HIGH : LOW);
  return sinks;
};
开发者ID:artfuldev,项目名称:RIoT,代码行数:8,代码来源:input-pullup.ts

示例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;
};
开发者ID:artfuldev,项目名称:RIoT,代码行数:20,代码来源:fade.ts

示例5: createSinks

const application = (arduino: Sources) => {
  const sinks = createSinks();
  sinks.LED$ = periodic(20).sample(arduino.D2$);
  return sinks;
};
开发者ID:artfuldev,项目名称:RIoT,代码行数:5,代码来源:button-activated-led.ts


注:本文中的@amnisio/rivulet.periodic函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。