Commit 9eb9bb38 authored by springob's avatar springob
Browse files

* added new branch for special ProgBob Hardware version

git-svn-id: https://svn.code.sf.net/p/robodude/code/bobdude@19 bbe26285-3967-4f0a-9db1-5cc42c1bf15a
parents
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<CodeBlocks_project_file>
<FileVersion major="1" minor="6" />
<Project>
<Option title="BobDude" />
<Option pch_mode="2" />
<Option compiler="gcc" />
<Build>
<Target title="Release">
<Option output="bin/Release/BobDude" prefix_auto="1" extension_auto="1" />
<Option working_dir="bin/Release/" />
<Option object_output="obj/Release/" />
<Option type="0" />
<Option compiler="gcc" />
<Compiler>
<Add option="-O3" />
<Add directory="D:/libs/wxWidgets-3.0.2/lib/wx/include/msw-unicode-static-3.0" />
<Add directory="include" />
</Compiler>
<ResourceCompiler>
<Add directory="D:/libs/wxWidgets-2.8.10/build-release/lib" />
</ResourceCompiler>
</Target>
</Build>
<Compiler>
<Add option="-Wall" />
<Add option="-g" />
<Add option="-pipe" />
<Add option="-fexceptions" />
<Add option="-mthreads" />
<Add option="-D__GNUWIN32__" />
<Add option="-D__WXMSW__" />
<Add directory="D:/libs/wxWidgets-3.0.2/include" />
<Add directory="D:/libs/wxWidgets-3.0.2/contrib/include" />
<Add directory="D:/libs/boost_1_39_0" />
<Add directory="." />
<Add directory="C:/MinGW/msys/1.0/home/nils" />
</Compiler>
<ResourceCompiler>
<Add directory="D:/libs/wxWidgets-2.8.10/include" />
</ResourceCompiler>
<Linker>
<Add option="-Wl,--enable-auto-import" />
<Add option="-Wl,-Bstatic" />
<Add option="-static" />
<Add library="libwx_mswu-3.0.a" />
<Add library="libwxpng-3.0.a" />
<Add library="libwxjpeg-3.0.a" />
<Add library="libwxtiff-3.0.a" />
<Add library="D:\lib\libboost_program_options-mgw34-mt.lib" />
<Add library="D:\lib\libboost_system-mgw34-mt.lib" />
<Add library="D:\lib\libboost_thread-mgw34-mt.lib" />
<Add library="libkernel32.a" />
<Add library="libuser32.a" />
<Add library="libgdi32.a" />
<Add library="libwinspool.a" />
<Add library="libcomdlg32.a" />
<Add library="libadvapi32.a" />
<Add library="libshell32.a" />
<Add library="libavrdude.a" />
<Add library="C:\MinGW\msys\1.0\home\nils\libusb-win32-bin-1.2.6.0\lib\gcc\libusb.a" />
<Add library="libole32.a" />
<Add library="liboleaut32.a" />
<Add library="libuuid.a" />
<Add library="libcomctl32.a" />
<Add library="libwsock32.a" />
<Add library="libodbc32.a" />
<Add library="libhid.a" />
<Add library="libsetupapi.a" />
<Add library="stdc++" />
<Add library="libwxscintilla-3.0.a" />
<Add library="libwxregexu-3.0.a" />
<Add library="libwxexpat-3.0.a" />
<Add library="z" />
<Add directory="D:/libs/wxWidgets-3.0.2/lib" />
<Add directory="D:/MinGW/lib/gcc/mingw32/4.4.0" />
<Add directory="C:/MinGW/msys/1.0/home/nils/avrdude" />
<Add directory="D:/libs/libusb-win32-src-0.1.12.2" />
<Add directory="D:/libs/libusb-pbatard/msvc" />
</Linker>
<Unit filename="HTMLButton.cpp" />
<Unit filename="HTMLButton.h" />
<Unit filename="MainFrame.cpp" />
<Unit filename="MainFrame.h" />
<Unit filename="PlatformDialog.cpp" />
<Unit filename="PlatformDialog.h" />
<Unit filename="BobDudeApp.cpp" />
<Unit filename="BobDudeApp.h" />
<Unit filename="avrdude.cpp" />
<Unit filename="avrdude.h" />
<Unit filename="part.cpp" />
<Unit filename="part.h" />
<Unit filename="programmer.cpp" />
<Unit filename="programmer.h" />
<Unit filename="resource.rc">
<Option compilerVar="WINDRES" />
</Unit>
<Unit filename="stdplatform.cpp" />
<Unit filename="stdplatform.h" />
<Unit filename="update.cpp" />
<Unit filename="update.h" />
<Unit filename="wxsmith/MainFrame.wxs" />
<Unit filename="wxsmith/PlatformDialog.wxs" />
<Unit filename="xhex.cpp" />
<Unit filename="xhex.h" />
<Unit filename="xml/nodes.cpp" />
<Unit filename="xml/nodes.h" />
<Unit filename="xml/stream.cpp" />
<Unit filename="xml/stream.h" />
<Extensions>
<code_completion />
<envvars />
<debugger />
<wxsmith version="1">
<gui name="wxWidgets" src="BobDudeApp.cpp" main="BobDudeDialog" init_handlers="necessary" language="CPP" />
<resources>
<wxFrame wxs="wxsmith/MainFrame.wxs" src="MainFrame.cpp" hdr="MainFrame.h" fwddecl="0" i18n="1" name="MainFrame" language="CPP" />
<wxDialog wxs="wxsmith/PlatformDialog.wxs" src="PlatformDialog.cpp" hdr="PlatformDialog.h" fwddecl="0" i18n="1" name="PlatformDialog" language="CPP" />
</resources>
</wxsmith>
<DoxyBlocks>
<comment_style block="0" line="0" />
<doxyfile_project />
<doxyfile_build />
<doxyfile_warnings />
<doxyfile_output />
<doxyfile_dot />
<general />
</DoxyBlocks>
</Extensions>
</Project>
</CodeBlocks_project_file>
/***************************************************************
* Name: RoboDudeApp.cpp
* Purpose: Code for Application Class
* Author: Nils Springob (springob@nicai-systems.de)
* Created: 2009-10-04
* Copyright: Nils Springob (http://nibo.nicai-systems.de)
* License:
**************************************************************/
#include "BobDudeApp.h"
#include <wx/stdpaths.h>
#include <wx/filename.h>
//(*AppHeaders
#include "MainFrame.h"
#include <wx/image.h>
//*)
IMPLEMENT_APP(BobDudeApp);
MainFrame * frame;
extern MainFrame * frame;
void appendLogLine(const char * text) {
frame->appendLogLine(text);
}
bool BobDudeApp::OnInit() {
bool wxsOK = true;
if (!wxApp::OnInit()) {
wxsOK = false;
}
if (m_one.IsAnotherRunning()) {
// Create a IPC client and use it to ask the existing process to show itself.
wxClient *client = new wxClient;
wxConnectionBase *conn = client->MakeConnection("localhost", "/tmp/bobdude_socket_1351a1bebae7", "restart");
if (files.size()>0) {
for (unsigned int i=0; i< files.size(); i++) {
conn->Execute(files[i]);
}
} else {
conn->Execute(".");
}
delete conn;
delete client;
// Don't enter the message loop.
return false;
} else {
// Start a IPC server.
m_server = new CServer;
m_server->Create("/tmp/bobdude_socket_1351a1bebae7");
}
wxInitAllImageHandlers();
if ( wxsOK ) {
frame = new MainFrame(0);
frame->Show(true);
SetTopWindow(frame);
wxsOK = true;
}
return wxsOK;
}
int BobDudeApp::OnExit() {
delete m_server;
return this->wxApp::OnExit();
}
void BobDudeApp::OnInitCmdLine(wxCmdLineParser& parser) {
parser.SetDesc (g_cmdLineDesc);
// must refuse '/' as parameter starter or cannot use "/path" style paths
parser.SetSwitchChars (wxT("-"));
}
bool BobDudeApp::OnCmdLineParsed(wxCmdLineParser& parser) {
// to get at your unnamed parameters use
for (unsigned int i = 0; i < parser.GetParamCount(); i++) {
files.Add(parser.GetParam(i));
}
wxString configFile;
// and other command line parameters
if (parser.Found( wxT("c"), &configFile)) {
} else {
configFile = ::wxStandardPaths::Get().GetDataDir() + ::wxFileName::GetPathSeparator() + "avrdude.conf";
}
// then do what you need with them.
conf = configFile;
avrdude = new Avrdude("BobDude", static_cast<const char*>(configFile));
return true;
}
bool CConnection::OnExec(const wxString& topic, const wxString& data) {
if (topic.compare("restart") == 0) {
frame->Show(true);
frame->Restore();
frame->Raise();
if (data.compare(".")==0) {
//appendLogLine("[no file]");
} else {
appendLogLine("\n----------------------------\n");
frame->loadFile(data);
}
}
return true;
}
/***************************************************************
* Name: BobDudeApp.h
* Purpose: Defines Application Class
* Author: Nils Springob (springob@nicai-systems.de)
* Created: 2009-10-04
* Copyright: Nils Springob (http://nibo.nicai-systems.de)
* License:
**************************************************************/
#ifndef BOBDUDEAPP_H
#define BOBDUDEAPP_H
#include <wx/app.h>
#include <wx/cmdline.h>
#include <wx/snglinst.h>
#include <wx/ipc.h>
#define VERSION_STR "1.1.1"
#include "avrdude.h"
class CConnection : public wxConnection
{
protected:
bool OnExec(const wxString& topic, const wxString& data);
};
class CServer : public wxServer
{
public:
wxConnectionBase *OnAcceptConnection(const wxString& topic) {
return new CConnection;
}
};
class BobDudeApp : public wxApp {
private:
wxSingleInstanceChecker m_one;
CServer *m_server;
public:
virtual bool OnInit();
virtual int OnExit();
virtual void OnInitCmdLine(wxCmdLineParser& parser);
virtual bool OnCmdLineParsed(wxCmdLineParser& parser);
wxString conf;
wxArrayString files;
Avrdude * avrdude;
};
static const wxCmdLineEntryDesc g_cmdLineDesc [] = {
{ wxCMD_LINE_SWITCH, "h", "help", "displays help on the command line parameters", wxCMD_LINE_VAL_NONE, wxCMD_LINE_OPTION_HELP },
{ wxCMD_LINE_OPTION, "c", "config", "configuration file", wxCMD_LINE_VAL_STRING },
{ wxCMD_LINE_PARAM, NULL, NULL, "bob3-file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
{ wxCMD_LINE_NONE }
};
DECLARE_APP(BobDudeApp);
#endif // BOBDUDEAPP_H
#include "HTMLButton.h"
HTMLButton::HTMLButton() {
initialize();
}
HTMLButton::HTMLButton(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxHtmlWindow(parent, id, pos, size, style, name) {
initialize();
Bind(wxEVT_ENTER_WINDOW, &HTMLButton::handleMouseEvent, this);
Bind(wxEVT_LEAVE_WINDOW, &HTMLButton::handleMouseEvent, this);
Bind(wxEVT_MOTION, &HTMLButton::handleMouseEvent, this);
Bind(wxEVT_LEFT_DOWN, &HTMLButton::handleMouseEvent, this);
Bind(wxEVT_LEFT_UP, &HTMLButton::handleMouseEvent, this);
}
HTMLButton::~HTMLButton() {
}
void HTMLButton::initialize() {
m_styles["default"] = "<body>";
m_styles["hover"] = "<body>";
m_styles["active"] = "<body>";
m_styles["disabled"] = "<body>";
m_style = "default";
}
void HTMLButton::setStyleHTML(const wxString& style, const wxString& html) {
m_styles[style] = html;
updateHtml();
}
void HTMLButton::setHTML(const wxString& html) {
m_html = html;
updateHtml();
}
void HTMLButton::activateStyle(const wxString& style) {
m_disabled = (style=="disabled");
m_style = style;
updateHtml();
}
void HTMLButton::updateHtml() {
SetPage(m_styles[m_style]+m_html);
}
void HTMLButton::handleMouseEvent(wxMouseEvent& event) {
event.StopPropagation();
if (m_disabled) {
return;
}
if (event.Entering()) {
activateStyle("hover");
SetCursor(GetDefaultHTMLCursor(wxHtmlWindowInterface::HTMLCursor_Link));
m_clickState = 0;
} else if (event.Leaving()) {
activateStyle("default");
SetCursor(wxNullCursor);
m_clickState = 0;
} else if (event.LeftDown()) {
m_clickState = 1;
activateStyle("active");
} else if (event.LeftUp()) {
if (m_clickState == 1) {
wxCommandEvent ev(wxEVT_BUTTON);
GetEventHandler()->ProcessEvent(ev);
}
activateStyle("hover");
m_clickState = 0;
}
}
#ifndef _HTML_BUTTON_H_
#define _HTML_BUTTON_H_
#include <wx/html/htmlwin.h>
class HTMLButton: public wxHtmlWindow
{
private:
int m_clickState;
bool m_disabled;
wxStringToStringHashMap m_styles;
wxString m_html;
wxString m_style;
void updateHtml();
void handleMouseEvent(wxMouseEvent& event);
public:
HTMLButton();
HTMLButton(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHW_DEFAULT_STYLE,
const wxString& name = wxT("htmlWindow"));
virtual ~HTMLButton();
void initialize();
void setStyleHTML(const wxString& style, const wxString& html);
void setHTML(const wxString& html);
void activateStyle(const wxString& style);
};
#endif // _HTML_BUTTON_H_
This diff is collapsed.
#ifndef MAINFRAME_H
#define MAINFRAME_H
//(*Headers(MainFrame)
#include <wx/sizer.h>
#include <wx/menu.h>
#include <wx/filedlg.h>
#include <wx/frame.h>
#include <wx/html/htmlwin.h>
#include <wx/gauge.h>
//*)
#include "HTMLButton.h"
#include "PlatformDialog.h"
class xhex;
class MainFrame: public wxFrame
{
public:
MainFrame(wxWindow* parent,wxWindowID id=wxID_ANY);
virtual ~MainFrame();
//(*Declarations(MainFrame)
wxMenu* MenuHelp;
wxMenuItem* MenuItem5;
HTMLButton* HtmlWindowFile;
wxMenuItem* MenuItem1;
wxFileDialog* FileDialog1;
wxMenu* Menu1;
wxMenuItem* MenuItemOpen;
wxMenuItem* MenuItemExit;
HTMLButton* HtmlWindowPlatform;
wxMenu* MenuFile;
wxHtmlWindow* HtmlWindowLog;
wxMenuBar* MenuBar1;
wxGauge* GaugeProgress;
HTMLButton* HtmlWindowProgram;
//*)
PlatformDialog *platformDialog;
void loadFile(const wxString& name);
void appendLogLine(const wxString& text);
void appendLogError(const wxString& text);
void appendLogSuccess(const wxString& text);
void clearLog();
void updateGUI();
protected:
//(*Identifiers(MainFrame)
static const long ID_HTMLWINDOWFILE;
static const long ID_HTMLWINDOWPLATFORM;
static const long ID_HTMLWINDOWPROGRAM;
static const long ID_HTMLWINDOWLOG;
static const long ID_GAUGE_PROGRESS;
static const long ID_MENUITEM_OPEN;
static const long ID_MENUITEM_RESET_MCU;
//*)
private:
xhex * xhexfile;
wxString portBackup;
wxString m_filename;
wxString m_flashsize;
wxString m_eepromsize;
wxString m_fuses;
//(*Handlers(MainFrame)
void OnMenuItemOpenSelected(wxCommandEvent& event);
void OnMenuItemAboutSelected(wxCommandEvent& event);
void OnMenuItemExitSelected(wxCommandEvent& event);
void OnButtonProgramClick(wxCommandEvent& event);
void OnMenuItemResetMCU(wxCommandEvent& event);
//*)
void OnEditPlatform(wxCommandEvent& event);
DECLARE_EVENT_TABLE()
wxString getFileHTML();
};
#endif
#include "PlatformDialog.h"
#include "xhex.h"
#include <wx/msw/registry.h>
//(*InternalHeaders(PlatformDialog)
#include <wx/intl.h>
#include <wx/button.h>
#include <wx/string.h>
//*)
//(*IdInit(PlatformDialog)
const long PlatformDialog::ID_COMBOBOX_PLATFORM = wxNewId();
const long PlatformDialog::ID_COMBOBOX_MCU = wxNewId();
const long PlatformDialog::ID_COMBOBOX_BITCLOCK = wxNewId();
const long PlatformDialog::ID_COMBOBOX_PROGRAMMER = wxNewId();
const long PlatformDialog::ID_COMBOBOX_INTERFACE = wxNewId();
const long PlatformDialog::ID_COMBOBOX_BAUDRATE = wxNewId();
//*)
BEGIN_EVENT_TABLE(PlatformDialog,wxDialog)
//(*EventTable(PlatformDialog)
//*)
END_EVENT_TABLE()
PlatformDialog::PlatformDialog(wxWindow* parent,wxWindowID id)
{
//(*Initialize(PlatformDialog)
wxStaticText* StaticTextMCU;
wxStaticText* StaticTextPlatform;
wxBoxSizer* BoxSizer1;
wxFlexGridSizer* FlexGridSizer1;
Create(parent, id, _("Platform Configuration"), wxDefaultPosition, wxDefaultSize, wxCAPTION|wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER|wxCLOSE_BOX, _T("id"));
SetMinSize(wxSize(250,250));
BoxSizer1 = new wxBoxSizer(wxVERTICAL);
FlexGridSizer1 = new wxFlexGridSizer(0, 2, 0, 0);
FlexGridSizer1->AddGrowableCol(1);
StaticTextPlatform = new wxStaticText(this, wxID_ANY, _("Platform:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextPlatform, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxPlatform = new wxComboBox(this, ID_COMBOBOX_PLATFORM, wxEmptyString, wxDefaultPosition, wxSize(220,-1), 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_PLATFORM"));
FlexGridSizer1->Add(ComboBoxPlatform, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticTextMCU = new wxStaticText(this, wxID_ANY, _("MCU:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextMCU, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxMCU = new wxComboBox(this, ID_COMBOBOX_MCU, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_MCU"));
ComboBoxMCU->Disable();
FlexGridSizer1->Add(ComboBoxMCU, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticTextBitclock = new wxStaticText(this, wxID_ANY, _("Bitclock:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextBitclock, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxBitclock = new wxComboBox(this, ID_COMBOBOX_BITCLOCK, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_BITCLOCK"));
ComboBoxBitclock->Append(_("default"));
ComboBoxBitclock->Append(_("1"));
ComboBoxBitclock->Append(_("2"));
ComboBoxBitclock->Append(_("3"));
ComboBoxBitclock->Append(_("4"));
ComboBoxBitclock->Append(_("5"));
ComboBoxBitclock->Append(_("6"));
ComboBoxBitclock->Append(_("7"));
ComboBoxBitclock->Append(_("8"));
ComboBoxBitclock->Append(_("10"));
ComboBoxBitclock->Append(_("15"));
ComboBoxBitclock->Append(_("20"));
ComboBoxBitclock->Append(_("50"));
ComboBoxBitclock->Append(_("100"));
ComboBoxBitclock->Disable();
FlexGridSizer1->Add(ComboBoxBitclock, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticTextProgrammer = new wxStaticText(this, wxID_ANY, _("Programmer:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextProgrammer, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxProgrammer = new wxComboBox(this, ID_COMBOBOX_PROGRAMMER, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_PROGRAMMER"));
ComboBoxProgrammer->Disable();
FlexGridSizer1->Add(ComboBoxProgrammer, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticTextInterface = new wxStaticText(this, wxID_ANY, _("Interface:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextInterface, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxInterface = new wxComboBox(this, ID_COMBOBOX_INTERFACE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_INTERFACE"));
ComboBoxInterface->Disable();
FlexGridSizer1->Add(ComboBoxInterface, 1, wxALL|wxEXPAND|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL, 5);
StaticTextBaudrate = new wxStaticText(this, wxID_ANY, _("Baudrate:"), wxDefaultPosition, wxDefaultSize, 0, _T("wxID_ANY"));
FlexGridSizer1->Add(StaticTextBaudrate, 0, wxALL|wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5);
ComboBoxBaudrate = new wxComboBox(this, ID_COMBOBOX_BAUDRATE, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0, 0, 0, wxDefaultValidator, _T("ID_COMBOBOX_BAUDRATE"));
ComboBoxBaudrate->Append(_("default"));
ComboBoxBaudrate->Append(_("110"));
ComboBoxBaudrate->Append(_("300"));
ComboBoxBaudrate->Append(_("600"));
ComboBoxBaudrate->Append(_("1200"));
ComboBoxBaudrate->Append(_("2400"));