A maior rede de estudos do Brasil

Grátis
LidarPythonCode

Pré-visualização | Página 6 de 7

callback=fHaltCallback)
####
 GPIO.add_event_detect( iPinInt, GPIO.RISING, callback=f32K)
####
 ## GPIO.add_event_detect( iAlertEmailTimerTrigger, GPIO.FALLING, callback=fEmailAlertAlarm )
 #enable uno to collect and send 
 GPIO.output(iPiReady, GPIO.LOW)
 serialPort.flushOutput()
 serialPort.flushInput()
 except Exception as e:
 print("fSetup " + str(e))
 return;
 
##
 return;
###################################################################################
#
###################################################################################
def fOperatingDisplayOLED():
 ## global iOLED_MinuteCount
 iRowBase = 0
 iRow = iRowBase
 oLock = threading.Lock()
 
 while ( not bIsGPIO_CleanUp):
 font = ImageFont.truetype("FreeMonoBold.ttf", 14, encoding="unic")
 ## font = ImageFont.truetype("code2000.ttf", 8, encoding="unic")
 with oLock:
 try:
 OLEDdevice.clear()
 with canvas( OLEDdevice ) as draw:
 draw.line((0, 32, 90, 32), fill="white")
 ## draw.line((0, 32, 5, 28), fill="white")
# draw.line((0, 32, 45, 1), fill="white")
# draw.line((0, 32, 45, 50), fill="white")
 
 
 for key, value in sorted(oOD.oScans.items(), reverse=True):
 if( oOD.oScans[key] != 0 ):
 ## print( key )
 ## draw.line( (0, iRow, (oOD.oScans[key] / 5), iRow ), fill="white")
 draw.text( ((oOD.oScans[key] / 5), iRow ), ".", font=font, fill="white" )
 iRow += 1
 ## print( "Row %d angle %d dist %d %d" %(iRow, key, oOD.oScans[key],(oOD.oScans[key] / 5) ) )
 finally:
 iRow = iRowBase
 oTriggerOLED.clear()
 ## oAspectChange.set() ## release aspect change
 oTriggerOLED.wait()
 return;
 
def fOperatingDisplayOLED1():
 ## global iOLED_MinuteCount
 iCount = iZero
 oLock = threading.Lock()
 
 while ( not bIsGPIO_CleanUp):
 font = ImageFont.truetype("FreeMonoBold.ttf", 14, encoding="unic")
 ## font = ImageFont.truetype("code2000.ttf", 8, encoding="unic")
 with oLock:
 try:
 with canvas( OLEDdevice ) as draw:
 dt = datetime.datetime.now()
 sM = "%02d:%02d:%02d" %(dt.hour, dt.minute, dt.second)
 draw.text( ( 20, iZero ), sM, font=font, fill="white" )
 sM = "%02d/%02d/%02d" %( dt.month, dt.day, dt.year )
 draw.text( ( 0, 15 ), sM, font=font, fill="white" )
 draw.text( ( 85, 15 ), str(oOD.DistanceLength), font=font, fill="white" )
 if( (iCount == iZero) or (iCount == iOne) ): 
 draw.text( (iZero, 30), oVin.sVoltageMsg, font=font, fill="white" )
 if( (iCount == iTwo) or (iCount == iThree) ):
 draw.text( (iZero, 30), "Run:" + oRT.fDoRunTime(), font=font, fill = iOne )
 elif( (iCount == iFour) or (iCount == iFive) ):
 draw.text( (iZero, 30), oE.sTemperatureC + "C " + oE.sTemperatureF + "F " + oE.sHumidity + "%", font=font, fill=iOne )
 elif( (iCount == iSix) or (iCount == iSeven) ):
 draw.text((iZero, 30), oE.sPressure + " mmHg " + oE.sTrending, font=font, fill=iOne )
 elif( (iCount == 8) or (iCount == 9) ):
 draw.text((iZero, 30), "Alt:" + oE.sAltitude + "m", font=font, fill=iOne )
 elif( (iCount == 10) or (iCount == 11) ):
 draw.text((iZero, 30), "Z:" + str(round(fltScanAspectChange, iTwo)), font=font, fill=iOne )
 ## iTrends[]
 if( len(oE.iTrends) < 2 ):
 draw.line((iZero, 55, 5, 55), fill="white")
 else:
 x = 0
 yBase = 55
 y1 = yBase
 Pbase = oE.iTrends[iZero]
 for i in oE.iTrends:
 ## drawLine(x,y1,x+1,y2,color) ## draw line between previous reading and current
 y2 = yBase - (i - Pbase)
 draw.line((x, y1, x + 1, y2), fill="white")
 y1 = y2; ## Make current reading previous
 x = x + 2
 ## print( "x:" + str(x) + " y:" + str(y) + " len:" + str(len(oE.iTrends)) + " trend;" + str(i) )
 ## draw.line((iZero, 55, 5, 55), fill="white")
## draw.text((0, 0), oVin.sVoltageMsg, fill=1)
## draw.text((0, 0), oVin.sVoltageMsg, fill=1)
 iCount += 1
 if( iCount >= 12 ):
 iCount = iZero
 finally:
 oTriggerOLED.clear()
 oTriggerOLED.wait() 
 return;
###################################################################################
#
###################################################################################
#def fDisplayOLED_Message(sOLED_Message1, sOLED_Message2 =""):
#
# oled.cls()
# oled.canvas.text((0,19), sOLED_Message1, fill=1)
# if (len(sOLED_Message2)):
# oled.canvas.text((0, 29), sOLED_Message2, fill=1)
#
# oled.display()
#
# return;
###################################################################################
# read from rtc eeprom
###################################################################################
class cEEPROM_READ:
 def __init__(self):
 self.EEPROMbus = smbus.SMBus(1)
 self.Device_Address = 0x57
 
 def read_AT24C32_byteSeq(self, EEPROM_Memory_Address ):
 return self.EEPROMbus.read_byte(self.Device_Address);
 
 def set_current_AT24C32_address( self, EEPROM_Memory_Address ):
 a1 = int( EEPROM_Memory_Address/256 )
 a0 = int( EEPROM_Memory_Address % 256 )
 self.EEPROMbus.write_i2c_block_data( self.Device_Address, a1, [a0] )
 return;
## def read_AT24C32_byte( self, EEPROM_Memory_Address ):
## self.set_current_AT24C32_address( EEPROM_Memory_Address )
## return self.EEPROMbus.read_byte( self.Device_Address );
 def fReadEEPROM( self, iStartingAddress, iEndingAddress ):
 sString = ""
 sTemp = b""
 for iX in range( iStartingAddress, iEndingAddress ):
 if ( iX < (iEndingAddress - 1) ):
 sTemp = bytes( [self.read_AT24C32_byteSeq(iX)] )
 sString = sString + sTemp.decode('utf-8')
 return sString;
###################################################################################
#
###################################################################################
def fDoTheThing():
 global bIsGPIO_CleanUp
 global oMP #a must have
 
 try:
####
 oMP = cMP_Tweak(mpQsend, mpQrcv, mpTweakerEvent )
####
 fSetup()
####
 #serial sending thread
 oTriggerSerialSend.clear()#see 32K handler
 procSerialSendQueue = threading.Thread(target = fTh_SendSerial)
 procSerialSendQueue.daemon = True
 procSerialSendQueue.start()
####
 ## oAspectChange.clear()
 procDoAspectChange = threading.Thread(target = fChangeScanAspect)
 procDoAspectChange.daemon = True
 procDoAspectChange.start()
####
 oDoVolt.clear()
 procDoVolts = threading.Thread(target = fMeasureVoltageArduino)
 procDoVolts.daemon = True
 procDoVolts.start()
####

Crie agora seu perfil grátis para visualizar sem restrições.