Beatsense Music Service…

beatsense

If you’re a fan of music, you will like BeatSense.  The site became active in October 2015.  I have since created two rooms Chillstep and Full of Treble.  The perk in these rooms is that your playlist (sourced from YouTube videos) is shared.

That means as you listen to the songs you enjoy, other users may add to that playlist which helps in finding new music.   For my two rooms, the more modern music gets many more viewers than the classical music but it works well to have music that plays consistently that is of my interests while I work.

The site is active, has been positive in receiving feedback and is consistently under development and adding new features.  Give it a look and enjoy the sounds!

Army Forms Going to PDF…

After a year of no longer having support of XFDL/Lotus Form Filler documents it would appear that the Open XFDL project had moved on.  At least that was my thought but it has now become apparent that there is still a community in need of improving XFDL interfacing with databases.

Please add comments and discuss what is the future of the XFDL format.  Will this be a legacy format within the military or will it phase out soon?

Back in Service…

For those frequently this blog, thank you for your visits!  This has been out of service for the time I was out of country and returning to working nights for the past year has made it hard to find the time to post updates.  But there are a few projects that I have on the burner so keep watching for updates as we move forward…

Tuba Christmas…

image3

Snow on the ground, cold in the air, music all around.  It’s Christmas time and with the season brings Tuba Christmas again.  After a decade of rest for my lungs, it’s been nice getting the rusty brass behemoth to sound good.

Sample music from practice: 

For those unfamiliar with the event, here are some good videos:

Arduino Game

At times, I have fun creating devices.  The similarity to programming amazes me and the ability to be able interact with the physical world is a lot of fun.  I took my standard game, a tank that moves side to side and shoots objects from the sky (think Space Invaders).  Here’s the shopping list.

  1. Microcontroller – Arduino Uno
  2. Display – Nokia 5110 LCD
  3. Sensor – ADXL334 Triple Axis Acelerometer
  4. Tactile Switch and misc wiring/resistors.

So for a relatively small amount of shopping, you have the ability to make an interactive game.  The wiring basically merges basic wiring for the tactile switch, standard input for triple axis acelerometer, and

Enough talk, here’s a picture:

Here’s a video of it:

And here’s the code I wrote:

#include 
#include 
 
// Display
Adafruit_PCD8544 display = Adafruit_PCD8544(7, 6, 5, 4, 3);
 
// Setup
int pressed = false;
int times = 0;
int led = 13;
int but = 12;
int val = 0;
int count = 0;
 
// Tank size and direction
int tx = 0;
int ty = 0;
int tw = 10;
int th = 4;
int td = 0;
 
// Bullet
bool bAlive = false;
int bx = 0;
int by = 0;
int bw = 3;
int bh = 3;
 
// Accelerometer
const int powerpin = 18;
const int groundpin = 14;
const int xpin = A3;
int xMoveInit = 0;
 
void setup()
{
  Serial.begin(9600);
   
  pinMode(led, OUTPUT);
  pinMode(but, INPUT);
  pinMode(groundpin, OUTPUT);
  pinMode(powerpin, OUTPUT);
   
  digitalWrite(groundpin, LOW); 
  digitalWrite(powerpin, HIGH);
   
  display.begin();
  display.setContrast(50);
  
  tx = (display.width()/2)-(tw/2);
  ty = display.height()-10-th;
   
  xMoveInit = analogRead(xpin);
}
 
void loop()
{
  // clear
  display.clearDisplay();
  // x,y,h,w,color
   
  // movement
  if(isPressed() == true)
  {
    //display.fillRect(30,12,24,24,BLACK);
    if(bAlive == false)
    {
      bAlive = true;
      bx = tx+(tw/2);
      by = ty+bh;
    }
  }
   
  // draw
  drawGround();
  drawTank();
  drawBullet();
   
  // show
  display.display();
   
  // wait
  delay(10);
}
 
void drawTank()
{
  doMove();
   
  tx += td;
   
  if(tx+tw+1 >= display.width())
  {
    tx = display.width()-tw-1;
  }
   
  if(tx <= 0)
  {
    tx = 1;
  }
   
  display.drawRect(tx,ty,tw,th,BLACK);
}
 
void drawBullet()
{
  if(by+bh <= 0)
  {
    bAlive = false;
    return;
  }
  by -= 2;
 
  display.fillRect(bx,by,bw,bh,BLACK);
}
 
void drawGround()
{
  int lx = 0;
  int ly = display.height()-10;
  int lw = display.width();
  int lh = 10;
   
  display.fillRect(lx,ly,lw,lh, BLACK);
}
 
void doMove()
{
  int xMoveTemp = analogRead(xpin);
  int diff = xMoveInit-xMoveTemp;
   
  // DEBUG
  Serial.print("Diff: ");
  Serial.print(diff);
  Serial.println();
   
  if(diff >= 20)
  {
    if(diff >= 40)
    {
      td = -2;
      return;
    }
    td = -1;
    return;
  }
   
  if(diff <= -20)
  {
    if(diff <= -40)
    {
      td = 2;
      return;
    }
    td = 1;
    return;
  }
   
  td = 0;
}
 
bool isPressed()
{
  val = digitalRead(but);
  if(val == LOW and pressed == false) {
    return false;
  }
  return true;
}

PyGTK 3, great and embarassing…

So, working to get away from WX as my main GUI source and using GTK as I’ve been an Ubnutu, then Mint user with Gnome for years. Building windows in Glade3 was not too bad and the rapid prototyping with Python makes it a great tool. Sadly, the documentation for PyGTK 3 does not exist. There are differences yet the examples that are found are all for PyGTK 2. Don’t believe me? Try finding information on drawing to a window. Most notable difference is the use of Cairo instead of GDK but it just starts there. Anyhow, just venting on what should be a great set up which is made difficult by the lack of documentation.

I’m back!

Okay, I realize that I have not posted anything new to this blog in about 6 months.  For those of you who are not new to this blog, I apologize.  It’s been a very busy year.  I have picked up a command position for a large company and this has taken most of my time.  And, it’s been a busy year for my civilian job as a corrections officer.  Between those things, this blog has been pushed behind.  But, there are many projects I’m working on so I wanted to post a message saying:

  • I’m alive.
  • I’ll be posting to this blog more frequently.
  • Be prepared for new projects to be showing on these pages soon.

Thank you for your time and pateince!

XFDL in MS Access…

Just wanted to pass a link for the updated XFDL in MS Access Project.  Included in the zip are:

AccessXFDL – This folder has a working example of opening an XFDL form in access.  Does not work for all forms yet but will produce a form for most XFDLs.

libxfdl – This is the DLL made for an extension to VBA to take a part XFDL files and return a string of the data.

Here’s the link: http://dl.dropbox.com/u/18666533/AccessXFDL.zip

Enjoy!

Who Knew…

Just a fun fact.  Apparently, from The Beatle’s White Album, the song Martha My Dear is inspired Paul McCartney’s Old English Sheepdog. named Martha.  As a sheepdog owner, these dogs are one of my favorite breeds so figured this is a fact worth passing on.  Enjoy the picture as well:

Installing OpenCV

So tinkering with OpenCV the past day has been fun.  This past summer, a co-worker and I made an application to crop images and resize them automatically to speed up booking at the jail we work at.

The first problem was face detection.  To create a method, we first invert the image.  Then run a line from left to right until the background color changes.  Do the same thing from right to left and then find the center.  Do that several times through the picture would lead us to a good center location for the face.

The second problem was that we did all this with Windows API/GDI.  These methods were very low level and difficult to run simple methods on.

For some reason, we never found OpenCV until reading a slashdot article last night.  This library is awesome for face detection and other visual work.  I use a Linux box at home and the work computers use Windows, so I like that code can be compiled with only changes to the compiler going between each computer.

Installation

The install in linux was very easy.  Ubuntu has great documentation for installing anything with apt.  Since I’m using Mint 12 (gotta get away from Gnome 3!), I was able to follow this guide.

For Windows, it was a bit more tricky.  I read guides walking me through CMake and such.  Fortunately, I found that OpenCV 2.0’s installer does not need to be compiled, just extracted.  Using this guide I was able to get it work.  To simplify things, I’ve put two zips on my server for anyone to use.

  1. OpenCV_INSTALL.zip has the installer for OpenCV 2.0, CMake guide for those using Visual C++, and a sample codeblocks project.
  2. OpenCV_DONE.zip includes the extracted source and a sample codeblocks project.

Let me know if you have any issues.  Remember, for the codeblocks project to compile, you’ll have to sent compiler search directory to [src]/include/opencv and the linker search directory to [src]/lib

Enjoy!

XFDL with PHP 2…

Recent progress with doing XFDL forms in PHP.  I put some time into this project recently figuring that this web based viewer would be the most applicable.  Think if AKO’s MyForms, a setup where you can pass forms from one user to the next to get it filled out and signed; if that program never needed to leave the web?  With doing XFDL forms in PHP, that is possible!  My code is a mess right now so I will put up the PHP, Javascript for the page on a later post.

For now, go to the old version to see what the forms should be like and go to the new version to see progress on the viewer.

wxWidgets and ODBC…

Since wxWidgets > 2.8 has dropped wxODBC, I decided to learn how to use sql.h on my own.  I made a simple program to retrieve and print data in C for the command line and everything worked well.  Unfortunately, when I placed this code in my wxWidgets GUI program, it failed.  This was due to wx being unicode, so I had a whole world of learning on how to make sql.h talk with wx.  I’ve outlined the steps to make this work:

With ODBC, sql.h can work with unicode, the functions are the same, but different variables are sent.  WX defines as Unicode (as it’s usually compiled) and ODBC will map the function to the unicode variant.  For example, in a C++ program with #define UNICODE 1, such as WX, SQLDriverConnect will map to SQLDriverConnectW, the unicode variant.  The other option is SQLDriverConnectA which will allow ANSI variables.  Most of the functions you’ll need have an ‘A Variant’, which is what I’ll refer to the functions ending in A.

To Send Data:

  1. Cast your variable as a SQLWCHAR pointer.
  2. Set a string to that pointer, type cast the string too.
  3. Use the functions of ODBC that end with an A.
  4. Send that function a variable type cast as (SQLCHAR*).
SQLWCHAR *connStr;
connStr = (SQLWCHAR*)"DSN=testDB;";
SQLDriverConnectA(dbc, NULL, (SQLCHAR*)connStr, SQL_NTS,
    (SQLCHAR*)outstr, sizeof(outstr), &outstrlen,
     SQL_DRIVER_COMPLETE);

To Return Data:

  1. Do the same steps.
SQLWCHAR colName[256];
SQLDescribeColA(hstmt, i+1, (SQLCHAR*)colName, 255, &colNameLen,
      &dataType, &colSize, &numDecimalDigits, &allowsNullValues);

Convert SQLWCHAR to wxString:

  1. Use wxString’s PrintF() function and interpret the variable with a capital S.
SQLWCHAR colName[256];
wxString test;
test.PrintF(_("Column Name: %S"),colName);

Convert wxString to SQLWCHAR:

  1. Declare your buffer variable as SQLCHAR array.
  2. Cycle through each char in wxString and assign to your SQLCHAR array.
  3. Add a null value on the end (so SQL_NTS knows to stop!)
  4. Typecast the variable as a pointer in send.
wxString send = wxT("SELECT * FROM master");
SQLCHAR sqlTest[1024];
unsigned int j;
for(j=0;j
	

Watch Out! Here comes a dart!!

It’s like if php and java met on a lonely night, dart would be the result.

Google Dart, a new language developed to be the ‘new javascript’ is soon to be available from Google.  Check out the webpage that’s set up to show you the language and give a nice tutorial.  It has an interpreter on the page so you can tinker and get a feel for it.  It seems to me, after playing with the language a bit, it’s like if php and java met on a lonely night, dart would be the result.  An advantage of this language, is unlike HTML5, you will not have to wait for a browser to be made to understand this language.  It can be cross-compiled to javascript on the server side until browsers catch up!  Unfortunately, this is not something I’ve been able to apply to a live server, yet.

XFDL in PHP…

Lately, I have started working on the OpenXFDL project again, concentrating efforts in making a C++ application with WX Widgets that can compile for Windows, Mac, and Linux.  Getting frustrated with libxml2 and wanting to learn more of xpath queries, I decided to make a XFDL reader in PHP.  This can be applied easily as browser/e-mail plugins to view XFDL forms without the need of an external viewer.  I’ve been bad about posting but I’ll work to add more to this blog soon.  For now, here is a sight to try it out with.  Unlike previous stuff, you can do a straight XFDL form instead of converting to XML first.  Try it out!

Apologize…

I know its been awhile since I’ve posted on here.  About a month ago, I got a new job where I’m working overnights so its been tough getting programming as a hobby in and especially writing as it while I adjust to the new work shift.  Some projects I’ve been working on:

1. I’ve gotten real heavy into using microprocessors.  Recently, I’ve gone to programming on the Arduino to using the ATMega in its own circuit (programmed while on the Arduino board for testing and then once ready to complete, finishing it on its own circuit.)

2. As usual, working on an XFDL for Linux project.  The GUI in WXWidgets is coming along, working out using libxml2 to parse the file, which is taking awhile but its beginning to flow.  Keep checking back for updates as they happen.

3. Finally got a Mac OSX running with xCode in Virtual Box.  I’m going to get back into Objective C and iPhone apps as I get it working more smoothly.

Thank you for checking in, I’ll be posting more regularly from here on out.

Fixing libcoolkey…

With my new CAC card, I found that libcoolkey.so was not working with Firefox correctly.  The new, 144k CAC cards do not play well with the old version of libcoolkey.  I did find that the ‘experimental’ release of libcoolkey will fix this problem, here is the fix:

amd64 (64bit)

sudo su
apt-get purge coolkey libckyapplet1 libckyapplet1-dev
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/libckyapplet1_1.1.0-7_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/libckyapplet1-dev_1.1.0-7_amd64.deb
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/coolkey_1.1.0-7_amd64.deb
dpkg -i libckyapplet1_1.1.0-7_amd64.deb libckyapplet1-dev_1.1.0-7_amd64.deb coolkey_1.1.0-7_amd64.deb

i386 (32bit)

sudo su
apt-get purge coolkey libckyapplet1 libckyapplet1-dev
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/libckyapplet1_1.1.0-7_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/libckyapplet1-dev_1.1.0-7_i386.deb
wget http://ftp.us.debian.org/debian/pool/main/c/coolkey/coolkey_1.1.0-7_i386.deb
dpkg -i libckyapplet1_1.0-7_i386.deb libckyapplet1-dev_1.1.0-7_i386.deb coolkey_1.1.0-7_i386.deb

A side note, if you are registered with https://software.forge.mil/, then there is a fix in the project ‘Community CAC’ that includes libcackey which offers a fix for this as well.

Netflix on Linux.

Netflix is a great resource for watching videos, particularly the ‘Watch Now’ feature for instant streaming.  Unfortunately, for Linux users, Netflix uses a Microsoft PlayReady, Silverlight plugin for this feature.  This is to protect the content from piracy (arrgh, pirates!!) so they have no problems with copyright.  Too bad for Linux, as this feature is not available in any way, shape, or form.  There is no way to develop a fix for to use this in Linux either, as PlayReady is proprietary.  If this angers you as much as it should any Linux user, that the only work around is to use Windows, then please visit and sign this petition.

#! Statler – b43 driver fix.

This week I switched to #! (Crunchbang) because my Ubuntu was getting slow.  I love the speed and was very happy with the wifi because it had the b43 driver working by default.  Except, I could not get on my network after the most recent upgrade, but I found a work-around after a day of reading forums.  Surprisingly, it’s not too complicated!  You just need to create a conf file for b43 to use PIO and it will not through a DMA error anymore… my hardware is: Broadcom Corporation BCM4312 802.11b/g LP-PHY [14e4:4315] (rev 01).  This is the only line you should need.

sudo echo "options b43 pio=0 qos=0" > /etc/modprobe.d/b43.conf

Reference: This article from Ubuntu Forums.

Programming concepts and ideas in convienant discussion and code snippets.