Exemple #1
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.nextEnabled = False

        title = QLabel("Programming Bootloader")
        switchesLabel = QLabel(
            "Set the MX2+ DIP switches for bootloader programming as shown below.\nThen power-cycle the SmartDrive."
        )
        switchesLabel.setWordWrap(True)
        self.pixMap = QtGui.QPixmap(
            resource.path('images/bootloaderProgramming.jpg'))

        self.progressBar = ProgressBar()
        self.startButton = QPushButton("Start")
        self.startButton.clicked.connect(self.onStart)
        self.startButton.show()
        self.stopButton = QPushButton("Stop")
        self.stopButton.clicked.connect(self.onStop)
        self.stopButton.hide()

        self.labels = [
            title, switchesLabel, self.progressBar, self.startButton,
            self.stopButton
        ]

        self.picture = QLabel(self)
        self.picture.setPixmap(
            self.pixMap.scaled(self.getPictureSize(), Qt.KeepAspectRatio))

        self.layout.addWidget(title)
        self.layout.addWidget(switchesLabel)
        self.layout.addWidget(self.picture)
        self.layout.addWidget(self.progressBar)
        self.layout.addWidget(self.startButton)
        self.layout.addWidget(self.stopButton)
Exemple #2
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.nextEnabled = False

        self.pixMap = QtGui.QPixmap(resource.path('images/runMX2+.jpg'))

        title = QLabel(
            "Set the MX2+ DIP switches for running the firmware as shown below. \nThen power-cycle the SmartDrive."
        )
        title.setWordWrap(True)

        note = QLabel(
            "NOTE: if you need to limit the speed, set DIP 7 OFF. For other configuration settings, please check out the 'Help' menu of this program."
        )
        note.setWordWrap(True)

        self.labels = [title, note]

        self.picture = QLabel(self)
        self.picture.setPixmap(
            self.pixMap.scaled(self.getPictureSize(), Qt.KeepAspectRatio))

        self.layout.addWidget(title)
        self.layout.addWidget(note)
        self.layout.addWidget(self.picture)
Exemple #3
0
def load(name, mm=False):
    mtype="model"
    if mm:
        mtype="mapmodel"

    path=resource.path(mtype, name)
    out=[]
    try:
        f=open(path, "r")
        data=f.read().strip().split("\n")
        f.close()

        faces=[]

        vertices=[]

        texcoords=[]

        for l in data:
            l=l.split(" ")
            if l[0] == "vertex":
                vertices.append([float(x) for x in l[1:]])
            elif l[0] == "texcoord":
                texcoords.append([float(x) for x in l[1:]])
            elif l[0] == "face":
                faces.append([[int(x) for x in l[1:7]], l[7]])

        out=[vertices, texcoords, faces]
    except:
        pass
    return out
Exemple #4
0
def load_image(img):
    if img in surfaces:
        return surfaces[img]
    i=pygame.image.load(resource.path("image", img))
    dat=i, pygame.image.tostring(i, "RGBA")
    surfaces[img]=dat
    return dat
Exemple #5
0
def load(name, mm=False):
    mtype = "model"
    if mm:
        mtype = "mapmodel"

    path = resource.path(mtype, name)
    out = []
    try:
        f = open(path, "r")
        data = f.read().strip().split("\n")
        f.close()

        faces = []

        vertices = []

        texcoords = []

        for l in data:
            l = l.split(" ")
            if l[0] == "vertex":
                vertices.append([float(x) for x in l[1:]])
            elif l[0] == "texcoord":
                texcoords.append([float(x) for x in l[1:]])
            elif l[0] == "face":
                faces.append([[int(x) for x in l[1:7]], l[7]])

        out = [vertices, texcoords, faces]
    except:
        pass
    return out
Exemple #6
0
    def programFirmware(self):
        self.firmwarePercent = 0
        self.status.emit(0, 'Programming SmartDrive Bluetooth')

        # BleUpdate process
        self.isProgramming = True
        self.updateOutput = ''
        self.firmwareProcess = QProcess()
        self.firmwareProcess.errorOccurred.connect(self.processError)
        self.firmwareProcess.readyReadStandardOutput.connect(self.onFirmwareDataReady)
        self.firmwareProcess.readyReadStandardError.connect(self.onFirmwareErrorReady)
        self.firmwareProcess.finished.connect(self.onFirmwareFinished)
        self.stopSignal.connect(self.firmwareProcess.kill)

        program = resource.path(exePath)
        args = [
            "update",
            resource.path(self.fwFileName),
        ]
        self.firmwareProcess.start(program, args)
Exemple #7
0
def load_sound(name):
    global lastchannel

    path = resource.path("sound", name)

    channels[name] = pygame.mixer.Channel(lastchannel)
    lastchannel += 1

    snd = pygame.mixer.Sound(path)

    return snd
Exemple #8
0
def load_sound(name):
    global lastchannel

    path=resource.path("sound", name)
    
    channels[name]=pygame.mixer.Channel(lastchannel)
    lastchannel+=1

    snd=pygame.mixer.Sound(path)
    
    return snd
Exemple #9
0
    def programBootloader(self):
        goodPort, portErr = self.checkPort()
        if not goodPort:
            self.bootloaderFailed.emit(
                "Couldn't open serial port: {}".format(portErr))
            return

        self.isProgramming = True
        self.lpc21ispOutput = ''
        self.bootloaderPercent = 0
        self.bootloaderState = ''
        self.bootloaderStatus.emit(0, '')

        # lpc21isp process
        self.bootloaderProcess = QProcess()
        self.bootloaderProcess.errorOccurred.connect(
            self.processBootloaderError)
        self.bootloaderProcess.readyReadStandardOutput.connect(
            self.onBootloaderDataReady)
        self.bootloaderProcess.readyReadStandardError.connect(
            self.onBootloaderErrorReady)
        self.bootloaderProcess.finished.connect(self.onLPC21ISPFinished)
        self.stopSignal.connect(self.bootloaderProcess.kill)

        program = resource.path('exes/lpc21isp')
        if sys.platform.startswith('win'):
            program += '.exe'
        args = [
            "-wipe",
            resource.path("firmwares/ota-bootloader.hex"),
            self.portName,
            "38400",  # baudrate
            "12000"  # crystal frequency on board
        ]
        if sys.platform.startswith('win'):
            args[2] = "\\\\.\\" + self.portName
        self.bootloaderProcess.start(program, args)
Exemple #10
0
    def getDeviceInfo(self):
        '''Gets the MAC Address and License Key from the Device before proramming'''
        self.resetDeviceInfo()

        # BleUpdate process
        self.isProgramming = True
        self.getOutput = ''
        self.getProcess = QProcess()
        self.getProcess.errorOccurred.connect(self.processError)
        self.getProcess.readyReadStandardOutput.connect(self.onGetDataReady)
        self.getProcess.readyReadStandardError.connect(self.onGetErrorReady)
        self.getProcess.finished.connect(self.onGetFinished)
        self.stopSignal.connect(self.getProcess.kill)

        program = resource.path(exePath)
        args = [
            "get"
        ]
        self.getProcess.start(program, args)
Exemple #11
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)
        self.previousEnabled = False

        self.pixMap = QtGui.QPixmap(resource.path('images/cable.jpg'))

        title = QLabel("Welcome to SmartDrive MX2+ Programming")
        cableLabel = QLabel(
            "Plug in the programming cables to the SmartDrive as shown below.\nMake sure the SmartDrive is OFF.\nRefer to the 'Help' menu for BLE setup instructions."
        )
        cableLabel.setWordWrap(True)
        self.labels = [title, cableLabel]

        self.picture = QLabel(self)
        self.picture.setPixmap(
            self.pixMap.scaled(self.getPictureSize(), Qt.KeepAspectRatio))

        self.layout.addWidget(title)
        self.layout.addWidget(cableLabel)
        self.layout.addWidget(self.picture)
Exemple #12
0
    def start(self):
        '''Determines if there is a valid cc-debugger attached to the system'''
        self.firmwarePercent = 0
        self.status.emit(0, '')
        self.resetDeviceInfo()

        # BleUpdate process
        self.isProgramming = True
        self.listOutput = ''
        self.listProcess = QProcess()
        self.listProcess.errorOccurred.connect(self.processError)
        self.listProcess.readyReadStandardOutput.connect(self.onListDataReady)
        self.listProcess.readyReadStandardError.connect(self.onListErrorReady)
        self.listProcess.finished.connect(self.onListFinished)
        self.stopSignal.connect(self.listProcess.kill)

        program = resource.path(exePath)
        args = [
            "list"
        ]
        self.listProcess.start(program, args)
Exemple #13
0
    def initUI(self):
        QApplication.setStyle(QStyleFactory.create('Cleanlooks'))

        self.setStyleSheet("QLabel {font: 15pt} QPushButton {font: 15pt}")
        self.setWindowTitle('Programmer')

        # Create the actions for the program
        exitAction = Action(resource.path('icons/toolbar/exit.png'), 'Exit Programmer', self)
        exitAction.setShortcut('Ctrl+Q')
        exitAction.setStatusTip('Exit application')
        exitAction.triggered.connect(self.close)

        refreshAction = Action(resource.path('icons/toolbar/refresh.png'), 'Refresh Serial Ports', self)
        refreshAction.setShortcut('Ctrl+R')
        refreshAction.setStatusTip('Refresh Serial Port List')
        refreshAction.triggered.connect(self.refreshPorts)

        openAction = Action(resource.path('icons/toolbar/open.png'), 'Select MX2+ Firmware', self)
        openAction.setStatusTip('Open MX2+ OTA File.')
        openAction.setShortcut('Ctrl+O')
        openAction.triggered.connect(self.onOpenFirmwareFile)

        openBleAction = Action(resource.path('icons/toolbar/open.png'), 'Select BLE Firmware', self)
        openBleAction.setStatusTip('Open BLE Project File.')
        openBleAction.setShortcut('Ctrl+B')
        openBleAction.triggered.connect(self.onOpenBLEProject)

        aboutAction = Action(resource.path('icons/toolbar/about.png'), 'About', self)
        aboutAction.setStatusTip('About MX2+ Programmer')
        aboutAction.triggered.connect(self.about)

        switchInfoAction = Action(resource.path('icons/toolbar/info.png'), 'DIP Switch Info', self)
        switchInfoAction.setStatusTip('MX2+ DIP Switch Info')
        switchInfoAction.triggered.connect(self.showSwitchInfo)

        bleInfoAction = Action(resource.path('icons/toolbar/info.png'), 'BLE Programmer Info', self)
        bleInfoAction.setStatusTip('BLE Programmer Info')
        bleInfoAction.triggered.connect(self.showBLEInfo)

        # Create the widgets for the program (embeddable in the
        # toolbar or elsewhere)
        self.port_selector = QComboBox(self)
        self.refreshPorts()
        self.port_selector.activated[str].connect(self.changePort)

        # Set up the Menus for the program
        self.menubar_init()
        self.menubar_add_menu('&File')
        self.menu_add_action('&File', exitAction)
        self.menu_add_action('&File', refreshAction)
        self.menu_add_action('&File', openAction)
        self.menu_add_action('&File', openBleAction)

        self.menubar_add_menu('&Help')
        self.menu_add_action('&Help', aboutAction)
        self.menu_add_action('&Help', switchInfoAction)
        self.menu_add_action('&Help', bleInfoAction)

        # Set up the toolbars for the program
        self.toolbar_init()
        self.toolbar_create('toolbar1')
        self.toolbar_add_action('toolbar1', exitAction)

        self.toolbar_add_separator('toolbar1')
        self.toolbar_add_action('toolbar1', refreshAction)
        self.toolbar_add_widget('toolbar1', QLabel(' Serial Port: '))
        self.toolbar_add_widget('toolbar1', self.port_selector)

        self.toolbar_add_separator('toolbar1')
        self.toolbar_add_action('toolbar1', openAction)

        self.toolbar_add_widget('toolbar1', QLabel(' MX2+ Version: '))
        self.firmwareLabel = QLabel('<b><i>unknown</i></b>')
        self.toolbar_add_widget('toolbar1', self.firmwareLabel)

        self.toolbar_add_widget('toolbar1', QLabel(' crc: '))
        self.crcLabel = QLabel('<b><i>unknown</i></b>')
        self.toolbar_add_widget('toolbar1', self.crcLabel)

        self.toolbar_add_separator('toolbar1')
        self.toolbar_add_action('toolbar1', openBleAction)
        self.toolbar_add_widget('toolbar1', QLabel(' BLE: '))
        self.bleLabel = QLabel('<b><i>unknown</i></b>')
        self.toolbar_add_widget('toolbar1', self.bleLabel)

        # main UI
        self.startPage = pages.StartPage()
        self.bootloaderPage = pages.BootloaderPage()
        self.firmwarePage = pages.FirmwarePage()
        self.blePage = pages.BLEPage()
        self.endPage = pages.EndPage()

        self.pager = Pager()
        self.pager.addPage(self.startPage)
        self.pager.addPage(self.bootloaderPage)
        self.pager.addPage(self.firmwarePage)
        self.pager.addPage(self.blePage)
        self.pager.addPage(self.endPage)

        # main controls
        '''
        self.scrollArea = QScrollArea(self)
        self.scrollArea.setWidget(self.pager)
        self.scrollArea.setWidgetResizable(True)
        self.setCentralWidget(self.scrollArea)
        '''
        self.setCentralWidget(self.pager)
        self.setGeometry(0, 0, 1200, 1000)
        self.center()
        self.show()
        #self.setFixedSize(self.size())

        # force the user to select OTA file
        self.timer = QTimer()
        self.timer.setSingleShot(True)
        self.timer.timeout.connect(self.onOpenFirmwareFile)
        self.timer.start(500)

        # force the user to select project.bgproj file
        self.timer2 = QTimer()
        self.timer2.setSingleShot(True)
        self.timer2.setInterval(500)
        self.timer2.timeout.connect(self.onOpenBLEProject)
        self.timer.timeout.connect(self.timer2.start)
Exemple #14
0
def load_world(name):
    path=resource.path("map", name)

    f=open(path, "r")

    data=f.read()
    f.close()

    data=data.split("\n")

    entities=[]
    mdls=[]

    for line in data:
        while " \t" in line:
            line=line.replace("\t", " ")
        while "  " in line:
            line=line.replace("  ", " ")

        line=line.replace(" ", "")
        
        line=line.split(",")

        if line == []: continue
        
        if line[0] == "jumppad" and len(line) >= 10:
            line[1]=float(line[1])
            line[2]=float(line[2])
            line[3]=float(line[3])
            line[4]=float(line[4])
            line[5]=float(line[5])
            line[6]=float(line[6])
            line[7]=float(line[7])
            line[8]=float(line[8])
            line[9]=float(line[9])

            entities.append([
                    "jumppad",
                    line[1], line[2], line[3],
                    line[4], line[5], line[6],
                    line[7], line[8], line[9]])
        elif line[0] in ["glasscube", "physcube", "gfxcube", "cube"] and len(line) >= 7:
            line[1]=float(line[1])
            line[2]=float(line[2])
            line[3]=float(line[3])
            line[4]=float(line[4])
            line[5]=float(line[5])
            line[6]=float(line[6])

            tex=None
            scale=0.5
            gfx=True
            phys=True

            if len(line) >= 8:
                try:
                    scale=float(line[7])
                except:
                    tex=line[7]

            if len(line) >= 9:
                tex=line[8]

            name="cube"

            if line[0] == "physcube":
                gfx=False
            elif line[0] == "gfxcube":
                phys=False
            elif line[0] == "glasscube":
                name="glasscube"

            entities.append([name, line[1], line[2], line[3], line[4], line[5], line[6], tex, scale, gfx, phys])
        elif line[0] == "model" and len(line) >= 6:
            line[1]=float(line[1])
            line[2]=float(line[2])
            line[3]=float(line[3])
            line[4]=float(line[4])
            
            mdl=line[5]

            mdls.append([line[1], line[2], line[3], line[4], mdl])

    entities.sort(lambda a, b: cmp(a[0], b[0]))

    return World(entities, mdls)