hoc-sys: change stuff

This commit is contained in:
souldbminersmwc
2025-11-09 16:07:13 -05:00
parent a76c2b33b6
commit e72f9d8e60
14 changed files with 406 additions and 397 deletions

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it
@@ -23,13 +27,20 @@
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors * stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* -------------------------------------------------------------------------- * --------------------------------------------------------------------------
*/ */
#include "base_gui.h" #include "base_gui.h"
#include "../elements/base_frame.h" #include "../elements/base_frame.h"
#include "logo_rgba_bin.h" #include "logo_rgba_bin.h"
#define LOGO_X 20 #define LOGO_X 20
#define LOGO_Y 45 #define LOGO_Y 45
#define LOGO_LABEL_FONT_SIZE 35 #define LOGO_LABEL_FONT_SIZE 35
#define VERSION_X (LOGO_X + 250) #define VERSION_X (LOGO_X + 250)
#define VERSION_Y LOGO_Y-40 #define VERSION_Y LOGO_Y-40
#define VERSION_FONT_SIZE 15 #define VERSION_FONT_SIZE 15
@@ -45,12 +56,9 @@ std::string getVersionString() {
void BaseGui::preDraw(tsl::gfx::Renderer* renderer) void BaseGui::preDraw(tsl::gfx::Renderer* renderer)
{ {
// Draw "Horizon OC " in default color // renderer->drawBitmap(LOGO_X, LOGO_Y, LOGO_WIDTH, LOGO_HEIGHT, logo_rgba_bin);
renderer->drawString("Horizon OC ", false, LOGO_X, LOGO_Y, LOGO_LABEL_FONT_SIZE, renderer->a(TEXT_COLOR)); renderer->drawString("Horizon OC overlay", false, LOGO_X, LOGO_Y, LOGO_LABEL_FONT_SIZE, renderer->a(TEXT_COLOR));
// renderer->drawString(TARGET_VERSION, false, VERSION_X, VERSION_Y, VERSION_FONT_SIZE, tsl::bannerVersionTextColor);
// Draw "Gaea" in green
tsl::Color greenColor(40, 204, 40, 255); // Light green
renderer->drawString("Gaea", false, LOGO_X + 225, LOGO_Y, LOGO_LABEL_FONT_SIZE, greenColor);
} }
tsl::elm::Element* BaseGui::createUI() tsl::elm::Element* BaseGui::createUI()

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,14 +1,7 @@
/* /*
* -------------------------------------------------------------------------- * Copyright (C) Switch-OC-Suite
* "THE BEER-WARE LICENSE" (Revision 42): *
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net> * Copyright (c) 2023 hanai3Bi
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
/*
* *
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
@@ -23,322 +16,297 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
#include "base_menu_gui.h" /* --------------------------------------------------------------------------
#include "fatal_gui.h" * "THE BEER-WARE LICENSE" (Revision 42):
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
// Cache hardware model to avoid repeated syscalls
BaseMenuGui::BaseMenuGui() #include "base_menu_gui.h"
{ #include "fatal_gui.h"
tsl::initializeThemeVars();
this->context = nullptr;
this->lastContextUpdate = 0;
this->listElement = nullptr;
// Initialize all voltages to zero once // Cache hardware model to avoid repeated syscalls
memset(&cpuVoltageUv, 0, sizeof(u32) * 5); // Zero all 5 voltage values at once
// Pre-cache hardware model during initialization BaseMenuGui::BaseMenuGui() : tempColors{tsl::Color(0), tsl::Color(0), tsl::Color(0)}
IsMariko(); {
tsl::initializeThemeVars();
this->context = nullptr;
this->lastContextUpdate = 0;
this->listElement = nullptr;
// Initialize display strings // Initialize all voltages to zero once
memset(displayStrings, 0, sizeof(displayStrings)); memset(&cpuVoltageUv, 0, sizeof(u32) * 5); // Zero all 5 voltage values at once
}
BaseMenuGui::~BaseMenuGui() { // Pre-cache hardware model during initialization
delete this->context; // delete handles nullptr automatically IsMariko();
}
// Fast preDraw - just renders pre-computed strings // Initialize display strings
void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) { memset(displayStrings, 0, sizeof(displayStrings));
BaseGui::preDraw(renderer); }
if(!this->context) [[unlikely]] return;
BaseMenuGui::~BaseMenuGui() {
delete this->context; // delete handles nullptr automatically
}
// Fast preDraw - just renders pre-computed strings
void BaseMenuGui::preDraw(tsl::gfx::Renderer* renderer) {
BaseGui::preDraw(renderer);
if(!this->context) [[unlikely]] return;
// All constants pre-calculated and cached // All constants pre-calculated and cached
static constexpr const char* const labels[] = { static constexpr const char* const labels[10] = {
"App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg", "CPU", "GPU", "PLL", "PMIC", "BAT" "App ID", "Profile", "CPU", "GPU", "MEM", "SoC", "Board", "Skin", "Now", "Avg"
}; };
static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1}; static constexpr u32 dataPositions[6] = {63-3+3, 200-1, 344-1-3, 200-1, 342-1, 321-1};
static u32 labelWidths[10]; static u32 labelWidths[10];
static bool positionsInitialized = false; static bool positionsInitialized = false;
if (!positionsInitialized) { if (!positionsInitialized) {
for (int i = 0; i < 10; i++) { for (int i = 0; i < 10; i++) {
labelWidths[i] = renderer->getTextDimensions(labels[i], false, SMALL_TEXT_SIZE).first; labelWidths[i] = renderer->getTextDimensions(labels[i], false, SMALL_TEXT_SIZE).first;
} }
positionsInitialized = true; positionsInitialized = true;
} }
static u32 positions[10] = {24-1, 310-labelWidths[1], 24-1, 192-labelWidths[3], 332-labelWidths[4], 24-1, 192 - labelWidths[6], 332-labelWidths[7], 192 - labelWidths[8], 332-labelWidths[9]}; static u32 positions[10] = {24-1, 310-labelWidths[1], 24-1, 192-labelWidths[3], 332-labelWidths[4], 24-1, 192 - labelWidths[6], 332-labelWidths[7], 192 - labelWidths[8], 332-labelWidths[9]};
static u32 maxProfileValueWidth = renderer->getTextDimensions("PD Charger", false, SMALL_TEXT_SIZE).first; // longest word static u32 maxProfileValueWidth = renderer->getTextDimensions("PD Charger", false, SMALL_TEXT_SIZE).first; // longest word
u32 y = 91; u32 y = 91;
// === TOP SECTION === // === TOP SECTION ===
// renderer->drawRoundedRect(14, 70-1, 420, 30+2, 10.0f, renderer->aWithOpacity(tsl::tableBGColor)); renderer->drawRoundedRect(14, 70-1, 420, 30+2, 10.0f, renderer->aWithOpacity(tsl::tableBGColor));
// App ID - use pre-formatted string // App ID - use pre-formatted string
renderer->drawString(labels[0], false, positions[0], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(labels[0], false, positions[0], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(displayStrings[0], false, positions[0] + labelWidths[0] + 9, y, SMALL_TEXT_SIZE, tsl::infoTextColor); renderer->drawString(displayStrings[0], false, positions[0] + labelWidths[0] + 9, y, SMALL_TEXT_SIZE, tsl::infoTextColor);
// Profile - use pre-formatted string // Profile - use pre-formatted string
renderer->drawString(labels[1], false, 423 - maxProfileValueWidth - labelWidths[1] - 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(labels[1], false, 423 - maxProfileValueWidth - labelWidths[1] - 9, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(displayStrings[1], false, 423 - maxProfileValueWidth, y, SMALL_TEXT_SIZE, tsl::infoTextColor); renderer->drawString(displayStrings[1], false, 423 - maxProfileValueWidth, y, SMALL_TEXT_SIZE, tsl::infoTextColor);
y = y + 38; // Direct assignment instead of += 38 y = 129; // Direct assignment instead of += 38
// === MAIN DATA SECTION === // === MAIN DATA SECTION ===
// renderer->drawRoundedRect(14, 106, 420, 116, 10.0f, renderer->aWithOpacity(tsl::tableBGColor)); renderer->drawRoundedRect(14, 106, 420, 116, 10.0f, renderer->aWithOpacity(tsl::tableBGColor));
// === FREQUENCY SECTION === // === FREQUENCY SECTION ===
// Labels first (better cache locality) // Labels first (better cache locality)
renderer->drawString(labels[2], false, positions[2], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(labels[2], false, positions[2], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(labels[3], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(labels[3], false, positions[3], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(labels[4], false, positions[4], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(labels[4], false, positions[4], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
// Current frequencies - use pre-formatted strings // Current frequencies - use pre-formatted strings
renderer->drawString(displayStrings[2], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU renderer->drawString(displayStrings[2], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU
renderer->drawString(displayStrings[3], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU renderer->drawString(displayStrings[3], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU
renderer->drawString(displayStrings[4], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM renderer->drawString(displayStrings[4], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM
y = y + 20; // Direct assignment (129 + 20) y = 149; // Direct assignment (129 + 20)
// === REAL FREQUENCIES === // === REAL FREQUENCIES ===
renderer->drawString(displayStrings[5], false, positions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real renderer->drawString(displayStrings[5], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU real
renderer->drawString(displayStrings[6], false, positions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real renderer->drawString(displayStrings[6], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU real
renderer->drawString(displayStrings[7], false, positions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM real renderer->drawString(displayStrings[7], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // MEM real
y = y + 20; // Direct assignment (149 + 20) y = 169; // Direct assignment (149 + 20)
// === VOLTAGES === // === VOLTAGES ===
renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage renderer->drawString(displayStrings[8], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // CPU voltage
renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage renderer->drawString(displayStrings[9], false, dataPositions[1], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // GPU voltage
// Memory voltage - check if VDD is present // Memory voltage - check if VDD is present
if (emcVoltageUv && vddVoltageUv) { if (emcVoltageUv && vddVoltageUv) {
renderer->drawStringWithColoredSections(displayStrings[10], false, {""}, dataPositions[5]-16, y, SMALL_TEXT_SIZE, tsl::infoTextColor, tsl::separatorColor); renderer->drawStringWithColoredSections(displayStrings[10], false, {""}, dataPositions[5]-16, y, SMALL_TEXT_SIZE, tsl::infoTextColor, tsl::separatorColor);
} else if (vddVoltageUv) { } else if (vddVoltageUv) {
renderer->drawString(displayStrings[10], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); renderer->drawString(displayStrings[10], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor);
} else if (emcVoltageUv) { } else if (emcVoltageUv) {
renderer->drawString(displayStrings[10], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor); renderer->drawString(displayStrings[10], false, dataPositions[2], y, SMALL_TEXT_SIZE, tsl::infoTextColor);
} }
// y = y + 20; // Direct assignment (169 + 22) y = 191; // Direct assignment (169 + 22)
// === TEMPERATURE SECTION ===
// renderer->drawString(displayStrings[17], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[3]); // CPU // Labels
// renderer->drawString(displayStrings[18], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[4]); // GPU renderer->drawString(labels[5], false, positions[5], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
// renderer->drawString(displayStrings[19], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[5]); // PLL renderer->drawString(labels[6], false, positions[6]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(labels[7], false, positions[7], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
y = y + 22; // Direct assignment (149 + 20)
// Temperatures with color - use pre-computed colors
// === TEMPERATURE SECTION === renderer->drawString(displayStrings[11], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[0]); // SOC
// Labels renderer->drawString(displayStrings[12], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[1]); // PCB
renderer->drawString(labels[5], false, positions[5], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); renderer->drawString(displayStrings[13], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[2]); // Skin
renderer->drawString(labels[6], false, positions[6]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
renderer->drawString(labels[7], false, positions[7], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); y = 211; // Direct assignment (191 + 20)
// Temperatures with color - use pre-computed colors // === SOC VOLTAGE & POWER ===
renderer->drawString(displayStrings[11], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[0]); // SOC // SOC voltage (if available)
renderer->drawString(displayStrings[12], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[1]); // PCB if (socVoltageUv) [[likely]] {
renderer->drawString(displayStrings[13], false, dataPositions[2], y, SMALL_TEXT_SIZE, tempColors[2]); // Skin renderer->drawString(displayStrings[14], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor);
}
y = y + 20; // Direct assignment (191 + 20)
// Power labels and values
// === SOC VOLTAGE & POWER === renderer->drawString(labels[8], false, positions[8]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
// SOC voltage (if available) renderer->drawString(labels[9], false, positions[9], y, SMALL_TEXT_SIZE, tsl::sectionTextColor);
if (socVoltageUv) [[likely]] {
renderer->drawString(displayStrings[14], false, dataPositions[0], y, SMALL_TEXT_SIZE, tsl::infoTextColor); renderer->drawString(displayStrings[15], false, dataPositions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power now
} renderer->drawString(displayStrings[16], false, dataPositions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power avg
}
// Power labels and values
renderer->drawString(labels[8], false, positions[8]-1, y, SMALL_TEXT_SIZE, tsl::sectionTextColor); // Optimized refresh - now does all the string formatting once per second
renderer->drawString(labels[9], false, positions[9], y, SMALL_TEXT_SIZE, tsl::sectionTextColor); void BaseMenuGui::refresh()
{
renderer->drawString(displayStrings[15], false, dataPositions[3], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power now const u64 ticks = armGetSystemTick();
renderer->drawString(displayStrings[16], false, dataPositions[4], y, SMALL_TEXT_SIZE, tsl::infoTextColor); // Power avg // Use cached comparison - 1 billion nanoseconds
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] {
y = y + 20; // Direct assignment (191 + 20) return; // Early exit for most calls
}
renderer->drawString(displayStrings[20], false, dataPositions[0], y, SMALL_TEXT_SIZE, tempColors[4]); // BAT
renderer->drawString(displayStrings[21], false, dataPositions[1], y, SMALL_TEXT_SIZE, tempColors[5]); // PMIC this->lastContextUpdate = ticks;
y = y + 20; // Direct assignment (191 + 20) // Lazy context allocation
if (!this->context) [[unlikely]] {
this->context = new SysClkContext;
} }
// Optimized refresh - now does all the string formatting once per second // === ULTRA-FAST VOLTAGE READING ===
void BaseMenuGui::refresh() // Pre-computed domain configuration based on hardware
{ static const PowerDomainId domains[] = {
PcvPowerDomainId_Max77621_Cpu, // [0] CPU
const u64 ticks = armGetSystemTick(); PcvPowerDomainId_Max77621_Gpu, // [1] GPU
// Use cached comparison - 1 billion nanoseconds PcvPowerDomainId_Max77812_Dram, // [2] EMC/DRAM - Mariko only
if (armTicksToNs(ticks - this->lastContextUpdate) <= 1000000000UL) [[likely]] { PcvPowerDomainId_Max77620_Sd0, // [3] SOC - EOS only
return; // Early exit for most calls PcvPowerDomainId_Max77620_Sd1 // [4] VDD2 - EOS only
} };
this->lastContextUpdate = ticks; // Voltage array for direct indexing
u32* voltages[] = {&cpuVoltageUv, &gpuVoltageUv, &emcVoltageUv, &socVoltageUv, &vddVoltageUv};
// Lazy context allocation
if (!this->context) [[unlikely]] { // Single regulator init/exit cycle
this->context = new SysClkContext; if (R_SUCCEEDED(rgltrInitialize())) [[likely]] {
} if (IsMariko()) {
// Mariko with EOS: all 5 domains
// === ULTRA-FAST VOLTAGE READING === for (int i = 0; i < 5; ++i) {
// Pre-computed domain configuration based on hardware RgltrSession session;
static const PowerDomainId domains[] = { if (R_SUCCEEDED(rgltrOpenSession(&session, domains[i]))) [[likely]] {
PcvPowerDomainId_Max77621_Cpu, // [0] CPU if (R_FAILED(rgltrGetVoltage(&session, voltages[i]))) {
PcvPowerDomainId_Max77621_Gpu, // [1] GPU *voltages[i] = 0;
PcvPowerDomainId_Max77812_Dram, // [2] EMC/DRAM - Mariko only }
PcvPowerDomainId_Max77620_Sd0, // [3] SOC rgltrCloseSession(&session);
PcvPowerDomainId_Max77620_Sd1 // [4] VDD2 } else {
}; *voltages[i] = 0;
}
// Voltage array for direct indexing }
u32* voltages[] = {&cpuVoltageUv, &gpuVoltageUv, &emcVoltageUv, &socVoltageUv, &vddVoltageUv}; } else {
// Erista
// Single regulator init/exit cycle // Erista with EOS: CPU, GPU, SOC, VDD (no DRAM)
if (R_SUCCEEDED(rgltrInitialize())) [[likely]] { for (int i = 0; i < 5; ++i) {
if (IsMariko()) { if (i == 2) continue; // Skip DRAM domain
// Mariko with EOS: all 5 domains
for (int i = 0; i < 5; ++i) { RgltrSession session;
RgltrSession session; if (R_SUCCEEDED(rgltrOpenSession(&session, domains[i]))) [[likely]] {
if (R_SUCCEEDED(rgltrOpenSession(&session, domains[i]))) [[likely]] { if (R_FAILED(rgltrGetVoltage(&session, voltages[i]))) {
if (R_FAILED(rgltrGetVoltage(&session, voltages[i]))) { *voltages[i] = 0;
*voltages[i] = 0; }
} rgltrCloseSession(&session);
rgltrCloseSession(&session); } else {
} else { *voltages[i] = 0;
*voltages[i] = 0; }
} emcVoltageUv = 0; // Erista never supports DRAM
} }
} else { }
// Erista
// Erista with EOS: CPU, GPU, SOC, VDD (no DRAM) rgltrExit();
for (int i = 0; i < 5; ++i) { } else {
if (i == 2) continue; // Skip DRAM domain // Zero all voltages on regulator failure
memset(&cpuVoltageUv, 0, sizeof(u32) * 5);
RgltrSession session; }
if (R_SUCCEEDED(rgltrOpenSession(&session, domains[i]))) [[likely]] {
if (R_FAILED(rgltrGetVoltage(&session, voltages[i]))) { // === SYSCLK CONTEXT UPDATE ===
*voltages[i] = 0; const Result rc = sysclkIpcGetCurrentContext(this->context);
} if (R_FAILED(rc)) [[unlikely]] {
rgltrCloseSession(&session); FatalGui::openWithResultCode("sysclkIpcGetCurrentContext", rc);
} else { return;
*voltages[i] = 0; }
}
emcVoltageUv = 0; // Erista never supports DRAM // === FORMAT ALL DISPLAY STRINGS (once per second) ===
} // App ID (hex conversion)
} sprintf(displayStrings[0], "%016lX", context->applicationId);
rgltrExit(); // Profile
} else { strcpy(displayStrings[1], sysclkFormatProfile(context->profile, true));
// Zero all voltages on regulator failure
memset(&cpuVoltageUv, 0, sizeof(u32) * 5); // Current frequencies
} u32 hz = context->freqs[0]; // CPU
sprintf(displayStrings[2], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
// === SYSCLK CONTEXT UPDATE ===
const Result rc = sysclkIpcGetCurrentContext(this->context); hz = context->freqs[1]; // GPU
if (R_FAILED(rc)) [[unlikely]] { sprintf(displayStrings[3], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
FatalGui::openWithResultCode("sysclkIpcGetCurrentContext", rc);
return; hz = context->freqs[2]; // MEM
} sprintf(displayStrings[4], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
// === FORMAT ALL DISPLAY STRINGS (once per second) === // Real frequencies
// App ID (hex conversion) hz = context->realFreqs[0]; // CPU
sprintf(displayStrings[0], "%016lX", context->applicationId); sprintf(displayStrings[5], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
// Profile hz = context->realFreqs[1]; // GPU
strcpy(displayStrings[1], sysclkFormatProfile(context->profile, true)); sprintf(displayStrings[6], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
// Current frequencies hz = context->realFreqs[2]; // MEM
u32 hz = context->freqs[0]; // CPU sprintf(displayStrings[7], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
sprintf(displayStrings[2], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U); // Voltages
sprintf(displayStrings[8], "%.1f mV", cpuVoltageUv / 1000.0);
hz = context->freqs[1]; // GPU sprintf(displayStrings[9], "%.1f mV", gpuVoltageUv / 1000.0);
sprintf(displayStrings[3], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U);
// Memory voltage (handle VDD case)
hz = context->freqs[2]; // MEM if (emcVoltageUv && vddVoltageUv) {
sprintf(displayStrings[4], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U); //sprintf(displayStrings[10], "%u%u mV", vddVoltageUv / 1000U, emcVoltageUv / 1000U);
//sprintf(displayStrings[10], "%u%.1f mV", vddVoltageUv / 1000U, emcVoltageUv / 1000.0f);
// Real frequencies sprintf(displayStrings[10], "%u.%u%u mV", vddVoltageUv / 1000U, (vddVoltageUv % 1000U) / 100U, emcVoltageUv / 1000U);
hz = context->realFreqs[0]; // CPU } else if (vddVoltageUv) {
sprintf(displayStrings[5], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U); //sprintf(displayStrings[10], "%u mV", vddVoltageUv / 1000U);
sprintf(displayStrings[10], "%u.%u mV", vddVoltageUv / 1000U, (vddVoltageUv % 1000U) / 100U);
hz = context->realFreqs[1]; // GPU } else if (emcVoltageUv) {
sprintf(displayStrings[6], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U); sprintf(displayStrings[10], "%u mV", emcVoltageUv / 1000U);
}
hz = context->realFreqs[2]; // MEM
sprintf(displayStrings[7], "%u.%u MHz", hz / 1000000U, (hz / 100000U) % 10U); // Temperatures and pre-compute colors
u32 millis = context->temps[0]; // SOC
// Voltages sprintf(displayStrings[11], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
sprintf(displayStrings[8], "%.1f mV", cpuVoltageUv / 1000.0); tempColors[0] = tsl::GradientColor(millis * 0.001f);
sprintf(displayStrings[9], "%.1f mV", gpuVoltageUv / 1000.0);
millis = context->temps[1]; // PCB
// Memory voltage (handle VDD case) sprintf(displayStrings[12], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
if (emcVoltageUv && vddVoltageUv) { tempColors[1] = tsl::GradientColor(millis * 0.001f);
//sprintf(displayStrings[10], "%u%u mV", vddVoltageUv / 1000U, emcVoltageUv / 1000U);
//sprintf(displayStrings[10], "%u%.1f mV", vddVoltageUv / 1000U, emcVoltageUv / 1000.0f); millis = context->temps[2]; // Skin
sprintf(displayStrings[10], "%u.%u%u mV", vddVoltageUv / 1000U, (vddVoltageUv % 1000U) / 100U, emcVoltageUv / 1000U); sprintf(displayStrings[13], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
} else if (vddVoltageUv) { tempColors[2] = tsl::GradientColor(millis * 0.001f);
//sprintf(displayStrings[10], "%u mV", vddVoltageUv / 1000U);
sprintf(displayStrings[10], "%u.%u mV", vddVoltageUv / 1000U, (vddVoltageUv % 1000U) / 100U); // SOC voltage (if available)
} else if (emcVoltageUv) { if (socVoltageUv) {
sprintf(displayStrings[10], "%u mV", emcVoltageUv / 1000U); sprintf(displayStrings[14], "%u mV", socVoltageUv / 1000U);
} }
// Power
u32 millis = context->temps[SysClkThermalSensor_SOC]; // SOC sprintf(displayStrings[15], "%d mW", context->power[0]); // Now
sprintf(displayStrings[11], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U); sprintf(displayStrings[16], "%d mW", context->power[1]); // Avg
tempColors[0] = tsl::GradientColor(millis * 0.001f); }
millis = context->temps[SysClkThermalSensor_PCB]; // PCB tsl::elm::Element* BaseMenuGui::baseUI()
sprintf(displayStrings[12], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U); {
tempColors[1] = tsl::GradientColor(millis * 0.001f); auto* list = new tsl::elm::List();
this->listElement = list;
millis = context->temps[SysClkThermalSensor_Skin]; // Skin this->listUI();
sprintf(displayStrings[13], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
tempColors[2] = tsl::GradientColor(millis * 0.001f); return list;
}
millis = context->temps[HocClkThermalSensor_Battery]; //
sprintf(displayStrings[20], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
tempColors[3] = tsl::GradientColor(millis * 0.001f);
millis = context->temps[HocClkThermalSensor_PMIC]; //
sprintf(displayStrings[21], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
tempColors[4] = tsl::GradientColor(millis * 0.001f);
// millis = context->temps[HocClkThermalSensor_GPU]; // Skin
// sprintf(displayStrings[18], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
// tempColors[4] = tsl::GradientColor(millis * 0.001f);
// millis = context->temps[HocClkThermalSensor_PLL]; // Skin
// sprintf(displayStrings[19], "%u.%u °C", millis / 1000U, (millis % 1000U) / 100U);
// tempColors[5] = tsl::GradientColor(millis * 0.001f);
// SOC voltage (if available)
if (socVoltageUv) {
sprintf(displayStrings[14], "%u mV", socVoltageUv / 1000U);
}
// Power
sprintf(displayStrings[15], "%d mW", context->power[0]); // Now
sprintf(displayStrings[16], "%d mW", context->power[1]); // Avg
}
tsl::elm::Element* BaseMenuGui::baseUI()
{
auto* list = new tsl::elm::List();
this->listElement = list;
this->listUI();
return list;
}

View File

@@ -1,14 +1,7 @@
/* /*
* -------------------------------------------------------------------------- * Copyright (C) Switch-OC-Suite
* "THE BEER-WARE LICENSE" (Revision 42): *
* <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net> * Copyright (c) 2023 hanai3Bi
* wrote this file. As long as you retain this notice you can do whatever you
* want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
/*
* *
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
@@ -23,69 +16,65 @@
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/ */
#pragma once /* --------------------------------------------------------------------------
* "THE BEER-WARE LICENSE" (Revision 42):
#include "../../rgltr_services.h" * <p-sam@d3vs.net>, <natinusala@gmail.com>, <m4x@m4xw.net>
#include "../../ipc.h" * wrote this file. As long as you retain this notice you can do whatever you
#include "base_gui.h" * want with this stuff. If you meet any of us some day, and you think this
* stuff is worth it, you can buy us a beer in return. - The sys-clk authors
* --------------------------------------------------------------------------
*/
class BaseMenuGui : public BaseGui #pragma once
{
protected:
SysClkContext* context;
std::uint64_t lastContextUpdate;
std::uint32_t cpuVoltageUv;
std::uint32_t gpuVoltageUv;
std::uint32_t emcVoltageUv;
std::uint32_t socVoltageUv; //add soc voltage
std::uint32_t vddVoltageUv;//add vdd2 voltage
public: #include "../../rgltr_services.h"
uint64_t systemtickfrequency = 19200000; #include "../../ipc.h"
bool g_hardwareModelCached = false; #include "base_gui.h"
bool g_isMariko = false;
bool g_isAula = false;
bool IsMariko() { class BaseMenuGui : public BaseGui
if (!g_hardwareModelCached) { {
SetSysProductModel model = SetSysProductModel_Invalid; protected:
setsysGetProductModel(&model); SysClkContext* context;
g_isMariko = (model == SetSysProductModel_Iowa || std::uint64_t lastContextUpdate;
model == SetSysProductModel_Hoag || std::uint32_t cpuVoltageUv;
model == SetSysProductModel_Calcio || std::uint32_t gpuVoltageUv;
model == SetSysProductModel_Aula); std::uint32_t emcVoltageUv;
g_hardwareModelCached = true; std::uint32_t socVoltageUv; //add soc voltage
} std::uint32_t vddVoltageUv;//add vdd2 voltage
return g_isMariko;
}
bool IsAula() { public:
bool g_hardwareModelCached = false;
bool g_isMariko = false;
bool IsMariko() {
if (!g_hardwareModelCached) { if (!g_hardwareModelCached) {
SetSysProductModel model = SetSysProductModel_Invalid; SetSysProductModel model = SetSysProductModel_Invalid;
setsysGetProductModel(&model); setsysGetProductModel(&model);
g_isMariko = (model == SetSysProductModel_Aula); g_isMariko = (model == SetSysProductModel_Iowa ||
model == SetSysProductModel_Hoag ||
model == SetSysProductModel_Calcio ||
model == SetSysProductModel_Aula);
g_hardwareModelCached = true;
} }
return g_isAula; return g_isMariko;
} }
bool IsErista() { bool IsErista() {
return !IsMariko(); return !IsMariko();
} }
BaseMenuGui(); BaseMenuGui();
~BaseMenuGui(); ~BaseMenuGui();
void preDraw(tsl::gfx::Renderer* renderer) override; void preDraw(tsl::gfx::Renderer* renderer) override;
tsl::elm::List* listElement; tsl::elm::List* listElement;
tsl::elm::Element* baseUI() override; tsl::elm::Element* baseUI() override;
void refresh() override; void refresh() override;
virtual void listUI() = 0; virtual void listUI() = 0;
private: private:
char displayStrings[32][32]; // Pre-formatted display strings char displayStrings[17][32]; // Pre-formatted display strings
tsl::Color tempColors[6] = { tsl::Color tempColors[3]; // Pre-computed temperature colors
tsl::Color(0), tsl::Color(0), tsl::Color(0), };
tsl::Color(0), tsl::Color(0), tsl::Color(0)
};
};

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it

View File

@@ -1,4 +1,8 @@
/* /*
* Copyright (C) Switch-OC-Suite
*
* Copyright (c) 2023 hanai3Bi
*
* Copyright (c) Souldbminer and Horizon OC Contributors * Copyright (c) Souldbminer and Horizon OC Contributors
* *
* This program is free software; you can redistribute it and/or modify it * This program is free software; you can redistribute it and/or modify it