Skip to content

Instantly share code, notes, and snippets.

View squarewave's full-sized avatar

Alex Thayer squarewave

  • Mozilla
  • San Luis Obispo
View GitHub Profile
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
extern crate euclid;
extern crate gleam;
extern crate glutin;
extern crate webrender;
extern crate winit;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#include <TimerOne.h>
#include <SPI.h>
#include <Mirf.h>
#include <MirfHardwareSpiDriver.h>
#include <MirfSpiDriver.h>
#include <nRF24L01.h>
// pin macros
#define CLR(x,y) ( PORT ## x&=(~(1<<y)) )
#define SET(x,y) ( PORT ## x|=(1<<y) )
namespace rollingaveragernamespace {
RollingAverager::RollingAverager() {
this.buffer_index_ = 0;
this.buffer_ = {0};
this.sum = 0;
}
long RollingAverager::Roll(long next_input) {
++this.buffer_index_;
this.buffer_index_ &= (kBufferSize - 1);