Code:
//*************************************************************************
// draw_filter_curves to LCD
//*************************************************************************
void draw_filter_curves (void)
{
// clear old curve
disp.fillRect(20,48,112,38,ST7735_BLACK);
// draw filter lowpass curve ------------------------------------------
const uint8_t x_plot = 68;
const uint8_t y_plot = 85;
uint8_t x = 40;
uint16_t r = 0;
uint8_t y = 0;
uint8_t y_ = 0;
uint8_t i = 0;
uint8_t i_ = 0;
uint8_t q_typ = 12; // Filter Q
uint16_t resonance = 0;
// pot_1 cutoff value
// pot_2 resonancy
for (i = 0; i < 48; i++)
{
resonance = (Filter_curve[(i * 8)]);
resonance = (((resonance >> 2) * pot_2) >> 7);
r = (x + r - y) + resonance;
y = r / q_typ;
disp.drawLine((pot_1 / 2) + x_plot - i_,(y_plot - y_ / 2), (pot_1 / 2) + x_plot - i, (y_plot - y / 2),ST7735_RED);
i_ = i;
y_ = y;
}
disp.drawLine(20, (y_plot - y_ / 2), 20 + (pot_1 / 2), (y_plot - y_ / 2), ST7735_RED);
}
// Sine filter curv ----------------------------
const byte Filter_curve[385] PROGMEM = {
1, 2, 2, 3, 2, 3, 3, 4,
5, 4, 7, 5, 9, 7, 10, 11,
11, 13, 13, 17, 16, 18, 21, 21,
23, 25, 27, 28, 32, 31, 36, 36,
39, 41, 43, 46, 48, 51, 53, 55,
57, 62, 63, 65, 70, 70, 75, 76,
81, 82, 85, 89, 92, 94, 97, 100,
104, 107, 109, 112, 116, 119, 122, 124,
129, 130, 135, 137, 140, 144, 147, 148,
154, 155, 158, 163, 163, 169, 169, 174,
177, 178, 182, 185, 187, 191, 192, 195,
199, 200, 203, 205, 209, 210, 212, 216,
216, 220, 221, 223, 226, 227, 230, 230,
233, 235, 235, 239, 238, 241, 242, 243,
245, 245, 246, 249, 247, 251, 249, 252,
251, 252, 253, 253, 253, 254, 254, 254,
253, 255, 254, 253, 253, 254, 252, 253,
251, 251, 250, 250, 248, 248, 246, 246,
245, 242, 243, 240, 239, 238, 236, 234,
233, 231, 230, 226, 226, 224, 221, 219,
217, 215, 212, 211, 208, 206, 202, 201,
198, 196, 192, 190, 188, 184, 182, 179,
177, 173, 170, 168, 164, 162, 158, 156,
153, 149, 147, 143, 141, 136, 135, 131,
128, 125, 122, 118, 116, 113, 109, 106,
104, 101, 96, 95, 92, 88, 85, 83,
80, 77, 74, 71, 69, 66, 63, 61,
57, 56, 53, 50, 49, 45, 43, 42,
38, 37, 35, 32, 31, 29, 26, 26,
22, 22, 20, 19, 16, 16, 13, 14,
11, 10, 10, 8, 8, 6, 6, 5,
4, 5, 2, 3, 2, 2, 2, 3,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0,
};