Tuesday, May 29, 2012

Huawei stumbles

When I bought my Huawei Ideos X5 (U8800) Android phone in April 2011 nobody I showed it to had heard of the Chinese company. Indeed, they seemed reluctant to boost their profile, and did not show the Huawei name anywhere on the phone, labelling it as an Ideos X5 "with Google". Actually, my partner had unknowingly owned a Huawei phone for some time, but she did not realise this because her phone had a Virgin logo. Huawei want to become more prominent, but my recent experiences with the company show that they have some way to go before people think Huawei when they think of smartphones.

A recent article in The Guardian said that Huwei "... wants to place its products in the hands of millions of western consumers, and become the fourth largest manufacturer of smartphones by the end of this year". They went on to say that "Huawei's stated ambition is to become as big as Cisco or IBM, with annual revenues of $100bn in 10 years".

If Huawei want to be taken seriously then they need to provide acceptable customer service and support. In the Android world this is mostly determined by their ability to provide prompt bug-free firmware updates. So how have they gone?

VersionAndroid releaseX5 release
2.2 - FroyoMay 2010April 2011
2.3 - GingerbreadDecember 2010December 2011
4.0.4 - Ice Cream SandwichOctober 2011April 2012 (unofficial)
There has been a delay of about a year after each Android release for Huawei to customise a version for the X5. That's a bit slow, but if they were bug free then it would be just about acceptable. Unfortunately they have problems releasing updated firmware without introducing new bugs. The XDA wiki, showing all the Huawei firmwares, shows the large number of releases, and Huawei's inconvenient propensity to remove older releases. They also tended to announce upcoming firmware release dates, but then not meet those dates.

I updated from the official 2.2 to the official 2.3, but found this added problems such as unresponsive widgets and the removal of the extremely impressive SRS WOW HD equaliser setting which made the built-in speaker sound great. On the plus side it added a fast boot option, which made the cold boot time go from very slow to very fast. Overall, though, it wasn't a great upgrade.

As you will have noted in the above table, there is now an Ice Cream Sandwich firmware for the X5. This is an unofficial Aurora firmware, which means that it's not provided by Huawei, and upgrading to it is a bit more involved than you'd expect for consumer hardware. However, the procedure is well documented, and the result is well worth it. I've found the upgrade to be relatively bug-free, and the internal speaker is now loud enough to be useful again. Although this firmware is still under constant development it is stable enough for everyday use. I'd recommend it to all users of this phone. Huawei have not announced an official update to Ice Cream Sandwich, so it's unlikely that one will ever be produced. (Update 31-May-2012: Apparently Huawei are not releasing any further updates for this phone.)

If I were purchasing an Android phone now I would probably go for a more highly-regarded company such as Samsung or Sony. Huawei do not yet offer the support I would consider mandatory, and they are not as widely used as the aforementioned brands, meaning that unofficial firmwares are less likely to appear. And unofficial firmwares are where one turns when the phone provided is slow or loses interest in an old model, which seems inevitable nowadays.

Sunday, May 6, 2012

More words in my word game

If you enjoyed my recent word game but want more then I'm happy to announce that I've added a bunch of uncommon words, more than tripling the number in the quiz. Have fun!

Fix for Obtaining IP Address Android problem

I occasionally had the Obtaining IP Address bug with my Huawei X5 (U8800), but it was rare enough that I never bothered looking for a fix. This is where your Wifi doesn't connect, and if you go into network settings you'll see a continuous loop of scanning , obtaining IP address, and disconnecting. But then my partner got a Sony Xperia Arc S which exhibited a similar problem much more often, so a cure was urgently required.

The Sony Xperia Arc S has a lot of user complaints about this issue, and a related one where the Wifi shows as having Limited Connectivity. Both of our phones have only exhibited these problems on our home network, which means that solutions involving changes to the home network are possible. In our case, a suggestion to try static IP addresses appears to solved the problem. It's not ideal, and it points to a problem with the phones or the wireless router, but if it leads to a resolution then that's good enough for me. So, how to we set up static IP?

Step 1: Tell your router to give a static IP to your phone. 

Go to your routers administration site. Then find DHCP settings. On my Belkin it's under Advanced Setup | LAN | DHCP Client Lists. Since my phone has already connected I can see it in the list under a host name of android-#####, next to which is a check box labelled Fix. Ticking that will ensure that whenever my phone connects it will be given the same IP address. If your phone has never connected then you can add a new entry based on the phone's MAC address, which you should be able to find in the phone's settings menu, under About phone | Status.

Step 2: Tell your phone to use a static IP address

If you are using Android 2.x (e.g. Gingerbread or Froyo) then setting a static IP address in the phone's network settings will apply to all connections, which means if you wander into McDonald's or your work, where dynamic IP addresses are used, then networking will not work until you turn off static IP. Luckily there are lots of apps to automate this switching. I used Wifi Static from farproc, which automatically switches between static and dynamic depending on which network you are connecting to. This worked really well, and totally solved my problem until I updated to Ice Cream Sandwich.

If you are using ICS then network settings apply to networks individually, so you can set your home network to use static IP, and all other networks to use dynamic. To get to the area to change this do a long press on the Wifi network to change, and click Modify network.You may then need to tick Show advanced options, and the rest should then be straightforward. Make sure to uninstall Wifi Static if you have it installed, as it is not needed in ICS.

Saturday, April 21, 2012

WebGL fractals

If you're after pretty pictures then go straight to the

WebGL fractal zoomer

- I'll wait. It works in most modern browsers except for Internet Explorer. To zoom in click on the location to zoom with the left-mouse button; too zoom out press the right-mouse button.

As I've noted previously I generally practise programming new platforms by developing fractal generators. WebGL, which can be thought of as OpenGL for the web, lowers the barriers to entry for writing 3D code. It has the potential to allow vastly improved web graphics, unleashing the hugely powerful 3D graphics hardware in many systems, and best of all, is now available in all the good web browsers, including Mozilla Firefox, Google Chrome, Opera and Safari. For all these reasons it was an obvious next choice for building a fractal generator.

WebGL combines Javascript and shader code on a web page to utilise the graphics card's hardware facilities to produce images. Prior to WebGL one common method to access the 3D hardware was through the XNA platform, which requires Visual Studio, the Microsoft .NET framework, and some other tools. I used the predecessor to XNA, Managed DirectX, in my previous 3D fractal work, and it was a lot of effort to get started. WebGL just needs a compatible browser, and then the coding can be done in any old text editor.

My immediate programming goal was to recreate the output of my existing browser-based fractal zoomer, which I built after the release of the Canvas feature in web browsers to test it out. I described it in a bit more detail in a previous post. In theory, using the graphics card hardware I should be able to achieve the exact same output but much faster, in more detail, and without taxing the CPU.

I started by learning WebGL at the lessons section of the appropriately-titled Learning WebGL site. Serendipitously, that site provided code that showed pretty much exactly what I wanted to do - Zooming into the Mandelbrot set in a WebGL fragment shader. That code made the usage of pixel (aka fragment) shaders very clear to me. In my previous DirectX work I diverted off into writing my own stuff before I fully understood pixel shaders, so I missed out of a very useful element for building fractals. Essentially, you provide instructions for how each given pixel should be coloured. This is a perfect match for the calculation of fractals, where each element of the fractal is determined solely by its coordinates. It was then straightforward to make the modifications to get the simplify the interface to match my old zoomer, and modify the colours to match too.

A great benefit of WebGL programming which should not be underestimated is the ability to see the code of any WebGL page. As with any HTML page, just view the source, and you can see how the magic is created, and learn from others. This was one of the critical elements in the fast adoption of HTML and Javascript.

Looking at my zoomer, you'll notice that if you zoom in for a while it gets blocky. This is where you are reaching the limits of medium precision floating point numbers. I made a small attempt at using high precision numbers with the highp command, but it didn't seem to have any effect. I guess it may be hardware dependent. It may also be, as noted in the  WebGL Specification
OpenGL ES 2.0, and therefore WebGL, does not support double-precision floating-point data. 
The speed of the zoomer is highly influenced by the speed of your video card. Integrated cards, such as in laptops or business PCs, may be a trifle slow in 2012. Come back in a year or two when you've upgraded to be really impressed!

Note that I've used a little bit of JQuery in the code. Although this was an example of using WebGL, adding a minimal bit of JQuery to the mix allowed for easy capturing of user-input without cluttering the code.

I am very impressed with WebGL. It's an easy way to get access to 3D hardware, the code is easy to write, and the benefit of being able to look at other peoples' code is a great incentive. If I want to learn more 3D graphics programming in future I'll certainly look at WebGL first. Maybe by then Microsoft will have added WebGL to Internet Explorer.

P.S. I found the WebGL quick reference card (pdf) very useful in explaining the C-like elements of the language used in the shaders.

Saturday, April 14, 2012

Bicycle law changes in Western Australia

Changes to poorly designed laws are always welcome, especially when illicit activities which you commonly  perform become legal. For Western Australian cyclists the latest amendments are particularly welcome - Amendments to Bicycle Regulations (September 2011).

My two highlights are:

  • pedelec bicycles are now allowed on shared paths, so if I'm riding on an electric bike and my partner is on a normal bike I don't need to stick to the smelly, noisy, busy and dangerous road while by partner frolics along the lovingly-designed, flat scenic shared pedestrian / bike path, and
  • when bicycle lights are required the front white light does not need to be steady, but can be flashing. I much prefer this because my front light is used to make me visible to other road users, but not for me to see with, and I believe flashing assists this. Also, flashing lights use much less power than steady lights. 

Now the two rule changes I am most waiting for are for the maximum power of pedelecs to be increased from 200W to the European standard of 250W, and for pedelecs to be allowed on public transport. Maybe next year...

Friday, March 30, 2012

From tiny acorns...


With 2TB hard disks, 32GB SDHC cards and 8GB USB flash drives now commonplace it is easy to forget how much can be done in a small amount of code. A compressed jpeg photograph from a 6 megapixel camera might take about 2MB. So how did people cope in the 1980's when the common double-sided 5 1/4" floppy disks could only store 360kB, and what can you do with 1kB today?

As an aside, a byte, historically, is the amount of data required to store one character. Changes to encode international alphabets mean this is no longer strictly true, but it's still a good rule of thumb.

Back in the early days of the IBM PC-compatible home users did not have much digital media to store. Digital cameras did not exist, and digital music, photo and video was not common. The types of items I stored were word processing documents, source code, and games. These days documents and games can be huge, with the media assets of games filling an entire 6GB DVD. Source code is still tiny, though, which leads to some pretty impressive and surprising achievements.

All of the text up to the end of the preceding paragraph has contained 1085 characters. There is an ongoing competition called JS1K where javascript of less than 1000 bytes is written that performs interesting feats. This year I was most impressed with the JS1k Speech Synthesizer, which in only 909 bytes turns text into (mostly intelligible) speech. Annotated code is provided, but it's still be bit obtuse to me. Actually, a great benefit of javascript code is that anyone can read it, by just viewing the source in their browser. I used to expect that if the code was short then it would be understandable, but this is definitely not the case, especially when lots of minification has been done.

Seeing the JS1K demos reminded me of when I followed the PC demoscene. One of the most popular current competitions is the 4kB intro. I am particular impressed with the 2009 demo elevated. Although you can watch a YouTube version it's a lot more impressive downloading and running the proper 4kB Windows code (note that there is a Windows 7 version). Recall that a single digital photograph takes about 2MB, and then ponder how this multi-minute video, of flying over a photo-realistic landscape, with associated music can fit into just 4kB.

Finally, and slightly offtopic, Twibright Optar is interesting software which can store 200 kB on a single A4 sheet of paper. Think of it as an enlarged QR code. It might not sound that useful, but consider that paper may, when stored correctly, last many hundreds of years. Then think about your old floppy disks and how you can read them nowadays. Or do you trust The Cloud?

Wednesday, March 21, 2012

A4 paper

The A series of paper, of which A4 is the most well-known member, is described as being metric. Its dimensions of 210mm x 297mm, don't seem particularly well chosen, but they are actually pretty special.

297 ÷ 210 = 1.41128 = √2

In fact, all of the A sizes have sides that are the ratio 1 : √2. I'll leave it as a simple proof for the reader to show that dividing a page of those dimensions in half will result in two smaller pages with the same 1 : √2 ratio. This is the only ratio which retains its proportion when halved.

Now, looking at the area:
297 * 210 ≈ 62500 = 1000000 ÷ 16 = 1000000 ÷ 24

If you have an A3 page handy you'll find its figures are:
297 * 420 ≈ 125000 = 1000000 ÷ 8 = 1000000 ÷ 23

If you follow this pattern up to A0 you'll find it has an area of 1000000 ÷ 20 = 1m2

How cool is that!

Wikipedia says that all countries around the world except the US and Canada have settled on A4 as their standard letter paper size, though US letter is in common use in countries neighbouring the United States.



Bonus fact: A6 is commonly used for postcards and toilet paper.