diff --git a/options.txt b/options.txt index c06f7f5..61eb1f5 100644 --- a/options.txt +++ b/options.txt @@ -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 diff --git a/src/FileBrowser.cpp b/src/FileBrowser.cpp index b14c186..ed246c5 100644 --- a/src/FileBrowser.cpp +++ b/src/FileBrowser.cpp @@ -1383,7 +1383,11 @@ void FileBrowser::DisplayStatusBar() u32 y = screenMain->ScaleY(STATUS_BAR_POSITION_Y); char bufferOut[128]; - snprintf(bufferOut, 128, "LED 0 Motor 0 Track 18.0 ATN 0 DAT 0 CLK 0"); + 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 } diff --git a/src/main.cpp b/src/main.cpp index f922bdc..b888181 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -32,6 +32,7 @@ extern "C" #include "rpi-mailbox-interface.h" #include "interrupt.h" #include +#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) { diff --git a/src/options.cpp b/src/options.cpp index 43fc279..18ebba9 100644 --- a/src/options.cpp +++ b/src/options.cpp @@ -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) diff --git a/src/options.h b/src/options.h index ea9a2d3..c3c8249 100644 --- a/src/options.h +++ b/src/options.h @@ -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; diff --git a/src/rpi-mailbox-interface.c b/src/rpi-mailbox-interface.c index a65ba03..6078d6c 100644 --- a/src/rpi-mailbox-interface.c +++ b/src/rpi-mailbox-interface.c @@ -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