aniketker / webiopi

Automatically exported from code.google.com/p/webiopi
0 stars 0 forks source link

Easier setting up of multiple (digital) ports via config parameter for complex chips #34

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by andreas....@googlemail.com on 25 Feb 2013 at 11:48

GoogleCodeExporter commented 9 years ago
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]
# setup
1 = IN
2 = OUT 0
3 = OUT 0
4 = OUT 1

[~mygpio]
# reset
1 = IN
2 = IN
3 = IN
4 = OUT 0

[mydac]
0 = 1.0

Original comment by tro...@trouch.com on 25 Feb 2013 at 1:50

GoogleCodeExporter commented 9 years ago
this is even better as it handles the value (re)setting also. maybe pullups can 
be done also this way.

Original comment by andreas....@googlemail.com on 25 Feb 2013 at 2:06

GoogleCodeExporter commented 9 years ago
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

Original comment by tro...@trouch.com on 25 Feb 2013 at 7:51

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 27 Mar 2013 at 11:59

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 28 Mar 2013 at 12:03

GoogleCodeExporter commented 9 years ago

Original comment by tro...@trouch.com on 4 Jan 2014 at 9:01

GoogleCodeExporter commented 9 years ago
Is this issue solved in webiopi-0.7.0?
How do you setup pullups or pulldowns in the config file?

Best regards

Jacques

Original comment by j...@csm-instruments.com on 30 Mar 2014 at 3:36

GoogleCodeExporter commented 9 years ago
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

Original comment by andreas....@googlemail.com on 31 Mar 2014 at 12:15

GoogleCodeExporter commented 9 years ago
Hello, 
I have found a python program which does it, could it be done also in the 
Webiopi config file ?

#1/usr/bin/env python
#sample python code to test digital inputs on Custard Pi 2
#www.sf-innovations.co.uk
#This program sets up pins 7,22,18 & 16
#As inputs with a pull up resistor
#Scans all 4 inputs
#Prints results to screen
#Waits 1 second
#Repeats 10 times
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

Original comment by j...@csm-instruments.com on 1 Apr 2014 at 9:15

GoogleCodeExporter commented 9 years ago
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

Original comment by andreas....@googlemail.com on 1 Apr 2014 at 10:18