Browse Source

Feature: Intel HEX File support.

If extension is .bin will be uploaded straight, if extension .hex will first be converted and saved as infile.hex.bin and the uploaded
master
heck 2 years ago
parent
commit
89b7c2f2ec
  1. 8
      Builds/MacOSX/HelloWorldDemo.xcodeproj/project.pbxproj
  2. BIN
      Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate
  3. BIN
      Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo
  4. 37
      Source/HelloWorldDemo.h

8
Builds/MacOSX/HelloWorldDemo.xcodeproj/project.pbxproj

@ -18,6 +18,7 @@
5C4FFCDF8D6FDF200EC517F5 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A95C42174C07FAA2B2B65C4C /* Security.framework */; };
8A4DDBE72A850D4F0032C112 /* libch341eeprom.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A4DDBE62A850D190032C112 /* libch341eeprom.a */; };
8A4DDBE82A850D660032C112 /* libusb-1.0.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A4DDBE52A850BFC0032C112 /* libusb-1.0.a */; };
8A92C8982A85735700923F81 /* libfvhex2bin.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8A1882DE2A85625700E34232 /* libfvhex2bin.a */; };
A237F9B254E95B3173479FF5 /* Main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E7DABA4EA84ACAB407A52BAE /* Main.cpp */; };
F7500DD6050381FC1C00196C /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0050B1C17FE29F9C95B64D51 /* QuartzCore.framework */; };
FB5FD2A4E19C899FDDF1A2FF /* RecentFilesMenuTemplate.nib in Resources */ = {isa = PBXBuildFile; fileRef = 6FC6928C1E798507B5702338 /* RecentFilesMenuTemplate.nib */; };
@ -35,6 +36,7 @@
5E7B98148BAD54B9201CF2C7 /* juce_core */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_core; path = "~/JUCE/modules/juce_core"; sourceTree = "<absolute>"; };
6FC6928C1E798507B5702338 /* RecentFilesMenuTemplate.nib */ = {isa = PBXFileReference; lastKnownFileType = file.nib; path = RecentFilesMenuTemplate.nib; sourceTree = SOURCE_ROOT; };
800D138984C3A1FF22A52A42 /* juce_gui_basics */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_gui_basics; path = "~/JUCE/modules/juce_gui_basics"; sourceTree = "<absolute>"; };
8A1882DE2A85625700E34232 /* libfvhex2bin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfvhex2bin.a; path = ../../../heck_fv_hex2bin/src/libfvhex2bin.a; sourceTree = "<group>"; };
8A4DDBE52A850BFC0032C112 /* libusb-1.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libusb-1.0.a"; path = "../../../../../../../opt/local/lib/libusb-1.0.a"; sourceTree = "<group>"; };
8A4DDBE62A850D190032C112 /* libch341eeprom.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libch341eeprom.a; path = ../../../../heck_fvflash/src/libch341eeprom.a; sourceTree = "<group>"; };
957408F71F4B186C7A55CAA4 /* juce_events */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_events; path = "~/JUCE/modules/juce_events"; sourceTree = "<absolute>"; };
@ -54,6 +56,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
8A92C8982A85735700923F81 /* libfvhex2bin.a in Frameworks */,
50FE42A5C0417BF97C544A26 /* Cocoa.framework in Frameworks */,
8A4DDBE72A850D4F0032C112 /* libch341eeprom.a in Frameworks */,
58F81FF61B2E3330A4DC84D5 /* Foundation.framework in Frameworks */,
@ -125,6 +128,7 @@
F0AEE2DC91681642918BB3F7 /* Frameworks */ = {
isa = PBXGroup;
children = (
8A1882DE2A85625700E34232 /* libfvhex2bin.a */,
8A4DDBE62A850D190032C112 /* libch341eeprom.a */,
8A4DDBE52A850BFC0032C112 /* libusb-1.0.a */,
E1F338292664601BF133048D /* Cocoa.framework */,
@ -349,11 +353,13 @@
"$(HOME)/JUCE/modules",
"$(inherited)",
/Users/heck/src/heck_fvflash/src,
/Users/heck/src/heck_fv_hex2bin/src,
);
INFOPLIST_FILE = "Info-App.plist";
INFOPLIST_PREPROCESS = NO;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = (
/Users/heck/src/heck_fv_hex2bin/src,
/Users/heck/src/heck_fvflash/src,
/opt/local/lib,
);
@ -421,11 +427,13 @@
"$(HOME)/JUCE/modules",
"$(inherited)",
/Users/heck/src/heck_fvflash/src,
/Users/heck/src/heck_fv_hex2bin/src,
);
INFOPLIST_FILE = "Info-App.plist";
INFOPLIST_PREPROCESS = NO;
INSTALL_PATH = "$(HOME)/Applications";
LIBRARY_SEARCH_PATHS = (
/Users/heck/src/heck_fv_hex2bin/src,
/Users/heck/src/heck_fvflash/src,
/opt/local/lib,
);

BIN
Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate

Binary file not shown.

BIN
Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo

Binary file not shown.

37
Source/HelloWorldDemo.h

@ -45,12 +45,15 @@
*******************************************************************************/
#pragma once
#include <filesystem>
#include <libch341eeprom.h>
#include <libfvhex2bin.h>
//==============================================================================
class HelloWorldDemo : public Component, public juce::FilenameComponentListener
{
public:
int fv1flash_write(std::string &filename) {
ch341_operation_desc opdesc{};
@ -80,7 +83,7 @@ public:
false, // is for saving,
{}, // browser wildcard suffix,
{}, // enforced suffix,
"Drop fv-1 program \n\nHere\n\nto upload (bin file)")); // text when nothing selected
"Drop fv-1 program \n\nHere\n\nto upload (hex file)")); // text when nothing selected
addAndMakeVisible (fileComp.get());
fileComp->addListener (this);
@ -140,15 +143,35 @@ public:
void filenameComponentChanged (juce::FilenameComponent* fileComponentThatHasChanged) override
{
if (fileComponentThatHasChanged == fileComp.get()) {
std::string filename = fileComp->getCurrentFile().getFullPathName().toStdString();
std::string infilename = fileComp->getCurrentFile().getFullPathName().toStdString();
std::string uploadfilename = infilename;
if(fileComp->getCurrentFile().getFileExtension().toStdString() == ".hex")
{
std::string outfilename = infilename + ".bin";
// Convert
status_label.setText("Converting hex2bin...", juce::NotificationType::dontSendNotification);
int status = heckfv_hex2bin(infilename.data(), outfilename.data());
if (status != 0) {
status_label.setColour (Label::textColourId, Colours::red);
status_label.setText("Convert Error: hex2bin conversion failed)", juce::NotificationType::dontSendNotification);
return;
}
uploadfilename = outfilename;
}
// Upload
status_label.setText("Uploading...", juce::NotificationType::dontSendNotification);
if (fv1flash_write(filename) == 0) {
status_label.setColour (Label::textColourId, Colours::green);
status_label.setText("Upload Successful", juce::NotificationType::dontSendNotification);
} else {
if (fv1flash_write(uploadfilename) != 0) {
status_label.setColour (Label::textColourId, Colours::red);
status_label.setText("Upload Error: fv-1 board not found)", juce::NotificationType::dontSendNotification);
return;
}
status_label.setColour (Label::textColourId, Colours::green);
status_label.setText("Upload Successful", juce::NotificationType::dontSendNotification);
}
}

Loading…
Cancel
Save