oxford
This commit is contained in:
parent
367d996afc
commit
581c63a6aa
3
.gitattributes
vendored
Normal file
3
.gitattributes
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
*.wav filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.m4a filter=lfs diff=lfs merge=lfs -text
|
||||||
|
*.asd filter=lfs diff=lfs merge=lfs -text
|
||||||
BIN
audio/20220622-171706.wav
(Stored with Git LFS)
Normal file
BIN
audio/20220622-171706.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/20220622-171706.wav.asd
(Stored with Git LFS)
Normal file
BIN
audio/20220622-171706.wav.asd
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/Untitled Project/Ableton Project Info/Project8_1.cfg
Normal file
BIN
audio/Untitled Project/Ableton Project Info/Project8_1.cfg
Normal file
Binary file not shown.
BIN
audio/Untitled Project/Backup/Untitled [2022-06-24 152453].als
Normal file
BIN
audio/Untitled Project/Backup/Untitled [2022-06-24 152453].als
Normal file
Binary file not shown.
0
audio/Untitled Project/Icon
Normal file
0
audio/Untitled Project/Icon
Normal file
BIN
audio/Untitled Project/Untitled.als
Normal file
BIN
audio/Untitled Project/Untitled.als
Normal file
Binary file not shown.
BIN
audio/comme_ca.m4a
(Stored with Git LFS)
Normal file
BIN
audio/comme_ca.m4a
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/comme_ca.wav
(Stored with Git LFS)
Normal file
BIN
audio/comme_ca.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E1.read.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E1.read.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E10.they_only.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E10.they_only.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E11.knew.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E11.knew.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E12.from.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E12.from.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E13.books.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E13.books.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E2.old_tales.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E2.old_tales.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E3.traversed_provinces.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E3.traversed_provinces.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E4.crossed_seas.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E4.crossed_seas.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E5.visited.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E5.visited.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E6.new_peoples.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E6.new_peoples.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E7.to_see.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E7.to_see.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E8.face_to_face.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E8.face_to_face.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/E9.persons.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/E9.persons.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/EA.we_read_in_old_tales.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/EA.we_read_in_old_tales.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/EB.that_men_traversed_provinces.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/EB.that_men_traversed_provinces.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/EC.crossed_seas_and_visited_new_peoples.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/EC.crossed_seas_and_visited_new_peoples.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/ED.to_see_face_to_face_persons.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/ED.to_see_face_to_face_persons.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/EE.whom_they_only_knew_from_books.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/EE.whom_they_only_knew_from_books.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/ENGLISH.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/ENGLISH.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L0.legimus.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L0.legimus.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L1.in_veteribus.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L1.in_veteribus.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L10.noverant.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L10.noverant.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L11.coram.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L11.coram.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L12.quoque_viderent.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L12.quoque_viderent.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L2.historiis.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L2.historiis.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L3.quosdam_lustrasse_provincias.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L3.quosdam_lustrasse_provincias.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L4.novos.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L4.novos.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L5.adiisse_populos.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L5.adiisse_populos.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L6.maria_transisse.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L6.maria_transisse.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L7.ut_eos.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L7.ut_eos.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L8.quos.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L8.quos.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/L9.ex_libris.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/L9.ex_libris.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LA.legimus_in_vereribus_historiis.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LA.legimus_in_vereribus_historiis.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LATIN.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LATIN.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LB.quodam_lustrasse_provincias.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LB.quodam_lustrasse_provincias.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LC.novos_adiisse_populos_maria_transisse.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LC.novos_adiisse_populos_maria_transisse.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LD.ut_eos_quos_ex_libris_noverant.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LD.ut_eos_quos_ex_libris_noverant.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/edits/LE.coram_quoque_viderent.wav
(Stored with Git LFS)
Normal file
BIN
audio/edits/LE.coram_quoque_viderent.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
84
audio/edits/translation.rtf
Normal file
84
audio/edits/translation.rtf
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
{\rtf1\ansi\ansicpg1252\cocoartf2638
|
||||||
|
\cocoatextscaling0\cocoaplatform0{\fonttbl\f0\froman\fcharset0 TimesNewRomanPSMT;\f1\froman\fcharset0 TimesNewRomanPS-ItalicMT;}
|
||||||
|
{\colortbl;\red255\green255\blue255;\red24\green55\blue106;\red0\green0\blue0;}
|
||||||
|
{\*\expandedcolortbl;;\cssrgb\c12157\c28627\c49020;\cssrgb\c0\c0\c0;}
|
||||||
|
\paperw11900\paperh16840\margl1440\margr1440\vieww11520\viewh8400\viewkind0
|
||||||
|
\deftab720
|
||||||
|
\pard\pardeftab720\partightenfactor0
|
||||||
|
|
||||||
|
\f0\fs37\fsmilli18667 \cf2 \expnd0\expndtw0\kerning0
|
||||||
|
Dear Sam,
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 Thank you for the message. I am okay, and hope you are, too.
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 The section you print reads:
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'85 studia conciliant. Legimus in veteribus |
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 Historiis, quosdam lustrasse provincias, |
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 novos adiisse \{sic.\} populos, maria transisse, |
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 ut eos quos ex libris noverant, coram |
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 quoque viderent. Sicut \{sic.\} pitagoras memphi= |
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 I have checked this against the printing in
|
||||||
|
\f1\i Patrologia Latina
|
||||||
|
\f0\i0 , and have marked two variants: PL records \'91adisse\'92 and \'91Sic\'92, but I have transcribed what is in Gutenberg. The final phrase finishes \'91memphiticos vates\'92.
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 Hope this helps.
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 Best wishes,
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 \'a0
|
||||||
|
\fs32 \cf0 \
|
||||||
|
|
||||||
|
\fs37\fsmilli18667 \cf2 Alan.}
|
||||||
BIN
audio/libris_laborem.m4a
(Stored with Git LFS)
Normal file
BIN
audio/libris_laborem.m4a
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/libris_laborem.wav
(Stored with Git LFS)
Normal file
BIN
audio/libris_laborem.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/phrases/ENGLISH.wav
(Stored with Git LFS)
Normal file
BIN
audio/phrases/ENGLISH.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
audio/phrases/LATIN.wav
(Stored with Git LFS)
Normal file
BIN
audio/phrases/LATIN.wav
(Stored with Git LFS)
Normal file
Binary file not shown.
96
libs/42line/FASTSENSOR.h
Normal file
96
libs/42line/FASTSENSOR.h
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// #include <Arduino.h>
|
||||||
|
#include <FastTouch.h>
|
||||||
|
|
||||||
|
static float alpha = 0.2;
|
||||||
|
static int baseline_fluctuation = 5;
|
||||||
|
static int baseline_fluctuation_hits = 100;
|
||||||
|
static int max_s = 60;
|
||||||
|
|
||||||
|
typedef void(*toggle_cb)(bool, int);
|
||||||
|
|
||||||
|
struct SENSOR_t {
|
||||||
|
|
||||||
|
int PIN, base, num_base, max_c, v, prev, raw, cutoff_s;
|
||||||
|
int dv;
|
||||||
|
unsigned long timestamp_calib;
|
||||||
|
toggle_cb fn_toggle_cb;
|
||||||
|
bool call_toggle = false;
|
||||||
|
|
||||||
|
SENSOR_t(const int& pin, int cutoff) {
|
||||||
|
PIN = pin;
|
||||||
|
max_c = max_s;
|
||||||
|
num_base = 0;
|
||||||
|
cutoff_s = cutoff;
|
||||||
|
fn_toggle_cb = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void plug_toggle_cb(toggle_cb fn) {
|
||||||
|
fn_toggle_cb = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
void baseline(int n, int d) {
|
||||||
|
float cum = 0;
|
||||||
|
for (int i = 0; i < n; i++){
|
||||||
|
update(false, false);
|
||||||
|
if(abs(dv) < baseline_fluctuation){
|
||||||
|
cum += v;
|
||||||
|
}
|
||||||
|
delay(d);
|
||||||
|
|
||||||
|
}
|
||||||
|
base = (int)floor(cum / n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void calibrate() {
|
||||||
|
// if(abs(dv) < baseline_fluctuation) {
|
||||||
|
// num_base++;
|
||||||
|
// if (num_base > baseline_fluctuation_hits)
|
||||||
|
// base = (int) (alpha * (float)v + (1.0 - alpha) * (float)base);
|
||||||
|
// } else {
|
||||||
|
// num_base = 0;
|
||||||
|
// }
|
||||||
|
if(v > max_c) max_c = v;
|
||||||
|
timestamp_calib = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(bool calib = true, bool filt = true) {
|
||||||
|
raw = fastTouchRead(PIN);
|
||||||
|
if(filt)
|
||||||
|
v = filter(raw);
|
||||||
|
else
|
||||||
|
v = raw;
|
||||||
|
dv = v - prev;
|
||||||
|
if(calib) calibrate();
|
||||||
|
|
||||||
|
if(fn_toggle_cb) {
|
||||||
|
int m_v = map(v, base, max_c, 0, 100);
|
||||||
|
int m_prev = map(prev, base, max_c, 0, 100);
|
||||||
|
if(m_prev < cutoff_s && m_v >= cutoff_s)
|
||||||
|
fn_toggle_cb(true, PIN);
|
||||||
|
else if(m_prev > cutoff_s && m_v <= cutoff_s)
|
||||||
|
fn_toggle_cb(false, PIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
prev = v;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
int map_range(int min_v, int max_v) {
|
||||||
|
return map(v, base, max_c, min_v, max_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int map_range_raw(int min_v, int max_v) {
|
||||||
|
return map(raw, base, max_c, min_v, max_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int filter(int n) {
|
||||||
|
return (int) (alpha * n + (1.0 - alpha) * prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool touch() {
|
||||||
|
return (v > cutoff_s);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
64
libs/42line/SENSOR.h
Normal file
64
libs/42line/SENSOR.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
static float alpha = 0.2;
|
||||||
|
static int baseline_fluctuation = 75;
|
||||||
|
static int max_s = 3000;
|
||||||
|
|
||||||
|
typedef struct SENSOR_t {
|
||||||
|
|
||||||
|
int PIN, base, num_base, max_c, v, prev;
|
||||||
|
int dv;
|
||||||
|
unsigned long timestamp_calib;
|
||||||
|
|
||||||
|
SENSOR_t(int& pin) {
|
||||||
|
PIN = pin;
|
||||||
|
max_c = max_s;
|
||||||
|
num_base = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void baseline(int n, int d) {
|
||||||
|
int cum = 0;
|
||||||
|
for (int i = 0; i < n; i++){
|
||||||
|
update(false, false);
|
||||||
|
if(abs(dv) < baseline_fluctuation){
|
||||||
|
cum += v;
|
||||||
|
}
|
||||||
|
delay(d);
|
||||||
|
}
|
||||||
|
base = (int)(cum / n);
|
||||||
|
}
|
||||||
|
|
||||||
|
void calibrate() {
|
||||||
|
if(abs(dv) < baseline_fluctuation) {
|
||||||
|
num_base++;
|
||||||
|
if (num_base > 25)
|
||||||
|
base = (int) (alpha * (float)v + (1.0 - alpha) * (float)base);
|
||||||
|
} else {
|
||||||
|
num_base = 0;
|
||||||
|
}
|
||||||
|
if(v > max_c) max_c = v;
|
||||||
|
timestamp_calib = millis();
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(bool calib = true, bool filt = true) {
|
||||||
|
int d = touchRead(PIN);
|
||||||
|
if(filt)
|
||||||
|
v = filter(d);
|
||||||
|
else
|
||||||
|
v = d;
|
||||||
|
dv = v - prev;
|
||||||
|
prev = v;
|
||||||
|
if(calib) calibrate();
|
||||||
|
}
|
||||||
|
|
||||||
|
int map_range(int min_v, int max_v) {
|
||||||
|
return map(v, base, max_c, min_v, max_v);
|
||||||
|
}
|
||||||
|
|
||||||
|
int filter(int n) {
|
||||||
|
return (int) (alpha * n + (1.0 - alpha) * prev);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
135
libs/42line/SOUND.h
Normal file
135
libs/42line/SOUND.h
Normal file
@ -0,0 +1,135 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <Audio.h>
|
||||||
|
#include "WORDS.h"
|
||||||
|
|
||||||
|
static int time_interval_random_start = 2000;
|
||||||
|
|
||||||
|
typedef void(*synth_toggle_cb)(bool, int);
|
||||||
|
|
||||||
|
void _random_wav(AudioPlaySdWav* wav, E_WORDS* e_words, int MAX_WORD) {
|
||||||
|
int w = (int)random(0, MAX_WORD);
|
||||||
|
wav->play(words[e_words[w]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
enum WAVPLAY_STATE {
|
||||||
|
LATIN, ENGLISH, RANDOM, NONE
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct WAVPLAY_t {
|
||||||
|
|
||||||
|
int pin;
|
||||||
|
AudioPlaySdWav* wav;
|
||||||
|
E_PHRASES en_phrase;
|
||||||
|
E_PHRASES la_phrase;
|
||||||
|
E_WORDS* random_words;
|
||||||
|
int nbr_random_words;
|
||||||
|
synth_toggle_cb synth_toggle_func = NULL;
|
||||||
|
|
||||||
|
long random_start;
|
||||||
|
|
||||||
|
WAVPLAY_STATE state;
|
||||||
|
|
||||||
|
WAVPLAY_t(const int p, AudioPlaySdWav* w, E_PHRASES en, E_PHRASES la, E_WORDS* wds, int nbr_wds, synth_toggle_cb synth_func) {
|
||||||
|
pin = p;
|
||||||
|
wav = w;
|
||||||
|
en_phrase = en;
|
||||||
|
la_phrase = la;
|
||||||
|
random_words = wds;
|
||||||
|
nbr_random_words = nbr_wds;
|
||||||
|
state = NONE;
|
||||||
|
synth_toggle_func = synth_func;
|
||||||
|
}
|
||||||
|
|
||||||
|
void play(){
|
||||||
|
|
||||||
|
switch(state) {
|
||||||
|
case NONE:
|
||||||
|
wav->play(phrases[la_phrase]);
|
||||||
|
delay(25);
|
||||||
|
state = LATIN;
|
||||||
|
// Serial.println("state none > latin");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void stop(){
|
||||||
|
wav->stop();
|
||||||
|
if(state == RANDOM) synth_toggle_func(false, pin);
|
||||||
|
state = NONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void update(){
|
||||||
|
|
||||||
|
if(state == NONE) return;
|
||||||
|
|
||||||
|
if(wav->isPlaying()) {
|
||||||
|
// Serial.println("...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch(state) {
|
||||||
|
case LATIN:
|
||||||
|
wav->play(phrases[en_phrase]);
|
||||||
|
state = ENGLISH;
|
||||||
|
// Serial.println("state latin > english");
|
||||||
|
break;
|
||||||
|
case ENGLISH:
|
||||||
|
// _random_wav(wav, random_words, nbr_random_words);
|
||||||
|
state = RANDOM;
|
||||||
|
random_start = millis();
|
||||||
|
synth_toggle_func(true, pin);
|
||||||
|
// Serial.println("state english > random");
|
||||||
|
break;
|
||||||
|
case RANDOM:
|
||||||
|
if(millis() - random_start > time_interval_random_start) {
|
||||||
|
_random_wav(wav, random_words, nbr_random_words);
|
||||||
|
// Serial.println("random");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct DETUNE_t {
|
||||||
|
|
||||||
|
AudioSynthWaveformSine sine3;
|
||||||
|
AudioSynthWaveformSine sine2;
|
||||||
|
AudioSynthWaveformSine sine1;
|
||||||
|
|
||||||
|
int base_freq = 0;
|
||||||
|
|
||||||
|
DETUNE_t(int freq) {
|
||||||
|
set_frequency(freq);
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_frequency(int freq) {
|
||||||
|
sine1.frequency(freq);
|
||||||
|
sine2.frequency(freq);
|
||||||
|
sine3.frequency(freq);
|
||||||
|
base_freq = freq;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_detune(float detune) {
|
||||||
|
int det_mid = (int)(detune/2.0);
|
||||||
|
sine2.frequency(base_freq + det_mid);
|
||||||
|
|
||||||
|
if(detune > 100)
|
||||||
|
sine3.frequency(base_freq - det_mid);
|
||||||
|
else
|
||||||
|
sine3.frequency(base_freq - 2 * det_mid);
|
||||||
|
|
||||||
|
int r = (int)random(0, 100);
|
||||||
|
if(r > 33)
|
||||||
|
sine1.frequency(det_mid/2);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
55
libs/42line/WORDS.h
Normal file
55
libs/42line/WORDS.h
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
static const char* const words[] = {
|
||||||
|
"E1.read.wav",
|
||||||
|
"E2.old_tales.wav",
|
||||||
|
"E3.traversed_provinces.wav",
|
||||||
|
"E4.crossed_seas.wav",
|
||||||
|
"E5.visited.wav",
|
||||||
|
"E6.new_peoples.wav",
|
||||||
|
"E7.to_see.wav",
|
||||||
|
"E8.face_to_face.wav",
|
||||||
|
"E9.persons.wav",
|
||||||
|
"E10.they_only.wav",
|
||||||
|
"E11.knew.wav",
|
||||||
|
"E12.from.wav",
|
||||||
|
"E13.books.wav",
|
||||||
|
"L0.legimus.wav",
|
||||||
|
"L1.in_veteribus.wav",
|
||||||
|
"L2.historiis.wav",
|
||||||
|
"L3.quosdam_lustrasse_provincias.wav",
|
||||||
|
"L4.novos.wav",
|
||||||
|
"L5.adiisse_populos.wav",
|
||||||
|
"L6.maria_transisse.wav",
|
||||||
|
"L7.ut_eos.wav",
|
||||||
|
"L8.quos.wav",
|
||||||
|
"L9.ex_libris.wav",
|
||||||
|
"L10.noverant.wav",
|
||||||
|
"L11.coram.wav",
|
||||||
|
"L12.quoque_viderent.wav",
|
||||||
|
"ENGLISH.wav",
|
||||||
|
"LATIN.wav"
|
||||||
|
};
|
||||||
|
|
||||||
|
enum E_WORDS {
|
||||||
|
E1,E2,E3,E4,E5,E6,E7,E8,E9,E10,E11,E12,E13,L0,L1,L2,L3,L4,L5,L6,L7,L8,L9,L10,L11,L12,EN,LAT
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
static const char* const phrases[] = {
|
||||||
|
|
||||||
|
"EA.we_read_in_old_tales.wav",
|
||||||
|
"EB.that_men_traversed_provinces.wav",
|
||||||
|
"EC.crossed_seas_and_visited_new_peoples.wav",
|
||||||
|
"ED.to_see_face_to_face_persons.wav",
|
||||||
|
"EE.whom_they_only_knew_from_books.wav",
|
||||||
|
"LA.legimus_in_vereribus_historiis.wav",
|
||||||
|
"LB.quodam_lustrasse_provincias.wav",
|
||||||
|
"LC.novos_adiisse_populos_maria_transisse.wav",
|
||||||
|
"LD.ut_eos_quos_ex_libris_noverant.wav",
|
||||||
|
"LE.coram_quoque_viderent.wav"
|
||||||
|
};
|
||||||
|
|
||||||
|
enum E_PHRASES {
|
||||||
|
EA, EB, EC, ED, EE, LA, LB, LC, LD, LE
|
||||||
|
};
|
||||||
@ -0,0 +1,27 @@
|
|||||||
|
#include <FastTouch.h>
|
||||||
|
|
||||||
|
// Adrian Freed 2018
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
SerialUSB.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
SerialUSB.print(fastTouchRead(A2)); SerialUSB.print(" ");
|
||||||
|
SerialUSB.print(fastTouchRead(A3)); SerialUSB.print(" ");
|
||||||
|
SerialUSB.print(fastTouchRead(A4)); SerialUSB.print(" ");
|
||||||
|
SerialUSB.print(fastTouchRead(A5)); SerialUSB.print(" ");
|
||||||
|
SerialUSB.print(fastTouchRead(2)); SerialUSB.print(" ");
|
||||||
|
SerialUSB.print(fastTouchRead(3)); SerialUSB.print(" ");
|
||||||
|
|
||||||
|
for(int i=9;i<=11;++i)
|
||||||
|
{
|
||||||
|
SerialUSB.print(fastTouchRead(i)); SerialUSB.print(" ");
|
||||||
|
}
|
||||||
|
SerialUSB.println();
|
||||||
|
delay(100);
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,30 @@
|
|||||||
|
#include <FastTouch.h>
|
||||||
|
//
|
||||||
|
// Adrian Freed 2019
|
||||||
|
//
|
||||||
|
// report on whether pins are being touched based on how
|
||||||
|
// slow the pins arrive at HIGH from ground when a PULLUP resistor is enabled
|
||||||
|
// all pin except the built-in LED are probed. Note that each pin will be hard pulled
|
||||||
|
// to ground and that interrupts are briefly stopped during the measurement.
|
||||||
|
//
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
SerialUSB.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
for(int i=0;i<CORE_NUM_DIGITAL;++i)
|
||||||
|
{
|
||||||
|
if(i!=LED_BUILTIN)
|
||||||
|
{
|
||||||
|
SerialUSB.print(fastTouchRead(i)); SerialUSB.print(" ");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
SerialUSB.print("LED ");
|
||||||
|
}
|
||||||
|
SerialUSB.println();
|
||||||
|
delay(200);
|
||||||
|
}
|
||||||
@ -0,0 +1,44 @@
|
|||||||
|
#include <FastTouch.h>
|
||||||
|
|
||||||
|
// monotone touch sequencer
|
||||||
|
// Adrian Freed 2018
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
SerialUSB.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
const int tonepin=10;
|
||||||
|
const int notelength=140, notetonote=160;
|
||||||
|
SerialUSB.print(r = fastTouchRead(A2)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 587, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(A3)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 440, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(A4)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 880, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(A5)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 153, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(2)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 185, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(3)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 196, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(9)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 349, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(11)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 370, notelength/(r-1)); delay(notetonote);}
|
||||||
|
|
||||||
|
SerialUSB.println();
|
||||||
|
}
|
||||||
|
|
||||||
@ -0,0 +1,41 @@
|
|||||||
|
#include <FastTouch.h>
|
||||||
|
|
||||||
|
// monotone touch sequencer
|
||||||
|
// Adrian Freed 2018
|
||||||
|
|
||||||
|
void setup()
|
||||||
|
{
|
||||||
|
SerialUSB.begin(9600);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void loop()
|
||||||
|
{
|
||||||
|
int r;
|
||||||
|
const int tonepin=A0;
|
||||||
|
const int notelength=140, notetonote=190;
|
||||||
|
SerialUSB.print(r = fastTouchRead(A2)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 587/2, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(A3)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 440, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(A4)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 220, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(A5)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 153, notelength/(r-1)); delay(notetonote); }
|
||||||
|
SerialUSB.print(r = fastTouchRead(A1)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 185, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(A6)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 196, notelength/(r-1)); delay(notetonote);}
|
||||||
|
SerialUSB.print(r = fastTouchRead(A7)); SerialUSB.print(" ");
|
||||||
|
if(r>1)
|
||||||
|
{ tone(tonepin, 349, notelength/(r-1)); delay(notetonote);}
|
||||||
|
|
||||||
|
SerialUSB.println();
|
||||||
|
}
|
||||||
|
|
||||||
6
libs/FastTouch/README.md
Normal file
6
libs/FastTouch/README.md
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
# FastTouch
|
||||||
|
Use this library to detect whether your choice of Arduino pin is being touched.
|
||||||
|
The technique works with any Arduino pin that has an internal pull up resistor that
|
||||||
|
can be enabled. It returns a measure of how long it takes for a pin to rise
|
||||||
|
to a HIGH level after the pull up is enabled. This will be slowed by any
|
||||||
|
capacitive load added.
|
||||||
2
libs/FastTouch/keywords.txt
Executable file
2
libs/FastTouch/keywords.txt
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
fastTouchRead KEYWORD1
|
||||||
|
fastTouchMax KEYWORD1
|
||||||
9
libs/FastTouch/library.properties
Normal file
9
libs/FastTouch/library.properties
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
name=FastTouch
|
||||||
|
version=0.91
|
||||||
|
author=Adrian Freed <adrian@adrianfreed.com>
|
||||||
|
maintainer=Adrian Freed <adrian@adrianfreed.com>
|
||||||
|
sentence=Fast Touch Library
|
||||||
|
paragraph=Fast Capacitive Touch on any digital pin with a pull up option
|
||||||
|
category=Device Control
|
||||||
|
url=https://github.com/AdrianFreed/FastTouch
|
||||||
|
architectures=*
|
||||||
803
libs/FastTouch/src/FastTouch.cpp
Normal file
803
libs/FastTouch/src/FastTouch.cpp
Normal file
@ -0,0 +1,803 @@
|
|||||||
|
//
|
||||||
|
// FastTouch.cpp
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Created by AdrianFreed on 3/12/18.
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "FastTouch.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(CORE_TEENSY)
|
||||||
|
|
||||||
|
//#if defined(__IMXRT1052__) || defined(__IMXRT10562__)
|
||||||
|
|
||||||
|
#if defined(__IMXRT1052__) || defined(__IMXRT1062__)
|
||||||
|
|
||||||
|
FASTRUN
|
||||||
|
int fastTouchRead(int pin)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
const struct digital_pin_bitband_and_config_table_struct *p;
|
||||||
|
if (pin >= CORE_NUM_DIGITAL) return -1;
|
||||||
|
p = digital_pin_to_info_PGM + pin;
|
||||||
|
|
||||||
|
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
delayMicroseconds(1);
|
||||||
|
/* disable interrupts */
|
||||||
|
noInterrupts();
|
||||||
|
pinMode(pin, INPUT_PULLUP);
|
||||||
|
i=0;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
goto out;
|
||||||
|
i++;
|
||||||
|
|
||||||
|
for(;i<64;++i)
|
||||||
|
if((*(p->reg + 2) & p->mask)!=0)
|
||||||
|
break;
|
||||||
|
// v += fastDigitalRead(pin)? 0:1;
|
||||||
|
{
|
||||||
|
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
out:
|
||||||
|
interrupts();
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
#elif defined(__MKL26Z64__)|| defined(__IMXRT1052__) || defined(__IMXRT1062__) /* Teensy 3LC */
|
||||||
|
FASTRUN
|
||||||
|
int fastTouchRead(int pin)
|
||||||
|
{
|
||||||
|
const unsigned m = digitalPinToBitMask(pin);
|
||||||
|
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
delayMicroseconds(50);
|
||||||
|
/* disable interrupts */
|
||||||
|
noInterrupts();
|
||||||
|
pinMode(pin, INPUT_PULLUP);
|
||||||
|
|
||||||
|
// for(int i=0;i<64;++i)
|
||||||
|
// ft_o += *port&x;
|
||||||
|
{
|
||||||
|
register unsigned a,b,c,d,e,f;
|
||||||
|
register unsigned aa,ba,ca,da;
|
||||||
|
#ifdef CONDITIONALAPPROACH
|
||||||
|
register unsigned i=0;
|
||||||
|
|
||||||
|
|
||||||
|
a = *portInputRegister(pin) & m ;
|
||||||
|
a = *portInputRegister(pin) & m ;
|
||||||
|
a = *portInputRegister(pin) & m ;
|
||||||
|
b = *portInputRegister(pin) & m ;
|
||||||
|
c = *portInputRegister(pin) & m ;
|
||||||
|
d = *portInputRegister(pin) & m ;
|
||||||
|
e = *portInputRegister(pin) & m ;
|
||||||
|
f = *portInputRegister(pin) & m ;
|
||||||
|
aa = *portInputRegister(pin) & m;
|
||||||
|
ba = *portInputRegister(pin) & m;
|
||||||
|
ca = *portInputRegister(pin) & m;
|
||||||
|
da = *portInputRegister(pin) & m;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin) & m )
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
out: ;
|
||||||
|
|
||||||
|
#else
|
||||||
|
register unsigned i;
|
||||||
|
|
||||||
|
i = *portInputRegister(pin) & m;
|
||||||
|
i = *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i = *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
i+= *portInputRegister(pin) & m;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
interrupts();
|
||||||
|
|
||||||
|
// i += ((a & m)?0:1 ) + ((b& m )?0:1 ) +
|
||||||
|
// ((c & m)?0:1 ) + ((d& m)?0:1 ) + ((e & m)?0:1 ) + ((f& m)?0:1 );
|
||||||
|
//i += ((aa & m)?0:1 ) + ((ba& m )?0:1 ) +
|
||||||
|
// ((ca & m)?0:1 ) + ((da & m)?0:1 ) + ((ea & m)?0:1 ) + ((fa& m)?0:1 );
|
||||||
|
{volatile unsigned t = i, mm = m;
|
||||||
|
while(mm >>= 1)
|
||||||
|
t >>= 1;
|
||||||
|
i = 64 -t; } //+(a+b+c+d+e+f+da+ca+ba+aa 10+
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWrite(pin, LOW);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
FASTRUN
|
||||||
|
int fastTouchRead(int pin)
|
||||||
|
{
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWriteFast(pin, LOW);
|
||||||
|
delayMicroseconds(50);
|
||||||
|
/* disable interrupts */
|
||||||
|
noInterrupts();
|
||||||
|
pinMode(pin, INPUT_PULLUP);
|
||||||
|
|
||||||
|
// for(int i=0;i<64;++i)
|
||||||
|
// ft_o += *port&x;
|
||||||
|
{
|
||||||
|
register unsigned i=0;
|
||||||
|
register uint8_t a,b,c,d,e,f;
|
||||||
|
register uint8_t aa,ba,ca,da;
|
||||||
|
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
|
||||||
|
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
a = *portInputRegister(pin) ;
|
||||||
|
b = *portInputRegister(pin) ;
|
||||||
|
c = *portInputRegister(pin) ;
|
||||||
|
d = *portInputRegister(pin) ;
|
||||||
|
e = *portInputRegister(pin) ;
|
||||||
|
f = *portInputRegister(pin) ;
|
||||||
|
aa = *portInputRegister(pin) ;
|
||||||
|
ba = *portInputRegister(pin) ;
|
||||||
|
ca = *portInputRegister(pin) ;
|
||||||
|
da = *portInputRegister(pin) ;
|
||||||
|
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
if( *portInputRegister(pin))
|
||||||
|
goto out;
|
||||||
|
++i;
|
||||||
|
out:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interrupts();
|
||||||
|
// i += ((a & m)?0:1 ) + ((b& m )?0:1 ) +
|
||||||
|
// ((c & m)?0:1 ) + ((d& m)?0:1 ) + ((e & m)?0:1 ) + ((f& m)?0:1 );
|
||||||
|
//i += ((aa & m)?0:1 ) + ((ba& m )?0:1 ) +
|
||||||
|
// ((ca & m)?0:1 ) + ((da & m)?0:1 ) + ((ea & m)?0:1 ) + ((fa& m)?0:1 );
|
||||||
|
{volatile uint8_t t =10-(a+b+c+d+e+f+da+ca+ba+aa);
|
||||||
|
i+= t; }
|
||||||
|
pinMode(pin, OUTPUT_OPENDRAIN);
|
||||||
|
digitalWriteFast(pin, LOW);
|
||||||
|
|
||||||
|
return i;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int fastTouchMax()
|
||||||
|
{
|
||||||
|
return 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
243
libs/FastTouch/src/FastTouch.h
Normal file
243
libs/FastTouch/src/FastTouch.h
Normal file
@ -0,0 +1,243 @@
|
|||||||
|
//
|
||||||
|
//
|
||||||
|
//FastTouch.h
|
||||||
|
// Fast Touch Sensing for AVR and Teensy 3
|
||||||
|
// Adrian Freed 2006-2018 Copyright. All Rights Reserved.
|
||||||
|
// Tested on Teensy 2.0, Clio, Lilypad, Lilypad USB, Flora, Leonardo, UNO, Micro, BLEpad, PRO Mini,
|
||||||
|
// Teensy 3.2 (more sensitive with optimized compiler settings and higher clock rate)
|
||||||
|
// Teensy 3LC
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef FastTouch_h
|
||||||
|
#define FastTouch_h
|
||||||
|
|
||||||
|
#include <Arduino.h>
|
||||||
|
#if defined(CORE_TEENSY)
|
||||||
|
#include "core_pins.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef BIT_SET
|
||||||
|
# define BIT_SET(value, bit) ((value) |= (1UL << (bit)))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//Arduino
|
||||||
|
#if (defined(ARDUINO_AVR_MEGA) || \
|
||||||
|
defined(ARDUINO_AVR_MEGA1280) || \
|
||||||
|
defined(ARDUINO_AVR_MEGA2560) || \
|
||||||
|
defined(__AVR_ATmega1280__) || \
|
||||||
|
defined(__AVR_ATmega1281__) || \
|
||||||
|
defined(__AVR_ATmega2560__) || \
|
||||||
|
defined(__AVR_ATmega2561__))
|
||||||
|
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
(((P) >= 22 && (P) <= 29) ? &PORTA : \
|
||||||
|
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PORTB : \
|
||||||
|
(((P) >= 30 && (P) <= 37) ? &PORTC : \
|
||||||
|
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PORTD : \
|
||||||
|
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PORTE : \
|
||||||
|
(((P) >= 54 && (P) <= 61) ? &PORTF : \
|
||||||
|
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PORTG : \
|
||||||
|
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PORTH : \
|
||||||
|
(((P) == 14 || (P) == 15) ? &PORTJ : \
|
||||||
|
(((P) >= 62 && (P) <= 69) ? &PORTK : &PORTL))))))))))
|
||||||
|
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
(((P) >= 22 && (P) <= 29) ? &DDRA : \
|
||||||
|
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &DDRB : \
|
||||||
|
(((P) >= 30 && (P) <= 37) ? &DDRC : \
|
||||||
|
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &DDRD : \
|
||||||
|
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &DDRE : \
|
||||||
|
(((P) >= 54 && (P) <= 61) ? &DDRF : \
|
||||||
|
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &DDRG : \
|
||||||
|
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &DDRH : \
|
||||||
|
(((P) == 14 || (P) == 15) ? &DDRJ : \
|
||||||
|
(((P) >= 62 && (P) <= 69) ? &DDRK : &DDRL))))))))))
|
||||||
|
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
(((P) >= 22 && (P) <= 29) ? &PINA : \
|
||||||
|
((((P) >= 10 && (P) <= 13) || ((P) >= 50 && (P) <= 53)) ? &PINB : \
|
||||||
|
(((P) >= 30 && (P) <= 37) ? &PINC : \
|
||||||
|
((((P) >= 18 && (P) <= 21) || (P) == 38) ? &PIND : \
|
||||||
|
((((P) >= 0 && (P) <= 3) || (P) == 5) ? &PINE : \
|
||||||
|
(((P) >= 54 && (P) <= 61) ? &PINF : \
|
||||||
|
((((P) >= 39 && (P) <= 41) || (P) == 4) ? &PING : \
|
||||||
|
((((P) >= 6 && (P) <= 9) || (P) == 16 || (P) == 17) ? &PINH : \
|
||||||
|
(((P) == 14 || (P) == 15) ? &PINJ : \
|
||||||
|
(((P) >= 62 && (P) <= 69) ? &PINK : &PINL))))))))))
|
||||||
|
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 7 && (P) <= 9) ? (P) - 3 : \
|
||||||
|
(((P) >= 10 && (P) <= 13) ? (P) - 6 : \
|
||||||
|
(((P) >= 22 && (P) <= 29) ? (P) - 22 : \
|
||||||
|
(((P) >= 30 && (P) <= 37) ? 37 - (P) : \
|
||||||
|
(((P) >= 39 && (P) <= 41) ? 41 - (P) : \
|
||||||
|
(((P) >= 42 && (P) <= 49) ? 49 - (P) : \
|
||||||
|
(((P) >= 50 && (P) <= 53) ? 53 - (P) : \
|
||||||
|
(((P) >= 54 && (P) <= 61) ? (P) - 54 : \
|
||||||
|
(((P) >= 62 && (P) <= 69) ? (P) - 62 : \
|
||||||
|
(((P) == 0 || (P) == 15 || (P) == 17 || (P) == 21) ? 0 : \
|
||||||
|
(((P) == 1 || (P) == 14 || (P) == 16 || (P) == 20) ? 1 : \
|
||||||
|
(((P) == 19) ? 2 : \
|
||||||
|
(((P) == 5 || (P) == 6 || (P) == 18) ? 3 : \
|
||||||
|
(((P) == 2) ? 4 : \
|
||||||
|
(((P) == 3 || (P) == 4) ? 5 : 7)))))))))))))))
|
||||||
|
|
||||||
|
|
||||||
|
// --- Arduino 644 ---
|
||||||
|
#elif (defined(__AVR_ATmega644__) || \
|
||||||
|
defined(__AVR_ATmega644P__))
|
||||||
|
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PORTB : (((P) >= 8 && (P) <= 15) ? &PORTD : (((P) >= 16 && (P) <= 23) ? &PORTC : &PORTA)))
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &DDRB : (((P) >= 8 && (P) <= 15) ? &DDRD : (((P) >= 8 && (P) <= 15) ? &DDRC : &DDRA)))
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PINB : (((P) >= 8 && (P) <= 15) ? &PIND : (((P) >= 8 && (P) <= 15) ? &PINC : &PINA)))
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 15) ? (P) - 8 : (((P) >= 16 && (P) <= 23) ? (P) - 16 : (P) - 24)))
|
||||||
|
|
||||||
|
#elif defined(__AVR_ATmega32U4__) && defined(CORE_TEENSY)
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
(((P) == 22 || (P) == 23 || (P) == 5 || (P) == 6 || (P) == 7 || (P) == 8 || (P) == 11 || (P) == 12) ? &PORTD : (((P) == 9 || (P) == 10) ? &PORTC : (((P) >= 17 && (P) <= 21)) ? &PORTF : (((P) == 24) ? &PORTE : &PORTB)))
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
(((P) == 22 || (P) == 23 || (P) == 5 || (P) == 6 || (P) == 7 || (P) == 8 || (P) == 11 || (P) == 12) ? &DDRD : (((P) == 9 || (P) == 10) ? &DDRC : (((P) >= 17 && (P) <= 21)) ? &DDRF : (((P) == 24) ? &DDRE : &DDRB)))
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
(((P) == 22 || (P) == 23 || (P) == 5 || (P) == 6 || (P) == 7 || (P) == 8 || (P) == 11 || (P) == 12) ? &PIND : (((P) == 9 || (P) == 10) ? &PINC : (((P) >= 17 && (P) <= 21)) ? &PINF : (((P) == 24) ? &PINE : &PINB)))
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 0 && (P) <= 3) ? (P) : (((P) >= 5 && (P) < 9) ? (P) - 5 : (((P) == 4) ? 7 : (((P) == 9) ? 6 : (((P) == 10) ? 7 : \
|
||||||
|
(((P) == 11) ? 6 : (((P) == 12) ? 7 : (((P) == 13) ? 4 : (((P) == 14) ? 5 : (((P) == 15) ? 6 : (((P) == 16) ? 7 :\
|
||||||
|
(((P) == 17) ? 6 : (((P) == 18) ? 5 : (((P) == 19) ? 4 : (((P) == 20) ? 1 : (((P) == 21) ? 0 : (((P) == 22) ? 4 : (((P) == 23) ? 5 :\
|
||||||
|
(((P) == 24) ? 6 : 6 )))))))))))))))))))
|
||||||
|
|
||||||
|
// --- Arduino Leonardo ---
|
||||||
|
#elif (defined(ARDUINO_AVR_LEONARDO) || \
|
||||||
|
defined(__AVR_ATmega16U4__) || \
|
||||||
|
defined(__AVR_ATmega32U4__))
|
||||||
|
|
||||||
|
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PORTD : (((P) == 5 || (P) == 13) ? &PORTC : (((P) >= 18 && (P) <= 23)) ? &PORTF : (((P) == 7) ? &PORTE : &PORTB)))
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &DDRD : (((P) == 5 || (P) == 13) ? &DDRC : (((P) >= 18 && (P) <= 23)) ? &DDRF : (((P) == 7) ? &DDRE : &DDRB)))
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
((((P) >= 0 && (P) <= 4) || (P) == 6 || (P) == 12 || (P) == 24 || (P) == 25 || (P) == 29) ? &PIND : (((P) == 5 || (P) == 13) ? &PINC : (((P) >= 18 && (P) <= 23)) ? &PINF : (((P) == 7) ? &PINE : &PINB)))
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 8 && (P) <= 11) ? (P) - 4 : (((P) >= 18 && (P) <= 21) ? 25 - (P) : (((P) == 0) ? 2 : (((P) == 1) ? 3 : (((P) == 2) ? 1 : (((P) == 3) ? 0 : (((P) == 4) ? 4 : (((P) == 6) ? 7 : (((P) == 13) ? 7 : (((P) == 14) ? 3 : (((P) == 15) ? 1 : (((P) == 16) ? 2 : (((P) == 17) ? 0 : (((P) == 22) ? 1 : (((P) == 23) ? 0 : (((P) == 24) ? 4 : (((P) == 25) ? 7 : (((P) == 26) ? 4 : (((P) == 27) ? 5 : 6 )))))))))))))))))))
|
||||||
|
|
||||||
|
|
||||||
|
// --- Arduino Uno ---
|
||||||
|
#elif (defined(ARDUINO_AVR_UNO) || \
|
||||||
|
defined(ARDUINO_AVR_DUEMILANOVE) || \
|
||||||
|
defined(__AVR_ATmega328__) || \
|
||||||
|
defined(__AVR_ATmega328P__) || \
|
||||||
|
defined(__AVR_ATmega328PB__))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(__AVR_ATmega328PB__)
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : (((P) >= 14 && (P) <= 19) ? &PORTC : &PORTE)))
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : (((P) >= 14 && (P) <= 19) ? &DDRC : &DDRE)))
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : (((P) >= 14 && (P) <= 19) ? &PINC : &PINE)))
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (((P) >= 14 && (P) <= 19) ? (P) - 14 : (((P) >= 20 && (P) <= 21) ? (P) - 18 : (P) - 22))))
|
||||||
|
#else
|
||||||
|
#define __digitalPinToPortReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PORTD : (((P) >= 8 && (P) <= 13) ? &PORTB : &PORTC))
|
||||||
|
#define __digitalPinToDDRReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &DDRD : (((P) >= 8 && (P) <= 13) ? &DDRB : &DDRC))
|
||||||
|
#define __digitalPinToPINReg(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? &PIND : (((P) >= 8 && (P) <= 13) ? &PINB : &PINC))
|
||||||
|
#define __digitalPinToBit(P) \
|
||||||
|
(((P) >= 0 && (P) <= 7) ? (P) : (((P) >= 8 && (P) <= 13) ? (P) - 8 : (P) - 14))
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(AVR)
|
||||||
|
static byte ft_o,ft_p,ft_q,ft_r,ft_s,ft_t,ft_u,ft_v,ft_w,ft_x, ft_y, ft_z;
|
||||||
|
#define fastTouchRead(pin) \
|
||||||
|
( digitalWrite(pin, LOW), \
|
||||||
|
pinMode(pin, OUTPUT), \
|
||||||
|
delay(1), \
|
||||||
|
pinMode(pin, INPUT), \
|
||||||
|
/* disable interrupts */ \
|
||||||
|
BIT_SET(*__digitalPinToPortReg(pin), __digitalPinToBit(pin)), \
|
||||||
|
ft_o = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_p = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_q = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_r = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_s = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_t = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_u = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_v = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_w = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_x = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_y = *__digitalPinToPINReg(pin), \
|
||||||
|
ft_z = *__digitalPinToPINReg(pin), \
|
||||||
|
/* enable interrupts */ \
|
||||||
|
!(ft_p & (1<< __digitalPinToBit(pin))) + !(ft_q & (1<< __digitalPinToBit(pin))) + \
|
||||||
|
!(ft_r & (1<< __digitalPinToBit(pin))) + !(ft_s & (1<< __digitalPinToBit(pin))) + \
|
||||||
|
!(ft_t & (1<< __digitalPinToBit(pin)))+ !(ft_u & (1<< __digitalPinToBit(pin)))+ \
|
||||||
|
!(ft_v & (1<< __digitalPinToBit(pin)))+ !(ft_w & (1<< __digitalPinToBit(pin)))+ \
|
||||||
|
!(ft_x & (1<< __digitalPinToBit(pin)))+ !(ft_y & (1<< __digitalPinToBit(pin)))+ \
|
||||||
|
!(ft_z & (1<< __digitalPinToBit(pin))) )
|
||||||
|
#elif defined(_SAMD21_)
|
||||||
|
|
||||||
|
static volatile uint32_t ft_o,ft_p,ft_q,ft_r,ft_s,ft_t,ft_u,ft_v,ft_w,ft_x, ft_y, ft_z;
|
||||||
|
static volatile uint32_t ft_xo,ft_xp,ft_xq,ft_xr,ft_xs,ft_xt,ft_xu,ft_xv,ft_xw,ft_xx, ft_xy, ft_xz;
|
||||||
|
#define fastTouchRead(pin) \
|
||||||
|
( pinMode(pin, OUTPUT), \
|
||||||
|
digitalWrite(pin, LOW), \
|
||||||
|
delay(1), \
|
||||||
|
pinMode(pin, INPUT_PULLUP), \
|
||||||
|
/* disable interrupts */ \
|
||||||
|
ft_p = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_q = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_r = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_s = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_t = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_u = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_v = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_w = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_x = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_y = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_z = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xo = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xp = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xq = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xr = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xs = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xt = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xu = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xv = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xw = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xx = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xy = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
ft_xz = PORT->Group[g_APinDescription[pin].ulPort].IN.reg, \
|
||||||
|
/* enable interrupts */ \
|
||||||
|
!(ft_p & (1ul << g_APinDescription[pin].ulPin)) + !(ft_q & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_r & (1ul << g_APinDescription[pin].ulPin)) + !(ft_s & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_t & (1ul << g_APinDescription[pin].ulPin)) + !(ft_u & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_v & (1ul << g_APinDescription[pin].ulPin)) + !(ft_w & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_x & (1ul << g_APinDescription[pin].ulPin)) + !(ft_y & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_z & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xo & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xp & (1ul << g_APinDescription[pin].ulPin)) + !(ft_xq & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xr & (1ul << g_APinDescription[pin].ulPin)) + !(ft_xs & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xt & (1ul << g_APinDescription[pin].ulPin)) + !(ft_xu & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xv & (1ul << g_APinDescription[pin].ulPin)) + !(ft_xw & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xx & (1ul << g_APinDescription[pin].ulPin)) + !(ft_xy & (1ul << g_APinDescription[pin].ulPin)) + \
|
||||||
|
!(ft_xz & (1ul << g_APinDescription[pin].ulPin)) \
|
||||||
|
)
|
||||||
|
|
||||||
|
#else
|
||||||
|
int fastTouchRead( int );
|
||||||
|
extern int fastTouchMax(void);
|
||||||
|
#endif
|
||||||
|
#endif /* FastTouch_h */
|
||||||
377
sketch_42line/sketch_42line.ino
Normal file
377
sketch_42line/sketch_42line.ino
Normal file
@ -0,0 +1,377 @@
|
|||||||
|
#include <FASTSENSOR.h>
|
||||||
|
#include <WORDS.h>
|
||||||
|
#include <Audio.h>
|
||||||
|
#include <SOUND.h>
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* TOUCH
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
static const int PIN_A = 1; // white
|
||||||
|
static const int PIN_B = 3; // red
|
||||||
|
static const int PIN_C = 5; // black
|
||||||
|
static const int PIN_D = 16; // green
|
||||||
|
static const int PIN_E = 17; // yellow
|
||||||
|
static const int PIN_F = 22; // blue -> orange -> yellow
|
||||||
|
|
||||||
|
static int cutoff = 20;
|
||||||
|
|
||||||
|
SENSOR_t s_A(PIN_A, cutoff);
|
||||||
|
SENSOR_t s_B(PIN_B, cutoff);
|
||||||
|
SENSOR_t s_C(PIN_C, cutoff);
|
||||||
|
SENSOR_t s_D(PIN_D, cutoff);
|
||||||
|
SENSOR_t s_E(PIN_E, cutoff);
|
||||||
|
SENSOR_t s_F(PIN_F, cutoff);
|
||||||
|
|
||||||
|
static int READ_DELAY = 150;
|
||||||
|
|
||||||
|
///forward declare
|
||||||
|
|
||||||
|
void synth_toggle(bool p, int pin);
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* WORDS
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
static E_WORDS voice_A_words[] = {E1, E2, L0, L1, L2};
|
||||||
|
static E_WORDS voice_B_words[] = {E3, L3};
|
||||||
|
static E_WORDS voice_C_words[] = {E4, E5, E6, L4, L5, L6};
|
||||||
|
static E_WORDS voice_D_words[] = {E7, E8, E9, L7, L8, L9, L10};
|
||||||
|
static E_WORDS voice_E_words[] = {E10, E11, E12, E13, L11, L12};
|
||||||
|
|
||||||
|
static int MAX_WORD = 4;
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* AUDIO
|
||||||
|
------------------------*/
|
||||||
|
// Use these with the Teensy 4 Audio Shield
|
||||||
|
#define SDCARD_CS_PIN 10
|
||||||
|
#define SDCARD_MOSI_PIN 11
|
||||||
|
#define SDCARD_SCK_PIN 13
|
||||||
|
#define SDCARD_SCK_PIN 13
|
||||||
|
|
||||||
|
|
||||||
|
AudioOutputI2S audioOutput;
|
||||||
|
AudioControlSGTL5000 sgtl5000_1;
|
||||||
|
|
||||||
|
// WAV
|
||||||
|
|
||||||
|
AudioPlaySdWav wav_A;
|
||||||
|
AudioPlaySdWav wav_B;
|
||||||
|
AudioPlaySdWav wav_C;
|
||||||
|
AudioPlaySdWav wav_D;
|
||||||
|
AudioPlaySdWav wav_E;
|
||||||
|
AudioPlaySdWav wav_F;
|
||||||
|
|
||||||
|
WAVPLAY_t wavplay_A(PIN_A, &wav_A, EA, LA, voice_A_words, 5, synth_toggle);
|
||||||
|
WAVPLAY_t wavplay_B(PIN_B, &wav_B, EB, LB, voice_B_words, 2, synth_toggle);
|
||||||
|
WAVPLAY_t wavplay_C(PIN_C, &wav_C, EC, LC, voice_C_words, 6, synth_toggle);
|
||||||
|
WAVPLAY_t wavplay_D(PIN_D, &wav_D, ED, LD, voice_D_words, 7, synth_toggle);
|
||||||
|
WAVPLAY_t wavplay_E(PIN_E, &wav_E, EE, LE, voice_E_words, 6, synth_toggle);
|
||||||
|
|
||||||
|
AudioMixer4 wav_mixer1;
|
||||||
|
AudioMixer4 wav_mixer2;
|
||||||
|
|
||||||
|
AudioConnection patchCordA1(wav_A, 0, wav_mixer1, 0);
|
||||||
|
AudioConnection patchCordA2(wav_A, 1, wav_mixer2, 0);
|
||||||
|
AudioConnection patchCordB1(wav_B, 0, wav_mixer1, 1);
|
||||||
|
AudioConnection patchCordB2(wav_B, 1, wav_mixer2, 1);
|
||||||
|
AudioConnection patchCordC1(wav_C, 0, wav_mixer1, 2);
|
||||||
|
AudioConnection patchCordC2(wav_C, 1, wav_mixer2, 2);
|
||||||
|
AudioConnection patchCordD1(wav_D, 0, wav_mixer1, 3);
|
||||||
|
AudioConnection patchCordD2(wav_D, 1, wav_mixer2, 3);
|
||||||
|
|
||||||
|
// SYNTH
|
||||||
|
|
||||||
|
float freq = 300;
|
||||||
|
DETUNE_t synth(freq);
|
||||||
|
|
||||||
|
AudioMixer4 synth_mixer;
|
||||||
|
|
||||||
|
AudioConnection patchCord1(synth.sine3, 0, synth_mixer, 2);
|
||||||
|
AudioConnection patchCord2(synth.sine2, 0, synth_mixer, 1);
|
||||||
|
AudioConnection patchCord3(synth.sine1, 0, synth_mixer, 0);
|
||||||
|
|
||||||
|
// MIX
|
||||||
|
|
||||||
|
AudioMixer4 main_mixer_L;
|
||||||
|
AudioMixer4 main_mixer_R;
|
||||||
|
|
||||||
|
AudioConnection patchCord12(synth_mixer, 0, main_mixer_L, 1);
|
||||||
|
AudioConnection patchCord13(synth_mixer, 0, main_mixer_R, 1);
|
||||||
|
AudioConnection patchCord14(wav_mixer1, 0, main_mixer_L, 0);
|
||||||
|
AudioConnection patchCord15(wav_mixer2, 0, main_mixer_R, 0);
|
||||||
|
|
||||||
|
//!!!!-----!!!
|
||||||
|
|
||||||
|
AudioConnection patchCordE1(wav_E, 0, main_mixer_L, 2);
|
||||||
|
AudioConnection patchCordE2(wav_E, 1, main_mixer_R, 2);
|
||||||
|
AudioConnection patchCordF1(wav_F, 0, main_mixer_L, 3);
|
||||||
|
AudioConnection patchCordF2(wav_F, 1, main_mixer_R, 3);
|
||||||
|
|
||||||
|
//!!!!-----!!!
|
||||||
|
|
||||||
|
AudioConnection patchCord16(main_mixer_R, 0, audioOutput, 1);
|
||||||
|
AudioConnection patchCord17(main_mixer_L, 0, audioOutput, 0);
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* STATES
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
SENSOR_t* synth_sensor = NULL;
|
||||||
|
int synth_PIN = -1;
|
||||||
|
bool gain_up = false;
|
||||||
|
|
||||||
|
float synth_gain_v = 0;
|
||||||
|
float synth_gain_max = 0.7;
|
||||||
|
float synth_gain_interval_ms = 1500;
|
||||||
|
float synth_gain_increments_ms = 0.01;
|
||||||
|
long synth_last_increment = 0;
|
||||||
|
|
||||||
|
bool sensor_touch[6] = {false, false, false, false, false, false};
|
||||||
|
|
||||||
|
void synth_toggle(bool p, int pin) {
|
||||||
|
if(synth_PIN == pin && !p) {
|
||||||
|
gain_up = false;
|
||||||
|
synth_gain(0);
|
||||||
|
synth_sensor = NULL;
|
||||||
|
synth_PIN = -1;
|
||||||
|
} else if(p && synth_PIN < 0) {
|
||||||
|
synth_PIN = pin;
|
||||||
|
if(pin == PIN_A) synth_sensor = &s_A;
|
||||||
|
else if(pin == PIN_B) synth_sensor = &s_B;
|
||||||
|
else if(pin == PIN_C) synth_sensor = &s_C;
|
||||||
|
else if(pin == PIN_D) synth_sensor = &s_D;
|
||||||
|
else if(pin == PIN_E) synth_sensor = &s_E;
|
||||||
|
else if(pin == PIN_F) synth_sensor = &s_F;
|
||||||
|
gain_up = true;
|
||||||
|
synth_gain(0.5);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void random_wav(AudioPlaySdWav* wav, E_WORDS* e_words) {
|
||||||
|
int w = (int)random(0, MAX_WORD);
|
||||||
|
wav->play(words[e_words[w]]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* CALLBACK
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
void toggle_signal_cb(bool p, int pin) {
|
||||||
|
|
||||||
|
SENSOR_t* sensor = NULL;
|
||||||
|
|
||||||
|
switch(pin) {
|
||||||
|
case PIN_A:
|
||||||
|
if(p) wavplay_A.play();
|
||||||
|
else wavplay_A.stop();
|
||||||
|
sensor = &s_A;
|
||||||
|
sensor_touch[0] = p;
|
||||||
|
break;
|
||||||
|
case PIN_B:
|
||||||
|
if(p) wavplay_B.play();
|
||||||
|
else wavplay_B.stop();
|
||||||
|
sensor = &s_B;
|
||||||
|
sensor_touch[1] = p;
|
||||||
|
break;
|
||||||
|
case PIN_C:
|
||||||
|
if(p) wavplay_C.play();
|
||||||
|
else wavplay_C.stop();
|
||||||
|
sensor = &s_C;
|
||||||
|
sensor_touch[2] = p;
|
||||||
|
break;
|
||||||
|
case PIN_D:
|
||||||
|
if(p) wavplay_D.play();
|
||||||
|
else wavplay_D.stop();
|
||||||
|
sensor = &s_D;
|
||||||
|
sensor_touch[3] = p;
|
||||||
|
break;
|
||||||
|
case PIN_E:
|
||||||
|
if(p) wavplay_E.play();
|
||||||
|
else wavplay_E.stop();
|
||||||
|
sensor = &s_E;
|
||||||
|
sensor_touch[4] = p;
|
||||||
|
break;
|
||||||
|
case PIN_F:
|
||||||
|
if(p) wavplay_B.play();
|
||||||
|
else wavplay_B.stop();
|
||||||
|
sensor = &s_F;
|
||||||
|
sensor_touch[5] = p;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// state_synth(p, pin, sensor);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* SETUPS
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
|
||||||
|
void setup() {
|
||||||
|
Serial.begin(57600);
|
||||||
|
|
||||||
|
setup_audio();
|
||||||
|
|
||||||
|
setup_sensors();
|
||||||
|
|
||||||
|
synth_gain(0);
|
||||||
|
wav_gain(0.75);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_sensors() {
|
||||||
|
// baselines
|
||||||
|
s_A.baseline(50, 50);
|
||||||
|
s_B.baseline(50, 50);
|
||||||
|
s_C.baseline(50, 50);
|
||||||
|
s_D.baseline(50, 50);
|
||||||
|
s_E.baseline(50, 50);
|
||||||
|
s_F.baseline(50, 50);
|
||||||
|
|
||||||
|
// callbacks
|
||||||
|
s_A.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
s_B.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
s_C.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
s_D.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
s_E.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
s_F.plug_toggle_cb(toggle_signal_cb);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setup_audio() {
|
||||||
|
AudioMemory(8);
|
||||||
|
sgtl5000_1.enable();
|
||||||
|
sgtl5000_1.volume(0.5);
|
||||||
|
SPI.setMOSI(SDCARD_MOSI_PIN);
|
||||||
|
SPI.setSCK(SDCARD_SCK_PIN);
|
||||||
|
if (!(SD.begin(SDCARD_CS_PIN))) {
|
||||||
|
while (1) {
|
||||||
|
Serial.println("Unable to access the SD card");
|
||||||
|
delay(1000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* LOOP
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
void loop() {
|
||||||
|
|
||||||
|
s_A.update();
|
||||||
|
s_B.update();
|
||||||
|
s_C.update();
|
||||||
|
s_D.update();
|
||||||
|
s_E.update();
|
||||||
|
s_F.update();
|
||||||
|
|
||||||
|
// float synth_gain_max = 0.5;
|
||||||
|
// float synth_gain_interval_ms = 1500;
|
||||||
|
// float synth_gain_increments_ms = synth_gain_max / 1500;
|
||||||
|
// long synth_last_increment = -1;
|
||||||
|
|
||||||
|
if(synth_PIN > 0) {
|
||||||
|
int d = synth_sensor->map_range_raw(0, freq);
|
||||||
|
synth.set_detune(d);
|
||||||
|
|
||||||
|
// if(gain_up && synth_gain_v < synth_gain_max) {
|
||||||
|
// synth_gain_v += synth_gain_increments_ms;
|
||||||
|
// if(synth_gain_v > synth_gain_max)
|
||||||
|
// synth_gain_v = synth_gain_max;
|
||||||
|
// synth_gain(synth_gain_v);
|
||||||
|
|
||||||
|
// } else if(!gain_up && synth_gain_v > 0) {
|
||||||
|
// synth_gain_v -= synth_gain_increments_ms;
|
||||||
|
// if(synth_gain_v < 0) {
|
||||||
|
// synth_gain_v = 0;
|
||||||
|
// synth_sensor = NULL;
|
||||||
|
// synth_PIN = -1;
|
||||||
|
// }
|
||||||
|
// synth_gain(synth_gain_v);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
if(sensor_touch[0]) wavplay_A.update();
|
||||||
|
if(sensor_touch[1]) wavplay_B.update();
|
||||||
|
if(sensor_touch[2]) wavplay_C.update();
|
||||||
|
if(sensor_touch[3]) wavplay_D.update();
|
||||||
|
if(sensor_touch[4]) wavplay_E.update();
|
||||||
|
if(sensor_touch[5]) wavplay_B.update();
|
||||||
|
|
||||||
|
serial_plot_range(0, 100);
|
||||||
|
// serial_plot();
|
||||||
|
// serial_plot_base();
|
||||||
|
// serial_plot_range(0, 100);
|
||||||
|
|
||||||
|
delay(READ_DELAY);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* GAIN FUNCS
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
void synth_gain(float g){
|
||||||
|
synth_mixer.gain(0, g);
|
||||||
|
synth_mixer.gain(1, g);
|
||||||
|
synth_mixer.gain(2, g);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wav_gain(float g){
|
||||||
|
wav_mixer1.gain(0, g);
|
||||||
|
wav_mixer1.gain(1, g);
|
||||||
|
wav_mixer1.gain(2, g);
|
||||||
|
wav_mixer1.gain(3, g);
|
||||||
|
|
||||||
|
wav_mixer2.gain(0, g);
|
||||||
|
wav_mixer2.gain(1, g);
|
||||||
|
wav_mixer2.gain(2, g);
|
||||||
|
wav_mixer2.gain(3, g);
|
||||||
|
|
||||||
|
// shoudl add wav_e + f but whatever
|
||||||
|
}
|
||||||
|
|
||||||
|
/*-----------------------
|
||||||
|
* PLOT FUNCS
|
||||||
|
------------------------*/
|
||||||
|
|
||||||
|
void serial_plot_range(int min_v, int max_v) {
|
||||||
|
Serial.print(s_A.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.print(s_B.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.print(s_C.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.print(s_D.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.print(s_E.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.print(s_F.map_range(min_v, max_v)); Serial.print(" ");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial_plot_base(){
|
||||||
|
Serial.print(s_A.base); Serial.print(" ");
|
||||||
|
Serial.print(s_B.base); Serial.print(" ");
|
||||||
|
Serial.print(s_C.base); Serial.print(" ");
|
||||||
|
Serial.print(s_D.base); Serial.print(" ");
|
||||||
|
Serial.print(s_E.base); Serial.print(" ");
|
||||||
|
Serial.print(s_F.base); Serial.print(" ");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial_plot() {
|
||||||
|
Serial.print(s_A.v); Serial.print(" ");
|
||||||
|
Serial.print(s_B.v); Serial.print(" ");
|
||||||
|
Serial.print(s_C.v); Serial.print(" ");
|
||||||
|
Serial.print(s_D.v); Serial.print(" ");
|
||||||
|
Serial.print(s_E.v); Serial.print(" ");
|
||||||
|
Serial.print(s_F.v); Serial.print(" ");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
|
|
||||||
|
void serial_plot_dv() {
|
||||||
|
Serial.print(s_A.dv); Serial.print(" ");
|
||||||
|
Serial.print(s_B.dv); Serial.print(" ");
|
||||||
|
Serial.print(s_C.dv); Serial.print(" ");
|
||||||
|
Serial.print(s_D.dv); Serial.print(" ");
|
||||||
|
Serial.print(s_E.dv); Serial.print(" ");
|
||||||
|
Serial.print(s_F.dv); Serial.print(" ");
|
||||||
|
Serial.println("");
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user