Thursday, 12 January 2012

Steps to program c++, openGL, eclipse, minGW, freeglut, Glew

step 1: download the windows GNU compiler minGW and install

step 2: add minGW to path -> right click my computer and go to properties, select advanced settings, then environment variables. under system variables find Path and edit it. add a ; and then the path to the bin folder where you installed minGW. mine went into C:\MinGW\bin

step 3: download the source code for freeglut and compile using minGW. Open a command prompt and go to the src directory of freeglut. use the following commands for 64 bit to get the shared library (dll)
gcc -O2 -c -DFREEGLUT_EXPORTS *.c -I../include
gcc -shared -o freeglut64.dll *.o -Wl,--enable-stdcall-fixup,--out-implib,libfreeglut64.a -lopengl32 -lglu32 -lgdi32 -lwinmm


and for the static library
gcc -O2 -c -DFREEGLUT_STATIC *.c -I../include
ar rcs libfreeglut64_static.a *.o




for 32 bit systems go to http://pinyotae.blogspot.com/2010/05/build-freeglut-with-mingw.html for the commands

step 3: copy freeglut.dll into C:\Windows\SysWOW64 (or C:\Windows\System32 for 32 bit systems)

step 4: Copy the contents of the include\GL from the freeglut directory into the MinGW\include\GL directory

step 5: copy libfreeglut64_static.a and libfreeglut64.a into the minGW\lib directory.


step 6: download and extract eclipse. When i tried to get the 64 bit version of eclipse it crashed so I tried the 32 bit and that worked


step 7: to make a new project in eclipse (taken from http://tjwallas.weebly.com/5/post/2010/11/opengl-development-on-windows-7-freeglut-eclipse-gnu-cc-compiler-mingw-ftw.html)
Uncheck "Show project type and toolchains ...."

4. Make sure MinGW GCC is selected from the list of toolchains on the right.

5. Enter a name for your project and then click finish.
6. Right click your project main folder from the project explorer and click properties.


7. From the left menu expand C/C++ build and click settings.
8. From the submenu that appears Click Libraries, which is found under MinGW C++ linker add the following libraries using the tiny add button at the top-right: "glu32" , "opengl32" , "freeglut" (Without the quotes). Then finally, click ok.
I also added glew32 as well. also, as I am using freeglut64 i add freeglut64 instead of just freeglut


Step 8: To get Glew set up... glew is only compiled for visual studio so you have to download the source code (http://glew.sourceforge.net/) and compile it using minGW (http://stackoverflow.com/questions/6005076/building-glew-on-with-mingw)

gcc -DGLEW_NO_GLU -O2 -Wall -W -Iinclude  -DGLEW_BUILD -o src/glew.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32.dll -Wl,--out-implib,lib/libglew32.dll.a    -o lib/glew32.dll src/glew.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
# Create library file: lib/libglew32.dll.a
ar cr lib/libglew32.a src/glew.o
gcc -DGLEW_NO_GLU -DGLEW_MX -O2 -Wall -W -Iinclude  -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c
gcc -shared -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
# Create library file: lib/libglew32mx.dll.a
ar cr lib/libglew32mx.a src/glew.mx.o
# Make the glew visualinfo program. Skip this if you want just the lib
gcc -c -O2 -Wall -W -Iinclude  -o src/glewinfo.o src/glewinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/glewinfo.exe src/glewinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
gcc -c -O2 -Wall -W -Iinclude  -o src/visualinfo.o src/visualinfo.c
gcc -O2 -Wall -W -Iinclude  -o bin/visualinfo.exe src/visualinfo.o -Llib  -lglew32 -L/mingw/lib -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32
Finally you have to copy the Glew include/GL files into the minGW/include/GL directory
copy the glew lib */.dll files into the C:\windows\SysWOW64 directory
copy the other files in the lib directory (*.a files) to the minGW/lib directory

i hope that is it...



Sunday, 8 January 2012

chilli

So its been a while since my last post and I apologise. Things have been pretty crazy and I haven't had much time for creativity. Just a quick update. Today we went wandering around the city and I picked up another Jamie Oliver book for < $16 :) This brings my total books of his up to 4 I think.

Anyway, in the front of the book there was a section on drying herbs and stuff and I started to think about the chilli that I had growing in the bedroom. They have been nice and red for a couple of days (almost a week) and I was worried about them going bad on the plant. So I decided to try and try them. With a quick lookup on the web I found that all you have to do is hang them in a dry well ventilated area for a while and let them dry. So over to Talia's showing table I go, grab a needle and some thread and chilli are a hanging :)



Edit: This of course led me to want to dry other things like the fresh herbs we get from our veggie boxes. I wish we had thought of doing this before because we have had to toss a bunch of herbs because we don't use them fast enough. Each bundle has 5-6 sprigs of parsley tied together with a bit of thread. The thread is then tied to the main white string (not thread) which is shifted off the wall to make sure the herbs don't touch.



~(' ')~

Wednesday, 28 December 2011

Frogger

Had the urge to draw last night so I drew what I saw. On the headboard of my bed there is a little plushy frog that has magnets in his feet so he can hug things. I got him for Christmas many many years ago and ever since I got this bed he has hugged the bars and watched over my at night. So I decided to draw him. It's not very good but i figure if i keep drawing what I see eventually I will draw something worth seeing.

~(' ')~

Tuesday, 27 December 2011

Knight Rider

So for my birthday one of my friends got me a soldering iron so I was finally able to dismantle a bunch of LEDs that Talia had given to by several months ago. The fun part was that this gave me enough LEDs to do my next electronics project. It was another fairly simple project that just turned on one of 10 leds in a row producing an effect similar to the one for the knightrider car KITT (yes, I'm that old).


Code:


int ledPins[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11};
int currentLED = 0;
int dir = 1;
int ledDelay = 65;

void setup()
{
  for(currentLED = 0; currentLED < 10; currentLED++)
  {
    pinMode(ledPins[currentLED], OUTPUT);
  }
  currentLED = 0;
}

void loop()
{
  digitalWrite(ledPins[currentLED], HIGH);
  delay(ledDelay);
  digitalWrite(ledPins[currentLED], LOW);
  currentLED = currentLED + dir;
  if(currentLED == 9)
  {
    dir = -1;
  }
  if(currentLED == 0)
  {
    dir = 1;
  }
}

Nothings really that complicated. Used an array to save all the pin numbers, and an index to point to the current led. Sadly I didn't have enough wires to connect things properly (I really need to get some wire strippers and a big spool of solid core wire) so I improvised a little with the ground wires :)

~(' ')~

Sunday, 18 December 2011

Dash Dash Dash Dot Dot Dot Dash Dash Dash....

So I was reading through a new arduino book (Beginning Arduino by  Michael McRoberts) that I found online through my school library and the second project they talk about is an SOS morse code blinking LED. Pretty simple. I'm not a huge fan of simple, I like interesting times. So I decided to skip what the book wanted me to do and make my own general morse code blinker.

First, the circuit. Its pretty simple, just an LED connected to pin 2 of the arduino, it has a 220 ohm resister to protect the led.


The fun part was the code. I wanted it to be able to display any message typed into the computer. So first I defined what a dash and a dot are. Thank you Wikipedia :) Then its some quick and dirty letter conversions and a loop to read in data from the serial port and we are off


Code:

/**
 * Author: John Stemberger
 * Date: December 18, 2011
 * Description: A morse code blinker. This will blink a sentence in Morse code. The sentence will either be the defualt sentence (SOS) or a sentence read in from the serial connection if one exists
 **/

char sentence[255] = "SOS\0";
int ledPin = 2;
int counter = 0;
int dotLength = 100;

void setup()
{
  // set up the pin
  pinMode(ledPin, OUTPUT);
  // setup serial connection to the computer to read the sentence
  Serial.begin(9600);

}

void dot()
{
  Serial.print("DOT ");
  digitalWrite(ledPin, HIGH);
  delay(dotLength);
  digitalWrite(ledPin, LOW);
  delay(dotLength);
}

void dash()
{
  Serial.print("DASH ");
  digitalWrite(ledPin, HIGH);
  delay(3*dotLength);
  digitalWrite(ledPin, LOW);
  delay(dotLength);
}

void displayLetter(char letter)
{
  // 1. a dash is equal to 3 dots
  // 2. the space between parts of the same letter is eual to one dot
  // 3. the space between two letters is equal to three dots
  // 4. the space between 2 words is equal to 7 dots
  switch(letter)
  {
  case 'A':
    dot();
    dash();
    break;
  case 'B':
    break;
  case 'C':
    dash();
    dot();
    dash();
    dot();
    break;
  case 'D':
    dash();
    dot();
    dot();
    break;
  case 'E':
    dot();
    break;
  case 'F':
    dot();
    dot();
    dash();
    dot();
    break;
  case 'G':
    dash();
    dash();
    dot();
    break;
  case 'H':
    dot();
    dot();
    dot();
    dot();
    break;
  case 'I':
    dot();
    dot();
    break;
  case 'J':
    dot();
    dash();
    dash();
    dash();
    break;
  case 'K':
    dash();
    dot();
    dash();
    break;
  case 'L':
    dot();
    dash();
    dot();
    dot();
    break;
  case 'M':
    dash();
    dash();
    break;
  case 'N':
    dash();
    dot();
    break;
  case 'O':
    dash();
    dash();
    dash();
    break;
  case 'P':
    dot();
    dash();
    dash();
    dot();
    break;
  case 'Q':
    dash();
    dash();
    dot();
    dash();
    break;
  case 'R':
    dot();
    dash();
    dot();
    break;
  case 'S':
    dot();
    dot();
    dot();
    break;
  case 'T':
    dash();
    break;
  case 'U':
    dot();
    dot();
    dash();
    break;
  case 'V':
    dot();
    dot();
    dot();
    dash();
    break;
  case 'W':
    dot();
    dash();
    dash();
    break;
  case 'X':
    dash();
    dot();
    dot();
    dash();
    break;
  case 'Y':
    dash();
    dot();
    dash();
    dash();
    break;
  case 'Z':
    dash();
    dash();
    dot();
    dot();
    break;
  case ' ':
    // spaces will have 3 dots before it, and 2 dots after (from the pervious letter and the end of this letter) so the space will need 2
    extra dots to make a total of 7
      delay(2*dotLength);
    break;
  default:
    Serial.print("unknown letter [");
    Serial.print(letter);
    Serial.println("]");
  }
  delay(2*dotLength);// the space between letters is 3 dots but the end of the last part of the letter will have a 1 dot delay (to finish that letter) so
  e only do 2 dots here.

}

void loop()
{
  if(Serial.available())
  {
    counter = 0;
    while(Serial.available())
    {
      // get the new sentence
      sentence[counter] = Serial.read();
      if(sentence[counter] >= 'a' && sentence[counter] <= 'z')
      {
        sentence[counter] = sentence[counter] - 'a' + 'A';
      }
      if((sentence[counter] < 'A' || sentence[counter] > 'Z') && sentence[counter] != ' ')
      {
        Serial.println('non valid letter, replacing with space');
        sentence[counter] = ' ';
      }

      counter++;
      if(counter > 254)
      {
        // we have hit the limit of our sentence so abport
        Serial.println("Sentence is too long, ignoring the rest.");
        break;
      }
    }// end while we have available data on the serial port
    sentence[counter] = '\0';
    Serial.flush();
  }// end if
  // if there is nothing available (we havent gotten anything) then display the currect message
  // echo it out to the serial port
  Serial.print("Displaying code for: ");
  Serial.println(sentence);
  counter = 0;
  while(sentence[counter] != '\0')
  {
    Serial.print(sentence[counter]);
    Serial.print("- ");
    displayLetter(sentence[counter]);
    counter++;
  }
  Serial.println("\nEnd message");
  delay(500);
}

~(' ')~

pizza pizza

So last night Talia requested some pizza and I was more than willing to provide. Until last night pizza has always been a several hour endeavour because we always made small personal pizzas which each take 15 minutes to cook and even longer to decorate so I wasn't really feeling like that much work. I also had a new recipe for pizza dough that I wanted to try out so I was excited. This recipe is almost the same as the old one except I add 4 Tbsp of olive oil to flavour the dough and I let to prove for an hour. Also, there was no added sugar because the yeast had time to prove the dough.


When I rolled out the pizza dough it was much bigger than the pizza pan I had so decided to make it a cheese stuffed crust pizza




 





In total the dough recipe made 2 full pizzas, a calzone and I have dough in the fridge for 1 more full pizza :)

Sunday, 11 December 2011

Reduce, Recycle, and of course.... REUSE!!!!!!

So I spent the better part of this morning carefully taking Talias old laptop apart to see if I could salvage any parts. Her laptop died a while ago (the graphics card melted) and she has wanted to take it apart for a while.

So I kept all of the pieces and screws, now I just have to figure out how to connect to all of these pieces. As an example of the times of pieces I salvages...
Wireless card. the black/white are where the antenna cables connect. You will see them in a bit

The bluetooth card. Cause everything is better with bluetooth

The monitor and several of the cables. The thick one is the monitor cable, I forget what the one above that is, but the top most cable is the antenna for the wireless

The power button circuit board. This is the smallest and simplest part so it is what I am going to be starting with.It has 12 cables, 7 LEDs, and 2 Buttons (a black and a grey one)

I'm going to slowly try and map out what all the pins are. I think I know which are the ground wires (there are 3 from what I can tell) and the LED wires, but I'm not 100% sure about them. I cant seem to find which cables are connected to the buttons but part of the problem is that my multimeter broke so I have to go and get it fixed before I can do much more :(

P.S. the LEDs are all blue