* Display the temperature status. Moved statusGet code from drawNetwork() into drawStatus(). Added types in common.h to fix building with latest libnx nacp.h, with the pc-build.
This commit is contained in:
parent
42efd240de
commit
793b912efd
@ -9,7 +9,7 @@ EXTRA_CFLAGS="-D__USE_MINGW_ANSI_STDIO"
|
||||
EXTRA_LDFLAGS="-lws2_32"
|
||||
endif
|
||||
|
||||
test : pc_main/main.cpp pc_main/pc_launch.c pc_main/pc_power.c pc_main/pc_netstatus.c \
|
||||
test : pc_main/main.cpp pc_main/pc_launch.c pc_main/pc_power.c pc_main/pc_netstatus.c pc_main/pc_thermalstatus.c \
|
||||
common/menu.c common/font.c common/language.c common/launch.c common/worker.c common/status.c \
|
||||
common/menu-entry.c common/menu-list.c common/message-box.c common/text.c \
|
||||
common/ui.c common/assets.c common/math.c common/theme.c \
|
||||
|
@ -23,6 +23,8 @@
|
||||
typedef uint8_t u8;
|
||||
typedef uint32_t u32;
|
||||
typedef uint64_t u64;
|
||||
typedef int8_t s8;
|
||||
typedef int32_t s32;
|
||||
typedef u32 Result;
|
||||
|
||||
typedef void (*workerThreadFunc)(void *);
|
||||
@ -65,6 +67,7 @@ typedef union {
|
||||
#include "power.h"
|
||||
#include "netloader.h"
|
||||
#include "netstatus.h"
|
||||
#include "thermalstatus.h"
|
||||
#include "status.h"
|
||||
|
||||
void menuStartupPath(void);
|
||||
|
@ -487,18 +487,17 @@ void drawCharge() {
|
||||
}
|
||||
}
|
||||
|
||||
void drawNetwork(int tmpX) {
|
||||
bool netstatusFlag=0;
|
||||
AssetId id;
|
||||
if (statusGet(&netstatusFlag, &id)) {
|
||||
if (netstatusFlag)
|
||||
void drawNetwork(int tmpX, AssetId id) {
|
||||
drawIcon(tmpX, 0 + 47 + 10 + 3, 24, 24, assetsGetDataBuffer(id), themeCurrent.textColor);
|
||||
}
|
||||
}
|
||||
|
||||
u32 drawStatus() {
|
||||
bool netstatusFlag=0;
|
||||
bool temperatureFlag=0;
|
||||
s32 temperature=0;
|
||||
AssetId id;
|
||||
|
||||
char timeString[9];
|
||||
char tmpstr[32];
|
||||
|
||||
time_t unixTime = time(NULL);
|
||||
struct tm* timeStruct = localtime((const time_t *)&unixTime);
|
||||
@ -507,14 +506,21 @@ u32 drawStatus() {
|
||||
int minutes = timeStruct->tm_min;
|
||||
int seconds = timeStruct->tm_sec;
|
||||
|
||||
sprintf(timeString, "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
snprintf(tmpstr, sizeof(tmpstr)-1, "%02d:%02d:%02d", hours, minutes, seconds);
|
||||
|
||||
u32 tmpX = GetTextXCoordinate(interuimedium20, 1180, timeString, 'r');
|
||||
u32 tmpX = GetTextXCoordinate(interuimedium20, 1180, tmpstr, 'r');
|
||||
|
||||
DrawText(interuimedium20, tmpX, 0 + 47 + 10, themeCurrent.textColor, timeString);
|
||||
DrawText(interuimedium20, tmpX, 0 + 47 + 10, themeCurrent.textColor, tmpstr);
|
||||
|
||||
drawCharge();
|
||||
drawNetwork(tmpX);
|
||||
|
||||
if (statusGet(&netstatusFlag, &id, &temperatureFlag, &temperature)) {
|
||||
if (netstatusFlag) drawNetwork(tmpX, id);
|
||||
if (temperatureFlag) {
|
||||
snprintf(tmpstr, sizeof(tmpstr)-1, "%.1f°C", ((float)temperature) / 1000);
|
||||
DrawText(interuiregular14, 1180 + 4, 0 + 47 + 10 + + 21 + 6, themeCurrent.textColor, tmpstr);
|
||||
}
|
||||
}
|
||||
|
||||
return tmpX;
|
||||
}
|
||||
|
@ -10,6 +10,8 @@ static bool s_statusExit;
|
||||
static bool s_statusReady;
|
||||
static bool s_statusNetFlag;
|
||||
static AssetId s_statusNetAssetId;
|
||||
static bool s_statusTemperatureFlag;
|
||||
static s32 s_statusTemperature;
|
||||
|
||||
// This uses netstatusGetDetails from a dedicated thread, since nifmGetInternetConnectionStatus can block for a few seconds.
|
||||
|
||||
@ -18,8 +20,13 @@ static int statusThreadProc(void* unused)
|
||||
mtx_lock(&s_statusMtx);
|
||||
|
||||
struct timespec timeout = {0};
|
||||
bool tmpflag;
|
||||
bool tmpflag=0;
|
||||
bool thermalflag=0;
|
||||
bool thermal_initialized=0;
|
||||
AssetId tmpid;
|
||||
s32 temperature;
|
||||
|
||||
thermal_initialized = thermalstatusInit();
|
||||
|
||||
clock_gettime(CLOCK_MONOTONIC, &timeout);
|
||||
timeout.tv_sec++;
|
||||
@ -32,12 +39,16 @@ static int statusThreadProc(void* unused)
|
||||
break;
|
||||
|
||||
tmpflag = netstatusGetDetails(&tmpid);
|
||||
if (thermal_initialized) thermalflag = thermalstatusGetDetails(&temperature);
|
||||
|
||||
mtx_lock(&s_statusAccessMtx);
|
||||
|
||||
s_statusNetFlag = tmpflag;
|
||||
s_statusNetAssetId = tmpid;
|
||||
|
||||
s_statusTemperatureFlag = thermalflag;
|
||||
s_statusTemperature = temperature;
|
||||
|
||||
s_statusReady = 1;
|
||||
|
||||
mtx_unlock(&s_statusAccessMtx);
|
||||
@ -48,10 +59,12 @@ static int statusThreadProc(void* unused)
|
||||
|
||||
mtx_unlock(&s_statusMtx);
|
||||
|
||||
if (thermal_initialized) thermalstatusExit();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool statusGet(bool *netstatusFlag, AssetId *netstatusAssetId) {
|
||||
bool statusGet(bool *netstatusFlag, AssetId *netstatusAssetId, bool *temperatureFlag, s32 *temperature) {
|
||||
if (!s_statusReady) return 0;
|
||||
|
||||
mtx_lock(&s_statusAccessMtx);
|
||||
@ -59,6 +72,9 @@ bool statusGet(bool *netstatusFlag, AssetId *netstatusAssetId) {
|
||||
*netstatusFlag = s_statusNetFlag;
|
||||
*netstatusAssetId = s_statusNetAssetId;
|
||||
|
||||
*temperatureFlag = s_statusTemperatureFlag;
|
||||
*temperature = s_statusTemperature;
|
||||
|
||||
mtx_unlock(&s_statusAccessMtx);
|
||||
|
||||
return 1;
|
||||
|
@ -3,5 +3,5 @@
|
||||
|
||||
bool statusInit(void);
|
||||
void statusExit(void);
|
||||
bool statusGet(bool *netstatusFlag, AssetId *netstatusAssetId);
|
||||
bool statusGet(bool *netstatusFlag, AssetId *netstatusAssetId, bool *temperatureFlag, s32 *temperature);
|
||||
|
||||
|
7
common/thermalstatus.h
Normal file
7
common/thermalstatus.h
Normal file
@ -0,0 +1,7 @@
|
||||
#pragma once
|
||||
#include "common.h"
|
||||
|
||||
bool thermalstatusInit(void);
|
||||
void thermalstatusExit(void);
|
||||
bool thermalstatusGetDetails(s32 *temperature);
|
||||
|
14
nx_main/nx_thermalstatus.c
Normal file
14
nx_main/nx_thermalstatus.c
Normal file
@ -0,0 +1,14 @@
|
||||
#include "../common/common.h"
|
||||
|
||||
bool thermalstatusInit(void) {
|
||||
return R_SUCCEEDED(tsInitialize());
|
||||
}
|
||||
|
||||
void thermalstatusExit(void) {
|
||||
tsExit();
|
||||
}
|
||||
|
||||
bool thermalstatusGetDetails(s32 *temperature) {
|
||||
return R_SUCCEEDED(tsGetTemperatureMilliC(TsLocation_Internal, temperature));
|
||||
}
|
||||
|
15
pc_main/pc_thermalstatus.c
Normal file
15
pc_main/pc_thermalstatus.c
Normal file
@ -0,0 +1,15 @@
|
||||
#include "../common/common.h"
|
||||
|
||||
bool thermalstatusInit(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
void thermalstatusExit(void) {
|
||||
|
||||
}
|
||||
|
||||
bool thermalstatusGetDetails(s32 *temperature) {
|
||||
*temperature = 0;
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user