Skip to content

Commit

Permalink
Unify naming
Browse files Browse the repository at this point in the history
  • Loading branch information
akares committed Nov 14, 2024
1 parent d8ce506 commit 5853e50
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/skread/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type JSONResponse struct {
Remote string `json:"Remote"`
Button string `json:"Button"`
Ring string `json:"Ring"`
Measurements []skreader.MeasurementJSON `json:"measurements"`
Measurements []skreader.MeasurementJSON `json:"Measurements"`
}

func skConnect() (*skreader.Device, error) {
Expand Down
18 changes: 9 additions & 9 deletions measurement_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ import "time"
type MeasurementJSON struct {
Name string `json:"Name"`
Note string `json:"Note"`
UnixTime int64 `json:"unixtime"`
Timestamp int64 `json:"Timestamp"`
Illuminance IlluminanceJSON `json:"Illuminance"`
ColorTemperature ColorTemperatureJSON `json:"ColorTemperature"`
Tristimulus TristimulusJSON `json:"Tristimulus"`
CIE1931 CIE1931JSON `json:"CIE1931"`
CIE1976 CIE1976JSON `json:"CIE1976"`
DWL DWLJSON `json:"DWL"`
CRI CRIJSON `json:"CRI"`
Wavelengths []WavelengthGroupJSON `json:"wavelengths"`
WaveLengths []WaveLengthGroupJSON `json:"WaveLengths"`
}

type IlluminanceJSON struct {
Expand Down Expand Up @@ -61,7 +61,7 @@ type CRIRiJSON struct {
Value float64 `json:"value"`
}

type WavelengthGroupJSON struct {
type WaveLengthGroupJSON struct {
Type string `json:"type"`
Waves []WaveJSON `json:"waves"`
}
Expand All @@ -73,9 +73,9 @@ type WaveJSON struct {

func NewFromMeasurement(meas *Measurement, measName, measNote string, measTime time.Time) MeasurementJSON {
res := MeasurementJSON{
Name: measName,
Note: measNote,
UnixTime: measTime.Unix(),
Name: measName,
Note: measNote,
Timestamp: measTime.Unix(),
Illuminance: IlluminanceJSON{
LUX: meas.Illuminance.Lux.Val,
Fc: meas.Illuminance.FootCandle.Val,
Expand Down Expand Up @@ -105,7 +105,7 @@ func NewFromMeasurement(meas *Measurement, measName, measNote string, measTime t
RA: meas.ColorRenditionIndexes.Ra.Val,
Ri: []CRIRiJSON{},
},
Wavelengths: []WavelengthGroupJSON{
WaveLengths: []WaveLengthGroupJSON{
{Type: "1nm", Waves: []WaveJSON{}},
{Type: "5nm", Waves: []WaveJSON{}},
},
Expand All @@ -121,15 +121,15 @@ func NewFromMeasurement(meas *Measurement, measName, measNote string, measTime t

// Populate 1nm
for i, val := range &meas.SpectralData1nm {
res.Wavelengths[0].Waves = append(res.Wavelengths[0].Waves, WaveJSON{
res.WaveLengths[0].Waves = append(res.WaveLengths[0].Waves, WaveJSON{
Nm: 380 + i,
Value: val.Val,
})
}

// Populate 5nm
for i, val := range &meas.SpectralData5nm {
res.Wavelengths[1].Waves = append(res.Wavelengths[1].Waves, WaveJSON{
res.WaveLengths[1].Waves = append(res.WaveLengths[1].Waves, WaveJSON{
Nm: 380 + (i * 5),
Value: val.Val,
})
Expand Down

0 comments on commit 5853e50

Please sign in to comment.