filter settings
This commit is contained in:
parent
e2d57edf45
commit
0ffeb62954
14
config.toml
14
config.toml
@ -1,28 +1,30 @@
|
||||
# TH7 demo configuration file.
|
||||
[TH7]
|
||||
port = 9090
|
||||
debug = true
|
||||
port = 9090 # web port
|
||||
debug = true # enable to use simulated PCB for development
|
||||
|
||||
[DB]
|
||||
type = "sqlite3"
|
||||
path = "test.db"
|
||||
freq = 60
|
||||
|
||||
[Channel_1]
|
||||
type = 'U'
|
||||
filter.samples = 100
|
||||
filter.type = 1
|
||||
|
||||
[Channel_2]
|
||||
type = 'N'
|
||||
unit = 'C'
|
||||
filter.samples = 20
|
||||
|
||||
[Channel_3]
|
||||
type = 'T'
|
||||
unit = 'C'
|
||||
|
||||
[Channel_4]
|
||||
type = 'K'
|
||||
unit = 'C'
|
||||
|
||||
[Channel_6]
|
||||
type = 'J'
|
||||
unit = 'C'
|
||||
offset = -23.1
|
||||
|
||||
|
||||
|
@ -12,20 +12,19 @@ import (
|
||||
|
||||
var (
|
||||
ErrConfigBadThermocoupleType = errors.New("unrecognised thermocouple type")
|
||||
ErrConfigBadTemperatureUnit = errors.New("unrecognised temperature unit")
|
||||
)
|
||||
|
||||
var (
|
||||
thermocoupleTypes = map[string]thermocouple.Type{
|
||||
"B": thermocouple.B,
|
||||
"E": thermocouple.E,
|
||||
"J": thermocouple.J,
|
||||
"K": thermocouple.K,
|
||||
"N": thermocouple.N,
|
||||
"R": thermocouple.R,
|
||||
"S": thermocouple.S,
|
||||
"T": thermocouple.T,
|
||||
"UV": thermocouple.None,
|
||||
"B": thermocouple.B,
|
||||
"E": thermocouple.E,
|
||||
"J": thermocouple.J,
|
||||
"K": thermocouple.K,
|
||||
"N": thermocouple.N,
|
||||
"R": thermocouple.R,
|
||||
"S": thermocouple.S,
|
||||
"T": thermocouple.T,
|
||||
"U": thermocouple.None, // for uV measurements
|
||||
}
|
||||
)
|
||||
|
||||
@ -100,6 +99,7 @@ func Load() (config.Config, error) {
|
||||
c.Thermo = tc
|
||||
|
||||
c.Filter.SampleSize = v.GetInt(head + ".filter.samples")
|
||||
c.Filter.Type = v.GetInt(head + ".filter.type")
|
||||
|
||||
cfg.Channels = append(cfg.Channels, c)
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
|
||||
type Filter struct {
|
||||
SampleSize int `json:"sample_size"`
|
||||
Type int `json:"type"`
|
||||
}
|
||||
|
||||
type Channel struct {
|
||||
|
@ -9,3 +9,33 @@ func AlphaBetaFilter(arr []float64, init float64) float64 {
|
||||
}
|
||||
return value
|
||||
}
|
||||
|
||||
// Simple lag filter. value = old * 0.9 + new * 0.1
|
||||
func Lag_1(arr []float64, init float64) float64 {
|
||||
value := init
|
||||
for i := range arr {
|
||||
value = value*0.9 + arr[i]*0.1
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
// Simple lag filter. value = old * 0.95 + new * 0.05
|
||||
func Lag_2(arr []float64, init float64) float64 {
|
||||
value := init
|
||||
for i := range arr {
|
||||
value = value*0.95 + arr[i]*0.05
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
// Simple lag filter. value = old * 0.99 + new * 0.01
|
||||
func Lag_3(arr []float64, init float64) float64 {
|
||||
value := init
|
||||
for i := range arr {
|
||||
value = value*0.99 + arr[i]*0.01
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user