Added option to display the Pi's CPU temperature.

This commit is contained in:
Stephen White 2019-10-20 13:45:47 +11:00
parent a382c75376
commit 82b494a5e2
6 changed files with 54 additions and 3 deletions

View file

@ -128,3 +128,7 @@ GraphIEC = 1
// Please see dmRotary.h for full implementation details.
//
//RotaryEncoderEnable = 1
// This option will display the temperature of the Pi's CPU.
// It should be about 52°C anything above 65°C is bad and there is something wrong with your hardware
//DisplayTemperature = 1

View file

@ -1383,7 +1383,11 @@ void FileBrowser::DisplayStatusBar()
u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y);
char bufferOut[128];
if (options.DisplayTemperature())
snprintf(bufferOut, 128, "LED 0 Motor 0 Track 18.0 ATN 0 DAT 0 CLK 0 00%cC", 248);
else
snprintf(bufferOut, 128, "LED 0 Motor 0 Track 18.0 ATN 0 DAT 0 CLK 0");
screenMain->PrintText(false, x, y, bufferOut, RGBA(0, 0, 0, 0xff), RGBA(0xff, 0xff, 0xff, 0xff));
#endif
}

View file

@ -32,6 +32,7 @@ extern "C"
#include "rpi-mailbox-interface.h"
#include "interrupt.h"
#include <uspi.h>
#include "rpi-mailbox.h"
}
#include "InputMappings.h"
#include "options.h"
@ -175,6 +176,24 @@ extern "C"
return result == 0x80;
}
int GetTemperature(unsigned& value)
{
rpi_mailbox_property_t* mp;
RPI_PropertyInit();
RPI_PropertyAddTag(TAG_GET_TEMPERATURE);
RPI_PropertyProcess();
value = 0;
if ((mp = RPI_PropertyGet(TAG_GET_TEMPERATURE)))
{
value = mp->data.buffer_32[1];
return 1;
}
return 0;
}
void usDelay(unsigned nMicroSeconds)
{
unsigned before;
@ -342,6 +361,7 @@ void UpdateScreen()
u32 oldTrack = 0;
u32 textColour = COLOUR_BLACK;
u32 bgColour = COLOUR_WHITE;
u32 oldTemp = 0;
RGBA atnColour = COLOUR_YELLOW;
RGBA dataColour = COLOUR_GREEN;
@ -499,6 +519,22 @@ void UpdateScreen()
if (options.GraphIEC())
screen.DrawLineV(graphX, top3, bottom, COLOUR_BLACK);
if (options.DisplayTemperature())
{
unsigned temp;
if (GetTemperature(temp))
{
temp /= 1000;
if (temp != oldTemp)
{
oldTemp = temp;
//DEBUG_LOG("%0x %d %d\r\n", temp, temp, temp / 1000);
snprintf(tempBuffer, tempBufferSize, "%02d", temp);
screen.PrintText(false, 43 * 8, y, tempBuffer, textColour, bgColour);
}
}
}
u32 track;
if (emulating == EMULATING_1541)
{

View file

@ -139,6 +139,7 @@ Options::Options(void)
, splitIECLines(0)
, ignoreReset(0)
, autoBootFB128(0)
, displayTemperature(0)
, lowercaseBrowseModeFilenames(0)
, screenWidth(1024)
, screenHeight(768)
@ -229,6 +230,7 @@ void Options::Process(char* buffer)
ELSE_CHECK_DECIMAL_OPTION(ignoreReset)
ELSE_CHECK_DECIMAL_OPTION(lowercaseBrowseModeFilenames)
ELSE_CHECK_DECIMAL_OPTION(autoBootFB128)
ELSE_CHECK_DECIMAL_OPTION(displayTemperature)
ELSE_CHECK_DECIMAL_OPTION(screenWidth)
ELSE_CHECK_DECIMAL_OPTION(screenHeight)
ELSE_CHECK_DECIMAL_OPTION(i2cBusMaster)

View file

@ -78,6 +78,8 @@ public:
inline unsigned int AutoBootFB128() const { return autoBootFB128; }
inline const char* Get128BootSectorName() const { return C128BootSectorName; }
inline unsigned int DisplayTemperature() const { return displayTemperature; }
inline unsigned int LowercaseBrowseModeFilenames() const { return lowercaseBrowseModeFilenames; }
DiskImage::DiskType GetNewDiskType() const;
@ -138,6 +140,8 @@ private:
unsigned int ignoreReset;
unsigned int autoBootFB128;
unsigned int displayTemperature;
unsigned int lowercaseBrowseModeFilenames;
unsigned int screenWidth;

View file

@ -5,12 +5,13 @@
#include "rpiHardware.h"
#include "rpi-mailbox.h"
#include "rpi-mailbox-interface.h"
#include "cache.h"
/* Make sure the property tag buffer is aligned to a 16-byte boundary because
we only have 28-bits available in the property interface protocol to pass
the address of the buffer to the VC. */
static int pt[PROP_BUFFER_SIZE] __attribute__((aligned(16)));
static int pt_index = 0;
static int *pt = (int *)UNCACHED_MEM_BASE;
static int pt_index ;
//#define PRINT_PROP_DEBUG 1