This commit is contained in:
William Clark 2023-11-21 14:57:53 +00:00
parent a58f3e8b5f
commit e2d57edf45
5 changed files with 10 additions and 14 deletions

View File

@ -99,7 +99,7 @@ func Load() (config.Config, error) {
} }
c.Thermo = tc c.Thermo = tc
c.Filter.SampleSize = v.GetInt(head+".filter.samples") c.Filter.SampleSize = v.GetInt(head + ".filter.samples")
cfg.Channels = append(cfg.Channels, c) cfg.Channels = append(cfg.Channels, c)
} }

View File

@ -15,8 +15,6 @@ const (
DurWaitRestart = 1000 * time.Millisecond DurWaitRestart = 1000 * time.Millisecond
) )
// Continuously sample each configured channel, apply filter, and save result // Continuously sample each configured channel, apply filter, and save result
// in a mutex controlled shared data object, that can be accessed at any time // in a mutex controlled shared data object, that can be accessed at any time
// by a web-request or similar. // by a web-request or similar.
@ -42,7 +40,7 @@ func startCacheService(t *TH7Adapter) {
channel_id := t.cfg.Channels[channel].Id channel_id := t.cfg.Channels[channel].Id
channel_gain := t.cfg.Channels[channel].Gain channel_gain := t.cfg.Channels[channel].Gain
for i:=0; i<t.cfg.Channels[channel].Filter.SampleSize; i++ { for i := 0; i < t.cfg.Channels[channel].Filter.SampleSize; i++ {
// update vref table // update vref table
t.pcbPort.UpdateTable() t.pcbPort.UpdateTable()
measurement := t.pcbPort.ReadChannel(channel_id, channel_gain) measurement := t.pcbPort.ReadChannel(channel_id, channel_gain)

View File

@ -1,6 +1,5 @@
package core package core
type Channel struct { type Channel struct {
Id int `json:"id"` Id int `json:"id"`
Value float64 `json:"value"` Value float64 `json:"value"`

View File

@ -1,6 +1,5 @@
package filter package filter
func AlphaBetaFilter(arr []float64, init float64) float64 { func AlphaBetaFilter(arr []float64, init float64) float64 {
value := init value := init