Category: Programming


I have been looking around for a new headunit for my car and not been able to find one that does what I need. Having Raspberry Pi’s and a Prusa i3 printer sitting around, I thought it should try building one.

For this I am using  Raspberry pi2 (yeh, old hat now) and a 7″ Waveshare touchscreen with 1024×600 resolution.

After 2 days of updates I have just found out that my distro is out of date!

Oh well time to upgrade.

XMOS startkit Step 1

So after spending all day yelling at my XMOS startkit I finally got a basic hello world flashing led code to work. This code flash’s one of the two leds closest to the ram.

#include <xs1.h>
#include <timer.h>

port p = XS1_PORT_1D;
int main() {
 while (1) {
     p <: 0;
delay_milliseconds(200);
p <: 1;
delay_milliseconds(200);
}
}

So how does all this work?

First up we need to reference the required header files. The most important one is xs1.h contains the core functions for working with XMOS Chips. We add this by adding the line

#include <xs1.h>

This contains the port definitions so that our programs will know what port p = XS1_PORT_1D means.

The second one required for the program to work is

#include <timer.h>

This allows us to use the timing function of the chip (I may be mistaken here in that it could actually be a core “C” header!) and allows the code to understand what delay_milliseconds(200); means.

After we have those two lines we need to define which pin our LED is connected to. According to the Startkits hardware manual the two of the leds are labelled D1 & D2 and are accessed through ports 1A and 1D (see page 10/17) and to access them we need to add

port p = XS1_PORT_1D

By changing port p = XS1_PORT_1D; to port p = XS1_PORT_1A; you can change between one of the two leds that are located next to the 256KB SPI flash chip. According to the schematic diagram in the hand book, these leds are connected between the chips pin and ground making them active low. To turn them on the chip needs to supply power to the led and this is done with the following.

p <: 1;

If you noticed the code, I put this line near the end, this is because on each cycle the following

 while (1) {
     p <: 0;

Checks to see if the if the variable “p” high (1), if it is, the pin is set low (0) by the following line. then after a delay, if the variable “p” is high the it will be set low and XS1_PORT_1D will be switched off.

If I understand myself, then all this will make sense and you (the reader) should be able to follow this.

Well I have had enough programming for today so time to pack up.

Raspberrypi+lcd proc working.

So after three hours of shouting and swearing at my Raspberry Pi B I finally had LCDproc working on it.

The problem in the end came down to ttyS0 not existing. Because the MX232 runs via USB, no matter what I tried to change it to (RPI uses ttyUSB0) it wouldn’t take. In the end I remembered so arcane command and typed

sudo ln ttyUSB0 ttyS0 to create the node and link it to ttyUSB0.

Once that was done the lcd jumped to life! if this hold after a restart I don’t know but at least it’s working now!

Well I am surprised, this has to be the first time I have ever been picked in a draw.

My Xmos Startkit arrived today (12-December-2013) I have the software installed on OSX 10.9 and working but now too tired to even play with the demo’s!

Thank you Xmos.com

Arduino Mega ADK and Sony Erricson Xperia Mini Pro X17i works (well sort off!)

Well After all the banging, thumping and moaning I have managed to get the Xperia Mini Pro X17i to communicate with the Arduino Mega ADK!

First was patching of the Arduino code aka firmware, that took a lot of work mostly due to running the 1.0.1 version of the Arduino  programming environment. After editing loads of it then replacing the Google ADK files with the ones from http://www.circuitsathome.com/category/mcu/arduino/usb-shield I got the code to compile and upload but still couldn’t get the Xperia Mini Pro X17i to recognize it (well the phone charged but that’s it) I hit on an idea of using the Xperia live dock!
Powering everything up (mega using separate adapter) I connected the phone to the dock and “Unsupported accessory” message popped up, Yes its at least reading it in the liveware manager app.  After looking back through the arduino code I found the answer in AndroidAccessory.cpp

The following lines

#define USB_ACCESSORY_VENDOR_ID         0x18D1
#define USB_ACCESSORY_PRODUCT_ID        0x2D00

Needed to be changed but to what I hear you ask? The VENDOR_ID and PRODUCT_ID are incorrect (this is stated but I just ignored it causing some of the grief) After a bit of google I worked out how to get my ID code in Windows 7.

Once I had my codes I changed the lines to this

#define USB_ACCESSORY_VENDOR_ID         0x0FCE
#define USB_ACCESSORY_PRODUCT_ID        0x0166

Recompiled and now it’s recognized as Supported Hardware! (This is just for the Sony Erricson Xperia Mini Pro X17i)

Now I need to learn how to modify the Android demo app to make it work!

Note to get the demokit app to work I had to edit the manifest file (see previous file) which solved the errors then I cheated and just suppressed/ignored the warnings and it compiled, unfortunately there a bug in it which is preventing the app from displaying properly or recognizing the board!

I hope this information will be helpfull to you out there also venturing into this field.

つづく

I have been trying to get into this android hardware development and like many I have been suffering from the
R cannot be resolved to a variable

After finding no luck with the solutions on the web I started pooking around the web.
In the end I found it was the following that caused the issue

All I did was delete
android:theme=”@android:style/Theme.Holo”

Run Project>Clean followed by refresh and that got rid of the R cannot be resolved to a variable issue.
Now I just need to solve the
The import android.text.SpannableStringBuilder is never used
Issue’s.

Well Been along time Since I have remembered to update this, so……

1st After 3 years I had to dump my bicycle and buy a new one,after keeping to the sub £200 market I finally had enough (probably spent the same and what I initially paid for the old bike in repairs!)

My new bike is a Forme Elements ( well with one or 2 alterations thanks to Ralphs cycles of Taunton)
Forme Element
And so far I’m quite happy with it but for the problem that my knees are now hurting due to inflamation of the joint (nothing to do with the new bike, just coincidence that it flared up with the new bike).
The bike cost £499 but I got it for £399. It is incredibly light weight for its size and came with a lifetimes free servicing, sweet, Just hope I last for a long time.

2nd – Wargames

Well Got board and decided to start another Warhammer 40K army so Now I Have 3(4) 40K armies !
World Eaters (Chaos Space marines),
Forces of Ultramar,
Eldar,
Add to that 2 Warhammer fantasy Armies
Dwarf’s,
High elves,
And a whole host of other models from various companies (Pegasus, Sodapop miniatures).
I should really be out painting *groan*.

3rd electronics
After looking for a Cheep Internet tablet I went for the Superpad III, this is an android powered Chinese tablet in the sub £150 market and so far I’m happy with it.
I’m trying to get into electronics and wanted an Oscilloscope Seeing the Arm DSO quad from seed studio really I cheep I ordered one unfortunately It’s stuck @ Chinese customs and my supplier is doing everything to solve this problem (Thank you for you help!).
I’ve also invested in an Arduino Uno with the intention of Home automation however, I came across a Netduino Plus
Netduino Plus
which has a built in ethernet shield for the same price, I just hope I keep remember how to program it. After having had the ceeling in my room replace due to asbestos I now have LED lighting in the room making the whole automation process simpler.

I just need to remember to update this and learn how to use all my new toys.

Well for the revamp of my web site I wanted 1 Jquery UI powered accordion to power the sites navigation and 1 for the blog style posts.
After searching for ages I still couldn’t come up with the solution, While on holiday it finally hit me all I had to do was define 2 instances (if that’s the correct terminology) and bingo it worked.

My code:
$(function() {
$( “#accordion” ).accordion();
$( “#news_accordion” ).accordion();
});

Then I just had to call them at the required positions with
id=”news_accordion”
and
id=”accordion”
and it all works !!!
just need to sort out a size issue and I’m finished and can go onto the other scripts.