Skip to content

Instantly share code, notes, and snippets.

#include <FlexiTimer2.h>
constexpr auto LED_PIN ( 13 );
constexpr auto NUM_BATTERIES ( 4 );
constexpr auto START_VALUE ( 205 ); // 1.0v
constexpr auto THRESHOLD_H ( 307 ); // 1.5v
constexpr auto THRESHOLD_L ( 205 ); // 1.0v
constexpr auto ALMOST_ZERO ( 21 ); // 0.1v
//平滑化する関数オブエクト。Batteryのメンバ関数として使う。
// WARNING: This a "legacy example based on a deprecated library". Check filters.lib
// for more accurate examples of filter functions
declare name "APFDelay";
import("maxmsp.lib");
APFSt(F,Q) = APF(_,F,0,Q),APF(_,F,0,Q);
process = APFSt(250,1.5):APFSt(700,4.5):APFSt(1250,6.3):APFSt(1600,15);
constexpr int NUM_BUTTONS ( 4 );
constexpr int LED_PIN ( 13 );
constexpr int GND_PINS[ NUM_BUTTONS ] { 5, 7, 9, 11 };
class Debounce{
static constexpr long RATE = 12;
static constexpr long THRESHOLD_L = 10;
static constexpr long THRESHOLD_H = 90;
long innerMul100;
constexpr int NUM_BUTTONS ( 4 ); //buttonの数
constexpr int LED_PIN ( 13 ); // LEDのピン
constexpr int GND_PINS[ NUM_BUTTONS ] { 5, 7, 9, 11 }; //結線の都合でGNDとして使用
// Button構造体の定義
struct Button{
const int PIN;
const int CC_NUM;
long innerMul100;
#include <LiquidCrystal.h>
LiquidCrystal lcd( 8, 9, 4, 5, 6, 7 );
constexpr auto KEYS ( A0 ); // キースイッチは A0に結線されている
// KEYの値。別途実測したもの。
constexpr auto NO_KEY ( 1022 );
constexpr auto SELECT_KEY ( 731 );
constexpr auto LEFT_KEY ( 510 );
constexpr auto DOWN_KEY ( 340 );
#include <MIDIUSB.h>
#include <DebFuncs.h>
const int LEDPIN = 13;
const int INPIN[] = {3,4,5,6};
const int CC_NUM[] = {25,26,27,28};
DF::Debounce debounce[4];
DF::IsDROPPED isDropped[4];
DF::IsRAISED isRaised[4];
#include <DebFuncs.h>
// Instantiate a set of function objects.
DF::Debounce debounceOne;
// or debounceOne(10),for example.
// You can set reaction rate from 0(no reaction) up to 100(no debouncing).
// The default value is 25.
DF::IsDROPPED isDroppedOne;
// Instantiate a set of arrays.
@ttatsf
ttatsf / RoomVal.hs
Created August 15, 2016 11:48
planRoom
module RoomVal (
RoomVal(..)
, initPossibles
, calcRmVal
, fixRmVal
, addHistStay
, addHistChange
, addVal
) where
@ttatsf
ttatsf / MyFunc.hs
Created August 15, 2016 11:48
planRoom
module MyFunc (
scanwl
, minimumF
) where
minimumF :: Ord b => (a -> b) -> [a] -> a
minimumF f [x] = x
minimumF f (x:y:xs)
| f x < f y = minimumF f (x:xs)
| otherwise = minimumF f (y:xs)
@ttatsf
ttatsf / Main.hs
Last active August 15, 2016 11:46
import RoomVal
import MyFunc
planRoom :: [Int] -> Int -> [(Int,Int)]
planRoom grpsList rmsNum =
reverse . rmHist . last .
foldl fixeds
(initRmVals $ head $ validGrpss grpsList rmsNum)
$ tail $ validGrpss grpsList rmsNum