From 23cd57d1aabb3ef5360b1f168d1998dc2d9f8c06 Mon Sep 17 00:00:00 2001 From: petrucci4prez Date: Sun, 18 Feb 2018 20:50:49 -0500 Subject: [PATCH] rearrange power monitor with mulitplot --- core | 2 +- drawing/Power.lua | 143 +++++++++++++++++++++++++------------------- schema/Patterns.lua | 102 ++++++++++++++++++++----------- 3 files changed, 151 insertions(+), 96 deletions(-) diff --git a/core b/core index 5fd6e1b..36cc286 160000 --- a/core +++ b/core @@ -1 +1 @@ -Subproject commit 5fd6e1b11239b1d24b6c1a18cbfb6c7f876acc96 +Subproject commit 36cc286cb33dff4a649bee9d8b2620f6033fd14a diff --git a/drawing/Power.lua b/drawing/Power.lua index 6f1d1cc..3198fa4 100644 --- a/drawing/Power.lua +++ b/drawing/Power.lua @@ -1,10 +1,12 @@ +local Patterns = require 'Patterns' local Text = require 'Text' +local TextColumn = require 'TextColumn' local Line = require 'Line' local ScalePlot = require 'ScalePlot' local Util = require 'Util' local _MODULE_Y_ = 348 -local _SEPARATOR_SPACING_ = 20 +-- local _SEPARATOR_SPACING_ = 20 local _TEXT_SPACING_ = 20 local _PLOT_SEC_BREAK_ = 20 local _PLOT_HEIGHT_ = 56 @@ -28,57 +30,79 @@ local header = _G_Widget_.Header{ local _RIGHT_X_ = _G_INIT_DATA_.RIGHT_X + _G_INIT_DATA_.SECTION_WIDTH -local dram_igpu = { - label = _G_Widget_.Text{ - x = _G_INIT_DATA_.RIGHT_X, - y = header.bottom_y, - text = 'DRAM | iGPU' - }, - value = _G_Widget_.Text{ - x = _RIGHT_X_, - y = header.bottom_y, - x_align = 'right', - text_color = _G_Patterns_.BLUE, - append_end = ' W', - text = '' - } -} +-- local dram_igpu = { +-- label = _G_Widget_.Text{ +-- x = _G_INIT_DATA_.RIGHT_X, +-- y = header.bottom_y, +-- text = 'DRAM | iGPU' +-- }, +-- value = _G_Widget_.Text{ +-- x = _RIGHT_X_, +-- y = header.bottom_y, +-- x_align = 'right', +-- text_color = _G_Patterns_.BLUE, +-- append_end = ' W', +-- text = '' +-- } +-- } -local _SEP_Y_ = header.bottom_y + _SEPARATOR_SPACING_ +-- local _SEP_Y_ = header.bottom_y + _SEPARATOR_SPACING_ -local separator = _G_Widget_.Line{ - p1 = {x = _G_INIT_DATA_.RIGHT_X, y = _SEP_Y_}, - p2 = {x = _RIGHT_X_, y = _SEP_Y_} -} +-- local separator = _G_Widget_.Line{ +-- p1 = {x = _G_INIT_DATA_.RIGHT_X, y = _SEP_Y_}, +-- p2 = {x = _RIGHT_X_, y = _SEP_Y_} +-- } -local _PKG0_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_ +-- local _PKG0_Y_ = _SEP_Y_ + _SEPARATOR_SPACING_ local pkg0 = { - label = _G_Widget_.Text{ + labels = _G_Widget_.TextColumn{ x = _G_INIT_DATA_.RIGHT_X, - y = _PKG0_Y_, - text = 'PKG 0' - }, - value = _G_Widget_.Text{ - x = _RIGHT_X_, - y = _PKG0_Y_, - x_align = 'right', - text_color = _G_Patterns_.BLUE, - text = '', - append_end = ' W' - }, + y = header.bottom_y, + 'Cores', + 'LLC+MC', + 'iGPU' + }, + core_value = _G_Widget_.Text{ + x = _RIGHT_X_, + y = header.bottom_y, + x_align = 'right', + text_color = Patterns.BLUE, + text = '', + append_end = ' W', + }, + llcmc_value = _G_Widget_.Text{ + x = _RIGHT_X_, + y = header.bottom_y + _TEXT_SPACING_, + x_align = 'right', + text_color = _G_Patterns_.PURPLE, + text = '', + append_end = ' W' + }, + + igpu_value = _G_Widget_.Text{ + x = _RIGHT_X_, + y = header.bottom_y + _TEXT_SPACING_ * 2, + x_align = 'right', + text_color = Patterns.YELLOW, + text = '', + append_end = ' W', + }, plot = _G_Widget_.ScalePlot{ x = _G_INIT_DATA_.RIGHT_X, - y = _PKG0_Y_ + _PLOT_SEC_BREAK_, + y = header.bottom_y + _TEXT_SPACING_ * 2 + _PLOT_SEC_BREAK_, width = _G_INIT_DATA_.SECTION_WIDTH, height = _PLOT_HEIGHT_, y_label_func = power_label_function, + {Patterns.PLOT_LINE_YELLOW, Patterns.PLOT_FILL_YELLOW}, + {Patterns.PLOT_LINE_PURPLE, Patterns.PLOT_FILL_PURPLE}, + {Patterns.PLOT_LINE_BLUE, Patterns.PLOT_FILL_BLUE} } } -local _CORE_Y_ = _PKG0_Y_ + _PLOT_SEC_BREAK_ * 2 + _PLOT_HEIGHT_ +local _CORE_Y_ = header.bottom_y + _TEXT_SPACING_ * 2 + _PLOT_SEC_BREAK_ * 2 + _PLOT_HEIGHT_ -local pp01 = { +local dram = { label = _G_Widget_.Text{ x = _G_INIT_DATA_.RIGHT_X, y = _CORE_Y_, @@ -140,21 +164,20 @@ local update = function(cr, update_frequency, is_using_ac) local igpu_uj_cnt = Util.read_file(IGPU_PATH, nil, '*n') local dram_uj_cnt = Util.read_file(DRAM_PATH, nil, '*n') - Text.set(dram_igpu.value, cr, - Util.precision_round_to_string( - calculate_power(cr, prev_dram_uj_cnt, dram_uj_cnt, update_frequency), 3) - ..' | '.. - Util.precision_round_to_string( - calculate_power(cr, prev_igpu_uj_cnt, igpu_uj_cnt, update_frequency), 3)) - local pkg0_power = calculate_power(cr, prev_pkg0_uj_cnt, pkg0_uj_cnt, update_frequency) local core_power = calculate_power(cr, prev_core_uj_cnt, core_uj_cnt, update_frequency) + local igpu_power = calculate_power(cr, prev_igpu_uj_cnt, igpu_uj_cnt, update_frequency) - Text.set(pkg0.value, cr, Util.precision_round_to_string(pkg0_power, 3)) - ScalePlot.update(pkg0.plot, cr, pkg0_power) + Text.set(pkg0.core_value, cr, Util.precision_round_to_string(core_power, 3)) + Text.set(pkg0.igpu_value, cr, Util.precision_round_to_string(igpu_power, 3)) + Text.set(pkg0.llcmc_value, cr, Util.precision_round_to_string(pkg0_power - core_power - igpu_power, 3)) + + ScalePlot.update(pkg0.plot, cr, igpu_power, pkg0_power - core_power, pkg0_power) - Text.set(pp01.value, cr, Util.precision_round_to_string(core_power, 3)) - ScalePlot.update(pp01.plot, cr, core_power) + local dram_power = calculate_power(cr, prev_dram_uj_cnt, dram_uj_cnt, update_frequency) + + Text.set(dram.value, cr, Util.precision_round_to_string(dram_power, 3)) + ScalePlot.update(dram.plot, cr, dram_power) prev_pkg0_uj_cnt = pkg0_uj_cnt prev_core_uj_cnt = core_uj_cnt @@ -174,14 +197,15 @@ local update = function(cr, update_frequency, is_using_ac) end end +Patterns = nil _MODULE_Y_ = nil -_SEPARATOR_SPACING_ = nil +-- _SEPARATOR_SPACING_ = nil _TEXT_SPACING_ = nil _PLOT_SEC_BREAK_ = nil _PLOT_HEIGHT_ = nil _RIGHT_X_ = nil -_SEP_Y_ = nil -_PKG0_Y_ = nil +-- _SEP_Y_ = nil +-- _PKG0_Y_ = nil _CORE_Y_ = nil _BATTERY_DRAW_Y_ = nil @@ -192,18 +216,15 @@ local draw = function(cr, current_interface, update_frequency, is_using_ac) Text.draw(header.text, cr) Line.draw(header.underline, cr) - Text.draw(dram_igpu.label, cr) - Text.draw(dram_igpu.value, cr) - - Line.draw(separator, cr) - - Text.draw(pkg0.label, cr) - Text.draw(pkg0.value, cr) + TextColumn.draw(pkg0.labels, cr) + Text.draw(pkg0.llcmc_value, cr) + Text.draw(pkg0.core_value, cr) + Text.draw(pkg0.igpu_value, cr) ScalePlot.draw(pkg0.plot, cr) - Text.draw(pp01.label, cr) - Text.draw(pp01.value, cr) - ScalePlot.draw(pp01.plot, cr) + Text.draw(dram.label, cr) + Text.draw(dram.value, cr) + ScalePlot.draw(dram.plot, cr) Text.draw(battery_draw.label, cr) Text.draw(battery_draw.value, cr) diff --git a/schema/Patterns.lua b/schema/Patterns.lua index ada223a..155d64e 100644 --- a/schema/Patterns.lua +++ b/schema/Patterns.lua @@ -3,69 +3,103 @@ local M = {} local Color = require 'Color' local Util = require 'Util' -local WHITE = 0xffffffff - -local GREY1 = 0xeeeeeeff -local GREY2 = 0xbfbfbfff -local GREY3 = 0xd6d6d6ff -local GREY4 = 0x888888ff -local GREY5 = 0x565656ff -local GREY6 = 0x2f2f2fb2 -local BLACK = 0x000000ff +-- text colors +M.WHITE = Color.init{hex_rgba = 0xffffff} -local BLUE1 = 0x99CEFFff -local BLUE2 = 0xBFE1FFff -local BLUE3 = 0x316BA6ff - -local RED1 = 0xFF3333ff -local RED2 = 0xFF8282ff -local RED3 = 0xFFB8B8ff - -local PURPLE1 = 0xeecfffff -local PURPLE2 = 0xcb91ffff -local PURPLE3 = 0x9523ffff - -M.WHITE = Color.init{hex_rgba = WHITE} - -M.LIGHT_GREY = Color.init{hex_rgba = GREY1} -M.MID_GREY = Color.init{hex_rgba = GREY3} -M.DARK_GREY = Color.init{hex_rgba = GREY4} - -M.BLUE = Color.init{hex_rgba = BLUE2} -M.RED = Color.init{hex_rgba = RED2} -M.PURPLE = Color.init{hex_rgba = PURPLE2} +M.LIGHT_GREY = Color.init{hex_rgba = 0xeeeeee} +M.MID_GREY = Color.init{hex_rgba = 0xd6d6d6} +M.DARK_GREY = Color.init{hex_rgba = 0x888888} +M.BLUE = Color.init{hex_rgba = 0xbfe1ff} +M.RED = Color.init{hex_rgba = 0xff8282} +M.PURPLE = Color.init{hex_rgba = 0xcb91ff} +M.YELLOW = Color.init{hex_rgba = 0xefe7aa +} +-- arc patterns +local GREY2 = 0xbfbfbf +local GREY5 = 0x565656 M.GREY_ROUNDED = Color.Gradient{ Color.ColorStop{hex_rgba = GREY5, stop = 0.0}, Color.ColorStop{hex_rgba = GREY2, stop = 0.5}, Color.ColorStop{hex_rgba = GREY5, stop = 1.0} } +local BLUE1 = 0x99CEFF +local BLUE3 = 0x316BA6 M.BLUE_ROUNDED = Color.Gradient{ Color.ColorStop{hex_rgba = BLUE3, stop = 0.0}, Color.ColorStop{hex_rgba = BLUE1, stop = 0.5}, Color.ColorStop{hex_rgba = BLUE3, stop = 1.0} } +local RED1 = 0xFF3333 +local RED3 = 0xFFB8B8 M.RED_ROUNDED = Color.Gradient{ Color.ColorStop{hex_rgba = RED1, stop = 0.0}, Color.ColorStop{hex_rgba = RED3, stop = 0.5}, Color.ColorStop{hex_rgba = RED1, stop = 1.0} } +local PURPLE1 = 0xeecfff +local PURPLE3 = 0x9523ff M.PURPLE_ROUNDED = Color.Gradient{ Color.ColorStop{hex_rgba = PURPLE3, stop = 0.0}, Color.ColorStop{hex_rgba = PURPLE1, stop = 0.5}, Color.ColorStop{hex_rgba = PURPLE3, stop = 1.0} } -M.TRANSPARENT_BLACK = Color.init{hex_rgba = BLACK, force_alpha = 0.7} - M.TRANSPARENT_BLUE = Color.Gradient{ - Color.ColorStop{hex_rgba = BLUE3, stop = 0.0, force_alpha = 0.2}, - Color.ColorStop{hex_rgba = BLUE1, stop = 1.0, force_alpha = 1.0} + Color.ColorStop{hex_rgba = BLUE3, stop = 0.0, alpha = 0.2}, + Color.ColorStop{hex_rgba = BLUE1, stop = 1.0, alpha = 1.0} } +-- plot patterns +local PLOT_BLUE1 = 0x003f7c +local PLOT_BLUE2 = 0x1e90ff +local PLOT_BLUE3 = 0x316ece +local PLOT_BLUE4 = 0x8cc7ff +M.PLOT_LINE_BLUE = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_BLUE1, stop = 0.0}, + Color.ColorStop{hex_rgba = PLOT_BLUE2, stop = 1.0} +} + +M.PLOT_FILL_BLUE = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_BLUE3, stop = 0.0, alpha = 0.2}, + Color.ColorStop{hex_rgba = PLOT_BLUE4, stop = 1.0, alpha = 1.0} +} + +local PLOT_PURPLE1 = 0x3e0077 +local PLOT_PURPLE2 = 0x9523ff +local PLOT_PURPLE3 = 0x7a30a3 +local PLOT_PURPLE4 = 0xeac4ff +M.PLOT_LINE_PURPLE = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_PURPLE1, stop = 0.0}, + Color.ColorStop{hex_rgba = PLOT_PURPLE2, stop = 1.0} +} + +M.PLOT_FILL_PURPLE = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_PURPLE3, stop = 0.0, alpha = 0.2}, + Color.ColorStop{hex_rgba = PLOT_PURPLE4, stop = 1.0, alpha = 1.0} +} + +local PLOT_YELLOW1 = 0x231f00 +local PLOT_YELLOW2 = 0x7c6f00 +local PLOT_YELLOW3 = 0x8c8225 +local PLOT_YELLOW4 = 0xfff387 +M.PLOT_LINE_YELLOW = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_YELLOW1, stop = 0.0}, + Color.ColorStop{hex_rgba = PLOT_YELLOW2, stop = 1.0} +} + +M.PLOT_FILL_YELLOW = Color.Gradient{ + Color.ColorStop{hex_rgba = PLOT_YELLOW3, stop = 0.0, alpha = 0.2}, + Color.ColorStop{hex_rgba = PLOT_YELLOW4, stop = 1.0, alpha = 1.0} +} + +-- panel pattern +M.TRANSPARENT_BLACK = Color.init{hex_rgba = 0x000000, alpha = 0.7} + M = Util.set_finalizer(M, function() print('Cleaning up Patterns.lua') end) + return M