Home
JAQForum Ver 24.01
Log In or Join  
Active Topics
Local Time 15:29 02 Jul 2025 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 : Trying to convert Arduino to MMBasic

Author Message
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 11:04pm 21 Apr 2016
Copy link to clipboard 
Print this post

I've been trying to convert an arduino program to MMBasic for a while now but not knowing too much about programming I'm stuck
Anyone able to give me some pointers or help on how to convert specific bits?
it's things like this that I'm stuck with
write8 0x29)
I've no idea how to translate write8
writeParam(PARAM_CHLIST, PARAM_CHLIST_ENUV Stuck on this one too
uint16_t no idea what this is or does
uint8_t same with this

class
public:
private:
boolean begin();

Stuck on those too

The code I'm trying to convert is in the zip file as 1,2,3 (text files)

The text file called 3-1 is where I've got as far as in converting
although I'm possibly totally wrong in how I've done it - someone might be able to give me some pointers on how to do it right

IF I can learn how - then hopefully I'll be able to do the next device without help (hoping anyway)

Edit: I'm not asking for a complete conversion, I'm asking for help with those specific bits or enough help so I can finish the conversion to mmbasic myself
2016-04-22_090430_Arduino_Code.zip Edited by lew247 2016-04-23
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4032
Posted: 11:43pm 21 Apr 2016
Copy link to clipboard 
Print this post

Some quick notes:

1. _t is just a convention to hint that it's a (user defined) data type
2. the number means the (minimum) number of bits
3. the initial letter u means unsigned

So, uint16_t means a data type that holds an unsigned 16-bit integer

John
 
JohnS
Guru

Joined: 18/11/2011
Location: United Kingdom
Posts: 4032
Posted: 11:50pm 21 Apr 2016
Copy link to clipboard 
Print this post

For converting code you can probably just treat a class as a sort of name around other things. A different class can use the same name(s) inside as another class, if it likes, as the compiler can be told which one you want, if it's not obvious from the context.

Here, write8 looks to be
void Adafruit_SI1145::write8(uint8_t reg, uint8_t val)

The void means it does not return a value.

The code is short and basically just sticks some values out using the Wire class.

public & private are about making clear how parts of a class can be used. (Vaguely like the way MMBasic has locals.) You can probably ignore public & private.

I expect you've figured boolean is about True & False values (you can use 1 and 0 I expect).

JohnEdited by JohnS 2016-04-23
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 03:04am 22 Apr 2016
Copy link to clipboard 
Print this post

No I had no clue what boolean was about.
so anything with void means it sends a command but doesn't expect something back?
I have no idea what signed and unsigned integers mean unfortunately, I'm still extremely new to all this.
how do I talk to the micromite when it comes to uint16 or uint8? is there a specific way or format to do it?
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 12:53pm 22 Apr 2016
Copy link to clipboard 
Print this post

  lew247 said   I've been trying to convert an arduino program to MMBasic for a while now but not knowing too much about programming I'm stuck
Anyone able to give me some pointers or help on how to convert specific bits?


Hi Lew,

My Solution was to buy a cheap Ardruino Kit and play around with a few tutorials to learn the code a bit.

Still got a lot to learn though, & would not have been able to answer your actual question.

Think it's worth the effort as there's a lot of Arduino code out there.

Cheers.

Edit:-

What does it do?

Presume from a couple of variables UV index might be involved in a weather type situation?Edited by Phil23 2016-04-23
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 01:27am 23 Apr 2016
Copy link to clipboard 
Print this post

  Phil23 said  
Presume from a couple of variables UV index might be involved in a weather type situation?


That's exactly what it is, a UV index module
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 10:41pm 24 Apr 2016
Copy link to clipboard 
Print this post

Can anyone help with thise?

Dim Slave Address As Byte?

Dim item1 As Single?

Dim item2 As String?

Dim item3 As Byte?

Dim item4 As Word?


I've no idea what these mean in terms of Micromite Basic

I'm guessing item1-4 would be constants and integers? but I've no idea if they are ot how they would be written in Micromite Basic
The other things are Byte, Single, String and Word
Anyone able to help me by telling me what they are in MMBasic or how to write them in a program?

 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 11:31pm 24 Apr 2016
Copy link to clipboard 
Print this post

  lew247 said  
  Phil23 said  
Presume from a couple of variables UV index might be involved in a weather type situation?


That's exactly what it is, a UV index module


Why not just start a fresh?

Do you know which module it is?
I may have one the same here to try & play with.
Have a bit of a habit of collecting sensors to play with.....

Cheers

Phil
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 11:37pm 24 Apr 2016
Copy link to clipboard 
Print this post

It's an SI1145 UV index module
Edited by lew247 2016-04-26
 
matherp
Guru

Joined: 11/12/2012
Location: United Kingdom
Posts: 10181
Posted: 03:04am 25 Apr 2016
Copy link to clipboard 
Print this post

  Quote  Can anyone help with thise?

Dim Slave Address As Byte?

Dim item1 As Single?

Dim item2 As String?

Dim item3 As Byte?

Dim item4 As Word?


Manual page 54, the syntax is standard MMBasic

byte == integer
word == integer
single == float
 
lew247

Guru

Joined: 23/12/2015
Location: United Kingdom
Posts: 1702
Posted: 05:07am 25 Apr 2016
Copy link to clipboard 
Print this post

Thanks matherp, its the one place I didn't think of looking. (stupidly - I never thought of looking there)
 
Phil23
Guru

Joined: 27/03/2016
Location: Australia
Posts: 1667
Posted: 08:42pm 25 Apr 2016
Copy link to clipboard 
Print this post

  lew247 said   It's an SI1145 UV index module


Hi Lew

Have you had a look at page 84 of the MM manual.
It talks about I²C communications, which is what the module uses.

It might help you in trying to convert the code.

Cheers

Phil
 
Print this page


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

The Back Shed's forum code is written, and hosted, in Australia.
© JAQ Software 2025