sunlightmeter

package
v0.0.0-...-f368eb9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 18, 2024 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MAX_JOB_DURATION = 8 * time.Hour
	RECORD_INTERVAL  = 30 * time.Second
	DB_PATH          = "sunlightmeter.db"
)

Variables

This section is empty.

Functions

func ServeResponse

func ServeResponse(w http.ResponseWriter, r *http.Request, message string, status int)

Populate the response div with a message, or reply with a JSON message

Types

type Conditions

type Conditions struct {
	JobID                 string  `json:"jobID"`
	Lux                   float64 `json:"lux"`
	FullSpectrum          float64 `json:"fullSpectrum"`
	Visible               float64 `json:"visible"`
	Infrared              float64 `json:"infrared"`
	DateRange             string  `json:"dateRange"`
	RecordedHoursInRange  float64 `json:"recordedHoursInRange"`
	FullSunlightInRange   float64 `json:"fullSunlightInRange"`
	LightConditionInRange string  `json:"lightConditionInRange"`
	AverageLuxInRange     float64 `json:"averageLuxInRange"`
}

type LuxResults

type LuxResults struct {
	Lux          float64
	Infrared     float64
	Visible      float64
	FullSpectrum float64
	JobID        string
}

type SLMeter

type SLMeter struct {
	*tsl2591.TSL2591
	LuxResultsChan chan LuxResults
	ResultsDB      *sql.DB

	Pid int
	// contains filtered or unexported fields
}

func (*SLMeter) Clear

func (m *SLMeter) Clear() http.HandlerFunc

Used to clear a div with htmx

func (*SLMeter) CurrentConditions

func (m *SLMeter) CurrentConditions() http.HandlerFunc

Serve data about the most recent entry saved to the db

func (*SLMeter) MonitorAndRecordResults

func (m *SLMeter) MonitorAndRecordResults()

Read from LuxResultsChan, write the results to sqlite

func (*SLMeter) ServeDashboard

func (m *SLMeter) ServeDashboard() http.HandlerFunc

Serve the homepage

func (*SLMeter) ServeResultsDB

func (m *SLMeter) ServeResultsDB() http.HandlerFunc

Serve the sqlite db for download

func (*SLMeter) ServeResultsGraph

func (m *SLMeter) ServeResultsGraph() http.HandlerFunc

Serve the results graph

func (*SLMeter) ServeResultsTab

func (m *SLMeter) ServeResultsTab() http.HandlerFunc

Update the info in the results tab

func (*SLMeter) ServeSensorStatus

func (m *SLMeter) ServeSensorStatus() http.HandlerFunc

Status of the sensor

func (*SLMeter) ServeSunlightControls

func (m *SLMeter) ServeSunlightControls() http.HandlerFunc

Serve the controls for the sensor, start/stop/export/current-conditions/signal-strength

func (*SLMeter) SignalStrength

func (m *SLMeter) SignalStrength() http.HandlerFunc

Check the signal strength of the wifi connection

func (*SLMeter) Start

func (m *SLMeter) Start() http.HandlerFunc

Start the sensor, and collect data in a loop

func (*SLMeter) Stop

func (m *SLMeter) Stop() http.HandlerFunc

Stop the sensor, and cancel the job context

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL