FlexBASIC as primary language use for P1/P2
Since it looks like ersmith is keeping flexprop updated, maybe it is time to look into dumping SimpleIDE.
FlexBASIC is starting to look and feel like a very powerful language to work with. The one big problem is, drivers for things that Parallax sells, like Ping, BME680, ..., etc.
Since flexprop can handle different object drivers, in the specific language, how do we go about getting or creating these drivers so they can be used among the different languages. I am not sure if FlexBASIC would be the preferential language for creating the drivers.
At the moment I am working with the ActivityBoard, which has a breadboard, ADC, and other things. I guess I would need some suggestions as to the best approach to creating a driver for a Ping and the ADC that is on the ActivityBoard and the drivers could be used between the different languages, in a useful manner.
I did look at the Parallax github site and it looks like most of the examples would have to be converted so they could be used with the flexprop, although I could be wrong with this assumption.
Anybody have some good advise or examples to present?
Thanks
Ray
Comments
I don't know what FlexBASIC uses for importing, it might be
class
, but Eric has done a stellar job at integrating them at compile time. They're so easy to work with I've even started making my own driver/handler-like spin modules even though my target deployment is C.Read the "basic.md" document for some hints.
Yes, I believe it is class. The problem that I see is a standardization of the module itself, so it can be used between FlexC and FlexBASIC.
I guess what I am looking for is an example driver module that can be used by FlexBASIC and FlexC. If everybody starts doing their own thing, driver module, then we will be back to the same predicament that the Parallax github site is in, or OBEX is/was.
As I mentioned earlier, maybe an example driver for the Ping or ADC would be a good starting point. Hopefully others could use that for further development.
Ray
Obex worked fine I thought.
Here's an example of what I used for my first test case. I grabbed Jonny Mac's jm_i2c_devices.spin2 compiled it and got a handle on how it was working (partly me learning how spin works too). It itself is a demo of using his jm_i2c.spin2 low level driver.
I then found out how to load Spin modules into FlexC -
struct __using( "jm_i2c.spin2" ) i2c;
And basically did exactly the same operations in C as JM did in his devices demo program. Ported but still using the low level driver as spin code. See attached:
Ah, I guess that example won't work on the Prop1. Jon has ported most of his examples from the Prop1, so I presume there will also be older versions by the names jm_i2c.spin and jm_i2c_devices.spin.
Pretty much everything I write is in FlexBASIC these days. Eric’s implementation of CLASS is just amazing. In one project I have 7 “classed” BASIC libs, two SPINs, and one PASM. Its really amazing what you can do. Example: want to add VGA? Drop-in Eric’s tile driver and turn it on. Three lines later you can just do a PRINT #2, “Hi there” and its on-screen. Done.
At some point I need to put my libraries up for release. Lots of stuff (SPI, I2C, date/time, advanced trig functions, etc) could probably be useful for others.
Since FlexBASIC and FlexC can work with P1 or P2, should the drivers be xxx.spin/xxx.spin2.
I was looking at SimpleSerial.spin2, which is setup to be used with P1 or P2. Basically it uses:
Maybe the file could be called something like xxx.drv and would contain both P1 and P2 code.
Also it seems that in some cases the same code could be shared between both the P1 and P2.
Again, I am not a Spin programmer, so not sure as to what the best approach would be.
Ray
Spin1 and Spin2 are different but related languages, a little bit like C and C++. It also happens that Parallax's Spin1 only runs on the P1, and Parallax's Spin2 only runs on P2, but flexspin can compile both .spin and .spin2 files for both processors. For flexspin, whether the file should be called .spin or .spin2 depends only on what kind of language features the file uses, not on the processor (for example, a .spin2 file uses
ABS x
to find the absolute value ofx
, whereas in a .spin file you would write||x
instead).