Go back to Richel Bilderbeek's homepage.

Go back to Richel Bilderbeek's C++ page.

 

 

 

 

 

(C++) Rasper

 

Rasper is a web application tool to toggle the Raspberry Pi its GPIO ports.

 

 

 

 

 

Downloads

 

 

 

 

 

 

Older downloads

 

Technical facts

 

Application type(s)

Operating system(s) or programming environment(s)

IDE(s):

Project type:

C++ standard:

Compiler(s):

Libraries used:

 

 

 

 

 

Qt project file: ./ToolRasper/ToolRasper.pro

 

QT       += core gui
#greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

LIBS += -lwt -lwthttp -lboost_signals -lboost_regex -lboost_system -lboost_filesystem -lboost_program_options
QMAKE_CXXFLAGS += -std=c++11 -Wall -Wextra
CONFIG   += console
CONFIG   -= app_bundle
TEMPLATE = app

INCLUDEPATH += \
  ../../Classes/CppAbout \
  ../../Classes/CppRaspberryPi \
  ../../Classes/CppTrace \
  ../../Classes/CppWtAboutDialog \
  ../../Classes/CppWtAutoConfig

SOURCES += \
    ../../Classes/CppAbout/about.cpp \
    ../../Classes/CppRaspberryPi/raspberrypigpiopin.cpp \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.cpp \
    ../../Classes/CppWtAutoConfig/wtautoconfig.cpp \
    raspermenudialog.cpp \
    wtmain.cpp \
    wtraspermaindialog.cpp \
    wtraspermenudialog.cpp \
    wtrasperresources.cpp

HEADERS += \
    ../../Classes/CppAbout/about.h \
    ../../Classes/CppRaspberryPi/raspberrypifwd.h \
    ../../Classes/CppRaspberryPi/raspberrypigpiopin.h \
    ../../Classes/CppTrace/trace.h \
    ../../Classes/CppWtAboutDialog/wtaboutdialog.h \
    ../../Classes/CppWtAutoConfig/wtautoconfig.h \
    raspermenudialog.h \
    wtraspermaindialog.h \
    wtraspermenudialog.h \
    wtrasperresources.h

OTHER_FILES += \
    ../../Classes/CppTrace/Licence.txt

RESOURCES += \
    ToolRasper.qrc

 

 

 

 

 

./ToolRasper/raspermenudialog.h

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#ifndef RASPERMENUDIALOG_H
#define RASPERMENUDIALOG_H

#include <string>
#include <vector>

#include "about.h"

namespace ribi {
namespace ToolRasper {

///The GUI independent part of the menu
struct MenuDialog
{
  ///Get this class its version
  std::string GetVersion() const noexcept;

  ///Get this class its version history
  std::vector<std::string> GetVersionHistory() const noexcept;

  ///Get this class its About
  About GetAbout() const noexcept;
};

} //~namespace ToolRasper
} //~namespace ribi

#endif // RASPERMENUDIALOG_H

 

 

 

 

 

./ToolRasper/raspermenudialog.cpp

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#include "about.h"
#include "raspermenudialog.h"

ribi::About ribi::ToolRasper::MenuDialog::GetAbout() const noexcept
{
  About a(
    "Richel Bilderbeek",
    "Rasper",
    "Raspberry Pi GPIO web application controller",
    "the 9th of February 2013",
    "2013",
    "http://www.richelbilderbeek.nl/ToolRasper.htm",
    GetVersion(),
    GetVersionHistory());
  //a.AddLibrary("IpAddress version: " + IpAddress::GetVersion());

  return a;
}

std::string ribi::ToolRasper::MenuDialog::GetVersion() const noexcept
{
  return "0.3";
}

std::vector<std::string> ribi::ToolRasper::MenuDialog::GetVersionHistory() const noexcept
{
  std::vector<std::string> v;
  v.push_back("2013-01-23: Version 0.1: initial version");
  v.push_back("2013-02-06: Version 0.2: progress on GUI");
  v.push_back("2013-02-09: Version 0.3: initial GUI");
  return v;
}

 

 

 

 

 

./ToolRasper/wtmain.cpp

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#include <Wt/WApplication>
#include <Wt/WEnvironment>

#include "wtrasperresources.h"
#include "wtraspermenudialog.h"
#include "wtautoconfig.h"

struct WtApplication : public Wt::WApplication
{
  WtApplication(const Wt::WEnvironment& env)
  : WApplication(env)
  {
    setTitle("Rasper");
    this->useStyleSheet("wt.css");
    root()->addWidget(new ribi::ToolRasper::WtMenuDialog);

  }
};

Wt::WApplication *createApplication(const Wt::WEnvironment& env)
{
  return new WtApplication(env);
}

int main(int argc, char **argv)
{
  //Create the resources
  ribi::ToolRasper::WtResources();

  ribi::WtAutoConfig::SaveDefaultStylesheet();
  ribi::WtAutoConfig a(argc,argv,createApplication);

  return a.Run();
}

 

 

 

 

 

./ToolRasper/wtraspermaindialog.h

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#ifndef WTRASPERMAINDIALOG_H
#define WTRASPERMAINDIALOG_H

#include <vector>
#include <Wt/WContainerWidget>
#include "raspberrypigpiopin.h"

namespace Wt
{
  struct WPushButton;
  struct WMouseEvent;
}


namespace ribi {

struct IpAddress;

namespace ToolRasper {

///Rasper its main dialog
struct WtMainDialog : public Wt::WContainerWidget
{
  WtMainDialog();

  private:
  struct Ui
  {
    Ui();
    std::vector<Wt::WPushButton*> m_buttons;
  } ui;

  std::vector<rpi::gpio::Pin> m_pins;

  ///Respond to the user changing the name edit
  void OnClick(const int pin_number);

  //const std::set<int> pins { 3,5,7,8,10,11,12,13,15,16,18,19,21,22,23,24,26 };
  //void OnClick1()  { OnClick( 1); }
  //void OnClick2()  { OnClick( 2); }
  void OnClick3()  { OnClick( 3); }
  //void OnClick4()  { OnClick( 4); }
  void OnClick5()  { OnClick( 5); }
  //void OnClick6()  { OnClick( 6); }
  void OnClick7()  { OnClick( 7); }
  void OnClick8()  { OnClick( 8); }
  //void OnClick9()  { OnClick( 9); }
  void OnClick10() { OnClick(10); }
  void OnClick11() { OnClick(11); }
  void OnClick12() { OnClick(12); }
  void OnClick13() { OnClick(13); }
  //void OnClick14() { OnClick(14); }
  void OnClick15() { OnClick(15); }
  void OnClick16() { OnClick(16); }
  //void OnClick17() { OnClick(17); }
  void OnClick18() { OnClick(18); }
  void OnClick19() { OnClick(19); }
  //void OnClick20() { OnClick(20); }
  void OnClick21() { OnClick(21); }
  void OnClick22() { OnClick(22); }
  void OnClick23() { OnClick(23); }
  void OnClick24() { OnClick(24); }
  //void OnClick25() { OnClick(25); }
  void OnClick26() { OnClick(26); }

  static const std::vector<rpi::gpio::Pin> CreatePins();
};

} //~namespace ToolRasper
} //~namespace ribi


#endif // WTRASPERMAINDIALOG_H

 

 

 

 

 

./ToolRasper/wtraspermaindialog.cpp

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#include <cassert>

#include <set>

//#include <boost/algorithm/string/trim.hpp>
#include <boost/lexical_cast.hpp>
//#include <boost/numeric/conversion/cast.hpp>
#include <boost/lambda/lambda.hpp>


#include <Wt/WAnchor>
#include <Wt/WBreak>
#include <Wt/WGroupBox>
#include <Wt/WImage>
#include <Wt/WLabel>

#include "raspberrypigpiopin.h"
#include "raspermenudialog.h"
#include "trace.h"
#include "wtrasperresources.h"
#include "wtaboutdialog.h"
#include "wtraspermaindialog.h"

const std::vector<rpi::gpio::Pin> ribi::ToolRasper::WtMainDialog::CreatePins()
{
  std::vector<rpi::gpio::Pin> v;
  for (int pin: rpi::gpio::Pin::CreatePinNumbers())
  {
    v.push_back(rpi::gpio::Pin(pin));
  }
  return v;
}

ribi::ToolRasper::WtMainDialog::Ui::Ui()
{
  for (int i=0; i!=rpi::gpio::GetMaxPinNumber(); ++i)
  {
    Wt::WPushButton * const button
      = new Wt::WPushButton;
    button->setText(".");
    m_buttons.push_back(button);
  }
}

ribi::ToolRasper::WtMainDialog::WtMainDialog()
  : m_pins(CreatePins())
{
  this->setContentAlignment(Wt::AlignCenter);

  //-1 as buttons are human counted
  //const std::set<int> pins { 3,5,7,8,10,11,12,13,15,16,18,19,21,22,23,24,26 };

  ui.m_buttons[ 1-1]->setText("3v3");
  //ui.m_buttons[ 1-1]->setText("1");
  //ui.m_buttons[ 1-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick1);
  ui.m_buttons[ 2-1]->setText("5 V");
  //ui.m_buttons[ 2-1]->setText("2");
  //ui.m_buttons[ 2-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick2);
  ui.m_buttons[ 3-1]->setText("3");
  ui.m_buttons[ 3-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick3);
  ui.m_buttons[ 4-1]->setText("DNC");
  //ui.m_buttons[ 4-1]->setText("4");
  //ui.m_buttons[ 4-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick4);
  ui.m_buttons[ 5-1]->setText("5");
  ui.m_buttons[ 5-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick5);
  ui.m_buttons[ 6-1]->setText("GND");
  //ui.m_buttons[ 6-1]->setText("6");
  //ui.m_buttons[ 6-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick6);
  ui.m_buttons[ 7-1]->setText("7");
  ui.m_buttons[ 7-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick7);
  ui.m_buttons[ 8-1]->setText("8");
  ui.m_buttons[ 8-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick8);
  ui.m_buttons[ 9-1]->setText("DNC");
  //ui.m_buttons[ 9-1]->setText("9");
  //ui.m_buttons[ 9-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick9);
  ui.m_buttons[10-1]->setText("10");
  ui.m_buttons[10-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick10);
  ui.m_buttons[11-1]->setText("11");
  ui.m_buttons[11-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick11);
  ui.m_buttons[12-1]->setText("12");
  ui.m_buttons[12-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick12);
  ui.m_buttons[13-1]->setText("13");
  ui.m_buttons[13-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick13);
  ui.m_buttons[14-1]->setText("DNC");
  //ui.m_buttons[14-1]->setText("14");
  //ui.m_buttons[14-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick14);
  ui.m_buttons[15-1]->setText("15");
  ui.m_buttons[15-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick15);
  ui.m_buttons[16-1]->setText("16");
  ui.m_buttons[16-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick16);
  ui.m_buttons[17-1]->setText("DNC");
  //ui.m_buttons[17-1]->setText("17");
  //ui.m_buttons[17-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick17);
  ui.m_buttons[18-1]->setText("18");
  ui.m_buttons[18-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick18);
  ui.m_buttons[19-1]->setText("19");
  ui.m_buttons[19-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick19);
  ui.m_buttons[20-1]->setText("DNC");
  //ui.m_buttons[20-1]->setText("20");
  //ui.m_buttons[20-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick20);
  ui.m_buttons[21-1]->setText("21");
  ui.m_buttons[21-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick21);
  ui.m_buttons[22-1]->setText("22");
  ui.m_buttons[22-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick22);
  ui.m_buttons[23-1]->setText("23");
  ui.m_buttons[23-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick23);
  ui.m_buttons[24-1]->setText("24");
  ui.m_buttons[24-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick24);
  ui.m_buttons[25-1]->setText("DNC");
  //ui.m_buttons[25-1]->setText("25");
  //ui.m_buttons[25-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick25);
  ui.m_buttons[26-1]->setText("26");
  ui.m_buttons[26-1]->clicked().connect(this,&ribi::ToolRasper::WtMainDialog::OnClick26);

  //Add buttons
  {
    Wt::WGroupBox * const box = new Wt::WGroupBox("Control buttons",this);
    for (int i=0; i!=rpi::gpio::GetMaxPinNumber(); ++i)
    {
      const int row = 1 - (i / (rpi::gpio::GetMaxPinNumber() / 2));
      const int col = i % (rpi::gpio::GetMaxPinNumber() / 2);
      const int button_index = (col * 2) + row;
      box->addWidget(ui.m_buttons[button_index]);

      ui.m_buttons[i]->setMaximumSize(43,32);
      ui.m_buttons[i]->setMinimumSize(43,32);

      if (col == ((rpi::gpio::GetMaxPinNumber() / 2) - 1)) box->addWidget(new Wt::WBreak);
    }
  }
  this->addWidget(new Wt::WBreak);
  //Add images
  {
    Wt::WGroupBox * const box = new Wt::WGroupBox("GPIO pins layout",this);
    const WtResources w;
    box->addWidget(new Wt::WBreak);
    box->addWidget(new Wt::WImage(w.GetImageGpioFilename().c_str()));
    box->addWidget(new Wt::WBreak);
    box->addWidget(new Wt::WAnchor( WtResources().GetImageGpioSource(), WtResources().GetImageGpioAttribute()));
  }
  this->addWidget(new Wt::WBreak);
  {
    Wt::WGroupBox * const box = new Wt::WGroupBox("Raspberry Pi",this);
    const WtResources w;
    box->addWidget(new Wt::WImage(w.GetImageRaspberryPiTopFilename().c_str()));
    box->addWidget(new Wt::WBreak);
    box->addWidget(new Wt::WAnchor( WtResources().GetImageRaspberryPiTopSource(), WtResources().GetImageRaspberryPiTopAttribute()));
  }
}

void ribi::ToolRasper::WtMainDialog::OnClick(const int pin_number)
{
  std::vector<rpi::gpio::Pin>::iterator iter = std::find_if(m_pins.begin(),m_pins.end(),
    [pin_number](const rpi::gpio::Pin& pin)
    {
      return pin.GetPinNumber() == pin_number;
    }
  );

  if (iter != m_pins.end())
  {
    (*iter).Toggle();
  }
}

 

 

 

 

 

./ToolRasper/wtraspermenudialog.h

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#ifndef WTRASPERMENUDIALOG_H
#define WTRASPERMENUDIALOG_H

#include <boost/shared_ptr.hpp>

#include <Wt/WContainerWidget>


namespace ribi {

struct IpAddress;

namespace ToolRasper {

struct WtMenuDialog : public Wt::WContainerWidget
{
  WtMenuDialog();
  private:
  Wt::WWidget * CreateNewAboutDialog();
  Wt::WWidget * CreateNewMainDialog() const;
  Wt::WWidget * CreateNewWelcomeDialog() const;
};

} //~namespace ToolRasper
} //~namespace ribi

#endif // WTRASPERMENUDIALOG_H

 

 

 

 

 

./ToolRasper/wtraspermenudialog.cpp

 

//---------------------------------------------------------------------------
/*
Rasper, Raspberry Pi GPIO web application controller
Copyright (C) 2013 Richel Bilderbeek

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
//---------------------------------------------------------------------------
//From http://www.richelbilderbeek.nl/ToolRasper.htm
//---------------------------------------------------------------------------
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>

#include <Wt/WAnchor>
#include <Wt/WBreak>
#include <Wt/WContainerWidget>
#include <Wt/WGroupBox>
#include <Wt/WImage>
#include <Wt/WLabel>
#include <Wt/WStackedWidget>
#include <Wt/WMenu>
#include <Wt/WMenuItem>

#include "raspermenudialog.h"
#include "wtaboutdialog.h"
#include "wtautoconfig.h"
#include "wtraspermaindialog.h"
#include "wtrasperresources.h"
#include "wtraspermenudialog.h"

#include <QFile>

ribi::ToolRasper::WtMenuDialog::WtMenuDialog()
{
  this->setContentAlignment(Wt::AlignCenter);
  {
    Wt::WLabel * const title = new Wt::WLabel("Rasper");
    title->setStyleClass("title");
    this->addWidget(title);
  }
  //Menu
  {
    Wt::WStackedWidget * const contents = new Wt::WStackedWidget;
    Wt::WMenu * const menu = new Wt::WMenu(contents,Wt::Horizontal);
    menu->setStyleClass("menu");
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Welcome",
        CreateNewWelcomeDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "Start",
        CreateNewMainDialog());
      menu->addItem(item);
    }
    {
      Wt::WMenuItem * const item = new Wt::WMenuItem(
        "About",
        CreateNewAboutDialog());
      menu->addItem(item);
    }
    //Display menu on top
    this->addWidget(menu);
    this->addWidget(new Wt::WBreak);
    //Display contents below menu
    this->addWidget(contents);
  }
}

Wt::WWidget * ribi::ToolRasper::WtMenuDialog::CreateNewAboutDialog()
{
  About a = MenuDialog().GetAbout();
  a.AddLibrary("WtAutoConfig version: " + WtAutoConfig::GetVersion());
  WtAboutDialog * const d = new WtAboutDialog(a,false);
  assert(d);
  return d;
}

Wt::WWidget * ribi::ToolRasper::WtMenuDialog::CreateNewMainDialog() const
{
  WtMainDialog * const d = new WtMainDialog;
  assert(d);
  return d;
}

Wt::WWidget * ribi::ToolRasper::WtMenuDialog::CreateNewWelcomeDialog() const
{
  Wt::WContainerWidget * dialog = new Wt::WContainerWidget;
  dialog->setContentAlignment(Wt::AlignCenter);
  dialog->addWidget(new Wt::WBreak);
  new Wt::WLabel("Welcome to Rasper",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  new Wt::WLabel("Rasper is a Raspberry Pi GPIO web application controller",dialog);
  new Wt::WBreak(dialog);
  new Wt::WBreak(dialog);
  Wt::WGroupBox * const box = new Wt::WGroupBox("Raspberry Pi",dialog);
  box->addWidget(new Wt::WImage( WtResources().GetImageRaspberryPiDiagonallyFilename().c_str()));
  box->addWidget(new Wt::WBreak);
  box->addWidget(new Wt::WAnchor( WtResources().GetImageRaspberryPiDiagonallySource(), WtResources().GetImageRaspberryPiDiagonallyAttribute()));
  return dialog;
}

 

 

 

 

 

./ToolRasper/wtrasperresources.h

 

#ifndef WTRASPERRESOURCES_H
#define WTRASPERRESOURCES_H

#include <string>

namespace ribi {
namespace ToolRasper {

struct WtResources
{
  WtResources();
  std::string GetImageBackgroundAttribute() const noexcept { return "(C) Richel Bilderbeek"; }
  std::string GetImageBackgroundFilename() const noexcept;
  std::string GetImageBackgroundSource() const noexcept { return "http://www.richelbilderbeek.nl"; }

  std::string GetImageGpioAttribute() const noexcept { return "(C) Matt / raspberrypi-spy.co.uk"; }
  std::string GetImageGpioFilename() const noexcept;
  std::string GetImageGpioSource() const noexcept { return "http://www.raspberrypi-spy.co.uk/2012/06/simple-guide-to-the-rpi-gpio-header-and-pins"; }

  std::string GetImageRaspberryPiTopAttribute() const noexcept { return "(C) Maiakaat / Wikimedia Commons / CC-BY-SA-2.0 / Front of Raspberry Pi"; }
  std::string GetImageRaspberryPiTopFilename() const noexcept;
  std::string GetImageRaspberryPiTopSource() const noexcept { return "http://commons.wikimedia.org/wiki/File:Front_of_Raspberry_Pi.jpg"; }

  std::string GetImageRaspberryPiDiagonallyAttribute() const noexcept { return "(C) cowjuice / Wikimedia Commons / CC-BY-SA-3.0 / Raspberry Pi Photo"; }
  std::string GetImageRaspberryPiDiagonallyFilename() const noexcept;
  std::string GetImageRaspberryPiDiagonallySource() const noexcept { return "http://commons.wikimedia.org/wiki/File:Raspberry_Pi_Photo.jpg"; }

  private:

  static void Create(const std::string& filename) noexcept;

  static void Test();
};

} //~namespace ToolRasper
} //~namespace ribi

#endif // WTRASPERRESOURCES_H

 

 

 

 

 

./ToolRasper/wtrasperresources.cpp

 

#include "wtrasperresources.h"

#include <cassert>
#include <iostream>

#include <QFile>

ribi::ToolRasper::WtResources::WtResources()
{
  #ifndef NDEBUG
  Test();
  #endif
}

void ribi::ToolRasper::WtResources::Create(const std::string& filename) noexcept
{
  if (!QFile::exists(filename.c_str()))
  {
    const QString q = QString(":/images/") + QString(filename.c_str());
    QFile file(q);
    file.copy(filename.c_str());
    file.close();
  }
  if (!QFile::exists(filename.c_str()))
  {
    std::cerr << "Warning: '" << filename << "' not found\n";
  }
  assert(QFile::exists(filename.c_str()));

}

std::string ribi::ToolRasper::WtResources::GetImageBackgroundFilename() const noexcept
{
  const std::string s = "RichelbilderbeekNlBackground.png";
  Create(s);
  return s;
}

std::string ribi::ToolRasper::WtResources::GetImageGpioFilename() const noexcept
{
  const std::string s = "ToolRasperGpioLayout.png";
  Create(s);
  return s;
}

std::string ribi::ToolRasper::WtResources::GetImageRaspberryPiDiagonallyFilename() const noexcept
{
  const std::string s = "ToolRasperRaspberryPiDiagonally.jpg";
  Create(s);
  return s;
}

std::string ribi::ToolRasper::WtResources::GetImageRaspberryPiTopFilename() const noexcept
{
  const std::string s = "ToolRasperRaspberryPiTop.jpg";
  Create(s);
  return s;
}

void ribi::ToolRasper::WtResources::Test()
{
  {
    static bool is_tested = false;
    if (is_tested) return;
    is_tested = true;
  }
  WtResources().GetImageBackgroundFilename();
  WtResources().GetImageGpioFilename();
  WtResources().GetImageRaspberryPiDiagonallyFilename();
  WtResources().GetImageRaspberryPiTopFilename();
}

 

 

 

 

 

./ToolRasper/rasper_start_and_auto_update.sh

 

#!/bin/sh

WORKDIR=/home/pi/Projects/Tools/ToolRasper
MAKEFILE=$WORKDIR/Makefile

rm ToolRasperSource.zip
wget richelbilderbeek.nl/ToolRasperSource.zip
unzip -o ToolRasperSource.zip

touch $WORKDIR/ToolRasper.pro
qmake $WORKDIR/ToolRasper.pro -o $MAKEFILE

if [ -f $MAKEFILE ]
then
  echo "$WORKDIR created successfully"
else
  echo "$WORKDIR not created, now exiting script"
  exit
fi

make --makefile=$MAKEFILE --directory=$WORKDIR


chmod +x $WORKDIR/ToolRasper
$WORKDIR/ToolRasper

 

 

 

 

 

./ToolRasper/zip.sh

 

#!/bin/sh

echo "Removing user information"
rm *.user

echo "Removing possible temp file"
rm copy.txt
rm tmp.txt


echo "Creating of all main folders"

mkdir temp_zip
mkdir temp_zip/Classes
mkdir temp_zip/Tools

echo "Creating of all subfolders"

mkdir temp_zip/Classes/CppAbout
mkdir temp_zip/Classes/CppRaspberryPi
mkdir temp_zip/Classes/CppTrace
mkdir temp_zip/Classes/CppWtAboutDialog
mkdir temp_zip/Classes/CppWtAutoConfig
mkdir temp_zip/Tools/ToolRasper

echo "Copying files"

cp ../../Classes/CppAbout/about.cpp temp_zip/Classes/CppAbout/about.cpp
cp ../../Classes/CppAbout/about.h temp_zip/Classes/CppAbout/about.h
cp ../../Classes/CppRaspberryPi/raspberrypifwd.h temp_zip/Classes/CppRaspberryPi/raspberrypifwd.h
cp ../../Classes/CppRaspberryPi/raspberrypigpiopin.cpp temp_zip/Classes/CppRaspberryPi/raspberrypigpiopin.cpp
cp ../../Classes/CppRaspberryPi/raspberrypigpiopin.h temp_zip/Classes/CppRaspberryPi/raspberrypigpiopin.h
cp ../../Classes/CppTrace/Licence.txt temp_zip/Classes/CppTrace/Licence.txt
cp ../../Classes/CppTrace/trace.h temp_zip/Classes/CppTrace/trace.h
cp ../../Classes/CppWtAboutDialog/wtaboutdialog.cpp temp_zip/Classes/CppWtAboutDialog/wtaboutdialog.cpp
cp ../../Classes/CppWtAboutDialog/wtaboutdialog.h temp_zip/Classes/CppWtAboutDialog/wtaboutdialog.h
cp ../../Classes/CppWtAutoConfig/wtautoconfig.cpp temp_zip/Classes/CppWtAutoConfig/wtautoconfig.cpp
cp ../../Classes/CppWtAutoConfig/wtautoconfig.h temp_zip/Classes/CppWtAutoConfig/wtautoconfig.h
cp ../../Tools/ToolRasper/Licence.txt temp_zip/Tools/ToolRasper/Licence.txt
cp ../../Tools/ToolRasper/RichelbilderbeekNlBackground.png temp_zip/Tools/ToolRasper/RichelbilderbeekNlBackground.png
cp ../../Tools/ToolRasper/ToolRasper.pro temp_zip/Tools/ToolRasper/ToolRasper.pro
cp ../../Tools/ToolRasper/ToolRasper.qrc temp_zip/Tools/ToolRasper/ToolRasper.qrc
cp ../../Tools/ToolRasper/ToolRasperGpioLayout.png temp_zip/Tools/ToolRasper/ToolRasperGpioLayout.png
cp ../../Tools/ToolRasper/ToolRasperRaspberryPiDiagonally.jpg temp_zip/Tools/ToolRasper/ToolRasperRaspberryPiDiagonally.jpg
cp ../../Tools/ToolRasper/ToolRasperRaspberryPiTop.jpg temp_zip/Tools/ToolRasper/ToolRasperRaspberryPiTop.jpg
cp ../../Tools/ToolRasper/rasper_start_and_auto_update.sh temp_zip/Tools/ToolRasper/rasper_start_and_auto_update.sh
cp ../../Tools/ToolRasper/raspermenudialog.cpp temp_zip/Tools/ToolRasper/raspermenudialog.cpp
cp ../../Tools/ToolRasper/raspermenudialog.h temp_zip/Tools/ToolRasper/raspermenudialog.h
cp ../../Tools/ToolRasper/wtmain.cpp temp_zip/Tools/ToolRasper/wtmain.cpp
cp ../../Tools/ToolRasper/wtraspermaindialog.cpp temp_zip/Tools/ToolRasper/wtraspermaindialog.cpp
cp ../../Tools/ToolRasper/wtraspermaindialog.h temp_zip/Tools/ToolRasper/wtraspermaindialog.h
cp ../../Tools/ToolRasper/wtraspermenudialog.cpp temp_zip/Tools/ToolRasper/wtraspermenudialog.cpp
cp ../../Tools/ToolRasper/wtraspermenudialog.h temp_zip/Tools/ToolRasper/wtraspermenudialog.h
cp ../../Tools/ToolRasper/wtrasperresources.cpp temp_zip/Tools/ToolRasper/wtrasperresources.cpp
cp ../../Tools/ToolRasper/wtrasperresources.h temp_zip/Tools/ToolRasper/wtrasperresources.h
cp ../../Tools/ToolRasper/zip.sh temp_zip/Tools/ToolRasper/zip.sh

FILENAME="ToolRasperSource"
ZIP_FILENAME=$FILENAME".zip"

echo "Compressing files"

cd temp_zip
zip -r $FILENAME Classes
zip -r $FILENAME Tools
cd ..
cp "temp_zip/"$ZIP_FILENAME $ZIP_FILENAME

echo "Cleaning up"

echo "Emptying subfolders"

rm temp_zip/Classes/CppAbout/*.*
rm temp_zip/Classes/CppRaspberryPi/*.*
rm temp_zip/Classes/CppTrace/*.*
rm temp_zip/Classes/CppWtAboutDialog/*.*
rm temp_zip/Classes/CppWtAutoConfig/*.*
rm temp_zip/Tools/ToolRasper/*.*

echo "Removing subfolders"

rmdir temp_zip/Classes/CppAbout
rmdir temp_zip/Classes/CppRaspberryPi
rmdir temp_zip/Classes/CppTrace
rmdir temp_zip/Classes/CppWtAboutDialog
rmdir temp_zip/Classes/CppWtAutoConfig
rmdir temp_zip/Tools/ToolRasper

echo "Removing main folders"

rmdir temp_zip/Classes
rmdir temp_zip/Tools

echo "Removing temporary folder"

rm temp_zip/*.*
rmdir temp_zip

echo "Done"

# CreateQtProjectZipFile, version 1.3
# Copyright (C) 2012 Richel Bilderbeek
# Programmed on the 10th of June 2012
# by Richel Bilderbeek
#
# CreateQtProjectZipFile can be downloaded from http://www.richelbilderbeek.nl/ToolCreateQtProjectZipFile.htm
# Licenced under GPL 3.0

 

 

 

 

 

Go back to Richel Bilderbeek's C++ page.

Go back to Richel Bilderbeek's homepage.

 

Valid XHTML 1.0 Strict

This page has been created by the tool CodeToHtml