Skip to content

Commit dc1c796

Browse files
cclaussCloudyPadmal
authored andcommitted
Use print() function in both Python 2 and Python 3 (#82)
1 parent 158c4bf commit dc1c796

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

PSL/SENSORS/Sx1276.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#Registers adapted from sample code for SEMTECH SX1276
2+
from __future__ import print_function
3+
24
import time
35

46
def connect(SPI,frq,**kwargs):
@@ -70,7 +72,7 @@ def __init__(self,SPI,frq,**kwargs):
7072
self.reset()
7173
self.version = self.SPIRead(self.REG_VERSION,1)[0]
7274
if self.version!=0x12:
73-
print 'version error',self.version
75+
print('version error',self.version)
7476
self.sleep()
7577
self.setFrequency(self.frequency)
7678

@@ -110,7 +112,7 @@ def endPacket(self):
110112
while 1: #Wait for TX done
111113
if self.SPIRead(self.REG_IRQ_FLAGS,1)[0] & self.IRQ_TX_DONE_MASK: break
112114
else:
113-
print ('wait...')
115+
print('wait...')
114116
time.sleep(0.1)
115117
self.SPIWrite(self.REG_IRQ_FLAGS,[self.IRQ_TX_DONE_MASK])
116118

@@ -210,19 +212,19 @@ def setTxPower(self,level,pin):
210212
elif level>17:
211213
level = 17
212214
if level==17:
213-
print ('max power output')
215+
print('max power output')
214216
self.SPIWrite(self.REG_PA_DAC,[0x87])
215217
else:
216218
self.SPIWrite(self.REG_PA_DAC,[0x84])
217219
self.SPIWrite(self.REG_PA_CONFIG,[self.PA_BOOST|0x70|(level-2)])
218220

219-
print 'power',hex(self.SPIRead(self.REG_PA_CONFIG)[0])
221+
print('power',hex(self.SPIRead(self.REG_PA_CONFIG)[0]))
220222

221223
def setFrequency(self,frq):
222224
self._frequency = frq
223225
frf = (int(frq)<<19)/32000000
224-
print ('frf',frf)
225-
print ('freq',(frf>>16)&0xFF,(frf>>8)&0xFF,(frf)&0xFF)
226+
print('frf',frf)
227+
print('freq',(frf>>16)&0xFF,(frf>>8)&0xFF,(frf)&0xFF)
226228
self.SPIWrite(self.REG_FRF_MSB,[(frf>>16)&0xFF])
227229
self.SPIWrite(self.REG_FRF_MID,[(frf>>8)&0xFF])
228230
self.SPIWrite(self.REG_FRF_LSB,[frf&0xFF])
@@ -247,7 +249,7 @@ def setSignalBandwidth(self,sbw):
247249
bw = num
248250
break
249251
num+=1
250-
print ('bandwidth: ',bw)
252+
print('bandwidth: ',bw)
251253
self.SPIWrite(self.REG_MODEM_CONFIG_1,[(self.SPIRead(self.REG_MODEM_CONFIG_1)[0]&0x0F)|(bw<<4)])
252254

253255
def setCodingRate4(self,denominator):
@@ -290,7 +292,7 @@ def handleDio0Rise(self):
290292

291293
self.SPIWrite(self.REG_FIFO_ADDR_PTR,self.SPIRead(self.REG_FIFO_RX_CURRENT_ADDR,1))
292294
if self._onReceive:
293-
print self.packetLength
295+
print(self.packetLength)
294296
#self._onReceive(self.packetLength)
295297

296298
self.SPIWrite(self.REG_FIFO_ADDR_PTR,[0])
@@ -319,13 +321,12 @@ def getRaw(self):
319321
lora.beginPacket()
320322
lora.write([cntr])
321323
#lora.write([ord(a) for a in ":"]+[cntr])
322-
print (time.ctime(),[ord(a) for a in ":"]+[cntr], hex(lora.SPIRead(lora.REG_OP_MODE)[0]))
324+
print(time.ctime(),[ord(a) for a in ":"]+[cntr], hex(lora.SPIRead(lora.REG_OP_MODE)[0]))
323325
lora.endPacket()
324326
cntr+=1
325327
if cntr==255:cntr=0
326328
elif mode==RX:
327329
packet_size = lora.parsePacket()
328330
if packet_size:
329-
print 'data',lora.readAll()
330-
print ('Rssi',lora.packetRssi(),lora.packetSnr())
331-
331+
print('data',lora.readAll())
332+
print('Rssi',lora.packetRssi(),lora.packetSnr())

0 commit comments

Comments
 (0)