diff --git a/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.pbxproj b/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.pbxproj index 0f5ff16..5e8486b 100644 --- a/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.pbxproj +++ b/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 = ""; }; 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 = ""; }; + 8A1882DE2A85625700E34232 /* libfvhex2bin.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libfvhex2bin.a; path = ../../../heck_fv_hex2bin/src/libfvhex2bin.a; sourceTree = ""; }; 8A4DDBE52A850BFC0032C112 /* libusb-1.0.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libusb-1.0.a"; path = "../../../../../../../opt/local/lib/libusb-1.0.a"; sourceTree = ""; }; 8A4DDBE62A850D190032C112 /* libch341eeprom.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libch341eeprom.a; path = ../../../../heck_fvflash/src/libch341eeprom.a; sourceTree = ""; }; 957408F71F4B186C7A55CAA4 /* juce_events */ = {isa = PBXFileReference; lastKnownFileType = folder; name = juce_events; path = "~/JUCE/modules/juce_events"; sourceTree = ""; }; @@ -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, ); diff --git a/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate b/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate index 77d20ea..0cca8d4 100644 Binary files a/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate and b/Builds/MacOSX/HelloWorldDemo.xcodeproj/project.xcworkspace/xcuserdata/heck.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo b/Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo index e7ffd38..61f7db5 100755 Binary files a/Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo and b/Builds/MacOSX/build/Debug/HelloWorldDemo.app/Contents/MacOS/HelloWorldDemo differ diff --git a/Source/HelloWorldDemo.h b/Source/HelloWorldDemo.h index 2499e2c..ac80a3d 100644 --- a/Source/HelloWorldDemo.h +++ b/Source/HelloWorldDemo.h @@ -45,12 +45,15 @@ *******************************************************************************/ #pragma once - +#include #include +#include + //============================================================================== 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); } }