![]() |
Forum Index : Microcontroller and PC projects : Trying to convert Arduino to MMBasic
Author | Message | ||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
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 |
||||
JohnS Guru ![]() Joined: 18/11/2011 Location: United KingdomPosts: 4032 |
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 KingdomPosts: 4032 |
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). John |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
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: AustraliaPosts: 1667 |
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? |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
That's exactly what it is, a UV index module |
||||
lew247![]() Guru ![]() Joined: 23/12/2015 Location: United KingdomPosts: 1702 |
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: AustraliaPosts: 1667 |
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 KingdomPosts: 1702 |
It's an SI1145 UV index module |
||||
matherp Guru ![]() Joined: 11/12/2012 Location: United KingdomPosts: 10181 |
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 KingdomPosts: 1702 |
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: AustraliaPosts: 1667 |
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 |
||||
![]() |
![]() |
The Back Shed's forum code is written, and hosted, in Australia. | © JAQ Software 2025 |