Commit 6c9dafc8 authored by Jeroen Vreeken's avatar Jeroen Vreeken
Browse files

Clarify 2nd order filter code.

parent 28f20769
......@@ -29,6 +29,7 @@ dt_ui_color_text_title = "blue";
dt_ui_color_background = "lightgrey";
dt_ui_color_background_value = "white";
dt_ui_color_background_title = "silver";
dt_ui_color_border = "black";
dt_ui_color_indicator_off = "grey";
dt_ui_color_indicator_green = "#00ff00";
dt_ui_color_indicator_red = "#ff0000";
......@@ -274,7 +275,7 @@ function dt_ui_canvas(elementid)
this.element.style.borderStyle = "solid";
this.element.style.borderWidth = "1px";
this.element.style.borderColor = "black";
this.element.style.borderColor = dt_ui_color_border;
dt_ui_element.call(this, elementid);
}
......@@ -286,7 +287,7 @@ function dt_ui_title(elementid)
dt_ui_element.call(this, elementid);
this.title_set("untitled");
this.element.style.whiteSpace = "nowrap";
this.element.style.borderColor = "black";
this.element.style.borderColor = dt_ui_color_border;
this.element.style.borderStyle = "solid";
this.element.style.borderTopWidth = "0px";
this.element.style.borderBottomWidth = "1px";
......@@ -321,7 +322,9 @@ function dt_ui_window(elementid)
this.content.padding_height = dt_ui_padding_height_window;
this.content.padding_width = dt_ui_padding_width_window;
this.element.style.border = "thin solid black";
this.element.style.border = "thin";
this.element.style.borderColor = dt_ui_color_border;
this.element.style.borderStyle = "solid";
this.element.style.background = dt_ui_color_background;
this.element.style.position = "relative";
}
......@@ -408,7 +411,7 @@ function dt_ui_value(elementid)
this.align = "center";
this.element.style.borderStyle = "solid";
this.element.style.borderWidth = "1px";
this.element.style.borderColor = "black";
this.element.style.borderColor = dt_ui_color_border;
this.element.style.background = dt_ui_color_background_value;
this.element.style.alignContent = "center";
this.element.style.textAlign = this.align;
......
/*
Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2007
Copyright Jeroen Vreeken (jeroen@vreeken.net), 2007, 2015
Copyright Stichting C.A. Muller Radioastronomiestation, 2007
This program is free software: you can redistribute it and/or modify
......@@ -49,6 +49,11 @@ struct controller_block_private {
struct block_filter_iir_param param;
};
#define INDEX_ZERO 1
#define INDEX_POLE 0
#define INDEX_X 2
#define INDEX_Y 3
static void filter_iir_calculate(struct controller_block *iir)
{
struct controller_block_private *priv = iir->private;
......@@ -59,7 +64,7 @@ static void filter_iir_calculate(struct controller_block *iir)
float out;
ind = priv->ind;
transfer[ind][2] = input0;
transfer[ind][INDEX_X] = input0;
len = priv->len;
ind++;
ind = ind % len;
......@@ -70,10 +75,10 @@ static void filter_iir_calculate(struct controller_block *iir)
for (i = 0; i < len; i++) {
int j = (i + ind) % len;
out += transfer[i][1] * transfer[j][2];
out += transfer[i][0] * transfer[j][3];
out += transfer[i][INDEX_ZERO] * transfer[j][INDEX_X];
out += transfer[i][INDEX_POLE] * transfer[j][INDEX_Y];
}
transfer[ind][3] = out;
transfer[ind][INDEX_Y] = out;
priv->out = out;
}
......@@ -108,18 +113,20 @@ static int param_set(struct controller_block *iir, char *param, int argc,
iir->private->len = 0;
return -1;
}
iir->private->transfer[0][0] = 0;
iir->private->transfer[iir->private->param.len ][1] =
/* All zeros are prescaled with inverse gain */
iir->private->transfer[0][INDEX_POLE] = 0;
/* x0 input coefficient is always 1.0 */
iir->private->transfer[iir->private->param.len ][INDEX_ZERO] =
1.0 / iir->private->param.gain;
for (i = 0; i < iir->private->param.len; i++) {
iir->private->transfer[i + 1][0] =
iir->private->transfer[i + 1][INDEX_POLE] =
iir->private->param.poles[i];
iir->private->transfer[i][1] =
iir->private->transfer[i][INDEX_ZERO] =
iir->private->param.zeros[i] / iir->private->param.gain;
}
for (i = 0; i < iir->private->len; i++) {
iir->private->transfer[i][2] = 0;
iir->private->transfer[i][3] = 0;
iir->private->transfer[i][INDEX_X] = 0;
iir->private->transfer[i][INDEX_Y] = 0;
}
iir->private->ind = 0;
iir->private->out = 0;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment