Compare commits

3 Commits

Author SHA1 Message Date
744fdcd0d9 up 2024-11-17 21:08:10 +07:00
1b8c97f5e7 Merge branch 'main' into desktopApp 2024-11-16 23:13:50 +07:00
eaa0c62892 correct band guess 2024-11-16 23:03:12 +07:00
5 changed files with 26 additions and 21 deletions

4
Makefile Normal file
View File

@ -0,0 +1,4 @@
build:
go build -o bin/
run:
go run .

9
app.go
View File

@ -38,11 +38,12 @@ func NewApp() *Application {
Sep := widget.NewSeparator()
SpotLabelDX := canvas.NewText("t", color.Black)
SpotLabelFreqMhz := canvas.NewText("t", color.Black)
SpotLabelBand := canvas.NewText("t", color.Black)
SpotLabelDX := canvas.NewText("DX: ", color.Black)
SpotLabelFreqMhz := canvas.NewText("Freq: ", color.Black)
SpotLabelBand := canvas.NewText("Band: ", color.Black)
Spot := container.NewHBox(SpotLabelDX, SpotLabelFreqMhz, SpotLabelBand)
content := container.NewVBox(servicesLabel, Sep, TCPClientAll, FlexRadioAll, Sep, SpotLabelDX, SpotLabelFreqMhz, SpotLabelBand)
content := container.NewVBox(servicesLabel, Sep, TCPClientAll, FlexRadioAll, Sep, Spot)
w.SetContent(content)
app := &Application{

View File

@ -2,7 +2,6 @@ package main
import (
"fmt"
"log"
"os"
"gopkg.in/yaml.v2"
@ -51,13 +50,13 @@ func NewConfig(configPath string) *Config {
file, err := os.Open(configPath)
if err != nil {
log.Println("could not open config file")
Log.Errorln("could not open config file")
}
defer file.Close()
d := yaml.NewDecoder(file)
if err := d.Decode(&Cfg); err != nil {
log.Println("could not decod config file")
Log.Errorln("could not decod config file")
}
return Cfg

View File

@ -73,8 +73,6 @@ func main() {
go TCPClient.StartClient()
go TCPServer.StartServer()
Application.Start()
// Gracely closing all connextions if signal is received
go func() {
for sig := range sigCh {
@ -97,4 +95,6 @@ func main() {
os.Exit(0)
}
}()
Application.Start()
}

25
spot.go
View File

@ -134,60 +134,61 @@ func ProcessTelnetSpot(re *regexp.Regexp, spotRaw string, SpotChanToFlex chan Te
}
func (spot *TelnetSpot) GetBand() {
freq := FreqMhztoHz(spot.Frequency)
switch true {
case strings.HasPrefix(spot.Frequency, "1.8"):
case strings.HasPrefix(freq, "1.8"):
spot.Band = "160M"
if spot.Mode == "SSB" {
spot.Mode = "LSB"
}
case strings.HasPrefix(spot.Frequency, "3"):
case strings.HasPrefix(freq, "3."):
spot.Band = "80M"
if spot.Mode == "SSB" {
spot.Mode = "LSB"
}
case strings.HasPrefix(spot.Frequency, "5."):
case strings.HasPrefix(freq, "5."):
spot.Band = "60M"
if spot.Mode == "SSB" {
spot.Mode = "LSB"
}
case strings.HasPrefix(spot.Frequency, "7"):
case strings.HasPrefix(freq, "7."):
spot.Band = "40M"
if spot.Mode == "SSB" {
spot.Mode = "LSB"
}
case strings.HasPrefix(spot.Frequency, "10"):
case strings.HasPrefix(freq, "10."):
spot.Band = "30M"
case strings.HasPrefix(spot.Frequency, "14"):
case strings.HasPrefix(freq, "14."):
spot.Band = "20M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "18"):
case strings.HasPrefix(freq, "18."):
spot.Band = "17M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "21"):
case strings.HasPrefix(freq, "21."):
spot.Band = "15M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "24"):
case strings.HasPrefix(freq, "24."):
spot.Band = "12M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "28"):
case strings.HasPrefix(freq, "28."):
spot.Band = "10M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "29"):
case strings.HasPrefix(freq, "29."):
spot.Band = "10M"
if spot.Mode == "SSB" {
spot.Mode = "USB"
}
case strings.HasPrefix(spot.Frequency, "50"):
case strings.HasPrefix(freq, "50."):
spot.Band = "6M"
if spot.Mode == "SSB" {
spot.Mode = "USB"