Month: February 2011

Python GUI calc

Python GUI experiment. Simple calculator application made with Tk.
It’s a first choice because it’s integrated into Python, simple to use and powerful enough for most cases. It’s also cross platform like an interpreter.
However, there are many other libraries for GUI:


# Python GUI calculator 
# (C) 2011 -
# Original code by Emanuele Chiabrera
# Enhanced by Toropov Ivan 

from Tkinter import *

# button text list
cmdlst = ['7', '8', '9', '+', '%',
          '4', '5', '6', '-', '**',
          '1', '2', '3', '*', '//',
          '.', '0', 'CL', '/', '=']

class MyButton(Button):
    backref = None
    def Click(self):
        # back reference

class CalcApp:

    def __init__(self, master):
        frame = Frame(master)
        self.textbox = Entry(width=30, takefocus=1)

        self.buttons = []
        for n, c in enumerate(cmdlst):
            self.buttons.append(MyButton(frame, text=c, width=5))
            self.buttons[n]["command"] = self.buttons[n].Click
            self.buttons[n].backref = self
            self.buttons[n].grid(row=n/5, column=n%5)


    def BtnCmd(self, cmd):
        if cmd == '=':
                res = eval(self.textbox.get())
                res = "Error!"
            self.textbox.delete(0, END)
            self.textbox.insert(0, str(res))
        elif cmd == 'CL':
            self.textbox.delete(0, END)
            self.textbox.insert(END, cmd)

root = Tk()

calcapp = CalcApp(root)

What comes out:

Voltage Drop Protection

DC motor drive circuit with automatic load regulation. Main concept is to cut off power from DC Motor and sustain the voltage in the circuit. Also detect low-battery state.

#1 – Dual Op-Amp CA158 (Like LM358)
#1 – Trimmer 4.7 kΩ (voltage limit regulator)
#1 – NPN-MOSFET IRF530 (14A, 100V)
#1 – Capacitor C 0,1 µF
#1 – Capacitor C 0,33 µF
#1 – Led (Green – Bat ok)
#1 – Led (Red – Bat low)
#2 – Resistor R 220 Ω
#3 – Resistor R 15 kΩ
#1 – Brushed DC-Motor Permax 400 (6V)

Fonera 2.0n hardware

Model Name

Fonera SDK is originally based on Ralink SDK, also derived from OpenWRT project.

Build instructions can be found on this pages:

Download and build sources:
svn co fon-sdk
cd fon-sdk/
chmod +x
cd openwrt
make menuconfig

30 mm x 157 mm x 127 mm (excluding antenna)
12VDC, 1A (It seems to work with 6VDC)
#1 – USB 2.0/1.1
#1 – Ethernet WAN 10/100Mbps
#4 – Ethernet LAN 10/100Mbps
#2 – 3dBi Dipole Fixed Antennas
SoC Ralink RT3052F 320/384 MHz MIPS24KEc
64 MB – (32 MB cpu internal + 2×16 MB external PSC A3V56S40ETP-G6)
8 MB – MX29LV640DBTC-90G

External links:
Product briefing
RT3052F CPU Ref.
Ralink ApSoC SDK 3301
SDK User’s manual

Fonera SDK is originally based on Ralink SDK, also derived from OpenWRT project.

Build instructions can be found on this pages:

Download and build sources:
svn co fon-sdk
cd fon-sdk/
chmod +x
cd openwrt
make menuconfig

Dead after a few difficult years 🙁


Boost & RCF on Mac OSX with Xcode

Litle HowTo prepare Boost and RCF on Mac!
My work environment is Mac OS X Snow Leopard 10.6.6 and Xcode 3.2.5
Boost version is 1.45.0 and RCF version is 1.3

What is Boost and RCF?
Boost is a powerful and portable C++ library.
RCF is a Remote Call Framework something like RPC.

The two libraries written in C++ seems to be Cross Platform and Cross Compiler also 64 bit.
From RCF documentation only one thing must be done.
Use of the typedef’s in “boost/cstdint.hpp” for portability.

The first step is to download and compile boost.
The official site is

Extract downloaded file to your working directory, start terminal and navigate to the root of the extracted boost directory then execute “”
It’s build a bjam command-line tool that drives the Boost Build system.

cd ~/Documents/boost_1_45_0/
./ --with-libraries=all

Run bjam and wait, wait a lot!

./bjam --layout=tagged variant=debug -j 2 architecture=combined-x86-power stage

Apple’s version of the GCC toolchain with support for Darwin and MacOS X features such as frameworks.
Build all supported variants of the libraries.
Names of boost binaries include the encoded build properties such as variant and threading.
Build specified library.
Displays the list of Boost libraries.
Remove targets instead of building.
-j N
Run up to N commands in parallel. Only for multiprocessor compilation.
Explicitly request either 32-bit or 64-bit code generation.
Linking to the C++ standard library and compiler runtime support libraries.
Determines if bjam creates shared or static libraries.
Cause the produced binaries to be thread-safe.
Choosing a specific build variant by adding release or debug.

Now boost library is compiled and ready. Next step is RCF framework.
The Official site is
Download and extract RCF-1.3 to your working directory.

Create a new command-line project with Xcode.
Don’t forget to select “C++ stdc++” in Type box!

Go to “Project” menu and select “Edit project Settings” then select “Build” tag. Search for “Header Search Paths” settings and append RCF and Boost include path in the list. Search for Preprocessor Macro and add “RCF_USE_BOOST_ASIO”. Set also “Library Search Path” to “boost_1_45_0/stage/lib”.

Finally in the main window go to “Source” select and right-click, select “Add”, then “Existing Files”, navigate to “RCF-1.3/src/RCF”, find and add “RCF.cpp” file. Also go to “Targets” -> “Link Binary With Libraries” and add “libboost_system.a” and others “.a” files from the “boost_1_45_0/stage/lib” directory.

Open main.cpp and insert test code.

#include <iostream>
#include <rcf /Idl.hpp>
#include </rcf><rcf /RcfServer.hpp>
#include </rcf><rcf /TcpEndpoint.hpp>

RCF_BEGIN(I_Echo, "I_Echo")
RCF_METHOD_R1(std::string, echo, std::string)

class Echo
    std::string echo(const std::string &s)
        return s;

int main (int argc, char * const argv[])
	Echo echo;
	RCF::RcfServer server( RCF::TcpEndpoint("", 50001));
	std::cout < < "Server running..." << std::endl;

	RcfClient<I_Echo> client( RCF::TcpEndpoint("", 50001));

	std::string dts;
	std::cin >> dts;

	std::string ecs = client.echo(dts);

	std::cout << "Echo: " << ecs << std::endl;

    return 0;

External links:
Boost.Build is a high-level build system
RCF User Guide
Linking Custom Static Libraries from your iPhone Xcode Projects
The Boost C++ Libraries BoostBook Documentation Subset
Compiling Boost for the iPhone