mirror of
https://github.com/captain-amygdala/pistorm.git
synced 2026-02-11 18:44:50 +00:00
Add CPU temperature readings to UIs
The CLI now has --get-temperature and the GUI shows the temperature in the status bar. The GUI refreshes once every second.
This commit is contained in:
4
Makefile
4
Makefile
@@ -44,7 +44,7 @@ CXX = g++
|
||||
WARNINGS = -Wall -Wextra -pedantic
|
||||
|
||||
# Pi3 CFLAGS
|
||||
CFLAGS = $(WARNINGS) -I. -I./raylib -I./raylib/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -lstdc++
|
||||
CFLAGS = $(WARNINGS) -I. -I./raylib -I./raylib/external -I/opt/vc/include/ -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -lstdc++
|
||||
# Pi4 CFLAGS
|
||||
#CFLAGS = $(WARNINGS) -I. -I./raylib_pi4_test -I./raylib_pi4_test/external -march=armv8-a -mfloat-abi=hard -mfpu=neon-fp-armv8 -O3 -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
|
||||
|
||||
@@ -52,7 +52,7 @@ CFLAGS = $(WARNINGS) -I. -I./raylib -I./raylib/external -march=armv8-a -mfloa
|
||||
#LFLAGS = $(WARNINGS) `sdl2-config --libs`
|
||||
|
||||
# Pi3 standard raylib stuff
|
||||
LFLAGS = $(WARNINGS) -L/opt/vc/lib -L./raylib -lraylib -lbrcmGLESv2 -lbrcmEGL -lbcm_host -lstdc++
|
||||
LFLAGS = $(WARNINGS) -L/opt/vc/lib -L./raylib -lraylib -lbrcmGLESv2 -lbrcmEGL -lbcm_host -lstdc++ -lvcos -lvchiq_arm
|
||||
# Pi4 experimental crap
|
||||
# Graphics output on the Pi4 sort of REQUIRES X11 to be running, otherwise it is insanely slow and useless.
|
||||
#LFLAGS = $(WARNINGS) -L/usr/local/lib -L./raylib_pi4_test -lraylib -lGL -ldl -lrt -lX11 -DPLATFORM_DESKTOP
|
||||
|
||||
@@ -21,7 +21,3 @@ xdftool pistorm.hdf open part=DH99 + write piscsi/device_driver_amiga/pi-scsi.de
|
||||
xdftool pistorm.hdf open part=DH99 + makedir rtg
|
||||
xdftool pistorm.hdf open part=DH99 + write "rtg/PiGFX Install" rtg
|
||||
xdftool pistorm.hdf open part=DH99 + write "rtg/PiGFX Install.info" rtg
|
||||
xdftool pistorm.hdf open part=DH99 + makedir "rtg/PiGFX Install/Files"
|
||||
xdftool pistorm.hdf open part=DH99 + write rtg/rtg_driver_amiga/pigfx020.card "rtg/PiGFX Install/Files/pigfx020.card"
|
||||
xdftool pistorm.hdf open part=DH99 + write rtg/rtg_driver_amiga/pigfx030.card "rtg/PiGFX Install/Files/pigfx030.card"
|
||||
xdftool pistorm.hdf open part=DH99 + write rtg/rtg_driver_amiga/PiGFX.info "rtg/PiGFX Install/Files/PiGFX.info"
|
||||
|
||||
@@ -34,6 +34,7 @@ enum pistorm_dev_cmds {
|
||||
PI_CMD_SHOWFPS = 0x0118, // [W] Enable/disable RTG FPS display.
|
||||
PI_CMD_PALETTEDEBUG = 0x011A, // [W] Enable/disable RTG palette debug.
|
||||
PI_CMD_MEMCPY_Q = 0x0120, // [W] CopyMemQuick debug thing
|
||||
PI_CMD_GET_TEMP = 0x0121, // [R] Get the CPU core temperature
|
||||
|
||||
PI_CMD_QBASIC = 0x0FFC, // QBasic
|
||||
PI_CMD_NIBBLES = 0x0FFE, // Nibbles
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
#include <sys/reboot.h>
|
||||
#include <endian.h>
|
||||
|
||||
#include <interface/vmcs_host/vc_vchi_gencmd.h>
|
||||
|
||||
#define DEBUG_PISTORM_DEVICE
|
||||
|
||||
#ifdef DEBUG_PISTORM_DEVICE
|
||||
@@ -56,6 +58,37 @@ static uint32_t pi_dbg_string[32];
|
||||
|
||||
static uint32_t pi_cmd_result = 0, shutdown_confirm = 0xFFFFFFFF;
|
||||
|
||||
static bool pi_cmd_init = false;
|
||||
static VCHI_INSTANCE_T vchi_instance;
|
||||
static VCHI_CONNECTION_T *vchi_connection = NULL;
|
||||
|
||||
static uint32_t grab_pi_temperature() {
|
||||
if (!pi_cmd_init) {
|
||||
vcos_init();
|
||||
if (vchi_initialise(&vchi_instance) != 0) {
|
||||
DEBUG("VCHI initialization failed\n");
|
||||
return 0;
|
||||
}
|
||||
if (vchi_connect(NULL, 0, vchi_instance) != 0) {
|
||||
DEBUG("VCHI connection failed\n");
|
||||
return 0;
|
||||
}
|
||||
vc_vchi_gencmd_init(vchi_instance, &vchi_connection, 1);
|
||||
pi_cmd_init = true;
|
||||
}
|
||||
if (vc_gencmd(tmp_string, sizeof(tmp_string), "measure_temp") != 0) {
|
||||
DEBUG("Could not get temperature from VCHI\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Trim to '='
|
||||
char *ptr = strchr(tmp_string, '=');
|
||||
if (!ptr) {
|
||||
return 0;
|
||||
}
|
||||
return atoi(ptr+1);
|
||||
}
|
||||
|
||||
int32_t grab_amiga_string(uint32_t addr, uint8_t *dest, uint32_t str_max_len) {
|
||||
int32_t r = get_mapped_item_by_address(cfg, addr);
|
||||
uint32_t index = 0;
|
||||
@@ -605,7 +638,10 @@ uint32_t handle_pistorm_dev_read(uint32_t addr_, uint8_t type) {
|
||||
case PI_CMD_GET_FB:
|
||||
//DEBUG("[PISTORM-DEV] %s read from GET_FB: %.8X\n", op_type_names[type], rtg_get_fb());
|
||||
return rtg_get_fb();
|
||||
|
||||
break;
|
||||
case PI_CMD_GET_TEMP:
|
||||
return grab_pi_temperature();
|
||||
break;
|
||||
case PI_DBG_VAL1: case PI_DBG_VAL2: case PI_DBG_VAL3: case PI_DBG_VAL4:
|
||||
case PI_DBG_VAL5: case PI_DBG_VAL6: case PI_DBG_VAL7: case PI_DBG_VAL8:
|
||||
DEBUG("[PISTORM-DEV] Read DEBUG VALUE %d (%d / $%.8X)\n", (addr - PI_DBG_VAL1) / 4, pi_dbg_val[(addr - PI_DBG_VAL1) / 4], pi_dbg_val[(addr - PI_DBG_VAL1) / 4]);
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -19,7 +19,7 @@
|
||||
extern unsigned int pistorm_base_addr;
|
||||
struct ReqToolsBase *ReqToolsBase;
|
||||
|
||||
#define VERSION "v0.3.6"
|
||||
#define VERSION "v0.3.7"
|
||||
|
||||
#define button1w 54
|
||||
#define button1h 11
|
||||
@@ -39,6 +39,8 @@ struct ReqToolsBase *ReqToolsBase;
|
||||
#define statusbarw 507
|
||||
#define statusbarh 10
|
||||
|
||||
static int tick_counter = 0;
|
||||
|
||||
struct TextAttr font =
|
||||
{
|
||||
"topaz.font",
|
||||
@@ -227,7 +229,7 @@ struct Gadget RebootButton =
|
||||
|
||||
#define STATUSBAR_TXT_SIZE 128
|
||||
|
||||
UBYTE StatusBar_buf[STATUSBAR_TXT_SIZE] = "Reticulating splines...";
|
||||
UBYTE StatusBar_buf[STATUSBAR_TXT_SIZE] = "";
|
||||
|
||||
struct IntuiText StatusBar_text =
|
||||
{
|
||||
@@ -434,7 +436,7 @@ struct NewWindow winlayout =
|
||||
0, 0,
|
||||
512, 200,
|
||||
-1, -1,
|
||||
CLOSEWINDOW | GADGETUP | GADGETDOWN,
|
||||
CLOSEWINDOW | GADGETUP | GADGETDOWN | INTUITICKS,
|
||||
ACTIVATE | WINDOWCLOSE | WINDOWDRAG | WINDOWDEPTH,
|
||||
&QuitButton, NULL,
|
||||
(STRPTR)"PiStorm Interaction Tool",
|
||||
@@ -446,7 +448,19 @@ struct NewWindow winlayout =
|
||||
|
||||
static void WriteGadgetText(const char *text, UBYTE *buffer, struct Window *window, struct Gadget *gadget, int gad_max)
|
||||
{
|
||||
strncpy((char *)buffer, text, gad_max-1);
|
||||
ULONG newlen = strlen(text);
|
||||
ULONG oldlen = strlen((char *)buffer);
|
||||
|
||||
if (newlen < oldlen)
|
||||
{
|
||||
snprintf((char *)buffer, gad_max-1, "%s%*.*s", text, (int)(oldlen - newlen),
|
||||
(int)(oldlen - newlen), " ");
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy((char *)buffer, text, gad_max-1);
|
||||
}
|
||||
|
||||
RefreshGadgets(&QuitButton, window, NULL);
|
||||
}
|
||||
static void updateRTG(struct Window *window)
|
||||
@@ -568,6 +582,17 @@ int main()
|
||||
{
|
||||
closewin = TRUE;
|
||||
}
|
||||
else if ((class == INTUITICKS) && (!no_board))
|
||||
{
|
||||
tick_counter++;
|
||||
if ((tick_counter % 10) == 0)
|
||||
{
|
||||
char buf[32];
|
||||
unsigned short temp = pi_get_temperature();
|
||||
snprintf(buf, 32, "CPU Temperature: %u%cC", temp, 0xb0);
|
||||
WriteGadgetText(buf, StatusBar_buf, myWindow, &StatusBar, STATUSBAR_TXT_SIZE);
|
||||
}
|
||||
}
|
||||
else if (class == GADGETUP)
|
||||
{
|
||||
if (no_board && (address->GadgetID != GADQUIT) && (address->GadgetID != GADABOUT))
|
||||
|
||||
@@ -232,6 +232,12 @@ void pi_enable_piscsi(unsigned short val)
|
||||
WRITESHORT(PI_CMD_PISCSI_CTRL, val);
|
||||
}
|
||||
|
||||
unsigned short pi_get_temperature(void)
|
||||
{
|
||||
READSHORT(PI_CMD_GET_TEMP, short_val);
|
||||
return short_val;
|
||||
}
|
||||
|
||||
// Generic feature status setting function.
|
||||
// Example: pi_set_feature_status(PI_CMD_RTGSTATUS, 1) to enable RTG
|
||||
// pi_set_feature_status(PI_CMD_PISCSI_CTRL, PISCSI_CTRL_ENABLE) to enable PiSCSI
|
||||
|
||||
@@ -12,6 +12,8 @@ void pi_enable_rtg(unsigned short val);
|
||||
void pi_enable_net(unsigned short val);
|
||||
void pi_enable_piscsi(unsigned short val);
|
||||
|
||||
unsigned short pi_get_temperature(void);
|
||||
|
||||
void pi_reset_amiga(unsigned short reset_code);
|
||||
unsigned short pi_handle_config(unsigned char cmd, char *str);
|
||||
|
||||
|
||||
@@ -125,6 +125,16 @@ int __stdargs main (int argc, char *argv[]) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
case PI_CMD_GET_TEMP:
|
||||
{
|
||||
unsigned short temp = pi_get_temperature();
|
||||
if (temp == 0) {
|
||||
printf("Error getting temperature\n");
|
||||
} else {
|
||||
printf("CPU temp: %u%cC\n", temp, 0xb0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
printf ("Unhandled command %s.\n", argv[1]);
|
||||
return 1;
|
||||
@@ -156,6 +166,9 @@ int get_command(char *cmd) {
|
||||
if (strcmp(cmd, "--transfer-file") == 0 || strcmp(cmd, "--transfer") == 0 || strcmp(cmd, "--getfile") == 0) {
|
||||
return PI_CMD_TRANSFERFILE;
|
||||
}
|
||||
if (strcmp(cmd, "--get-temperature") == 0) {
|
||||
return PI_CMD_GET_TEMP;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user