def updateLabel(self): # Tries self.gotParams every 3 function calls self.paramCounter = self.paramCounter + 1 if self.gotParams is False and self.paramCounter >= 3: self.testParams() self.paramCounter = 0 # Checks if battery_monitor.py is online, if not it sets that voltage to 0 # otherwise ite formats the voltage data into an int to be shown in GUI try: stringMain = str(self.battery_voltage) stringMain = stringMain[5:] numMain = float(stringMain) numMain = int(numMain * 100) numMain = numMain / 100.0 except: if self.warningCounter == 0: print("battery monitor is not online!!") self.warningCounter = 1 numMain = 0.0 self.setColors(numMain) # Turns all the voltages into strings and sets them as text in GUI boxes self.labelMain.setText("{}".format(numMain)) try: numFL = (int(self.voltageFL * 100)) / 100 stringFL = str(numFL) self.labelFL.setText("{}".format(stringFL)) except: pass try: numFR = (int(self.voltageFR * 100)) / 100 stringFR = str(numFR) self.labelFR.setText("{}".format(stringFR)) except: pass try: numBL = (int(self.voltageBL * 100)) / 100 stringBL = str(numBL) self.labelBL.setText("{}".format(stringBL)) except: pass try: stringBR = float("{0:.2f}".format(self.voltageBR)) self.labelBR.setText("{}".format(stringBR)) except: pass QApplication.processEvents()
def updateLabel(self): # Tries self.gotParams every 3 function calls self.paramCounter = self.paramCounter + 1 if self.gotParams is False and self.paramCounter >= 3: self.testParams() self.paramCounter = 0 # Checks if battery_monitor.py is online, if not it sets that voltage to 0 # otherwise ite formats the voltage data into an int to be shown in GUI try: stringMain = str(self.battery_voltage) stringMain = stringMain[5:] numMain = float(stringMain) numMain = int(numMain * 100) numMain = numMain / 100.0 except: if self.warningCounter == 0: print("battery monitor is not online!!") self.warningCounter = 1 numMain = 0.0 self.setColors(numMain) # Turns all the voltages into strings and sets them as text in GUI boxes self.labelMain.setText("{}".format(numMain)) try: numFL = (int(self.voltageFL * 100)) / 100 stringFL = str(numFL) self.labelFL.setText("{}".format(stringFL)) except: pass try: numFR = (int(self.voltageFR * 100)) / 100 stringFR = str(numFR) self.labelFR.setText("{}".format(stringFR)) except: pass try: numBL = (int(self.voltageBL * 100)) / 100 stringBL = str(numBL) self.labelBL.setText("{}".format(stringBL)) except: pass try: stringBR = float("{0:.2f}".format(self.voltageBR)) self.labelBR.setText("{}".format(stringBR)) except: pass QApplication.processEvents()
def update_spectrogram(self): if self.spectrogram is not None: yticks = [ 0, self.highcut_freq / 2 / self.stft_freq - self.lowcut_freq * 2 / self.stft_freq, self.highcut_freq / self.stft_freq - self.lowcut_freq * 2 / self.stft_freq, self.highcut_freq / 2 * 3 / self.stft_freq - self.lowcut_freq * 2 / self.stft_freq, self.highcut_freq * 2 / self.stft_freq - self.lowcut_freq * 2 / self.stft_freq ] yticks_label = [ self.lowcut_freq, self.highcut_freq / 4, self.highcut_freq / 2, self.highcut_freq / 4 * 3, self.highcut_freq ] xticks = [ 0, self.frame_length / 4 - 1, self.frame_length / 2 - 1, self.frame_length * 3 / 4 - 1, self.frame_length - 1 ] xticks_label = [ -self.frame_time * 2, -self.frame_time / 2 * 3, -self.frame_time, -self.frame_time / 2, 0 ] font_size = 13 if self.cnt_fig % 40 == 0: self.ax.clear() #self.im = self.ax.imshow(self.spectrogram[int(self.lowcut_freq*100/self.overlap/self.stft_freq):int(self.highcut_freq*100/self.overlap/self.stft_freq)+1,:,0], aspect="auto", origin="lower", cmap="winter", interpolation='none', vmin=self.v_min, vmax=self.v_max) self.im = self.ax.imshow(self.spectrogram[ int(self.lowcut_freq * 100 / self.overlap / self.stft_freq):int(self.highcut_freq * 100 / self.overlap / self.stft_freq) + 1, :, 0], aspect="auto", origin="lower", cmap="jet", interpolation='none', vmin=12, vmax=16) self.ax.grid(None) self.ax.set_ylabel("Freq. [Hz]", fontsize=font_size, fontname='serif') self.ax.set_yticks(yticks) self.ax.set_yticklabels(["$%.1f$" % y for y in yticks_label], fontsize=font_size) self.ax.set_xticks(xticks) self.ax.set_xticklabels(["$%.1f$" % x for x in xticks_label], fontsize=font_size) self.ax.set_xlabel("Time [s]", fontsize=font_size, fontname='serif') if self.colorbarflag == 0: self.colorbarflag = 1 self.cb = self.fig.colorbar(self.im) elif self.colorbarflag == 1: self.cb.update_bruteforce(self.im) self.canvas.draw() self.cnt_fig += 1 QApplication.processEvents()