Kleines Post-Script eingebaut, was RAM und ROM Auslastung mittels einfacher Grafik darstellt.
This commit is contained in:
parent
cb0123eb0e
commit
9167fb6dce
@ -15,7 +15,7 @@
|
|||||||
</extensions>
|
</extensions>
|
||||||
</storageModule>
|
</storageModule>
|
||||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||||
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;com.st.stm32cube.ide.mcu.build.STMGCCErrorParser" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1136359567" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug">
|
<configuration artifactExtension="elf" artifactName="${ProjName}" buildArtefactType="org.eclipse.cdt.build.core.buildArtefactType.exe" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=org.eclipse.cdt.build.core.buildArtefactType.exe,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" cleanCommand="rm -rf" description="" errorParsers="org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GmakeErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.CWDLocator;org.eclipse.cdt.core.GCCErrorParser;com.st.stm32cube.ide.mcu.build.STMGCCErrorParser" id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1136359567" name="Debug" parent="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug" postannouncebuildStep="Print RAM und ROM Belegung" postbuildStep="python ..\\usage.py "D:\Program Files\Arm GNU Toolchain arm-none-eabi\13.2 Rel1\bin\arm-none-eabi-size" Elektronische_Last.elf ..\\STM32G071KBTX_FLASH.ld">
|
||||||
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1136359567." name="/" resourcePath="">
|
<folderInfo id="com.st.stm32cube.ide.mcu.gnu.managedbuild.config.exe.debug.1136359567." name="/" resourcePath="">
|
||||||
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1566530055" name="MCU ARM GCC" nonInternalBuilderId="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
|
<toolChain id="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug.1566530055" name="MCU ARM GCC" nonInternalBuilderId="com.st.stm32cube.ide.mcu.gnu.managedbuild.builder" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.toolchain.exe.debug">
|
||||||
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.812600019" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32G071KBTx" valueType="string"/>
|
<option id="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu.812600019" name="MCU" superClass="com.st.stm32cube.ide.mcu.gnu.managedbuild.option.target_mcu" useByScannerDiscovery="true" value="STM32G071KBTx" valueType="string"/>
|
||||||
|
@ -22,8 +22,7 @@
|
|||||||
#include "FanControl.hpp"
|
#include "FanControl.hpp"
|
||||||
#include "CLI.h"
|
#include "CLI.h"
|
||||||
#include "I2C.hpp"
|
#include "I2C.hpp"
|
||||||
#include "Display.hpp"
|
#include "Menu.hpp"
|
||||||
#include "Timer.hpp"
|
|
||||||
|
|
||||||
using namespace ElektronischeLast;
|
using namespace ElektronischeLast;
|
||||||
|
|
||||||
@ -50,13 +49,12 @@ static CLI_Command_t commands[] =
|
|||||||
{ "reboot", "System neu starten", reboot },
|
{ "reboot", "System neu starten", reboot },
|
||||||
};
|
};
|
||||||
|
|
||||||
static Timer timer = Timer();
|
|
||||||
static LED led = LED(500U);
|
static LED led = LED(500U);
|
||||||
static Display lcd = Display();
|
|
||||||
static FanControl fan = FanControl();
|
static FanControl fan = FanControl();
|
||||||
static iI2C eeprom = iI2C(0xA0U);
|
static iI2C eeprom = iI2C(0xA0U);
|
||||||
static iDAC dac = iDAC();
|
static iDAC dac = iDAC();
|
||||||
static iADC adc = iADC();;
|
static iADC adc = iADC();;
|
||||||
|
static Menu menu = Menu();
|
||||||
static std::uint32_t i_soll = 0U;
|
static std::uint32_t i_soll = 0U;
|
||||||
static PIDController pid =
|
static PIDController pid =
|
||||||
{
|
{
|
||||||
@ -83,10 +81,9 @@ int main (void)
|
|||||||
printf("\r\nElektronische Last\r\n");
|
printf("\r\nElektronische Last\r\n");
|
||||||
CLI_Init(commands, sizeof(commands)/sizeof(commands[0]));
|
CLI_Init(commands, sizeof(commands)/sizeof(commands[0]));
|
||||||
led.init();
|
led.init();
|
||||||
lcd.init();
|
|
||||||
fan.init();
|
fan.init();
|
||||||
eeprom.init();
|
eeprom.init();
|
||||||
timer.start(500U);
|
menu.init();
|
||||||
|
|
||||||
float voltage_gain = NAN;
|
float voltage_gain = NAN;
|
||||||
float current_gain = NAN;
|
float current_gain = NAN;
|
||||||
@ -113,35 +110,14 @@ int main (void)
|
|||||||
|
|
||||||
PIDController_Init(&pid);
|
PIDController_Init(&pid);
|
||||||
|
|
||||||
while(lcd.ready_for_data() == false)
|
|
||||||
{
|
|
||||||
lcd.run();
|
|
||||||
}
|
|
||||||
uint8_t degreeSymbol[] = {
|
|
||||||
0x0E,
|
|
||||||
0x0A,
|
|
||||||
0x0E,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00
|
|
||||||
};
|
|
||||||
lcd.lcd_set_user_chars(Display::SecondSign, degreeSymbol);
|
|
||||||
while(lcd.ready_for_data() == false)
|
|
||||||
{
|
|
||||||
lcd.run();
|
|
||||||
}
|
|
||||||
lcd.lcd_set_display(Display::eDispalyOn, Display::eCursorOff, Display::eCursorBlinkOff);
|
|
||||||
lcd.print(Display::Line1, "Elektronische Last");
|
|
||||||
|
|
||||||
while(1)
|
while(1)
|
||||||
{
|
{
|
||||||
led.blink();
|
led.blink();
|
||||||
|
|
||||||
|
menu.run();
|
||||||
|
|
||||||
if(last_tick != systick)
|
if(last_tick != systick)
|
||||||
{
|
{
|
||||||
timer.tick();
|
|
||||||
last_tick = systick;
|
last_tick = systick;
|
||||||
switch(modus)
|
switch(modus)
|
||||||
{
|
{
|
||||||
@ -171,37 +147,8 @@ int main (void)
|
|||||||
temperatur = adc.get_temperature();
|
temperatur = adc.get_temperature();
|
||||||
geschwindigkeit = fan.get_speed();
|
geschwindigkeit = fan.get_speed();
|
||||||
|
|
||||||
if(timer.elapsed())
|
menu.set_measurements(spannung, strom, temperatur, geschwindigkeit);
|
||||||
{
|
|
||||||
if(lcd.ready_for_data())
|
|
||||||
{
|
|
||||||
timer.start(500U);
|
|
||||||
|
|
||||||
char data[17U];
|
|
||||||
|
|
||||||
int32_t len = snprintf(data, sizeof(data) - 1, "%2" PRIu32 ".%02" PRIu32 "V",
|
|
||||||
spannung / 1000U, spannung % 1000U / 10U);
|
|
||||||
std::memset(&data[len], (int)' ', 16U - len);
|
|
||||||
snprintf(&data[12], sizeof(data) - 12, "%2" PRIu32 "%cC", temperatur, 0x1);
|
|
||||||
data[16] = '\0';
|
|
||||||
lcd.print(Display::Line1, data);
|
|
||||||
|
|
||||||
if(strom < 1000UL)
|
|
||||||
{
|
|
||||||
len = snprintf(data, sizeof(data) - 1, "%3" PRIu32 "mA", strom);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
len = snprintf(data, sizeof(data) - 1, "%" PRIu32 ".%02" PRIu32 "A",
|
|
||||||
strom / 1000U, strom % 1000U / 10U);
|
|
||||||
}
|
|
||||||
std::memset(&data[len], (int)' ', 16U - len);
|
|
||||||
snprintf(&data[9], sizeof(data) - 9, "%4" PRIu32 "RPM", geschwindigkeit);
|
|
||||||
data[16] = '\0';
|
|
||||||
lcd.print(Display::Line2, data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
lcd.run();
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
serial_cyclic();
|
serial_cyclic();
|
||||||
@ -209,6 +156,16 @@ int main (void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t get_current_sollstrom(void)
|
||||||
|
{
|
||||||
|
return i_soll;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_new_sollstrom(uint32_t soll)
|
||||||
|
{
|
||||||
|
i_soll = soll;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Callback Function for Command Line
|
* @brief Callback Function for Command Line
|
||||||
* @param [in] pfvOutFunction Function to Print Data to Output
|
* @param [in] pfvOutFunction Function to Print Data to Output
|
||||||
|
82
usage.py
Normal file
82
usage.py
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
import sys
|
||||||
|
import subprocess
|
||||||
|
import re
|
||||||
|
|
||||||
|
|
||||||
|
def draw(perc):
|
||||||
|
print("-", end="")
|
||||||
|
for i in range(100):
|
||||||
|
print("-", end="")
|
||||||
|
|
||||||
|
print("-")
|
||||||
|
|
||||||
|
print("|", end="")
|
||||||
|
for i in range(100):
|
||||||
|
if i < perc:
|
||||||
|
print("*", end="")
|
||||||
|
else:
|
||||||
|
print(" ", end="")
|
||||||
|
|
||||||
|
print("|")
|
||||||
|
|
||||||
|
print("-", end="")
|
||||||
|
for i in range(100):
|
||||||
|
print("-", end="")
|
||||||
|
|
||||||
|
print("-")
|
||||||
|
|
||||||
|
|
||||||
|
def get_flash(f):
|
||||||
|
rom = 0
|
||||||
|
l = re.search("FLASH.*LENGTH.*", f)
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("LENGTH.=.[0-9]*.K", l.group())
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("[0-9].*", l.group())
|
||||||
|
if l is not None:
|
||||||
|
rom = l.group().replace("K", "")
|
||||||
|
return int(rom)
|
||||||
|
|
||||||
|
|
||||||
|
def get_ram(f):
|
||||||
|
ram = 0
|
||||||
|
l = re.search("RAM.*LENGTH.*", f)
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("LENGTH.=.[0-9]*K", l.group())
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("[0-9].*", l.group())
|
||||||
|
if l is not None:
|
||||||
|
ram = l.group().replace("K", "")
|
||||||
|
l = re.search("CCMRAM.*LENGTH.*", f)
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("LENGTH.=.[0-9]*.K", l.group())
|
||||||
|
if l is not None:
|
||||||
|
l = re.search("[0-9].*", l.group())
|
||||||
|
if l is not None:
|
||||||
|
ram = int(ram) + int(l.group().replace("K", ""))
|
||||||
|
return ram
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
argc = len(sys.argv)
|
||||||
|
if argc == 4:
|
||||||
|
var = subprocess.check_output([sys.argv[1], str(sys.argv[2])], universal_newlines=True)
|
||||||
|
f = open(sys.argv[3]).read()
|
||||||
|
mrom = get_flash(f)
|
||||||
|
mram = get_ram(f)
|
||||||
|
mrom = int(mrom) * 1024
|
||||||
|
mram = int(mram) * 1024
|
||||||
|
var = str(var).replace("\t", " ").splitlines()[1].split()
|
||||||
|
romp = 100.0 / float(mrom) * float(int(var[0]))
|
||||||
|
ramp = 100.0 / float(mram) * float(int(var[1]) + int(var[2]))
|
||||||
|
print("RAM: {:.1f}%:".format(ramp))
|
||||||
|
draw(ramp)
|
||||||
|
print("FLASH: {:.1f}%".format(romp))
|
||||||
|
draw(romp)
|
||||||
|
else:
|
||||||
|
print("Invalid number of arguments!")
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
# execute only if run as a script
|
||||||
|
main()
|
Loading…
x
Reference in New Issue
Block a user