From 6621b861ce698ca26381286d659a1d6c35ffee1f Mon Sep 17 00:00:00 2001 From: ndwarshuis Date: Fri, 30 Jul 2021 22:02:46 -0400 Subject: [PATCH] REF rename a bunch of things --- drawing/common.lua | 61 +++++++++++++----------------------------- drawing/filesystem.lua | 2 +- drawing/graphics.lua | 8 +++--- drawing/memory.lua | 4 +-- drawing/network.lua | 8 +++--- drawing/power.lua | 14 +++++----- drawing/processor.lua | 8 +++--- drawing/readwrite.lua | 8 +++--- 8 files changed, 44 insertions(+), 69 deletions(-) diff --git a/drawing/common.lua b/drawing/common.lua index 36a2efb..af31179 100644 --- a/drawing/common.lua +++ b/drawing/common.lua @@ -265,16 +265,16 @@ M.make_labeled_scaled_timeseries = function(x, y, w, h, format_fun, label_fun, } end -M.annotated_scale_plot_draw_static = function(asp, cr) +M.labeled_scale_plot_draw_static = function(asp, cr) text.draw(asp.label, cr) end -M.annotated_scale_plot_draw_dynamic = function(asp, cr) +M.labeled_scale_plot_draw_dynamic = function(asp, cr) text.draw(asp.value, cr) scaledtimeseries.draw_dynamic(asp.plot, cr) end -M.annotated_scale_plot_set = function(asp, value) +M.labeled_scale_plot_set = function(asp, value) text.set(asp.value, value) scaledtimeseries.update(asp.plot, value) end @@ -342,15 +342,15 @@ M.make_text_circle = function(x, y, r, fmt, limit) } end -M.text_ring_draw_static = function(tr, cr) +M.text_circle_draw_static = function(tr, cr) arc.draw(tr.ring, cr) end -M.text_ring_draw_dynamic = function(tr, cr) +M.text_circle_draw_dynamic = function(tr, cr) thresholdtext.draw(tr.value, cr) end -M.text_ring_set = function(tr, value) +M.text_circle_set = function(tr, value) thresholdtext.set(tr.value, value) end @@ -365,36 +365,36 @@ local threshold_indicator = function(threshold) ) end -M.dial = function(x, y, radius, thickness, threshold, format) +M.make_dial = function(x, y, radius, thickness, threshold, format) return { dial = dial.make( F.make_semicircle(x, y, radius, DIAL_THETA0, DIAL_THETA1), arc.config(s.line(thickness, CAIRO_LINE_CAP_BUTT), theme.INDICATOR_BG), threshold_indicator(threshold) ), - text_ring = M.make_text_circle(x, y, radius - thickness / 2 - 2, format, threshold), + text_circle = M.make_text_circle(x, y, radius - thickness / 2 - 2, format, threshold), } end M.dial_set = function(dl, value) dial.set(dl.dial, value) - M.text_ring_set(dl.text_ring, value) + M.text_circle_set(dl.text_circle, value) end M.dial_draw_static = function(dl, cr) dial.draw_static(dl.dial, cr) - M.text_ring_draw_static(dl.text_ring, cr) + M.text_circle_draw_static(dl.text_circle, cr) end M.dial_draw_dynamic = function(dl, cr) dial.draw_dynamic(dl.dial, cr) - M.text_ring_draw_dynamic(dl.text_ring, cr) + M.text_circle_draw_dynamic(dl.text_circle, cr) end -------------------------------------------------------------------------------- -- compound dial -M.compound_dial = function(x, y, outer_radius, inner_radius, thickness, +M.make_compound_dial = function(x, y, outer_radius, inner_radius, thickness, threshold, num_dials) return compounddial.make( F.make_semicircle(x, y, outer_radius, DIAL_THETA0, DIAL_THETA1), @@ -408,7 +408,7 @@ end -------------------------------------------------------------------------------- -- annotated compound bar -M.compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold) +M.make_compound_bar = function(x, y, w, pad, labels, spacing, thickness, threshold) return { labels = textcolumn.make( F.make_point(x, y), @@ -504,33 +504,20 @@ M.make_threshold_text_row = function(x, y, w, label, append_end, limit) } end -M.text_row_crit_draw_static = M.text_row_draw_static +M.threshold_text_row_draw_static = M.text_row_draw_static -M.text_row_crit_draw_dynamic = function(row, cr) +M.threshold_text_row_draw_dynamic = function(row, cr) thresholdtext.draw(row.value, cr) end -M.text_row_crit_set = function(row, value) +M.threshold_text_row_set = function(row, value) thresholdtext.set(row.value, value) end --------------------------------------------------------------------------------- --- text column - -M.text_column = function(x, y, spacing, labels, x_align, color) - return textcolumn.make( - F.make_point(x, y), - labels, - _text_row_style(x_align, color), - nil, - spacing - ) -end - -------------------------------------------------------------------------------- -- multiple text row separated by spacing -M.make_text_rows_color = function(x, y, w, spacing, labels, color, format) +M.make_text_rows_formatted = function(x, y, w, spacing, labels, format) return { labels = textcolumn.make( F.make_point(x, y), @@ -542,7 +529,7 @@ M.make_text_rows_color = function(x, y, w, spacing, labels, color, format) values = textcolumn.make_n( F.make_point(x + w, y), #labels, - _text_row_style('right', color), + _text_row_style('right', theme.PRIMARY_FG), format, spacing, 0 @@ -550,18 +537,6 @@ M.make_text_rows_color = function(x, y, w, spacing, labels, color, format) } end -M.make_text_rows_formatted = function(x, y, w, spacing, labels, format) - return M.make_text_rows_color( - x, - y, - w, - spacing, - labels, - theme.PRIMARY_FG, - format - ) -end - M.make_text_rows = function(x, y, w, spacing, labels) return M.make_text_rows_formatted( x, diff --git a/drawing/filesystem.lua b/drawing/filesystem.lua index 6921c33..efe7228 100644 --- a/drawing/filesystem.lua +++ b/drawing/filesystem.lua @@ -43,7 +43,7 @@ return function() local BAR_Y = SEP_Y + SEPARATOR_SPACING - local fs = common.compound_bar( + local fs = common.make_compound_bar( geometry.RIGHT_X, BAR_Y, geometry.SECTION_WIDTH, diff --git a/drawing/graphics.lua b/drawing/graphics.lua index 614683c..d2c2c21 100644 --- a/drawing/graphics.lua +++ b/drawing/graphics.lua @@ -150,7 +150,7 @@ return function(update_freq) local GPU_BUS_CTRL = '/sys/bus/pci/devices/0000:01:00.0/power/control' local nvidia_off = function() - common.text_row_crit_set(internal_temp, -1) + common.threshold_text_row_set(internal_temp, -1) common.text_rows_set(clock_speed, 1, NA) common.text_rows_set(clock_speed, 2, NA) common.percent_timeseries_set(gpu_util, nil) @@ -171,7 +171,7 @@ return function(update_freq) memory_frequency, gpu_utilization, vid_utilization = __string_match(nvidia_settings_glob, NV_REGEX) - common.text_row_crit_set(internal_temp, temp_reading) + common.threshold_text_row_set(internal_temp, temp_reading) common.text_rows_set(clock_speed, 1, gpu_frequency..' Mhz') common.text_rows_set(clock_speed, 2, memory_frequency..' Mhz') @@ -194,7 +194,7 @@ return function(update_freq) common.text_row_draw_static(status, cr) line.draw(separator1, cr) - common.text_row_crit_draw_static(internal_temp, cr) + common.threshold_text_row_draw_static(internal_temp, cr) line.draw(separator2, cr) common.text_rows_draw_static(clock_speed, cr) @@ -207,7 +207,7 @@ return function(update_freq) local draw_dynamic = function(cr) common.text_row_draw_dynamic(status, cr) - common.text_row_crit_draw_dynamic(internal_temp, cr) + common.threshold_text_row_draw_dynamic(internal_temp, cr) common.text_rows_draw_dynamic(clock_speed, cr) common.percent_timeseries_draw_dynamic(gpu_util, cr) common.percent_timeseries_draw_dynamic(mem_util, cr) diff --git a/drawing/memory.lua b/drawing/memory.lua index 35fdb1c..517ed64 100644 --- a/drawing/memory.lua +++ b/drawing/memory.lua @@ -55,7 +55,7 @@ return function(update_freq) local MEM_Y = header.bottom_y + DIAL_RADIUS + DIAL_THICKNESS / 2 local DIAL_DIAMETER = DIAL_RADIUS * 2 + DIAL_THICKNESS - local mem = common.dial( + local mem = common.make_dial( MEM_X, MEM_Y, DIAL_RADIUS, @@ -69,7 +69,7 @@ return function(update_freq) local SWAP_X = MEM_X + DIAL_DIAMETER + DIAL_SPACING - local swap = common.dial( + local swap = common.make_dial( SWAP_X, MEM_Y, DIAL_RADIUS, diff --git a/drawing/network.lua b/drawing/network.lua index efe5ae5..dc02f90 100644 --- a/drawing/network.lua +++ b/drawing/network.lua @@ -96,13 +96,13 @@ return function(update_freq) local draw_static = function(cr) common.draw_header(cr, header) - common.annotated_scale_plot_draw_static(rx, cr) - common.annotated_scale_plot_draw_static(tx, cr) + common.labeled_scale_plot_draw_static(rx, cr) + common.labeled_scale_plot_draw_static(tx, cr) end local draw_dynamic = function(cr) - common.annotated_scale_plot_draw_dynamic(rx, cr) - common.annotated_scale_plot_draw_dynamic(tx, cr) + common.labeled_scale_plot_draw_dynamic(rx, cr) + common.labeled_scale_plot_draw_dynamic(tx, cr) end return {static = draw_static, dynamic = draw_dynamic, update = update} diff --git a/drawing/power.lua b/drawing/power.lua index 3584f37..7e00cdc 100644 --- a/drawing/power.lua +++ b/drawing/power.lua @@ -117,20 +117,20 @@ return function(update_freq) local update = function(is_using_ac) common.update_rate_timeseries(pkg0, read_pkg0_joules()) common.update_rate_timeseries(dram, read_dram_joules()) - common.annotated_scale_plot_set(bat, read_battery_power(is_using_ac)) + common.labeled_scale_plot_set(bat, read_battery_power(is_using_ac)) end local draw_static = function(cr) common.draw_header(cr, header) - common.annotated_scale_plot_draw_static(pkg0, cr) - common.annotated_scale_plot_draw_static(dram, cr) - common.annotated_scale_plot_draw_static(bat, cr) + common.labeled_scale_plot_draw_static(pkg0, cr) + common.labeled_scale_plot_draw_static(dram, cr) + common.labeled_scale_plot_draw_static(bat, cr) end local draw_dynamic = function(cr) - common.annotated_scale_plot_draw_dynamic(pkg0, cr) - common.annotated_scale_plot_draw_dynamic(dram, cr) - common.annotated_scale_plot_draw_dynamic(bat, cr) + common.labeled_scale_plot_draw_dynamic(pkg0, cr) + common.labeled_scale_plot_draw_dynamic(dram, cr) + common.labeled_scale_plot_draw_dynamic(bat, cr) end return {static = draw_static, dynamic = draw_dynamic, update = update} diff --git a/drawing/processor.lua b/drawing/processor.lua index efba8a0..8b81e45 100644 --- a/drawing/processor.lua +++ b/drawing/processor.lua @@ -46,7 +46,7 @@ return function(update_freq) local create_core = function(x, y) return { - loads = common.compound_dial( + loads = common.make_compound_dial( x, y, DIAL_OUTER_RADIUS, @@ -147,7 +147,7 @@ return function(update_freq) for conky_core_id, path in pairs(coretemp_paths) do local temp = __math_floor(0.001 * util.read_file(path, nil, '*n')) - common.text_ring_set(cores[conky_core_id].coretemp, temp) + common.text_circle_set(cores[conky_core_id].coretemp, temp) end -- For some reason this call is slow (querying anything with pstate in @@ -174,7 +174,7 @@ return function(update_freq) common.draw_header(cr, header) for i = 1, #cores do - common.text_ring_draw_static(cores[i].coretemp, cr) + common.text_circle_draw_static(cores[i].coretemp, cr) compounddial.draw_static(cores[i].loads, cr) end @@ -189,7 +189,7 @@ return function(update_freq) local draw_dynamic = function(cr) for i = 1, #cores do compounddial.draw_dynamic(cores[i].loads, cr) - common.text_ring_draw_dynamic(cores[i].coretemp, cr) + common.text_circle_draw_dynamic(cores[i].coretemp, cr) end common.text_rows_draw_dynamic(cpu_status, cr) diff --git a/drawing/readwrite.lua b/drawing/readwrite.lua index ad1116a..de032c0 100644 --- a/drawing/readwrite.lua +++ b/drawing/readwrite.lua @@ -93,13 +93,13 @@ return function(update_freq) local draw_static = function(cr) common.draw_header(cr, header) - common.annotated_scale_plot_draw_static(reads, cr) - common.annotated_scale_plot_draw_static(writes, cr) + common.labeled_scale_plot_draw_static(reads, cr) + common.labeled_scale_plot_draw_static(writes, cr) end local draw_dynamic = function(cr) - common.annotated_scale_plot_draw_dynamic(reads, cr) - common.annotated_scale_plot_draw_dynamic(writes, cr) + common.labeled_scale_plot_draw_dynamic(reads, cr) + common.labeled_scale_plot_draw_dynamic(writes, cr) end return {static = draw_static, dynamic = draw_dynamic, update = update}