Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 12:34 27 Nov 2024 Privacy Policy
Jump to

Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.

Forum Index : Microcontroller and PC projects : Basic for Android

Author Message
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 02:52am 23 Dec 2012
Copy link to clipboard 
Print this post

Here is a great variant of basic for android, open source and with access to device's hardware.

http://laughton.com/basic/versions/v01.71/index.html
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 07:27am 23 Dec 2012
Copy link to clipboard 
Print this post

Is working well with the sensors on the device, with Bluetooth, and GPS but the best part is that it can produce a standalone application (manually set or automated by a free third party tool). Still, is better (not for me yet) to use the Google tools, programing in Java.

The great thing I find at Android is the fact that you can install applications (without root-ing it) from your SD-Card or via USB cable from your PC. Probably, this will allow you to sell applications from your own "store" but also to share the free ones via email or forums.

But I'm still curious about Windows Phone 8 regarding to application development...

____________
Glenn, I remember that you said that you will choose another platform for your phone... which one?Edited by vasi 2012-12-24
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
isochronic
Guru

Joined: 21/01/2012
Location: Australia
Posts: 689
Posted: 03:31am 25 Dec 2012
Copy link to clipboard 
Print this post

I think Android 4.0 (and later) has features
built-in for running a variety of programming
languages, I read somewhere that you can install
something that runs basic, C, python, etc. I'll
try to get the details
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 11:34am 25 Dec 2012
Copy link to clipboard 
Print this post

At least Python is running for sure. But I don't know at what degree (a little game using the touch interface, a photo album example, nothing about the sensors in the examples ...).

Regarding to C/C++, there are Necessitas project (Qt and QMobile for Android) and Mosync. Necessitas is making native dynamic libraries who are integrated in a Java skeleton. Mosync I think is compiling for a Java VM, not sure.
Both projects still have a long way to go (some examples are working great, other are freezing).

I mentioned Re De Basic because people here are more accustomed with Basic language and because I was enthusiastic regarding to the features (I think it supports everything on the Android platform) supported already (here more details). You can test them directly on the device via the Basic interpreter, and you can make a standalone application at the end.

But this paragraph is interesting:
[quote]This project is a labor of love by the curator of The Dr. Richard Feynman Observatory and author of Atari Basic and Apple DOS 3.1. It is free to all, now, and forever. The underlying source code is available under the terms of the GNU General Public License.[/quote]

Also ruby, JRuby+Ruboto and MobyRuby (which is expected to be ported to Android after a complete iOS release) ...
Ruboto project have a movie on youtube.

There is also Processing (right now is the only variant of Java digested by my stomach) for Android, better known in the Arduino world. It benefits from a third party "library", coming with better support for the device's hardware.

I knew (not all of) them, but all are still under heavy development.Edited by vasi 2012-12-26
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 09:16pm 25 Dec 2012
Copy link to clipboard 
Print this post

Thank you for telling us about Re De Basic.
It seems to be exactly what I was looking for.

I managed to waste most of today playing with it!

Jim
VK7JH
MMedit   MMBasic Help
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 03:51am 17 Apr 2013
Copy link to clipboard 
Print this post

A good Bluetooth-to-Serial device is "Bluetooth Mate Silver" from SparkFun with a distance of 10 meters (there is also a Gold version, up to 100 meters) which can be used with any (5Vcc?) microcontroller, but boards with a 6 pin serial connector (standard of Arduino Pro) are at advantage.

In order to use it with BASIC!, you must pair it with your Android device. One thing I learned using BASIC!'s bluetooth commands is that does not matter if you send (bt.write) one char or an entire string of chars, it will always end sending a "newline" char so, you must take that into account when you process the transmission inside your microcontroller (if things were ok with bluetooth terminals using my first firmware test, for BASIC! I had to rewrite the firmware).

An excellent, free, Bluetooth Terminal is "Connection terminal" where you must press a "Send" button to send the char or the string. If you want immediate feedback when you touch a button from your virtual keyboard, then there is "BlueTerm" which it happens to be open-source. These tools are great for testing and debugging your firmware.

And now you can find an Arduino IDE in Google Play store for free, which can even compile sketches, without root rights. Just in case you would have asked what is the point in having Android testing terminals when you use the PC anyway...

So, I wanted to see if BASIC! can be a capable tool. I wanted to learn how to use the graphics, touch events, orientation screen sensitive apps, and "bluetooth" communications. And I ended up with this little program, starting from the existing examples





The text data is from GPS "sensor" (one of the given examples), the red LED will go ON/OFF if you touch the rectangular zone from his right (or bellow) and will toogle also a LED from your microcontroller board sending "0" for off and "1" for on. The green LED will signal the bluetooth status and the "button" assignated to it will close the bluetooth communication and the program. Tha radar thing does nothing, only redraws depending on the screen orientation - just to play with relative coordinates.

The way I draw the graphics (clear the screen and redraw everything at every 10 ms) is not the best method but is one of the two possible and it came with the GPS example. Anyway, avoid screen orientation sensitive applications if you have to make realtime graphs, stick with Landscape or Portrait.
Application will not start (well, I've not tested all the cases) if you don't have the Bluetooth module paired, so, if you still want to test the program, comment every command which starts with "bt." (or "BT.", doesn't matter, is not case sensitive) sequence.
Entire program can be written in a better way, you will see when you read the code but, is a start. Unfortunately, the relative coordinates thing make it relatively () hard to "decrypt" ....

To be honest, the language is good, but ... don't quite like it and is hard to write real applications on small Android devices, even if there is a real keyboard, the Android applications does not respond to a full category of events, as on PC. But is a nice and capable enough tool (I bet it can become quite "dangerous" in a BASIC programmer hands). I read in the documentation that you can make HTML+CSS user interfaces, and that will be great... don't know yet how to do that...
Even if the language can address general problems/projects and can make applications operable by anyone, is still only for a techie guy.
2013-04-17_135115_source2.zip

____________
Unfortunately, the GPS commands from BASIC! will not provide informations regarding to the satellites ("in view" versus "used", position, etc.) so, the "the radar screen" will remain empty
Edited by vasi 2013-04-19
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
vasi

Guru

Joined: 23/03/2007
Location: Romania
Posts: 1697
Posted: 12:20pm 18 Apr 2013
Copy link to clipboard 
Print this post

Regarding to the firmware of the microcontroller, is simple. You must use the serial port, set it at 9600 bps (if you acquired the bluetooth device from robofun.ro Romania) or 115200 bps (as I understand is set by default by SparkFun.com). Set a pin as digital output, connect a LED on it, then listen to the serial, and if the char is "0", turn the LED off. If is "1", turn the LED on.

For someone using AVRs and gcc-avr, I have here an example. Go at the home page of the project to see what library it uses - maybe it will be useful for you.
Hobbit name: Togo Toadfoot of Frogmorton
Elvish name: Mablung Miriel
Beyound Arduino Lang
 
TassyJim

Guru

Joined: 07/08/2011
Location: Australia
Posts: 6099
Posted: 06:05pm 18 Apr 2013
Copy link to clipboard 
Print this post

I am also having fun with Basic! on my Android phone.

I have found that you can get "stale" GPS data. The operating system simply returns the most recent data and you have to check to see if you really are getting current data from the GPS.

The method I use reads the GPS time (in milliseconds) and then wait one second and read again. If the difference between the two readings is somewhere close to 1000ms, I trust the data.

oldgpsTime=0
w=0
gps.open
gpsready:
gps.time mygpsTime
mygpscheck=mygpsTime-oldgpsTime
oldgpsTime=mygpsTime
print mygpscheck
if mygpscheck<600 | mygpscheck>2200 then
pause 1000
cls
print "Waiting for GPS"
w=w+1
if w<60 then goto gpsready % wait for 60 seconds
else
print "GPS data found"
GPS.LATITUDE lat1d
GPS.LONGITUDE lon1d
endif
print lat1d
print lon1d
gps.close
end


Jim
VK7JH
MMedit   MMBasic Help
 
Print this page


To reply to this topic, you need to log in.

© JAQ Software 2024