Posted by andreas.riegg
When using e.g. digital I/O port IC's in many cases its necessary so set them up as input or output. Moreover, in some cases they may also provide the possibility to enable pull-ups or pull-downs. This setting-up can be done in custom macros with python api calls, but it would be much simpler to provide this as config option. For GPIOS there is already the option in config.
A parameter scheme for e.g. setting up 8 digital IO's could just be
IIOOIOB_
where I = Input, O = Output, B = Bidirectional (like PCF8574), _ = default
For Pullup resistors this could be
UUUNDD_N
where U = Pullup enabled, D = Pulldown enabled, N = No pullup, _ = default again
As this options need some parsing this will be a little bit more effort to implement.
Posted by trouch
I thought this one and I would like to reuse the GPIO setup/reset notation and generalize it to other kind device.
Assume we have : [DEVICES] mygpio = MCP23017 mydac = MCP4921
then we could have : [mygpio]
1 = IN 2 = OUT 0 3 = OUT 0 4 = OUT 1
[~mygpio]
1 = IN 2 = IN 3 = IN 4 = OUT 0
[mydac] 0 = 1.0
Posted by andreas.riegg
this is even better as it handles the value (re)setting also. maybe pullups can be done also this way.
Posted by trouch
I think I will add this after the next release as we can init devices using custom scripts and deviceInstance(name) Python function. But I moved device init before script loading or the device will be not found in script setup(). I also imported deviceInstance in root package, to help calling it using webiopi.deviceInstance see r977
Posted by trouch
Posted by trouch
Posted by trouch
Posted by jfr@csm-instruments.com
Is this issue solved in webiopi-0.7.0? How do you setup pullups or pulldowns in the config file?
Best regards
Jacques
Posted by andreas.riegg
No, 0.7.0 makes no updates here.
Pullups/downs can be set for GPIOs, but I don't know exactly how, there was some answer in the support group how to do that some days/weeks ago, please use the search function of the group to find it.
Best
Andreas
Posted by jfr@csm-instruments.com
Hello, I have found a python program which does it, could it be done also in the Webiopi config file ?
import RPi.GPIO as GPIO import time GPIO.setmode(GPIO.BOARD)
GPIO.setup(7, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(22, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP) GPIO.setup(16, GPIO.IN, pull_up_down=GPIO.PUD_UP)
Best regards
Jacques
Posted by andreas.riegg
Sorry, no WebIOPi has been implemented to be NOT dependent on other packages or components.
The code you show uses the RPi.GPIO package which is NOT part of WebIOPi. Both can't be used together as their functionality overlaps partly.
However, the calls you show above can (almost identical) be put into a WebIOPi custom script in the setup() section (thus overlaps). The idea is to avoid this and allow such settings with WebIIOPi config file entries.
But, as I mentioned, this is still tbd.
Andreas