motionEyeOS (PINE A64(+)) 20170611 [Jun 16] | Ubuntu Images (Pinebook) 0.5.5-65 [Jun 15] | Ubuntu Minimal (PINE A64(+)) 0.5.5-65 [Jun 15] | Q4OS (Pinebook) 1805 [Jun 12] | Android 6.0.1 (Pinebook) 20170605 [Jun 5] | Win10 IoT (PINE A64(+)) 10.0.15063.0_20170602 [Jun 5] | FalconGate (PINE A64(+)) 20170430 [May 31] | Q4OS (PINE A64(+)) 1804 [May 30] | Armbian - Ubuntu (SOPINE) 5.27 [May 22]

Getting Started | Visit the WIKI | IRC Logs | Forum Rules/Policy


PADI IoT Dongle used for GPIO Expansion
#11
PADI IoT Dongle Video ( padiD_LED_lab_2 Part II )


padiD_LED_lab.py

Code:
#
# padiD_LED_lab.py  v0.1c  (for padi IoT dongle)
#
# mark h harris
# 11-16-2016
# 03-29-2017
#
# core
#    ser.open()
#    ser.close()
#    ser.isOpen()
#    ser.read(n)
#    ser.write('ATx\r')
#    ser.inWaiting()
#
# extended
#    serfmt(n)        serfmt(ser.inWaiting())
#    serwrt('ATxx')
#    serend()
#
# gpio
#    GC0(isbool)
#    GC1(isbool)
#    GC2(isbool)
#    GC3(isbool)
#    GC4(isbool)
#    GA5(isbool)
#    GC_blink(gc, n, n_time)
#    blinker(n_time)
#
#    Change Log:
#     03-29-2017   added GC4() GA5()
#
import serial as SER
import time as TM

ser = SER.Serial (
   port='/dev/ttyUSB0',
#   baudrate=115200,
   baudrate=38400,
   parity=SER.PARITY_NONE,
   stopbits=SER.STOPBITS_ONE,
   bytesize=SER.EIGHTBITS
)

def serfmt(n):
   outp=''
   for i in range(n):
       inp=ser.read(1)
       if inp!='\r' and inp!='\n':
           outp+=inp
       if inp=='\r':
           a=1
       if inp=='\n':
           print(outp)
           outp=''

def serwrt(datastr):
   return ser.write(datastr + '\r')

def GC0(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_0,'+onoff+',1')

def GC1(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_1,'+onoff+',1')

def GC2(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_2,'+onoff+',1')

def GC3(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_3,'+onoff+',1')

def GC4(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_4,'+onoff+',1')

def GA5(isbool):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PA_5,'+onoff+',1')

def GC_blink(gc, n, n_time):
   for i in range(n):
       gc(True)
       TM.sleep(n_time)
       outnull = ser.read(ser.inWaiting())
       gc(False)
       TM.sleep(n_time)
       outnull = ser.read(ser.inWaiting())

def blinker(n_time):
   kybInt=False
   cycleCount=0
   startTime=TM.time()
   while not kybInt:
       try:
           GC_blink(GC0, 1, n_time)
           GC_blink(GC1, 1, n_time)
           GC_blink(GC2, 1, n_time)
           GC_blink(GC3, 1, n_time)
           GC_blink(GC4, 1, n_time)
           GC_blink(GA5, 1, n_time)
           TM.sleep(.125)
           outnull = ser.read(ser.inWaiting())
           GC_blink(GA5, 1, n_time)
           GC_blink(GC4, 1, n_time)
           GC_blink(GC3, 1, n_time)
           GC_blink(GC2, 1, n_time)
           GC_blink(GC1, 1, n_time)
           GC_blink(GC0, 1, n_time)
           TM.sleep(.125)
           outnull = ser.read(ser.inWaiting())
           cycleCount+=1
       except KeyboardInterrupt:
           TM.sleep(.225)
           outnull = ser.read(ser.inWaiting())
           mins_time=(TM.time()-startTime)/60.0
           cpm_freq=cycleCount/mins_time
           GA5(False)
           TM.sleep(.125)
           GC4(False)
           TM.sleep(.125)
           GC3(False)
           TM.sleep(.125)
           GC2(False)
           TM.sleep(.125)
           GC1(False)
           TM.sleep(.125)
           GC0(False)
           TM.sleep(.125)
           outnull = ser.read(ser.inWaiting())
           print('\n\nCycle Count: '+str(cycleCount)+'\n')
           print('\ntime: '+str(mins_time)+' mins.\n')
           print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
           print('\nfreq: '+str(cpm_freq)+' cpm.\n')
           print('\nblinker successfully terminated via interrupt\n')
           TM.sleep(.225)
           ser.close()
           kybInt=True

def serend():
   ser.close()
   quit()

ssendsig.sh

Code:
#!/bin/bash
echo
PROCPID=$(ps ax |grep -i $1 |grep -v grep |grep -v sudo |grep -v ssendsig |awk '{print $1}' )
echo "PID: $PROCPID"
if [ "$PROCPID" != "" ]
 then
   if [[ "$2" != "HUP" && "$2" != "INT" && "$2" != "USR1" && "$2" != "USR2" ]]
     then
       echo "Error: valid signals are HUP INT USR1 USR2"
     else
       exec kill -SIG$2 $PROCPID
   fi
 else
   echo $1 "does not appear to be running"
fi

padiD_ablink.sh

Code:
#!/usr/bin/python
from padiD_LED_lab import *
#blinker(.038)
#blinker(.077)
blinker(0.125)


Notes:
1)  to run padiD_ablink.sh     sudo  -b  ./padiD_ablink.sh
2)  to stop by sending SIGINT     sudo  ~/bin/ssendsig.sh  padiD_ablink  INT
3)  be sure to have the padiD_ablink.sh code, and the padiD_LED_lab.py codes in current directory
4)  place the ssendsig.sh  code in your bin foler
I modified the PADI IoT Dongle by replacing the R11 resistor ( I2C1 port ) with a zero ohm shunt.  This allows six(6) gpio lines access via ATSG command.   See video link above.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#12
the LEDs & padi COM lights continue to blink after INT is sent. what does INT stop?
Reply
#13
(03-31-2017, 12:35 AM)dkryder Wrote: the LEDs & padi COM lights continue to blink after INT is sent. what does INT stop?

In the demo clip I simply restarted it right away;  sending SIGINT to a background process is just like pressing the keyboard interrupt ctrl-c ( ^c ) in the foreground-- and the Python codes catch the interrupt. If the interrupt has been coded for properly then the process can do normal cleanup processing and end gracefully, in this case close the serial port and print the process stats.

As a side note, not just any process can send the SIGINT !  It must be an authorized process, or the parent process. So, if you plan to end processes with SIGINT, you need to keep the parent process ( starting terminal session ) active !  The reason for the script ssendsig.sh is that the process number might be anything.  The script determines the process number from the process name ,  then sends SIGINT to the process number.

For the demo clip I just wanted to show the actual commands at the command line, and the termination stats on cleanup. Yes,  the I|O comm lights stop blinking when the AT command stream stops.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#14
   

The binary display debugger, with 74HC595 shift register in the foreground, is complete this weekend. With the IC popped out it can still be used as a parallel display for individual GPIO lines;  yet with the IC I was able to successfully expand the padi(s) three line control interface (serial) to eight gpio lines output as latched parallel bi-directional port. 

I will be posting the codes for this experiment, along with a rather involved demo video, that will highlight the padi stamp IoT dongle, as well be instructive for anyone interested in using the 74HC595 8bit serial to parallel interface in future projects;  its a standard.  The purpose of this post is to provide an update on continuing evaluation of the padi stamp, and to highlight the positives and the negatives while they are still fresh.

This particular padi is an older version of the firmware|software ;  so it has some inherent "bugs" if you will that have been pesky.  One is that the baud rate is locked in at 38400;  which means that the AT command stream runs slowly.  The second bug that I found is a little more severe, especially with the shift register control I'm attempting here ;  particularly as it pertains to clocking.  Setting a GPIO line "high" on the padi ( low-to-high transition ) has one of two issues: 1) it either 'rings' ,  or 2) it actually produces two(2) leading edge transitions for the single transaction.  In any case, the lines are entirely unsuitable for clock pulses out-of-box.

I got around the problem with the small red board in the center of the pic above. The savior chip is the LS7400N quad two input positive nand gate.  I have the top two gates cross wired to form an SR flip flop (set reset flip flop). This SR cleans up the signal from the padi giving the shift register a very nice clean leading edge for the SHCP. The STCP is not critical , sense I'm using the STCP as a final register to latch transaction, it only needs to happen once so all is good there. You can read more about SR(s) here.

The circuit in the pic above is essentially this one.  I am using the padi stamp to control all of the 74HC595 control lines including OE (output enable), SHCP (shift clock pulse), STCP (storage clock pulse), Data-in serial, MR (master reset), and of course the eight parallel output lines (with bi-directional port seen in the foreground). Also visible in the foreground right is a hard-wired switch that I can use to ground out the MR pullup resistor (which manually resets the register portion of the 74HC595).  I have also included a bi-directional level shifter to handle the voltage mismatch between the 74HC595 and the padi stamp IoT dongle.  I want to drive the leds with 5v as well allow 5v inputs on the parallel expansion port (foreground).

This expansion setup is one of the simpler serial-parallel setups and applies to the PineA64, the Raspberry PI, as well the various MCU(s) avaiable including the PADI IoT Dongle, and eventually the PADuino.

The really good news about the RTL8710 ( and successor modules ) is the ability to flash the firmware|software . The padi is less about its hardware (frankly speaking) and more about its software !  In subsequent blogs I will examine and evaluate the flashing process, and the padi sdk.

Ok, next time I'll have a video and some serial-parallel codes to share !


Notes:  the lines coming into the display board from left to right are:  yellow serial-data, orange OE, black ground, white 3v3 Lv, brown STCP, and violet SHCP.   The switch is the master reset;  also requires STCP.  The red wire in the foreground is the VDD 5v from the padi for HV on the four channel level shifter.
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply
#15
   

This is a close-in of the PADI IoT Dongle breakout.  Electrically it is not much different than the normal padi breakout board;  the exception is that the I|O pinouts are grouped (arduino style; female headers) in the logical groupings by port type;  SPI, I2C, and ADC .  In order to make use of the ADC ports, the optional card must be installed ( missing from this pic ).

   

The pic above is my current test setup ( codes posted below ).  In order from left to right;  the padi, the clocks ( shcp, stcp ) SR flip-flops,  the 74HC595 shift register binary display board, and the relay emulator SR flip-flops and 7404 inverter drivers board. 

The python codes posted below, and the 74HC595 shift register board, are being used to latch eight(8) parallel bits (with indicator LEDs) to the port on the front edge of the card. Those eight expanded gpio lines are then used to drive the relay emulator indicator board (comprised of 7404 inverter drivers, and nand SR latches). The first two boards have 3v3 logic, and the last two boards are 5v boards.  The codes are posted at the bottom.

The pic below is the back side of the 74HC595 shift register serial-paralle binary display board, just for fun.  The board is a 5 layer board soldered up in 3d Manhattan style. I tend to use color coding to keep things straight. 

   

Code:
#
# padiD_LED_lab_SR.py  v0.2d  (for padi IoT dongle)
#                             (new relay driver   )
#
# mark h harris
# 03-31-2016
# 04-05-2017
#
# core
#    ser.open()
#    ser.close()
#    ser.isOpen()
#    ser.read(n)
#    ser.write('ATx\r')
#    ser.inWaiting()
#
# extended
#    serfmt(n)        serfmt(ser.inWaiting())
#    serwrt('ATxx')
#    serend()
#
# shift register  74HC595
#    flushit()  read buffer from the padi; padi IoT dongle is verbose (bug)
#    D(isbool, tm) used by binary() to set the data serial input internally
#    oe(isbool) OE  output enable;  also CE  chip enable
#    shcp(tm) Shift Clock Pulse  74HC595 pin(11)
#    stcp(tm) Storage Clock Pulse 74HC595 pin(12) latch register to output
#    raw_cp(tm)  clock pulse used by binary internally;
#    cp(tm)  manual clock pulse for use on the terminal REPL
#    binary_inv(n, mode=1) mode=2 slow cycle;  mode=1 stcp;  mode=0 no stcp
#    binary(n, mode=1) mode=2 slow cycle;  mode=1 stcp;  mode=0 no stcp
#    HEXout(value, inv=0, mode=1)  manual use, uses binary()
#    oclock(inv)  inv= 1 inverted;  inv=0 standard
#    toggle()
#    all_LED(n)  n= 0|1
#    Q({Qnums}, inv=0, mode)  {Qnums}={q:n,q:n,...};  n= 0|1;  mode=see above
#    show()  binary internals on the manual console  REPL
#    set_Data(n)    n serialIn= 1 | 0
#
# Relays & Utilities
#    relays(rlys)   rlys={'A':n, 'B':n}; n= 1|0
#    walk(n)    n= 1|0
#    lamp_test(n)  n=1 binary;  n=2 relays
#
# Change Log:
#     03-31-2017   added shift register coding
#     04-03-2017   added Q_out coding
#     04-03-2017   added relay coding
#     04-05-2017   added HEXout coding
#     04-05-2017   cleaned up minor bugs and typos
#
import serial as SER
import time as TM

# Constants and common variables
tm = 0.038         # universal timing constant  ms
Q_out = 0x00       # virtual shift register
P_out = 0x00       # virtual pending shift register
serialIn = 0       # manual serial data input : used with cp(tm)
OEline = 0         # Output Enable line : CE chip enable

# Virtual bit configuration dictionaries
Qp = {"Q0":0x01, "Q1":0x02, "Q2":0x04, "Q3":0x08, "Q4":0x10, "Q5":0x20, "Q6":0x40, "Q7":0x80}
Qn = {"Q0":0xfe, "Q1":0xfd, "Q2":0xfb, "Q3":0xf7, "Q4":0xef, "Q5":0xdf, "Q6":0xbf, "Q7":0x7f}
Qp_inv = {"Q0":0x80, "Q1":0x40, "Q2":0x20, "Q3":0x10, "Q4":0x08, "Q5":0x04, "Q6":0x02, "Q7":0x01}
Qn_inv = {"Q0":0x7f, "Q1":0xbf, "Q2":0xdf, "Q3":0xef, "Q4":0xf7, "Q5":0xfb, "Q6":0xfd, "Q7":0xfe}

# serial comm channel : padi IoT dongle only works at 38400 (bug)
ser = SER.Serial (
   port='/dev/ttyUSB0',
#   baudrate=115200,
   baudrate=38400,
   parity=SER.PARITY_NONE,
   stopbits=SER.STOPBITS_ONE,
   bytesize=SER.EIGHTBITS
)

# Extended comms routines
def serfmt(n):
   outp=''
   for i in range(n):
       inp=ser.read(1)
       if inp!='\r' and inp!='\n':
           outp+=inp
       if inp=='\r':
           a=1
       if inp=='\n':
           print(outp)
           outp=''

def serwrt(datastr):
   return ser.write(datastr + '\r')

## Shift register routines
#  flush the read buffer from the padi;  padi IoT dongle is verbose (bug)
def flushit(n_time):
   while(ser.inWaiting()>0):
       outnull = ser.read(ser.inWaiting())
       TM.sleep(n_time)

#  used by binary()  to set the data serial input internally
#     con't call manually;  use set_Data(n)
def D(isbool, n_time):
   if isbool:
       onoff='1'
   else:
       onoff='0'
   wrtlen = serwrt('ATSG=W,PC_2,'+onoff+',1')
   TM.sleep(n_time)

#  OE  output enable;  also CE  chip enable
def oe(isbool):
   global OEline
   if isbool:
       onoff='1'
       OEline = 1    # outputs high-Z  disabled
   else:
       onoff='0'
       OEline = 0    # outputs enabled;  chip enabled
   wrtlen = serwrt('ATSG=W,PC_0,'+onoff+',1')
   TM.sleep(tm)

#  Shift Clock Pulse    74HC595 pin(11)
def shcp(n_time):
   wrtlen = serwrt('ATSG=W,PC_3,0,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_3,1,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_4,0,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_4,1,1')
   TM.sleep(n_time)

#  Storage Clock Pulse    74HC595 pin(12) ; latches register to outputs
def stcp(n_time):
   global Q_out
   Q_out = P_out
   wrtlen = serwrt('ATSG=W,PC_1,0,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_1,1,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_4,0,1')
   TM.sleep(n_time)
   wrtlen = serwrt('ATSG=W,PC_4,1,1')
   TM.sleep(n_time)
   flushit(n_time)
 
#  clock pulse used by binary internally;
#     don't call manually,  use cp(tm)
def raw_cp(n_time):
   shcp(n_time)
   stcp(n_time)

#  manual clock pulse for use on the terminal REPL
#     keeps track of the virtual shift register also...
def cp(n_time):
   global P_out
   D(serialIn, n_time)
   # shift bits 7,6,5 -> 6,5,4
   for i in range(5,8,1):
       Qb='Q'+str(i)
       Pb='Q'+str(i-1)
       bit = (Q_out & Qp[Qb])
       if (bit!=0):
           P_out = (P_out | Qp[Pb])
       else:
           P_out = (P_out & Qn[Pb])
   # shift bits 0 -> 7
   bit = (Q_out & Qp["Q0"])
   if (bit!=0):
       P_out = (P_out | Qp["Q7"])
   else:
       P_out = (P_out & Qn["Q7"])
   # shift bits 3,2,1 -> 2,1,0
   for i in range(1,4,1):
       Qb='Q'+str(i)
       Pb='Q'+str(i-1)
       bit = (Q_out & Qp[Qb])
       if (bit!=0):
           P_out = (P_out | Qp[Pb])
       else:
           P_out = (P_out & Qn[Pb])
   # set bit 3
   if (serialIn==1):
       P_out = (P_out | Qp["Q3"])
   else:
       P_out = (P_out & Qn["Q3"])
   shcp(n_time)
   stcp(n_time)

#  display value n "inverted"
#    used internally
def binary_inv(n, mode=1):
   global P_out
   P_out = n
   m=8
   for i in range(1,5,1):
       if (m & n >0):
           D(1, tm)
       else:
           D(0, tm)
       if (mode==2):
           raw_cp(tm)
       else:
           shcp(tm)
       m/=2
   m=128
   for i in range(1,5,1):
       if (m & n >0):
           D(1, tm)
       else:
           D(0, tm)
       if (mode==2):
           raw_cp(tm)
       else:
           shcp(tm)
       m/=2
   if (mode==1):
       stcp(tm)

#  display value n  standard   non-inverted
#    used internally
def binary(n, mode=1):
   global P_out
   P_out = n
   m=16
   for i in range(1,5,1):
       if (m & n >0):
           D(1, tm)
       else:
           D(0, tm)
       if (mode==2):
           raw_cp(tm)
       else:
           shcp(tm)
       m*=2
   m=1
   for i in range(1,5,1):
       if (m & n >0):
           D(1, tm)
       else:
           D(0, tm)
       if (mode==2):
           raw_cp(tm)
       else:
           shcp(tm)
       m*=2
   if (mode==1):
       stcp(tm)

#  hex serial to parallel output
def HEXout(value, inv=0, mode=1):
   if (inv==1):
       binary_inv(value, mode)
   else:
       binary(value, mode)

#  Binary Clock binary demo
#     not very accurate binary clock light pattern demo
def oclock(inv):
   kybInt=False
   cycleCount=0
   clock=1
   startTime=TM.time()
   while not kybInt:
       try:
           if (inv==1):
               binary_inv(clock, 1)
           else:
               binary(clock, 1)
           cycleCount+=1
           if (clock<255):
               clock+=1
           else:
               clock=1
       except KeyboardInterrupt:
           TM.sleep(.225)
           all_LED(0)
           mins_time=(TM.time()-startTime)/60.0
           cpm_freq=cycleCount/mins_time
           outnull = ser.read(ser.inWaiting())
           print('\n\nCycle Count: '+str(cycleCount)+'\n')
           print('\ntime: '+str(mins_time)+' mins.\n')
           print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
           print('\nfreq: '+str(cpm_freq)+' cpm.\n')
           print('\nblinker successfully terminated via interrupt\n')
           TM.sleep(.225)
           ser.close()
           kybInt=True

#  Toggle a set of light patterns
#      light pattern demo
def toggle():
   kybInt=False
   cycleCount=0
   startTime=TM.time()
   while not kybInt:
       try:
           for n in range(3):
               binary(0xbd, 1)
               binary(0x66, 1)
               binary(0xdb, 1)
               binary(0x66, 1)
           binary(0x00, 1)
           for n in range(3):
               binary(0xa5, 1)
               binary(0x5a, 1)
           binary(0x00, 1)
           for n in range(3):
               binary(0x69, 1)
               binary(0x96, 1)
           binary(0x00, 1)
           for n in range(3):
               binary(0xaa, 1)
               binary(0x55, 1)
           binary(0x00, 1)
           cycleCount+=1
       except KeyboardInterrupt:
           TM.sleep(.225)
           all_LED(0)
           mins_time=(TM.time()-startTime)/60.0
           cpm_freq=cycleCount/mins_time
           outnull = ser.read(ser.inWaiting())
           print('\n\nCycle Count: '+str(cycleCount)+'\n')
           print('\ntime: '+str(mins_time)+' mins.\n')
           print('\ntime: '+str(mins_time/60.0)+' hrs.\n')
           print('\nfreq: '+str(cpm_freq)+' cpm.\n')
           print('\nblinker successfully terminated via interrupt\n')
           TM.sleep(.225)
           ser.close()
           kybInt=True

#  Set ALL LED(s) ON|OFF  n = 1|0
def all_LED(n):
   global P_out
   if (n==1):
       P_out = 0xff
   else:
       P_out = 0x00
   D(n, tm)
   for i in range(8):
       shcp(tm)
   stcp(tm)

#  Set Q0-Q7 Qnums= {q:n, q:n, ... } n= 1|0; inv= 0|1; mode= 0, 1, 2
def Q(Qnums, inv=0, mode=1):
   Qout = Q_out
   if (Qout != P_out):
       return "error:  pending operation; use  stcp(tm) first"
   for Qnum in Qnums:
       n = Qnums[Qnum]
       Qin = 'Q' + str(Qnum)
       if (n==1):
           Qout = Qout | Qp[Qin]
       else:
           Qout = Qout & Qn[Qin]
   if (inv==1):
       binary_inv(Qout, mode)
   else:
       binary(Qout, mode)

#  show binary internals on the manual console  REPL
def show():
   print "Q_out : ", hex(Q_out)
   print "P_out : ", hex(P_out)
   print "Data  : ", hex(serialIn)
   print "OE    : ", hex(OEline)

#  manually set the serial data input for  cp(tm)
def set_Data(n):
   global serialIn
   serialIn = n

## Relays output control
#  set any relays ON|OFF n= 1|0  rlys={'A':n, 'B':n}
def relays(rlys):
   Qout = Q_out
   for rly in rlys:
       n = rlys[rly]
       if (rly=='A'):
           if (n==1):
               Qout = Qout | Qp['Q5']
               Qout = Qout & Qn['Q4']
           else:
               Qout = Qout | Qp['Q4']
               Qout = Qout & Qn['Q5']
       if (rly=='B'):
           if (n==1):
               Qout = Qout | Qp['Q1']
               Qout = Qout & Qn['Q0']
           else:
               Qout = Qout | Qp['Q0']
               Qout = Qout & Qn['Q1']
   binary(Qout, 1)
   Q({5:0,4:0,1:0,0:0}, 1)


#  lamp test all LED(s)
#     n= 1 binary;  n= 2 relays;
def lamp_test(n):
   if (n==1):
       all_LED(1)
       all_LED(0)
   if (n==2):
       relays({'A':1,'B':1})
       relays({'A':0,'B':0})

#  walk either n= 1|0  through the register
def walk(n):
   if (n==1):
       m=0
   else:
       m=1
   set_Data(n)
   cp(tm)
   set_Data(m)
   for i in range(8):
       cp(tm)

#  manually exit the REPL, turn off LED(s), close the serial comms port
def serend():
   HEXout(0xdd)
   HEXout(0x0)
   ser.close()
   quit()

#  Set initial conditions;  Power On Reset  
oe(0)
D(0, tm)
shcp(tm)
stcp(tm)
lamp_test(1)
walk(1)
marcushh777    Cool

please join us for a chat @  irc.pine64.xyz:6667   or ssl  irc.pine64.xyz:6697

( I regret that I am not able to respond to personal messages;  let's meet on irc! )
Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
  Padi Stamp LED pcb symbol is incorrect dkryder 4 438 03-11-2017, 11:02 PM
Last Post: pfeerick
  Padi Stamp v2.2.1, v3.5 (2016/10/08-16:57:18) MarkHaysHarris777 62 6,344 03-11-2017, 01:09 AM
Last Post: MarkHaysHarris777
  Several PADI connected to Pine via Wifi Traveler 3 631 02-07-2017, 07:10 AM
Last Post: MarkHaysHarris777
  broadcasting with padi stamp ? Grag38 2 332 01-31-2017, 08:23 AM
Last Post: Grag38
  PADI IoT Stamp is starting to get noticed... pfeerick 12 1,796 12-15-2016, 10:42 AM
Last Post: tllim

Forum Jump:


Users browsing this thread: 1 Guest(s)