Merge branch 'master' of ssh://code.bitgloo.com:222/clyne/stmdspgui into frequency-plot
commit
d13d5aec56
@ -0,0 +1,2 @@
|
|||||||
|
source [find interface/stlink.cfg]
|
||||||
|
source [find target/stm32l4x.cfg]
|
@ -0,0 +1,39 @@
|
|||||||
|
/**
|
||||||
|
* @file code.hpp
|
||||||
|
* @brief Functionality for compiling and disassembling source code.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Clyne Sullivan
|
||||||
|
*
|
||||||
|
* Distributed under the GNU GPL v3 or later. You should have received a copy of
|
||||||
|
* the GNU General Public License along with this program.
|
||||||
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STMDSPGUI_CODE_HPP
|
||||||
|
#define STMDSPGUI_CODE_HPP
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
#include <istream>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to open the most recently created binary file.
|
||||||
|
* @return An opened stream of the file if it exists, an empty stream otherwise.
|
||||||
|
*/
|
||||||
|
std::ifstream compileOpenBinaryFile();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to compile the given C++ algorithm code into a binary.
|
||||||
|
* Errors are reported to the log view.
|
||||||
|
* @param code The C++ code for the algorithm (usually from the text editor).
|
||||||
|
*/
|
||||||
|
void compileEditorCode(const std::string& code);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Disassembles the most recently compiled binary, outputting the results to
|
||||||
|
* the log view.
|
||||||
|
*/
|
||||||
|
void disassembleCode();
|
||||||
|
|
||||||
|
#endif // STMDSPGUI_CODE_HPP
|
||||||
|
|
@ -0,0 +1,124 @@
|
|||||||
|
/**
|
||||||
|
* @file gui_help.cpp
|
||||||
|
* @brief Defines the "Help" menu and provides its functionality.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Clyne Sullivan
|
||||||
|
*
|
||||||
|
* Distributed under the GNU GPL v3 or later. You should have received a copy of
|
||||||
|
* the GNU General Public License along with this program.
|
||||||
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "imgui.h"
|
||||||
|
#include "ImGuiFileDialog.h"
|
||||||
|
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
|
void log(const std::string& str);
|
||||||
|
|
||||||
|
static bool showDownloadFirmware = false;
|
||||||
|
static bool showHelp = false;
|
||||||
|
static std::string firmwareFile;
|
||||||
|
|
||||||
|
static void helpDownloadThread();
|
||||||
|
|
||||||
|
void helpRenderMenu()
|
||||||
|
{
|
||||||
|
if (ImGui::BeginMenu("Help")) {
|
||||||
|
if (ImGui::MenuItem("Open wiki...")) {
|
||||||
|
#ifdef STMDSP_WIN32
|
||||||
|
system("start "
|
||||||
|
#else
|
||||||
|
system("xdg-open "
|
||||||
|
#endif
|
||||||
|
"https://code.bitgloo.com/clyne/stmdspgui/wiki");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui::MenuItem("Download firmware...")) {
|
||||||
|
showDownloadFirmware = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::Separator();
|
||||||
|
if (ImGui::MenuItem("About")) {
|
||||||
|
showHelp = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::EndMenu();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void helpRenderDialog()
|
||||||
|
{
|
||||||
|
if (showDownloadFirmware) {
|
||||||
|
showDownloadFirmware = false;
|
||||||
|
ImGuiFileDialog::Instance()->OpenModal(
|
||||||
|
"ChooseFileFW", "Choose Firmware File", ".hex", ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGuiFileDialog::Instance()->Display("ChooseFileFW",
|
||||||
|
ImGuiWindowFlags_NoCollapse,
|
||||||
|
ImVec2(460, 540)))
|
||||||
|
{
|
||||||
|
if (ImGuiFileDialog::Instance()->IsOk()) {
|
||||||
|
firmwareFile = ImGuiFileDialog::Instance()->GetFilePathName();
|
||||||
|
#ifdef STMDSP_WIN32
|
||||||
|
size_t i = 0;
|
||||||
|
while ((i = firmwareFile.find('\\', i)) != std::string::npos) {
|
||||||
|
firmwareFile.replace(i, 1, "\\\\");
|
||||||
|
i += 2;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
std::thread(helpDownloadThread).detach();
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGuiFileDialog::Instance()->Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (showHelp) {
|
||||||
|
ImGui::Begin("help");
|
||||||
|
|
||||||
|
ImGui::Text("stmdspgui\nCompiled on " __DATE__ ".\n\nWritten by Clyne Sullivan.\n");
|
||||||
|
|
||||||
|
if (ImGui::Button("Close")) {
|
||||||
|
showHelp = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!firmwareFile.empty()) {
|
||||||
|
ImGui::Begin("Downloading");
|
||||||
|
|
||||||
|
ImGui::Text("Downloading firmware to device...");
|
||||||
|
|
||||||
|
ImGui::End();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void helpDownloadThread()
|
||||||
|
{
|
||||||
|
std::string command (
|
||||||
|
#ifdef STMDSP_WIN32
|
||||||
|
"openocd\\bin\\openocd.exe"
|
||||||
|
#else
|
||||||
|
"openocd"
|
||||||
|
#endif
|
||||||
|
" -f openocd.cfg -c \"program $0 reset exit\"");
|
||||||
|
|
||||||
|
command.replace(command.find("$0"), 2, firmwareFile);
|
||||||
|
|
||||||
|
std::cout << "Run: " << command << std::endl;
|
||||||
|
|
||||||
|
if (system(command.c_str()) == 0) {
|
||||||
|
log("Programming finished.");
|
||||||
|
} else {
|
||||||
|
log("Error while programming device!");
|
||||||
|
}
|
||||||
|
|
||||||
|
firmwareFile.clear();
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,19 @@
|
|||||||
|
/**
|
||||||
|
* @file gui_help.hpp
|
||||||
|
* @brief Defines the "Help" menu and provides its functionality.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Clyne Sullivan
|
||||||
|
*
|
||||||
|
* Distributed under the GNU GPL v3 or later. You should have received a copy of
|
||||||
|
* the GNU General Public License along with this program.
|
||||||
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STMDSPGUI_GUI_HELP
|
||||||
|
#define STMDSPGUI_GUI_HELP
|
||||||
|
|
||||||
|
void helpRenderMenu();
|
||||||
|
void helpRenderDialog();
|
||||||
|
|
||||||
|
#endif // STMDSPGUI_GUI_HELP
|
||||||
|
|
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* @file main.hpp
|
||||||
|
* @brief Common functions.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Clyne Sullivan
|
||||||
|
*
|
||||||
|
* Distributed under the GNU GPL v3 or later. You should have received a copy of
|
||||||
|
* the GNU General Public License along with this program.
|
||||||
|
* If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef STMDSPGUI_MAIN_HPP
|
||||||
|
#define STMDSPGUI_MAIN_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
void log(const std::string& str);
|
||||||
|
|
||||||
|
#endif // STMDSPGUI_MAIN_HPP
|
||||||
|
|
Loading…
Reference in New Issue