pixels4nickels / webiopi

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

Bug in PiFaceDigital driver preventing use of board parameter via config #112

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The PiFaceDigital driver does not handle the board config parameter correct. It 
fails when providing a value via config file as the conversion from string to 
integer misses.

Proposed solution is:

>>>>>

...
from webiopi.utils.types import toint
...
class PiFaceDigital():
    def __init__(self, board=0):
        self.board = toint(board)
        mcp = MCP23S17(0, 0x20 + self.board)
        mcp.writeRegister(mcp.getAddress(mcp.IODIR, 0), 0x00) # Port A as output
        mcp.writeRegister(mcp.getAddress(mcp.IODIR, 8), 0xFF) # Port B as input
        mcp.writeRegister(mcp.getAddress(mcp.GPPU,  0), 0x00) # Port A PU OFF
        mcp.writeRegister(mcp.getAddress(mcp.GPPU,  8), 0xFF) # Port B PU ON
        self.mcp = mcp

<<<<<

WebIOPi version used?
=> 0.7

Python version used?
=> 2/3

Distro used? (WebIOPi has only been tested on Raspbian Wheezy)
=> Raspbian Wheezy

Raspberry Pi board revision? (1 or 2)
=> n/a

Original issue reported on code.google.com by andreas....@googlemail.com on 20 Aug 2014 at 8:58

GoogleCodeExporter commented 9 years ago
Proposed solution was not correct, this one should work:

...
from webiopi.utils.types import toint
...

class PiFaceDigital():
    def __init__(self, board=0):
        board = toint(board)
        mcp = MCP23S17(0, 0x20 + board)
        mcp.writeRegister(mcp.getAddress(mcp.IODIR, 0), 0x00) # Port A as output
        mcp.writeRegister(mcp.getAddress(mcp.IODIR, 8), 0xFF) # Port B as input
        mcp.writeRegister(mcp.getAddress(mcp.GPPU,  0), 0x00) # Port A PU OFF
        mcp.writeRegister(mcp.getAddress(mcp.GPPU,  8), 0xFF) # Port B PU ON
        self.mcp = mcp
        self.board = board

Original comment by andreas....@googlemail.com on 21 Aug 2014 at 8:06