Ravioli >>an Arduino powered Laser Painter Project Ravioli
code| Sorce Code
    >>
The arduino sketch is organized into 4 tabs, "main," "commands", "library", and "utility." All abs depend upon functions defined in other tabs. The arduino program communicates with a python based GUI, coded using the GTK library, and the pySerial library for python.

code| Main
    >>Buses data to the appropriate functions

code| Commands
    >>A set of "command" functions

code| Library
    >>A set of functions that "Draw" ascii charators

code| Utilities
    >>A set of functionsthat the other tabs depend upon.

code| GUI
    >>A basic python based GUI to control the device via serial connection.

Main

Main includes the setup function, and the loop function. The loop function handles all of the inputs, and "buses" the data to other functions appropriately.
/*

Ravioli>>>
by Nick Topper
---------------------

    This sketch opperates the pan and tilt servos, 
    as well as a transistor controling a laser gun sight, 
    and a transistor shorting the ring, sleve, and base of a 
    16th" jack, in order to sigal a cannon camera's shutter 
    control. It is capable of writing charactors, and shapes for a 
    long exposure camera.
*/
    
#include <Servo.h>

//global variables and constants are defined here

//x is the the angle of the pan servo
int x = 90;
//y is the angle of the tilt servo
int y = 95;

//pin attached to the base pin of the laser's transistor, writeing HIGH to this pin turns on the laser.
const int laser = 8;

//pin attached to the base pin of the shutter control's transistor, writing HIGH to this pin takes a picture.
const int shutter = 7;

//delay time to move servo a small degree
int nug = 200;

//degree to "bump" the servos when writeing letters
int bump = 2;

//top and right margins for the text
int topMarg = y;
int rightMarg = x;

//define the servo objects
Servo pan;
Servo tilt;

void setup() {
//establish serial conection
  Serial.begin(9600);
  
//attach servo objects
  pan.attach(9);
  tilt.attach(10);

  pinMode(laser, OUTPUT);
  pinMode(shutter, OUTPUT);
  cord(x, y); 
}


void loop() {
  //the 'get" function takes any serial input, and runs it through several swich functions. It is defined in "utilites".
  get();
}

/*
  Any text sent within '{' and '}' represents a command, 
  all text outside of the brackets is written using the functions devined in the "library" file,
  this function assiocates each charactor with the apriporate command.
*/

void sketch(char in) {
  switch (in) {
  case 'A':
    A();
    break;
  case 'B':
    B();
    break;
  case 'C':
    C();
    break;
  case 'D':
    D();
    break;
  case 'E':
    E();
    break;
  case 'F':
    uF();
    break;
  case 'G':
    G();
    break;
  case 'H':
    H();
    break;
  case 'I':
    I();
    break;
  case 'J':
    J();
    break;
  case 'K':
    K();
    break;
  case 'L':
    L();
    break;
  case 'M':
    M();
    break;
  case 'N':
    N();
    break;
  case 'O':
    O();
    break;
  case 'P':
    P();
    break;
  case 'Q':
    Q();
    break;
  case 'R':
    R();
    break;
  case 'S':
    S();
    break;
  case 'T':
    T();
    break;
  case 'U':
    U();
    break;
  case 'V':
    V();
    break;
  case 'W':
    W();
    break;
  case 'X':
    X();
    break;
  case 'Y':
    Y();
    break;
  case 'Z':
    Z();
    break;
  case ' ':
   dRight();
   delay(nug);
   break;
   //with time, this function will include all ASCII charactors. 
  
  //Cmd makes a string of every charactor, and is terminated by '}'
  //cmdSwitch is an 'if' tree that takesa string, and carries out a function associated with the string
  case '{':
    cmdSwitch(Cmd());
    break;
  }
}

//cmdSwitch is an 'if' tree that takes a string, and carries out a function associated with the string. these functions are defined in the "commands" file
void cmdSwitch(String CMD) {
  if (CMD == "up") {
    setY(bump);
  }
  if (CMD == "down") {
    setY(0 - bump);
  }
  if (CMD == "right") {
    setX(bump);
  }
  if (CMD == "left") {
    setX(0 - bump);
  }
  if (CMD == "br") {
    br();
  }
  if (CMD == "size+") {
    sizeplus();
  }
  if (CMD == "size-") {
  sizeminus();
  }
  if (CMD == "back") {
    cord(rightMarg, topMarg);
  }
  if (CMD == "test") {
    test();
  }
  if (CMD == "speed-") {
    speedminus();
  }
  if (CMD == "speed+") {
    speedplus();
  }
  if (CMD == "wait") {
    delay(1000);
  }
  if (CMD == "snap") {
    snap();
  }
    if (CMD == "fib") {
    drawFib();
  }
}
>>back to top

Library

"Library" includes a separate command to write each ASCII character with the laser. It depends on the "dUp, dDown, dLeft, and dRight functions defined in "utilities," witch simply "bump" the pan ind tilt servo's in the appropriate direction, and manipulate the global x and y cursors. Library is not complete, but will eventually support all keyboard characters.
/*
  This file uses the on, off, dLeft, dRight, dUp, and dDown functions 
  declaired in the "utilities" sketch to draw ascii charactors. This 
  library is not yet complete.
*/

void A() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  delay(nug);
  on();
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void B() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  delay(nug);
  on();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  delay(nug);
  hRight();
  delay(nug);
}

void C() {
  on();
  dUp();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  off();
  dDown();
  dDown();
  delay(nug);
  on();
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void D() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  dDown();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void E() {
  on();
  dUp();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dLeft();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void uF() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dLeft();
  delay(nug);
  off();
  dDown();
  dRight();
  hRight();
  delay(nug);
}

void G() {
  dUp();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dDown();
  dLeft();
  delay(nug);
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void H() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  on();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void I() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void J() {
  dUp();
  delay(nug);
  on();
  dDown();
  dRight();
  delay(nug);
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
} 

void K() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dUp();
  dRight();
  delay(nug);
  off();
  dDown();
  dLeft();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void L() {
  dUp();
  dUp();
  delay(nug);
  on();
  dDown();
  dDown();
  delay(nug);
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void M() {
  on();
  dUp();
  dUp();
  delay(nug);
  dDown();
  dRight();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  dDown();
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void N() {
  on();
  dUp();
  dUp();
  delay(nug);
  dDown();
  dDown();
  dRight();
  delay(nug);
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void O() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void P() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dDown();
  dRight();
  hRight();
  delay(nug);
}

void Q() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  dDown();
  delay(nug);
  dLeft();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void R() {
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  dDown();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void S() {
  on();
  dUp();
  dRight();
  delay(nug);
  dLeft();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void T() {
  dRight();
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dLeft();
  delay(nug);
  on();
  dRight();
  dRight();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void U() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void V() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  delay(nug);
  on();
  dUp();
  dRight();
  delay(nug);
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void W() {
  dUp();
  dUp();
  delay(nug);
  on();
  dDown();
  dDown();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  dDown();
  dRight();
  delay(nug);
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void X() {
  on();
  dUp();
  dUp();
  dRight();
  delay(nug);
  off();
  dLeft();
  delay(nug);
  on();
  dDown();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void Y() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void Z() {
  on();
  dUp();
  dUp();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dDown();
  dDown();
  dLeft();
  delay(nug);
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void a() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void b() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void c() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  off();
  dDown();
  dLeft();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void d() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  off();
  dUp();
  delay(nug);
  on();
  dDown();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void e() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  dLeft();
  delay(nug);
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void lF() {
  on();
  dUp();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dLeft();
  delay(nug);
  off();
  dDown();
  dRight();
  hRight();
  delay(nug);
}

void g() {
  on();
  dUp();
  dRight();
  delay(nug);
  dDown();
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dUp();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void h() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void i() {
  on();
  dUp();
  delay(nug);
  off();
  y += (bump / 2);
  cord(x, y);
  delay(nug);
  on();
  delay(nug);
  off();
  y -= (bump / 2);
  cord(x, y);
  dDown();
  hRight();
}

void j() {
  on();
  dUp();
  delay(nug);
  off();
  y += (bump / 2);
  cord(x, y);
  delay(nug);
  on();
  delay(nug);
  off();
  y -= (bump / 2);
  cord(x, y);
  dDown();
  delay(nug);
  on();
  dDown();
  delay(nug);
  dLeft();
  dUp();
  delay(nug);
  off();
  dRight();
  dUp();
  hRight();
}

void k() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  delay(nug);
  on();
  dRight();
  delay(nug);
  off();
  dLeft();
  delay(nug);
  on();
  dDown();
  dRight();
  delay(nug);
  off();
  hRight();
}

void l() {
  on();
  dUp();
  dUp();
  delay(nug);
  off();
  dDown();
  dDown();
  hRight();
  delay(nug);
}

void m() {
  on();
  dUp();
  delay(nug);
  dDown();
  dRight();
  delay(nug);
  dUp();
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void n() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  off();
  hRight();
  delay(nug);
}

void o() {
  on();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

void p() {
  dDown();
  delay(nug);
  on();
  dUp();
  dUp();
  delay(nug);
  dRight();
  delay(nug);
  dDown();
  delay(nug);
  dLeft();
  delay(nug);
  off();
  dRight();
  hRight();
  delay(nug);
}

//with time, this library will include all ASCII charactors. 
>>back to top

Commands

"Commands" includes a set of functions useful for calibrating text before taking a photo. They are called by a serial communication. And characters within"{}" brackets are part of a command.
/*
  this tab is a set of uceful functions for calibrateing the text.
  They all depend upon functions delaired in "utilities"
*/

//sets the y axcess, and the top margen
void setY(int in) {
  y += in;
  topMarg = y;
  on();
  cord(x, y);
  delay(400);
  off();
}

//sets the x axcess, and the top margen
void setX(int in) {
  x += in;
  rightMarg =x;
  on();
  cord(x, y);
  delay(400);
  off();
}
 
//adds one degree to the size of a servo movement, and slowly writes an A
void sizeplus() {
      sizeManip(1);
    int old = nug;
    nug = 400;
    A();
    nug = old;
    cord(rightMarg, topMarg);
}

//subtracts one degree to the size of a servo movement, and slowly writes an A  
void sizeminus() {
      sizeManip(0 - 1);
    int old = nug;
    nug = 400;
    A();
    nug = old;
    cord(rightMarg, topMarg);
}

//subrtacts 50 milisecods from the delay time between servo commands
void speedplus() {
    speedManip(0 - 50);
    A();
    cord(rightMarg, topMarg);
}

//adds 50 milisecods to the delay time between servo commands
void speedminus() {
    speedManip(50);
    A();
    cord(rightMarg, topMarg);
}

//simulates a line break,useing the "topMarg" and "rightMarg" globals
void br() {
  y -= (bump * 3);
  x = rightMarg;
  cord(x, y);
}

//prints 'HELLO' with the current settings for speed, and size.
void test() {
    H();
    E();
    L();
    L();
    O();
    cord(rightMarg, topMarg);
}  

/*
  Cannon cameras take a 16th" jack for a shutter control.
  When the base and ring are shorted, the auto-focus is activated.
  When the base, ring, and sleve are shorted, the sutter is activated.
  The "shutter" pin is the base pin of a transistor. 
  The connector pin is attached to the base and ring of the jack.
  The emittor pin is attached to the tip of the jack. 
*/  
void snap() {
  digitalWrite(shutter, HIGH);
  delay(100);
  digitalWrite(shutter, LOW);
}

//sketches a fibonachi spiral
void drawFib() {
  on();
  int n = 0;
  int d = 100;

  while (n < 10) {
    x += fib(n);
    pan.write(x);
    delay(d);

    y += fib(n);
    tilt.write(y);
    delay(d);

    n += 1;
    d +=30;

    x -= fib(n);
    pan.write(x);
    delay(d);

    y -= fib(n);
    tilt.write(y);
    delay(d);
    x = 90;
    y = 100; 
  }
  off();
}
>>back to top

Utilities

"Utilities" contains a set of "lower level" functions, such as manipulating the current position of the laser, or the length of delay between servo commands. All functions depend on a few functions defined in this tab.
/*
  This file is a library of functions used by other functions in the other
  files to complete arbutrary tasks.
*/

//the 'get" function takes any serial input, and runs it through several swich functions.
void get() {
    delay(nug);
  while (Serial.available()) {
    delay(10);
    if (Serial.available() >0) {
      char c = Serial.read();
      sketch(c);
    }
  }
  delay(nug);
}

//makes a string of charactors within '{' and '}'
String Cmd() {
    String command;
    while (Serial.available()) {
    delay(10);
    if (Serial.available() >0) {
      char c = Serial.read();
        while (c != '}') {
      command += c;
      delay(10);
      c = Serial.read();
        }         
    }
      Serial.println(command);
      return command; 
  }
}

//minipulates the "bump" global, wich represents the distance (in degrees) of one servo movement in the dUp, dDown, dLeft, and dRight functions
void sizeManip(int in) {
  if (bump + in > 0) {
   bump += in;
  }
}

//minipulates the "nug" global, which represents the 
void speedManip(int in) {
  if (nug + in > 0) {  
  nug += in;
  }
}

//returns the n'th number of the fibonachi sequence, used to draw a spiral
int fib(int n) {
  int i = 1, j = 0, k, t;
  for (k = 1; k <= n; k++) {
    t = i + j;
    i = j;
    j = t;
  }
  return j;
}

/*
  the "laser" pin is arrached to the base
  of a transistor. Writing to the pin competes the
  laser's circut.
*/

//turns the laser on
void on() {
  digitalWrite(laser, HIGH);
}

//turns the laser off
void off() {
  digitalWrite(laser, LOW);
}

//sets the pan and tilt
void cord(int a, int b) {
  x = a;
  y = b;
  pan.write(x);
  tilt.write(y);
}

//"digital" movements up, down, left, and right.
void dUp() {
  y += bump;
  cord(x, y);
}

void dDown() {
  y -= bump;
  cord(x, y);
}

void dRight() {
  x += bump;
  cord(x, y);
}

void dLeft() {
  x -= bump;
  cord(x, y);
}

//bumps right half of a letter's length, for spaces between letters
void hRight() {
  if (bump > 1) {
    x += (bump / 2);
    cord(x, y);
  }
  else {
    dRight();
  }
}
>>back to top

GUI

"Ravioli" can be operated by any serial terminal, but having a graphic interface for calibration is a nice luxury. This was coded in python, using the PySerial library for the serial communication, and the Gtk library (in Linux) for graphics. The serial connection is hard coded, keep this in mind if you plan to use this.
#!/usr/bin/env python

import serial
from gi.repository import Gtk

laser =  serial.Serial('/dev/ttyACM0', 9600)

snapBool = False

from gi.repository import Gtk

class TableWindow(Gtk.Window):

    def __init__(self):
   
        Gtk.Window.__init__(self, title="Laser Control")

        table = Gtk.Table(6 , 8, True)
        self.add(table)
        
        self.text = Gtk.Entry()
        
        go = Gtk.Button(stock = Gtk.STOCK_OK)
        go.connect("clicked", self.go_clicked)
        
        snap = Gtk.CheckButton("Shutter")
        snap.connect("toggled", self.snap_toggled)
        
        up = Gtk.Button(stock = Gtk.STOCK_GO_UP)
        up.connect("clicked", self.up_clicked)
              
        left = Gtk.Button(stock=Gtk.STOCK_GO_BACK)
        Label=left.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Left")
        left.connect("clicked", self.left_clicked)

        right = Gtk.Button(stock = Gtk.STOCK_GO_FORWARD)
        Label=right.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Right")
        right.connect("clicked", self.right_clicked)
        
        down = Gtk.Button(stock = Gtk.STOCK_GO_DOWN)
        down.connect("clicked", self.down_clicked)
        
        speedplus = Gtk.Button(stock=Gtk.STOCK_MEDIA_FORWARD)
        Label=speedplus.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Faster")
        speedplus.connect("clicked", self.sp_clicked)
        
        speedminus = Gtk.Button(stock=Gtk.STOCK_MEDIA_REWIND)
        Label=speedminus.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Slower")
        speedminus.connect("clicked", self.sm_clicked)
        
        sizeplus = Gtk.Button(stock=Gtk.STOCK_ADD)
        Label=sizeplus.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Larger")
        sizeplus.connect("clicked", self.sizep_clicked)
        
        sizeminus = Gtk.Button(stock=Gtk.STOCK_REMOVE)
        Label=sizeminus.get_children()[0]
        Label=Label.get_children()[0].get_children()[1]
        Label=Label.set_label("Smaller")
        speedminus.connect("clicked", self.sizem_clicked)
        
        table.attach(up, 6, 7, 3, 4)
        table.attach(left, 5, 6, 4, 5)
        table.attach(right, 7, 8, 4, 5)
        table.attach(down, 6, 7, 5, 6)
        table.attach(sizeplus, 0, 1, 4, 5)
        table.attach(sizeminus, 0, 1 , 5, 6)
        table.attach(speedplus, 1, 2, 4, 5)
        table.attach(speedminus, 1, 2 , 5, 6)
        table.attach(self.text, 0, 7 , 1, 2)
        table.attach(go, 7, 8 , 1, 2)
        table.attach(snap, 0, 1, 0, 1)
        
    def up_clicked(self, button):
        laser.write('{up}')
        
    def left_clicked(self, button):
        laser.write('{left}')
        
    def right_clicked(self, button):
        laser.write('{right}')
    
    def down_clicked(self, button):
        laser.write('{down}')
       
    def sp_clicked(self, button):
        laser.write('{speed+}')
        
    def sm_clicked(self, button):
        laser.write('{speed-}')  
       
    def sizep_clicked(self, button):
        laser.write('{size+}')
        
    def sizem_clicked(self, button):
        laser.write('{size-}')
        
    def go_clicked(self, go):
        global snapBool
        if snapBool:
            laser.write("{snap}")
            laser.write("{wait}")
        laser.write(self.text.get_text())
        
    def snap_toggled(self, snap):
        global snapBool
        if snapBool:
            snapBool = False
        else:
            snapBool = True      
        
    
win = TableWindow()
win.connect("delete-event", Gtk.main_quit)
win.show_all()
Gtk.main()
>>back to top