ERIS CORE
eris_analyze_scope.h
Go to the documentation of this file.
1 /* Audio Library for Teensy 3.X
2  * Copyright (c) 2014, Paul Stoffregen, paul@pjrc.com
3  *
4  * Development of this audio library was funded by PJRC.COM, LLC by sales of
5  * Teensy and Audio Adaptor boards. Please support PJRC's efforts to develop
6  * open source software by purchasing Teensy or other PJRC products.
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a copy
9  * of this software and associated documentation files (the "Software"), to deal
10  * in the Software without restriction, including without limitation the rights
11  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12  * copies of the Software, and to permit persons to whom the Software is
13  * furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice, development funding notice, and this permission
16  * notice shall be included in all copies or substantial portions of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24  * THE SOFTWARE.
25  */
26 
27 
28 /**
29  * @file eris_analyze_scope.h
30  * @author Brian Monkaba (brian.monkaba@gmail.com)
31  * @brief
32  * @version 0.1
33  * @date 2021-08-24
34  *
35  * @copyright portions Copyright (c) 2021
36  *
37  */
38 
39 
40 
41 #ifndef eris_analyze_scope_h_
42 #define eris_analyze_scope_h_
43 
44 #include "Arduino.h"
45 #include "AudioStream.h"
46 
47 
48 #define OSCOPE_CAPTURE_LENGTH 640
49 
51 {
52 public:
54  myname(NULL), state(0), trigger_edge(0), delay_length(0), mem_length(OSCOPE_CAPTURE_LENGTH/2) {
55  short_name="scope";
56  unum_inputs=2;
57  unum_outputs=0;
58  category="analyze-function";
59  count = 0;
60  trigger_level = 0;
61  hdivide(5);
62  autoTrigger = true;
63  isAvailable = false;
65  edgeCount = 0;
66  edgeCount_ch2 = 0;
67  peakValue = 0;
68  peakValue_output = 0;
69  dot=0;
70  dotAvg=0;
71  dotLast=0;
72  dotAvgSlow=0;
73  dotDelta = 0;
74  dotAccel=0;
75  dotDeltaMACD=0;
76  dotMACD=0;
77  edgeTimer=0;
78  edgeDelay=0;
79  edgeTimer2=0;
80  edgeDelay2=0;
81 
82  //buffered outputs
83  edgeCount_output = 0;
85  dot_output=0;
86  dotAvg_output=0;
89  dotDelta_output = 0;
95 
96  memset(memory[0],0,sizeof(memory[0]));
97  memset(memory[1],0,sizeof(memory[1]));
98 
99  }
100 
101  virtual void update(void);
102  void name(const char *str) { myname = str; }
103  void trigger(void);
104  void trigger(float level, int edge);
105  void delay(uint32_t num) { delay_length = num; }
106  void length(uint32_t num) { mem_length = num; }
107  int16_t read(int8_t channel, uint16_t mem_index);
108  int16_t getPeakValue(){return peakValue_output;}
109  bool available(void);
110  void hdivide(int8_t horizontal_division){h_div = horizontal_division;auto_h_div = h_div; h_div_count=0;};
111  uint8_t getHDiv(){return h_div;}
112  int32_t getDotProduct(){return dot_output;}
113  int32_t getDotProductAvg(){return dotAvg_output;}
115  int32_t getDotMACD(){return dotMACD_output;}
116  int32_t getDotDelta(){return dotDelta_output;}
119  int32_t getEdgeCount(){return edgeCount_output;}
121  int32_t getEdgeDelay(){return edgeDelay_output;}
122  int32_t getEdgeDelay2(){return edgeDelay2_output;}
123 
124 private:
125  const char *myname;
126  uint8_t state;
127  int16_t memory[2][OSCOPE_CAPTURE_LENGTH] __attribute__ ((aligned (4))); //buffered output
128  int16_t _memory[2][OSCOPE_CAPTURE_LENGTH] __attribute__ ((aligned (4))); //working memory
131  uint8_t h_div;
132  int8_t h_div_count;
133  int8_t auto_h_div;
134  uint8_t trigger_edge; // trigger type, 0=none, 2=RISING, 3=FALLING
135  int16_t trigger_level;
137  uint32_t delay_length; // number of samples between trigger and sampling
138  uint32_t mem_length; // number of samples to capture
139  uint32_t edgeCount;
140  uint32_t edgeCount_ch2;
141  uint32_t count;
142  int16_t peakValue;
143  uint32_t edgeTimer;
144  uint32_t edgeDelay;
145  uint32_t edgeTimer2;
146  uint32_t edgeDelay2;
147  q63_t dot;
148  q63_t dotLast;
149  int32_t dotAvg;
150  int32_t dotAvgSlow;
151  int32_t dotDelta;
152  int32_t dotAccel;
153  int32_t dotDeltaMACD;
154  int32_t dotMACD;
155  //buffered output
156  volatile int16_t peakValue_output;
157  volatile uint32_t edgeCount_output;
158  volatile uint32_t edgeCount_ch2_output;
159  volatile uint32_t edgeDelay_output;
160  volatile uint32_t edgeDelay2_output;
161  volatile q63_t dot_output;
162  volatile q63_t dotLast_output;
163  volatile int32_t dotAvg_output;
164  volatile int32_t dotAvgSlow_output;
165  volatile int32_t dotDelta_output;
166  volatile int32_t dotAccel_output;
167  volatile int32_t dotDeltaMACD_output;
168  volatile int32_t dotMACD_output;
169 
171 };
172 
173 #endif
uint8_t unum_outputs
Definition: AudioStream.h:187
uint8_t unum_inputs
Definition: AudioStream.h:186
const char * short_name
Definition: AudioStream.h:184
const char * category
Definition: AudioStream.h:185
volatile uint32_t edgeCount_output
volatile int32_t dotMACD_output
volatile int16_t peakValue_output
volatile q63_t dotLast_output
virtual void update(void)
volatile int32_t dotAvgSlow_output
volatile uint32_t edgeDelay_output
void hdivide(int8_t horizontal_division)
audio_block_t * inputQueueArray[2]
int16_t memory[2][OSCOPE_CAPTURE_LENGTH] __attribute__((aligned(4)))
volatile int32_t dotAccel_output
int16_t read(int8_t channel, uint16_t mem_index)
void length(uint32_t num)
volatile int32_t dotDelta_output
volatile uint32_t edgeDelay2_output
volatile int32_t dotDeltaMACD_output
void trigger(float level, int edge)
void delay(uint32_t num)
volatile uint32_t edgeCount_ch2_output
void name(const char *str)
volatile int32_t dotAvg_output
int16_t _memory[2][OSCOPE_CAPTURE_LENGTH] __attribute__((aligned(4)))