Results 1 to 3 of 3

Thread: Qt5 Raspberry GUI class problem

  1. #1
    Join Date
    May 2021
    Posts
    1
    Qt products
    Qt/Embedded

    Default Qt5 Raspberry GUI class problem

    Hello ,

    i try to make a simple GUI and i have a problem wih lcdNumber Widget.

    In Qdialog class i have no problem to write a digit in lcdNumber, but if i try to call LCD function for write digit to lcdNumber from another class there is a problem
    anyone help me?

    Thanks

    Qt Code:
    1. #importation des library*************************************
    2.  
    3. import sys
    4. from PyQt5.QtCore import pyqtSlot
    5. from PyQt5.QtWidgets import QApplication,QDialog
    6. from PyQt5.uic import loadUi
    7. import RPi.GPIO as GPIO
    8. import threading
    9. import time
    10. from threading import Timer
    11. from PyQt5 import QtCore # inclut QTimer..
    12. import time
    13. from grove.i2c import Bus
    14. from threading import Timer
    15. from PyQt5 import QtTest
    16.  
    17. #Fin de l importation des library*****************************
    18.  
    19. #Configuration ADC************************************************
    20.  
    21. ADC_DEFAULT_IIC_ADDR = 0X04
    22.  
    23. ADC_CHAN_NUM = 8
    24. REG_RAW_DATA_START = 0X10
    25. REG_VOL_START = 0X20
    26. REG_RTO_START = 0X30
    27. REG_SET_ADDR = 0XC0
    28.  
    29. #Fin de configuration ADC***************************************
    30.  
    31. #Configuration des ports GPIO***********************************
    32.  
    33.  
    34. GPIO.setmode(GPIO.BOARD)
    35. GPIO.setwarnings(False)
    36. GPIO.setup(16, GPIO.OUT) #broche 16 en sortie
    37. GPIO.output(16, GPIO.LOW) #Mise a 0 de la pin 16 pour l'init
    38.  
    39.  
    40.  
    41. #Definition des variables***********************************
    42. global SB
    43. SB=0
    44. global SH
    45. SH=0
    46. global coupureF
    47. coupureF="OUI"
    48. global T
    49. T=0
    50. global M
    51. M=10
    52. global count
    53. count=0
    54. #**********************************************************
    55.  
    56. ########INTERFACE-GRAPHIQUE-Qt DESIGNER*********************
    57.  
    58.  
    59. class HMI(QDialog):
    60. def __init__(self):
    61. super(HMI, self).__init__()
    62. loadUi('BAI.ui',self)
    63. self.checkBox.stateChanged.connect(self.Alstom2570) #Programme Alstom -25°C à 70°C valider appel de la fonction Alstom2570
    64. self.spinBox.valueChanged.connect(self.etuve)
    65. self.lcdNumber.display(count)
    66. #stateChanged
    67.  
    68. def LCD(self):
    69. self.lcdNumber.display(count)
    70.  
    71. def Alstom2570(self): #Fonction appele lors de la selection du programme Alstom -25°C à 70°C
    72. #Toutes les variables sont declare et initialise pour correspondre au programme T2
    73. print("case coche")#debug
    74. global SB #definition de la variable SB (temperature seuil bas mise ss tension)
    75. global SH #definition de la variable SH (temperature seuil haut mise ss tension)
    76. SB=600 #variable definissant le seuil de temperature basse (si la temperature etuve descend sous -20°C mise ss tension)-20°C=600mV
    77. SH=3001 #variable definissant le seuil de temperature haute (si la temperature etuve depasse 65°C mise ss tension) 65°C=3001mV
    78. ####on choisis -20 et 65 afin d etre sur que l etuve arrive a ces temperature et quil n'y ai pas doscillation de temperature
    79. ###ayant pour effet des demarrages alleatoirs
    80. global TonF
    81. TonF=15*60000 #Temps ON 15min en ms (mise ss tension) a froid (seuil bas)
    82. global ToffF
    83. ToffF=15*60000 #Temps OFF 15min (mise hors tension) à froid (seuil bas)
    84. global T
    85. #T=-25 #uniquement pour debug ensuite T sera la value par ladc
    86. print("appel programme alstom2570")
    87.  
    88. Alstom2570class() #appel de la fonction permettant de sortir de class interface graphique Qt
    89.  
    90. def etuve(self):
    91. global Netuve
    92. Netuve=(self.spinBox.value())
    93. print(Netuve)
    94.  
    95.  
    96.  
    97.  
    98.  
    99.  
    100.  
    101.  
    102.  
    103. ########FIN DE DECLARATION DE L INTERFACE GRAPHIQUE Qt******
    104.  
    105.  
    106.  
    107. #Declaration et initialisation du convertisseur ADC*********
    108. #def start():
    109. #print("start")##debug !!
    110. class Pi_hat_adc:
    111. def __init__(self,bus_num=1,addr=ADC_DEFAULT_IIC_ADDR):
    112. self.bus=Bus(bus_num)
    113. self.addr=addr
    114. print("adc")
    115.  
    116.  
    117.  
    118. #Fin de l initialisation de l ADC******************************
    119.  
    120. #Declaration de la fonction permettant de lancer la convertion ADC**************************
    121. #Et de choisir le canal a convertir , la variable n *
    122. #represente le canal 1**************************************************************
    123.  
    124. def get_nchan_vol_milli_data(self):
    125. n=0
    126. #print("get_nchan_vol_milli_data")
    127. data=self.bus.read_i2c_block_data(self.addr,REG_VOL_START+n,2)
    128. val =data[1]<<8|data[0]
    129. return val
    130.  
    131. #Fin de la declaration de la fonction de pilotage de l ADC.************************************
    132.  
    133.  
    134. ADC = Pi_hat_adc() #retour a la class pour init adc
    135.  
    136. def ReadTemp():
    137. global T
    138. T=ADC.get_nchan_vol_milli_data() # La variable T correspond a la tension issue du capteur de temp*******
    139. #print(T) #il faudra inserer ici la convertion tension>temperature
    140.  
    141.  
    142.  
    143.  
    144. ###########################################################################################
    145. # PROGRAMME ALSTOM -25°C 70°C #
    146. # #
    147. ###########################################################################################
    148.  
    149. def Alstom2570class():
    150.  
    151. global TonF #variable temps ON froid (15min)
    152. global ToffF #variable temps OFF froid (15min)
    153. global M
    154. global T
    155. T=ADC.get_nchan_vol_milli_data()
    156. print(T) # debug
    157. global count
    158.  
    159. global Netuve #declaration de la variable Netuve permettant de recuperer le N etuve saisie par l utilisateur
    160. #print("Alstom2570class")
    161.  
    162.  
    163. while T > SB: #tant que la temperature n'arrive pas au seuil bas (on commence le T2 par le seuil bas)
    164. T=ADC.get_nchan_vol_milli_data() #(relecture de la temperature)
    165. QtTest.QTest.qWait(10000) #tempo pour ne pas saturer le pi
    166. print(T)
    167. myobjetx = QDialog() #HERE A NEED TO CALL LCD FUNCTION FOR WRITE VARIABLE IN lcdNumber WIDGET
    168. myobjetx.LCD()
    169. print("seuil bas atteind") #execution lorsque lon arrive au seuil bas
    170.  
    171.  
    172.  
    173. #Fin de la fonction ReadTemp permettant de lancer la convertion de l ADC**************************
    174. if __name__ == '__main__':
    175.  
    176.  
    177.  
    178. app=QApplication(sys.argv)
    179. widget=HMI()
    180. widget.show()
    181. sys.exit(app.exec_())
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2021
    Posts
    1
    Qt products
    Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Qt5 Raspberry GUI class problem

    Hi...I did some googling and found that occasionally this blunder seems when endeavoring to run a 32 bit application on 64 bit linux. Running the order "readelf - an arm-linux-gnueabihf-g++" affirmed that this was a 32 bit biniary. A bit really googling and I found that it has to do with the document, and that it can't discover the loader. By getting the 32 bit documents required, I no longer got any blunders.

    In particular, I downloaded ia32-libs from my store yet libc6-i386 may simply get the job done fine.

  3. #3
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,022
    Thanks
    280
    Thanked 818 Times in 807 Posts
    Qt products
    Qt5
    Platforms
    Windows Android

    Default Re: Qt5 Raspberry GUI class problem

    Hi...I did some googling and found that occasionally this blunder seems when endeavoring to run a 32 bit application on 64 bit linux. Running the order "readelf - an arm-linux-gnueabihf-g++" affirmed that this was a 32 bit biniary. A bit really googling and I found that it has to do with the document, and that it can't discover the loader. By getting the 32 bit documents required, I no longer got any blunders.

    In particular, I downloaded ia32-libs from my store yet libc6-i386 may simply get the job done fine.
    This is absolute nonsense and has nothing to do with the original question.

    The OP's problem is that the method Alstom2570class(), which is called from the Alstom2570() member function of the BMI class needs to have an argument of type BMI so it can call BMI methods. In addition, the BMI member function LCD() needs a value argument so that the LCD display can be set from outside the class.

    Qt Code:
    1. class BMI( QDialog ) :
    2. ...
    3. def LCD(self, value ):
    4. self.lcdNumber.display( value )
    5.  
    6.  
    7. def Alstom2570class( bmi ):
    8. global TonF #variable temps ON froid (15min)
    9. global ToffF #variable temps OFF froid (15min)
    10. global M
    11. global T
    12. T=ADC.get_nchan_vol_milli_data()
    13. print(T) # debug
    14. global count
    15.  
    16. global Netuve #declaration de la variable Netuve permettant de recuperer le N etuve saisie par l utilisateur
    17. #print("Alstom2570class")
    18.  
    19.  
    20. while T > SB: #tant que la temperature n'arrive pas au seuil bas (on commence le T2 par le seuil bas)
    21. T=ADC.get_nchan_vol_milli_data() #(relecture de la temperature)
    22. QtTest.QTest.qWait(10000) #tempo pour ne pas saturer le pi
    23. print(T)
    24. bmi.LCD( T ) #HERE A NEED TO CALL LCD FUNCTION FOR WRITE VARIABLE IN lcdNumber WIDGET
    25. print("seuil bas atteind") #execution lorsque lon arrive au seuil bas
    To copy to clipboard, switch view to plain text mode 

    But the structure of the code itself is terrible - global variables everywhere, confusion over what is a class and what is a function ("Alstom2570class" and "Alstom2570"). It looks like the OP just kept adding code, trying to get something to work, and ended up with spaghetti.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QT and SPI on Raspberry PI (include files problem)
    By MrMe in forum Qt Programming
    Replies: 3
    Last Post: 6th July 2018, 12:07
  2. Problem with school project, Raspberry & Bigbelly
    By kohiiro in forum Qt Programming
    Replies: 0
    Last Post: 14th March 2016, 07:40
  3. Raspberry Pi + touchscreen
    By robal in forum Qt for Embedded and Mobile
    Replies: 2
    Last Post: 24th March 2014, 12:08
  4. Raspberry Pi toolchain problem
    By dellboy in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 21st November 2012, 14:43
  5. Replies: 7
    Last Post: 2nd September 2010, 19:42

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.