示例#1
0
def LCD_WriteByte(Data, Command):
    if (Command != 0):
        ControlGPIO.VGI_SetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_DC_PIN)
    else:
        ControlGPIO.VGI_ResetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_DC_PIN)

    ControlSPI.VSI_WriteBytes(ControlSPI.VSI_USBSPI, 0, 0,
                              byref(c_uint8(Data)), 1)
示例#2
0
def procControlGPIO():
    pinId = request.args['pId']          # parse pinID on request parameter
    proc = request.args['proc']          # parse pinOnOff on request parameter
    callback = request.args['callback']  # parse callback string ( jsonp )

    if proc and proc == "on":
        ret = ControlGPIO.pinHigh(pinId)
        return callback + "(" + str(ret) + ")"
    elif proc == "off":
        ret = ControlGPIO.pinLow(pinId)
        return callback + "(" + str(ret) + ")"
示例#3
0
def readControlGPIO():
    uId = request.args['deviceUid']
    pinId = request.args['pinId']          # parse pinID on request parameter
    callback = request.args['callback']  # parse callback string ( jsonp )

    ret = ControlGPIO.pinStatus(uId, pinId)

    return callback + "(" + str(ret) + ")"
示例#4
0
def ConfigAdapter():
    nRet = ControlSPI.VSI_ScanDevice()
    if (nRet <= 0):
        print("No device connect!")
        exit()
    else:
        print(nRet)
    nRet = ControlSPI.VSI_OpenDevice(ControlSPI.VSI_USBSPI, 0, 0)
    if (nRet != ControlSPI.ERR_SUCCESS):
        print("No device connect!")
        print(nRet)
        exit()

    SPI_Init = ControlSPI.VSI_INIT_CONFIG()
    SPI_Init.ClockSpeed = 4500000
    SPI_Init.ControlMode = 1
    SPI_Init.CPHA = 0
    SPI_Init.CPOL = 0
    SPI_Init.LSBFirst = 0
    SPI_Init.MasterMode = 1
    SPI_Init.SelPolarity = 0
    SPI_Init.TranBits = 8
    nRet = ControlSPI.VSI_InitSPI(ControlSPI.VSI_USBSPI, 0, byref(SPI_Init))
    if (nRet != ControlSPI.ERR_SUCCESS):
        print("Initialization device error!")
        exit()
    else:
        print("Initialization device success!")
    #Config RST,DC,BL pin
    nRet = ControlGPIO.VGI_SetOutput(ControlGPIO.VGI_USBGPIO, 0,
                                     LCD_BL_PIN | LCD_DC_PIN | LCD_RST_PIN)
    if (nRet != ControlSPI.ERR_SUCCESS):
        print("Config GPIO error!!")
        exit()
    else:
        print("Config GPIO success!")
示例#5
0
WriteData = (c_byte * 8)()
for i in range(0, len(WriteData)):
    WriteData[i] = i
nRet = ControlI2C.VII_WriteBytes(ControlI2C.VII_USBI2C, 0, 0, 0xA0, 0x08,
                                 byref(WriteData), 8)
if (nRet != ControlI2C.ERR_SUCCESS):
    print("Write data error! %d" % nRet)
    exit()
else:
    print("Write data success!")
# Delay to ensure write complete
sleep(0.1)
# Control GPIO
# Set GPIO_7 and GPIO_8 to output mode
nRet = ControlGPIO.VGI_SetOutput(
    ControlGPIO.VGI_USBGPIO, 0,
    ControlGPIO.VGI_GPIO_PIN7 | ControlGPIO.VGI_GPIO_PIN8)
if (nRet != ControlGPIO.ERR_SUCCESS):
    print("Set pin output error!")
    exit()
else:
    print("Set pin output success!")
# GPIO_7 and GPIO_8 -> high level
nRet = ControlGPIO.VGI_SetOutput(
    ControlGPIO.VGI_USBGPIO, 0,
    ControlGPIO.VGI_GPIO_PIN7 | ControlGPIO.VGI_GPIO_PIN8)
if (nRet != ControlGPIO.ERR_SUCCESS):
    print("Set pin high error!")
    exit()
else:
    print("Set pin high success!")
示例#6
0
Program test environment
Pyhone version:3.4.1
Firmware version:2.7.21
Dependent files(MacOSX):libGinkgo_Driver.dylib,libusb-0.1.4.dylib,libusb-1.0.0.dylib,ControlGPIO.py
Dependent files(Windows):Ginkgo_Driver.dll,ControlGPIO.py
Dependent files(Linux):libGinkgo_Driver.so,libusb-1.0.so,ControlGPIO.py
More Infomation:www.viewtool.com
"""
from ctypes import *
from time import sleep
# import USB-GPIO module
import ControlGPIO

# Scan device(must call one more time)
nRet = c_int(0)
nRet = ControlGPIO.VGI_ScanDevice(1)
if (nRet <= 0):
    print("No device connect!")
    exit()
else:
    print("Connected device number is:" + repr(nRet))

# Open device(must call)
nRet = ControlGPIO.VGI_OpenDevice(ControlGPIO.VGI_USBGPIO, 0, 0)
if (nRet != ControlGPIO.ERR_SUCCESS):
    print("Open device error!")
    exit()
else:
    print("Open device success!")
# Set GPIO_7 and GPIO_8 to output
nRet = ControlGPIO.VGI_SetOutput(
示例#7
0
def LCD_Reset():
    ControlGPIO.VGI_ResetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_RST_PIN)
    sleep(0.01)
    ControlGPIO.VGI_SetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_RST_PIN)
示例#8
0
def LCD_SetBacklightState(state):
    if (state != 0):
        ControlGPIO.VGI_SetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_BL_PIN)
    else:
        ControlGPIO.VGI_ResetPins(ControlGPIO.VGI_USBGPIO, 0, LCD_BL_PIN)