Showing posts with label Windows Phone. Show all posts
Showing posts with label Windows Phone. Show all posts

April 27, 2014

Touchdevelop pt 2

I the first part I started with programming on the phone using touchdevelop.

This time I will go a little bit deeper and finish my bird song quiz app.

Basic functionality is to randomly get six bird sounds from my media list on the phone, display all six and play one of them letting the user guess which one is right. After choosing the app will tell you if it was correct.

In the last part we started out with this to get a random song:

action main()
      var mysongs := media→ songs
      var chosensong := songs→random
      player→play(chosensong)
end action


This time we do the same stuff but six times with a a while clause that adds stuff to a collection.

First we add the chosen song:

var quizlist:=collections→create string collection
quizlist→add(▷ getbirdname(chosensong→name))
var x:=0
while x < 5 do
   var decoy := ▷getbirdname(songs→random→name
   if quizlist→contains(decoy) then
   else
      quizlist→add(decoy)
      x := x+1
   end if
end while

As I want a bird song quiz I have to convert the mp3-name (for example white-tailed swallow.mp3) to a bird name. I do this by removing the .mp3 from the name together with all numbers I can find (sometimes I have many numbered sounds for a bird).  This is done in getbirdname and the symbol ▷  means that it calls a function that returns the bird name from the mp3 file name.

The function looks like this:

private atomic action getbirdname(s:string)
returns (out:string)
do
   out:=s→replace regex("[\\d-]","")→replace(".mp","")
end action

Simple regex to get rid of the digits and then I just remove the .mp-part and return the name.

Then I show the names from the quizlist and plays the chosen one on my phone with:

quizlist→sort 
player→play(chosensong)
"Choose bird:"→post to wall
□ chosen:= -1
while □ chosen < 0 do
   □ chosen := wall→pick string("Which bird is this?", "Choose an alternative.", quizlist)
end while
if quizlist→at(□ chosen)→equals(▷ getbirdname(target→name)
then
   "Correct"→post to wall
else
   "Incorrect"→post to wall
   ▷ getbirdname(target→name)→post to wall
end if

The  □ chosen means that it can save the result between rounds as a global persistant variable that can be stored in the cloud.

Oh by the way....
the symbol □ looks like this with a bit magnification:

I've just touched on what you can do with touchdevelop (try for example language→speak text("en-US", "female", ▷ getbirdname(chosensong→name)), but since I still haven't found any customer who wants his business system written in the language I will move on to graph databases next time.

See you!




March 25, 2014

Finally I can code on my way to work...

I have a Windows Phone and I love it. Sure, there are a bit fewer apps and in Sweden only one phone company has the Nokia 1520 as a phone of choice. The 1520 is a big phone, most people actually question if its a phone or a tablet when they see it.

For me that is a perfect size.

It barely slips down in my pocket and it is big enough to be used as a small tablet.
When I then discovered TouchDevelop a few weeks ago everything came together. I could finally do some serious coding on my phone!

So... what is TouchDevelop?

It is a programming language by Microsoft Research that lets you create software by clicking. It is made for developing by touch and it lets you use your programs on a windows phone, iPhone, iPad, android phone or tablet or on your PC.

What is it not?

Even though the tutorials use the LOGO-turtle it is not a simple language. TouchDevelop has a lot of power under the hood and it takes a while to get in to. You could use the language to do just about anything, but the more complex the task is the more you would wish that you made it in c# instead. It is simply a perfect tool for quick hacks or games that needs to run on your phone.


So over to the case:
I am a bird watcher and I travel a lot. To be able to recognize birds I need to learn their sounds. This is seriously boring and I usually end up with listening to a couple of songs and then giving up.
This time it should be more fun to learn sounds so I want to create a bird quiz-application on my phone that plays a sound and gives me a number of birds to choose from and in the end gives me a percentage on how many correct answers I made so I can be proud of the results.

Since I only have bird songs in my song list on my phone the first step would be to play a random song.

It is a simple task but it is something that still would take some time to do in a traditional language (c#).

In TouchDevelop this would look like this:

action main()
      var mysongs := media→ songs
      var chosensong := songs→random
      player→play(chosensong)
end action

Just run this and a random song. And all this by clicking on your phone.

To be continued...

October 31, 2012

Windows Phone 8 SDK is out!

I really, really need a Windows 8 phone right now. It is the creeping uneasiness that only a gadget junkie can understand.

I also need a 3d-printer, some new Win8-tablets and a .Net Gadgeteer. I also need the time to play around with them. Hey, I hardly have time to blog these days.

Most of the positive talk regarding Windows Phone 8 has been about the shared core with Windows 8, that you finally can use it on decent hardware and that you now have THREE different sizes of tiles instead of  a meager two.

The negative talk touched the fact that those who bought 7.5 phones can forget the possibility to upgrade them to version 8.

They are dinosaurs, soon extinct.

The thing I find most interesting in 8 is something else, the Company Hub and the new ways of deploying apps for companies who don't want their apps to be hanging on the Marketplace.

For you that might not sound so impressive.

For me it means that I can finally have a slight hope of working with coding Windows Phone 8 apps to customers.

Windows Phone is a much more interesting alternative for enterprise customers than to end customers (read: releasing stuff on the marketplace) as long as the market shares are the way they are. (Why release an app to 1.7% of all smart phone users instead of 50%?)

So if some company wants to use a mobile as an internal tool, I believe Windows Phone 8 could be a strong competitor right away. And maybe, maybe that could give me the chance to start developing WP8-apps outside of my apartment.
After all, there is so much more time at work than home.

Oh yeah... If you would like to start coding you can find the SDK here!

June 24, 2012

Windows Phone 8, will it finally make it?

I have been waiting for the version 8 of my favorite mobile OS and now when they showed it my feelings are a bit mixed. The main thing that stirs up my feelings is that you cannot upgrade a 7.5 telephone to Windows 8.
I didn't expect this from Microsoft. The early rumors where hinting that you would be able to upgrade your Lumia to the new OS. On the other hand, with a bit retrospective and with the talk of using parts of the Windows 8 kernel in the phones, I should have guessed.

This will on the other hand give me an edge in the ever ongoing "who has the coolest phone in the office"-competition, their Lumias will only make it to 7.8...

Every cloud has a silver lining...

So for the truly good news?

Version 8 finally gets a chance to compete with other smartphones when you just check the hardware specs.

It gets the multi-core processor, high resolution screens, true multitasking, integrated skype, offline maps.  The best and in my point of view, a critical must for the success of Windows on the phone is that it will share code with Windows 8. In effect this will mean that Microsoft is choosing one road for all its devices. It is Windows 8 from phone to Server. This also gives me confidence that Microsoft will not to as they do with Windows Phone 8 again, namely cut off their existing user base.
This seems like a long term strategic choice and even though it has a slightly bitter aftertaste it still is needed in the long run.

So will there be a long run?

I still believe that Windows 8 will make it. It simply has features that makes it so much more powerful than the iPad or the Android tablets. It is a real computer. And I believe that Windows 8 will be the beast that will pull the Windows phone.

I hope so.

Windows Phone 8 is just too sexy to disappear. Just look at those nice square things on the screen!