tree structure change
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -22,3 +22,6 @@ _testmain.go
|
|||||||
*.exe
|
*.exe
|
||||||
*.test
|
*.test
|
||||||
*.prof
|
*.prof
|
||||||
|
|
||||||
|
/gopow
|
||||||
|
resources.go
|
||||||
|
|||||||
24
Makefile
Executable file
24
Makefile
Executable file
@@ -0,0 +1,24 @@
|
|||||||
|
|
||||||
|
.PHONY: setup build resources lint clean
|
||||||
|
|
||||||
|
VERSION = $(shell git describe --always --dirty)
|
||||||
|
TIMESTAMP = $(shell git show -s --format=%ct)
|
||||||
|
|
||||||
|
default: build
|
||||||
|
|
||||||
|
setup:
|
||||||
|
go get -u github.com/jteeuwen/go-bindata/...
|
||||||
|
|
||||||
|
resources:
|
||||||
|
go-bindata -pkg resources -o internal/resources/resources.go resources/...
|
||||||
|
|
||||||
|
build: resources
|
||||||
|
go build -o ./gopow *.go
|
||||||
|
|
||||||
|
lint:
|
||||||
|
golint .
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -f gopow
|
||||||
|
rm -rf internal/resources
|
||||||
|
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"./gopow"
|
"os"
|
||||||
|
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/codegangsta/cli"
|
"github.com/codegangsta/cli"
|
||||||
"os"
|
|
||||||
|
"github.com/dhogborg/rtl-gopow/internal/gopow"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -75,6 +75,17 @@ func (g *GoPow) Render() error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// add some frequency and date annotation
|
||||||
|
err = table.AnnotateXScale(g.image)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
err = table.AnnotateYScale(g.image)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package gopow
|
package gopow
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
@@ -8,9 +9,23 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"code.google.com/p/draw2d/draw2d"
|
||||||
|
"code.google.com/p/freetype-go/freetype"
|
||||||
log "github.com/Sirupsen/logrus"
|
log "github.com/Sirupsen/logrus"
|
||||||
"github.com/dustin/go-humanize"
|
"github.com/dustin/go-humanize"
|
||||||
"github.com/lucasb-eyer/go-colorful"
|
"github.com/lucasb-eyer/go-colorful"
|
||||||
|
|
||||||
|
"github.com/dhogborg/rtl-gopow/internal/resources"
|
||||||
|
)
|
||||||
|
|
||||||
|
// font configuration
|
||||||
|
var (
|
||||||
|
dpi float64 = 72
|
||||||
|
fontfile string = "font/luxisr.ttf"
|
||||||
|
hinting string = "none"
|
||||||
|
size float64 = 24
|
||||||
|
spacing float64 = 1.5
|
||||||
|
wonb bool = true
|
||||||
)
|
)
|
||||||
|
|
||||||
type TableComplex struct {
|
type TableComplex struct {
|
||||||
@@ -21,14 +36,14 @@ type TableComplex struct {
|
|||||||
Min float64 // minimum power value, used for color rendering
|
Min float64 // minimum power value, used for color rendering
|
||||||
Max float64 // maximum dito
|
Max float64 // maximum dito
|
||||||
|
|
||||||
FreqStart float64
|
|
||||||
FreqEnd float64
|
|
||||||
|
|
||||||
Bins int // horizontal slots, columns, bandwidth
|
Bins int // horizontal slots, columns, bandwidth
|
||||||
Integrations int // vertical slots, rows
|
Integrations int // vertical slots, rows
|
||||||
|
|
||||||
TimeStart time.Time // real time
|
HzLow float64 // X Scale start
|
||||||
TimeEnd time.Time
|
HzHigh float64 // X Scale end
|
||||||
|
|
||||||
|
TimeStart *time.Time // real time, Y Scale
|
||||||
|
TimeEnd *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewTable(file string) (*TableComplex, error) {
|
func NewTable(file string) (*TableComplex, error) {
|
||||||
@@ -102,10 +117,36 @@ func (t *TableComplex) parseBuffer(filebuffer []byte) []*LineComplex {
|
|||||||
if t.Min > row.LowSample() {
|
if t.Min > row.LowSample() {
|
||||||
t.Min = row.LowSample()
|
t.Min = row.LowSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
if t.Max < row.HighSample() {
|
if t.Max < row.HighSample() {
|
||||||
t.Max = row.HighSample()
|
t.Max = row.HighSample()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if t.HzLow > row.HzLow {
|
||||||
|
t.HzLow = row.HzLow
|
||||||
|
}
|
||||||
|
if t.HzHigh < row.HzHigh {
|
||||||
|
t.HzHigh = row.HzHigh
|
||||||
|
}
|
||||||
|
|
||||||
|
if row.Time != nil {
|
||||||
|
|
||||||
|
if t.TimeStart == nil {
|
||||||
|
t.TimeStart = row.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.TimeEnd == nil {
|
||||||
|
t.TimeEnd = row.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.TimeStart.Unix() > row.Time.Unix() {
|
||||||
|
t.TimeStart = row.Time
|
||||||
|
}
|
||||||
|
|
||||||
|
if t.TimeEnd.Unix() < row.Time.Unix() {
|
||||||
|
t.TimeEnd = row.Time
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -175,3 +216,42 @@ func (t *TableComplex) ColorAt(x, y int) color.Color {
|
|||||||
return colorful.Hsv(hue, 1, 0.8)
|
return colorful.Hsv(hue, 1, 0.8)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *TableComplex) AnnotateXScale(img *image.RGBA) error {
|
||||||
|
|
||||||
|
// how many samples?
|
||||||
|
// const samples = 10
|
||||||
|
|
||||||
|
fontBytes, err := resources.Asset("resources/fonts/luxisr.ttf")
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
font, err := freetype.ParseFont(fontBytes)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
gc := draw2d.NewGraphicContext(img)
|
||||||
|
|
||||||
|
draw2d.RoundRect(gc, 5, 5, 95, 95, 10, 10)
|
||||||
|
gc.FillStroke()
|
||||||
|
gc.SetFontSize(18)
|
||||||
|
gc.MoveTo(10, 52)
|
||||||
|
|
||||||
|
gc.SetFont(font)
|
||||||
|
// gc.SetFontData(draw2d.FontData{"luxi", draw2d.FontFamilyMono, draw2d.FontStyleBold | draw2d.FontStyleItalic})
|
||||||
|
gc.SetFont(font)
|
||||||
|
|
||||||
|
width := gc.FillString("cou")
|
||||||
|
fmt.Printf("width: %f\n", width)
|
||||||
|
gc.RMoveTo(width+1, 0)
|
||||||
|
gc.FillString("cou")
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (t *TableComplex) AnnotateYScale(img *image.RGBA) error {
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user