Changeset 359 for powerbar


Ignore:
Timestamp:
Jan 31, 2012, 7:33:18 AM (13 years ago)
Author:
Rick van der Zwet
Message:

Add support for npm2000 power bars

Location:
powerbar
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • powerbar/npm2000.py

    r358 r359  
    1919
    2020MAX_BUFFER = 100
    21 MAX_PORTS = 24
     21# NPM4000
     22#MAX_PORTS = 24
     23# NPM2000
     24MAX_PORTS = 8
    2225
    2326# XOR all the 8bit values to get a checksum
     
    7477
    7578def getPortName(number):
    76     name = "U3"
    77     if number <= 8:
    78         name = "A%i" % number
    79     elif number <= 16:
    80         name = "B%i" % (number - 8)
    81     elif number <= 24:
    82         name = "C%i" % (number - 16)
    83     else:
    84         raise ValueError, "Port %i not defined" % number
     79    if MAX_PORTS == 8:
     80       name = "%i" % number
     81    else:
     82      if number <= 8:
     83          name = "%Ai" % number
     84      elif number <= 16:
     85          name = "B%i" % (number - 8)
     86      elif number <= 24:
     87          name = "C%i" % (number - 16)
     88      else:
     89          raise ValueError, "Port %i not defined" % number
    8590    return(name)
    8691
  • powerbar/npm4000.py

    r358 r359  
    1919
    2020MAX_BUFFER = 100
     21# NPM4000
    2122MAX_PORTS = 24
     23# NPM2000
     24# MAX_PORTS = 8
    2225
    2326# XOR all the 8bit values to get a checksum
     
    7477
    7578def getPortName(number):
    76     name = "U3"
    77     if number <= 8:
    78         name = "A%i" % number
    79     elif number <= 16:
    80         name = "B%i" % (number - 8)
    81     elif number <= 24:
    82         name = "C%i" % (number - 16)
    83     else:
    84         raise ValueError, "Port %i not defined" % number
     79    if MAX_PORTS == 8:
     80       name = "%i" % number
     81    else:
     82      if number <= 8:
     83          name = "%Ai" % number
     84      elif number <= 16:
     85          name = "B%i" % (number - 8)
     86      elif number <= 24:
     87          name = "C%i" % (number - 16)
     88      else:
     89          raise ValueError, "Port %i not defined" % number
    8590    return(name)
    8691
Note: See TracChangeset for help on using the changeset viewer.