Questions with regards to ESP8266 Basic and hardware interfacing and control via Basic commands

Moderator: Mmiscool

User avatar
By trackerj
#51793
forlotto wrote:@trackerj
Totem Pole "I ASSUME" = 595 shift register I believe for those wondering but I would not discount these 595 shift registers either as they do work rather well but you basically toggle them on or toggle them off I like the idea of the pcf8574 being able to control on or off state rather than just toggling on or off but either one is a workable solution I just feel we should have a good reference to both.

Thus the quest for beginning how to interface this thing and get it working with espbasic. TrackerJ are you able to get this going with espbasic instead of just LUA if so do you have an example of how to do so?


As soon as I have a bit of time and been able to install ESPBasic 3.0 can give it a try. I must admit that I'm still stuck at a ESP Basic version 2.0.Alpha 22 as 3.0 was loking too buggy.

Has start looking better from now on?

Do you have any ESPbasic 3.0 I2C related documentation? Cannot find anywhere how to define your SDA and SCL pins as in Arduino IDE or even LUA.
User avatar
By raintime
#51799 @Forlotto,

A nice thing about the board you have selected is that you can string up to eight of them in series, giving you up to 64 digital I/O port bits. Each board would be set with a different address. But this means the software would need the ability to handle different addresses.

It looks like (Fig. 8.2.2) that any bit the user wants to use as an input will have to be sent a HIGH value when the outputs are written to the chip, otherwise that input will be essentially shorted to ground when the outputs are written. Some device outputs can't tolerate shorts to ground.

You would need a "ConfigurePortExpander" routine where the user would specify which pins at each address are inputs and which are outputs.

Then you could have a WriteOutputBit (Address, BitNum, BitValue) routine, and a ReadInputBit (Address, BitNum, BitValue) routine. But this brings up another issue: In ESP BASIC we only have GOSUBs - we cannot pass parameters in parentheses back and forth like is done with procedure & function calls. So we can define special variables, say XPAddr, XPBitNum, and XPBitVal. Then we would use GOSUB [WriteExpanderPort] or GOSUB [ReadExpanderPort], and use these special variables as parameters for these GOSUBs. These GOSUBs would need to use the data specified in ConfigurePortExpander to do the job.

ConfigurePortExpander would need 8 special byte variables, XPort0...XPort7. Each one would hold a pattern of zeros (meaning outputs) and ones (meaning inputs).

It's a bit messy to have all these "special variables" hanging around inside a user program. If anything, it would be nice to have them in an INCLUDE or IMPORT file, along with the relevant GOSUB's discussed above. This points out the need for a wonderful new feature: INCLUDE {filename} (or, like Python, IMPORT {filename} ).

The best way (another definite dream that certainly appears too far out there for this year) would be to have a way to allow anyone to write their own procedures and functions with parameter passing and return values!
User avatar
By forlotto
#51802 @trackerj

I helped find the wprint bug via brute force and looking at the code after raintime introduced me to the black box with the question mark I began a search that got mmiscool t'd off a bit but my annoying persistence payed off turns out that char 160 replacements that I read in the code were causing the error now 3.17 and up should be super stable like previous versions there are some slight things that I am not sure of how to work or solve etc like manually tracking variables but who knows this may have fixed this as well to be honest or possibly I was just doing something incorrect. Anyhow it is plenty stable now head over and pick up your copy! Thanks to mmiscool he put in a lot of work fixing bugs in the last 24 hours there were so many bugs fixed in the last 24 hours that I cannot even tell you all of them and added functionality too as well as smoother operation of websockets!

@ everyone reading consider a donation to mmiscool he has worked on this hard for the last 2 days ironing out a lot this requires a lot of patience and work !
Visit http://www.esp8266basic.com and click the yellow donate button I donated 20.00 he was working overtime on basic these last couple of days it is important that we all support his efforts at least enough to buy him a drink or something he is currently at the bar lol lets see if we can't get him a little tipsy :P

Also I upgraded the first page of this post to include I2C code while I was on the hunt for the html bug I ran across the code and pasted it I will continue to upgrade as I learn more!
User avatar
By trackerj
#51829 Question still remain: How to change in ESPBasic the SDA/SCL used pins when initialise the I2C bus?
Something similar to :

Code: Select allid = 0
sda=2 --GPIO4
scl=1 --GPIO5
dev_addr = 0x20

-- init I2C nEXT BUS
function i2c_init()
    i2c.setup(id, sda, scl, i2c.SLOW)
end