Programming, WPF

IValueConverter

If you’re making an WPF Visual Basic application and make a custom IValueConverter for the first time you’ll probably see this message

“The name <your_class> does not exist in the namespace “clr-namespace:<your_application>

Here’s a screenshot from the XAML Designer:temp1

The fix is surprisingly easy:

  1. Change that line to “<local:Application…”
  2. Build the solution
  3. Change it back to “<local:ID2Converter…”
  4. Voila!

In case you’re wondering, my xaml.vb file looks like this:

Imports System.Globalization

Public Class ID2Converter
 Implements IValueConverter

 Public Function Convert(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.Convert
 ' blah blah blah
 End Function

 Public Function ConvertBack(ByVal value As Object, ByVal targetType As Type, ByVal parameter As Object, ByVal culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
 ' blah blah blah
 End Function
End Class

Public Class MyClass
' blah blah blah
End Class

So, you can put the IValueConverter in the same xaml.vb as the class using it. No need to declare namespace etc 🙂

Advertisements
Arduino, Programming

Arduino + DS1307 RTC

Another demo for interfacing an Arduino with the DS1307 Real Time Clock. The board I used (see here) also has an integrated 24C32 32K EEPROM which we won’t worry about in this demo.

Here’s a picture of my setup:

IMG_20151121_202254

Materials Used:

  • Arduino Uno R3
  • 16×2 LCD Shield
  • DS1307 board (I used this one) but you could use this one too
  • CR2032 button cell

Wiring details:

(NOTE: If you’re using the same board as me then wire to the side of the board with the pins SQ, DS, SCL, SDA, VCC, GND & BAT)

  1. Uno’s 5V (via LCD Shield) to RTC’s 5V
  2. Uno’s GND (via LCD Shield) to RTC’s GND
  3. Uno’s Analog Pin 4 (via LCD Shield) to RTC’s SDA
  4. Uno’s Analog Pin 5 (via LCD Shield) to RTC’s SCL
  5. Leave the other pins unconnected
  6. Put the button cell in!

You can find the code here. And voila! 🙂

Arduino, Programming

Arduino + HR-SR04 Ultrasonic

I wanted to try an Ultrasonic sensor so I bought the cheapest one I could find, the HR-SR04. I used this tutorial to learn about the ultrasonic. Basically I thought the Ultrasonic would provide an analog signal with the distance…well I was wrong. Distance is calculated based on the time taken for an echo signal to be sent and received.

Here’s a picture of my setup.

IMG_20151121_160922

Materials used:

Wiring is easy:

  1. Uno’s 5V (via LCD Shield) to sensor’s 5V
  2. Uno’s GND (via LCD Shield) to sensor’s GND
  3. Uno’s Digital Pin 0 (via LCD Shield) to sensor’s ECHO
  4. Uno’s Digital Pin 1 (via LCD Shield) to sensor’s TRIG

You can find the code here. And voila! 🙂

Arduino, Programming

Arduino IDE Alternatives

Ok the original Arduino IDE is good but not great. It’s pretty basic as it’s intended to be. I needed something better, something advanced. I didn’t try every alternative out there. I tried using Eclipse (it’s actually an eclipse plugin, see here) but I couldn’t get it work. I believe it didn’t work because I needed 32 bit Java. Anyways, I tried Visual Micro. This is something I liked. It’s also a plugin for Visual Studio. (FYI Visual Studio now comes in a free community edition, see here) Two things I didn’t like:
1) Creates too many files, that’s just how Visual Studio works. It creates several folders and files which I don’t need.
2) Some of the compilation errors didn’t show up. I was pulling my hair trying to figure out the cause of the error. I eventually figured out it after I compiled it using the original Arduino IDE.

The other “problem” for me was that I’m using a PC and laptop (it’s one of those convertible tablet/laptop) for development. I wanted to same the software on both systems. I didn’t want to install a big IDE like Visual Studio (with Visual Micro) on my laptop (it doesn’t have much space).

So I have decided to use Notepad++ for development and then use the original Arduino IDE with the “External editor” option activated.

Arduino, Programming

FTDI RX TX lights are reversed

I bought an XBee USB Adaptor (looks exactly this one but I bought from eBay) with an FTDI chip for USB to Serial comms and I noticed that the RX & TX lights are reversed. Don’t worry it can be fixed 🙂

  1. Download the “FT_Prog” program from here.
  2. Extract and install it
  3. Connect your FTDI board to your PC
  4. Run FT_Prog
  5. From the FT_Pro window, click on “Devices” and then “Scan and Parse”
  6. Go this:
    FT_Prog
  7. Notice C0 & C1 has RXLED#  & TXLED# (your setup might be the other way), swap them around.
  8. Click on “Devices” and then “Program”. This will bring up a new window.
  9. Click the “Program” button. It only takes a few seconds. It will provide a success message at the bottom of the window. Don’t ask me what to do if it shows an error message (sorry!).
  10. Press “Close” and close FT_Prog.
  11. Unplug the board from your PC and plug it back in.
  12. Voila! 🙂

NOTE: Each time you flash the FTDI, the port number changes and the serial number.

Programming

After all that [UPDATE]

After all that effort I uninstalled Qt5 lol. It’s good but I didn’t like it and here’s why (in order of most hated to least hated):

1) It doesn’t show you which files have changed since the last commit. In Eclipse it shows a right triangle on all the files that have changed.
2) The diff is crap! It doesn’t show it as a left and right file with differences highlighted. It’s just the diff output.

I might just go back to Eclipse…or Netbeans…

UPDATE:
I’m going to give QtCreator another chance. I felt I wasting time looking for other IDEs and features rather than focusing on my project.