1
0
forked from me/IronOS
* Ability to print hex

* Add device ID getter

* Refactor debug menu

* No longer need patch

* Update make_translation.py

* Fix typo

* Fix hex drawing
This commit is contained in:
Ben V. Brown
2022-06-16 21:39:53 +10:00
committed by GitHub
parent 165a9952c2
commit 078b8f5626
12 changed files with 104 additions and 38 deletions

View File

@@ -120,9 +120,6 @@ def get_constants(build_version: str) -> List[Tuple[str, str]]:
def get_debug_menu() -> List[str]:
return [
datetime.today().strftime("%d-%m-%y"),
"HW G ",
"HW M ",
"HW P ",
"Time ",
"Move ",
"RTip ",
@@ -131,7 +128,11 @@ def get_debug_menu() -> List[str]:
"Vin ",
"ACC ",
"PWR ",
"ID ",
"Max ",
"HW G ",
"HW M ",
"HW P ",
"Hall ",
]
@@ -429,7 +430,24 @@ def get_font_map_per_font(text_list: List[str], fonts: List[str]) -> FontMapsPer
def get_forced_first_symbols() -> List[str]:
forced_first_symbols = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
forced_first_symbols = [
"0",
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"a",
"b",
"c",
"d",
"e",
"f",
]
return forced_first_symbols

View File

@@ -74,6 +74,9 @@ void log_system_state(int32_t PWMWattsx10);
// Returns true if the tip is disconnected
bool isTipDisconnected();
// Return hardware unique ID if possible
uint64_t getDeviceID();
// Status LED controls
enum StatusLED {

View File

@@ -471,3 +471,7 @@ void setStatusLED(const enum StatusLED state) {
setBuzzer(false);
}
}
uint64_t getDeviceID() {
//
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
}

View File

@@ -282,5 +282,9 @@ bool isTipDisconnected() {
return tipTemp > tipDisconnectedThres;
}
void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() { return 0; }
void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() { return 0; }
uint64_t getDeviceID() {
//
return HAL_GetUIDw0() | ((uint64_t)HAL_GetUIDw1() << 32);
}

View File

@@ -310,6 +310,9 @@ void HAL_ResumeTick(void);
uint32_t HAL_GetHalVersion(void);
uint32_t HAL_GetREVID(void);
uint32_t HAL_GetDEVID(void);
uint32_t HAL_GetUIDw0(void);
uint32_t HAL_GetUIDw1(void);
uint32_t HAL_GetUIDw2(void);
void HAL_DBGMCU_EnableDBGSleepMode(void);
void HAL_DBGMCU_DisableDBGSleepMode(void);
void HAL_DBGMCU_EnableDBGStopMode(void);

View File

@@ -513,6 +513,24 @@ void HAL_GetUID(uint32_t *UID) {
UID[2] = (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
}
/**
* @brief Returns first word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw0(void) { return (READ_REG(*((uint32_t *)UID_BASE))); }
/**
* @brief Returns second word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw1(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 4U)))); }
/**
* @brief Returns third word of the unique device identifier (UID based on 96 bits)
* @retval Device identifier
*/
uint32_t HAL_GetUIDw2(void) { return (READ_REG(*((uint32_t *)(UID_BASE + 8U)))); }
/**
* @}
*/

View File

@@ -91,4 +91,5 @@ bool isTipDisconnected() {
void setStatusLED(const enum StatusLED state) {}
uint8_t preStartChecks() { return 0; }
uint8_t preStartChecks() { return 0; }
uint64_t getDeviceID() { return dbg_id_get(); }

View File

@@ -423,6 +423,13 @@ inline void stripLeaderZeros(char *buffer, uint8_t places) {
}
}
}
void OLED::drawHex(uint32_t x, FontStyle fontStyle) {
// print number to hex
for (uint_fast8_t i = 0; i < 8; i++) {
uint16_t value = (x >> (4 * (7 - i))) & 0b1111;
drawChar(value + 2, fontStyle);
}
}
// maximum places is 5
void OLED::printNumber(uint16_t number, uint8_t places, FontStyle fontStyle, bool noLeaderZeros) {
char buffer[7] = {0};

View File

@@ -89,6 +89,7 @@ public:
// Draws a checkbox
static void drawCheckbox(bool state) { drawSymbol((state) ? 16 : 17); }
static void debugNumber(int32_t val, FontStyle fontStyle);
static void drawHex(uint32_t x, FontStyle fontStyle);
static void drawSymbol(uint8_t symbolID); // Used for drawing symbols of a predictable width
static void drawArea(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
static void drawAreaSwapped(int16_t x, int8_t y, uint8_t wide, uint8_t height, const uint8_t *ptr); // Draw an area, but y must be aligned on 0/8 offset
@@ -104,8 +105,8 @@ public:
private:
static void drawChar(uint16_t charCode, FontStyle fontStyle); // Draw a character to the current cursor location
static void setFramebuffer(uint8_t *buffer);
static uint8_t * firstStripPtr; // Pointers to the strips to allow for buffer having extra content
static uint8_t * secondStripPtr; // Pointers to the strips
static uint8_t *firstStripPtr; // Pointers to the strips to allow for buffer having extra content
static uint8_t *secondStripPtr; // Pointers to the strips
static bool inLeftHandedMode; // Whether the screen is in left or not (used for offsets in GRAM)
static bool initDone;
static DisplayState displayState;

View File

@@ -691,46 +691,34 @@ void showDebugMenu(void) {
case 0: // Just prints date
break;
case 1:
// High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break;
case 2:
// High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break;
case 3:
// High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break;
case 4:
// system up time stamp
OLED::printNumber(xTaskGetTickCount() / TICKS_100MS, 5, FontStyle::SMALL);
break;
case 5:
case 2:
// Movement time stamp
OLED::printNumber(lastMovementTime / TICKS_100MS, 5, FontStyle::SMALL);
break;
case 6:
case 3:
// Raw Tip
{ OLED::printNumber(TipThermoModel::convertTipRawADCTouV(getTipRawTemp(0), true), 6, FontStyle::SMALL); }
break;
case 7:
case 4:
// Temp in C
OLED::printNumber(TipThermoModel::getTipInC(), 5, FontStyle::SMALL);
break;
case 8:
case 5:
// Handle Temp
OLED::printNumber(getHandleTemperature(0), 6, FontStyle::SMALL);
break;
case 9:
case 6:
// Voltage input
printVoltage();
break;
case 10:
case 7:
// Print ACC type
OLED::print(AccelTypeNames[(int)DetectedAccelerometerVersion], FontStyle::SMALL);
break;
case 11:
case 8:
// Power negotiation status
{
int sourceNumber = 0;
@@ -766,12 +754,32 @@ void showDebugMenu(void) {
OLED::print(PowerSourceNames[sourceNumber], FontStyle::SMALL);
}
break;
case 12:
case 9:
// Print device ID Numbers
{
uint64_t id = getDeviceID();
OLED::drawHex((uint32_t)(id >> 32), FontStyle::SMALL);
OLED::drawHex((uint32_t)(id & 0xFFFFFFFF), FontStyle::SMALL);
}
break;
case 10:
// Max deg C limit
OLED::printNumber(TipThermoModel::getTipMaxInC(), 3, FontStyle::SMALL);
break;
#ifdef HALL_SENSOR
case 11:
// High water mark for GUI
OLED::printNumber(uxTaskGetStackHighWaterMark(GUITaskHandle), 5, FontStyle::SMALL);
break;
case 12:
// High water mark for the Movement task
OLED::printNumber(uxTaskGetStackHighWaterMark(MOVTaskHandle), 5, FontStyle::SMALL);
break;
case 13:
// High water mark for the PID task
OLED::printNumber(uxTaskGetStackHighWaterMark(PIDTaskHandle), 5, FontStyle::SMALL);
break;
#ifdef HALL_SENSOR
case 14:
// Print raw hall effect value if availabe, none if hall effect disabled.
{
int16_t hallEffectStrength = getRawHallEffect();
@@ -781,6 +789,7 @@ void showDebugMenu(void) {
}
break;
#endif
default:
break;
}
@@ -792,9 +801,9 @@ void showDebugMenu(void) {
else if (b == BUTTON_F_SHORT) {
screen++;
#ifdef HALL_SENSOR
screen = screen % 14;
screen = screen % 15;
#else
screen = screen % 13;
screen = screen % 14;
#endif
}
GUIDelay();

View File

@@ -1,5 +1,5 @@
ifndef model
model:=TS100
model:=Pinecil
endif
ALL_MINIWARE_MODELS=TS100 TS80 TS80P
@@ -161,7 +161,7 @@ bootldr_size=0x0
CPUFLAGS= -march=rv32imac \
-mabi=ilp32 \
-mcmodel=medany -fsigned-char -fno-builtin -nostartfiles
DEV_LDFLAGS=-nostartfiles --specs=patch.specs
DEV_LDFLAGS=-nostartfiles
DEV_AFLAGS=
DEV_GLOBAL_DEFS= -DRTOS_FREERTOS -DDOWNLOAD_MODE=DOWNLOAD_MODE_FLASHXIP
DEV_CFLAGS=
@@ -192,10 +192,10 @@ $(shell find $(DEVICE_BSP_DIR) -type f -name '*.cpp') \
$(shell find $(SOURCE_MIDDLEWARES_DIR) -type f -name '*.cpp')
# code optimisation ------------------------------------------------------------
OPTIM=-Os -flto -finline-small-functions -fshort-wchar -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
OPTIM=-Os -flto -finline-small-functions -findirect-inlining -fdiagnostics-color -ffunction-sections -fdata-sections -fshort-enums -fsingle-precision-constant -fno-common
# global defines ---------------------------------------------------------------
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U
GLOBAL_DEFINES += $(DEV_GLOBAL_DEFS) -D USE_RTOS_SYSTICK -D MODEL_$(model) -D VECT_TAB_OFFSET=$(bootldr_size)U -fshort-wchar
DEBUG=-g3
ifdef swd_enable

View File

@@ -1,2 +0,0 @@
*link:
%(nano_link) %:replace-outfile(-lm_nano -lm)