Skip to content

Commit

Permalink
Merge pull request #42 from cyberbit/feature/basalt-1.7
Browse files Browse the repository at this point in the history
📦 update for Basalt 1.7
  • Loading branch information
cyberbit authored May 14, 2024
2 parents 6ae2cdc + 1be3ac6 commit 195b32b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/telem/init.lua
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
-- Telem by cyberbit
-- MIT License
-- Version 0.5.0
-- Version 0.5.1

local _Telem = {
_VERSION = '0.5.0',
_VERSION = '0.5.1',
util = require 'telem.lib.util',
input = require 'telem.lib.input',
output = require 'telem.lib.output',
Expand Down
37 changes: 21 additions & 16 deletions src/telem/lib/output/basalt/GraphOutputAdapter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ GraphOutputAdapter.MAX_ENTRIES = 50
GraphOutputAdapter.SCALE_TICK = 10

local function graphtrackrange (self)
local min = self.graphdata[1]
local max = self.graphdata[1]
local min = math.huge
local max = -math.huge

for k,v in ipairs(self.graphdata) do
if v < min then min = v end
Expand All @@ -34,51 +34,51 @@ function GraphOutputAdapter:constructor (frame, filter, bg, fg)
end

function GraphOutputAdapter:register (bg, fg)
local currentmin = 0
local currentmax = 1000
local currentmin = math.huge
local currentmax = -math.huge

self.tick = 0

self.bInnerFrame = self.bBaseFrame:addFrame()
:setBackground(bg)
:setSize('{parent.w}', '{parent.h}')
:setSize('parent.w + 1', 'parent.h')

local fGraph = self.bInnerFrame:addFrame('fGraph'):setBackground(bg)
:setPosition(1,1)
:setSize('{parent.w - 2}', '{parent.h - 6}')
:setSize('parent.w', 'parent.h - 6')

local fLabel = self.bInnerFrame:addFrame('fLabel'):setBackground(bg)
:setSize('{parent.w - 2}', 4)
:setPosition(1,'{parent.h - 5}')
:setSize('parent.w', 4)
:setPosition(1,'parent.h - 4')

local fLabelMax = self.bInnerFrame:addFrame('fLabelMax'):setBackground(bg)
:setSize(6, 1)
:setPosition('{parent.w - 7}',1)
:setPosition('parent.w - 6',1)

local fLabelMin = self.bInnerFrame:addFrame('fLabelMin'):setBackground(bg)
:setSize(6, 1)
:setPosition('{parent.w - 7}','{fLabel.y - 2}')
:setPosition('parent.w - 6','fLabel.y - 1')

self.label = fLabel:addLabel()
:setText("-----")
:setPosition('{parent.w/2-self.w/2}', 2)
:setPosition('parent.w/2-self.w/2', 2)
:setForeground(fg)
:setBackground(bg)

self.graph = fGraph:addGraph()
:setPosition(1,1)
:setSize('{parent.w - 1}', '{parent.h - 1}')
:setSize('parent.w - 1', 'parent.h - 1')
:setMaxEntries(self.MAX_ENTRIES)
:setBackground(bg)
:setGraphColor(fg)
:setGraphSymbol(' ')

self.graphscale = fGraph:addGraph()
:setGraphType('scatter')
:setPosition(1,'{parent.h - 1}')
:setSize('{parent.w - 1}', 2)
:setPosition(1,'parent.h')
:setSize('parent.w - 1', 2)
:setMaxEntries(self.MAX_ENTRIES)
:setBackground(colors.transparent)
:setBackground(bg)
:setGraphSymbol('|')

self.labelmax = fLabelMax:addLabel()
Expand All @@ -93,7 +93,7 @@ function GraphOutputAdapter:register (bg, fg)
:setForeground(fg)
:setBackground(bg)

self.graph:setMinValue(currentmin):setMaxValue(currentmax)
-- self.graph:setMinValue(currentmin):setMaxValue(currentmax)
end

function GraphOutputAdapter:write (collection)
Expand All @@ -107,6 +107,11 @@ function GraphOutputAdapter:write (collection)

local newmin, newmax = graphtrackrange(self)

if newmin == newmax then
newmin = newmin - 1
newmax = newmax + 1
end

self.graph:setMinValue(newmin):setMaxValue(newmax)

self.graph:addDataPoint(resultMetric.value)
Expand Down
4 changes: 2 additions & 2 deletions src/telem/lib/output/basalt/LabelOutputAdapter.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ function LabelOutputAdapter:register (bg, fg, fontSize)
-- TODO idk if this inner frame is necessary
self.bInnerFrame = self.bBaseFrame:addFrame()
:setBackground(bg)
:setSize('{parent.w}', '{parent.h}')
:setSize('parent.w', 'parent.h')

self.bLabelValue = self.bInnerFrame
:addLabel()
:setText("-----")
:setFontSize(fontSize or 2)
:setBackground(bg)
:setForeground(fg)
:setPosition('{parent.w/2-self.w/2}', '{parent.h/2-self.h/2}')
:setPosition('parent.w/2-self.w/2', 'parent.h/2-self.h/2')

self.bLabelName = self.bInnerFrame
:addLabel()
Expand Down

0 comments on commit 195b32b

Please sign in to comment.