Fixed SPI error
This commit is contained in:
parent
0f103cb34d
commit
4f564ca759
2 changed files with 11 additions and 9 deletions
|
@ -33,12 +33,12 @@ class IRSensor(object):
|
|||
raise IndexError("Invalid sensor specified!")
|
||||
|
||||
if sensor == 1:
|
||||
Spi.write(Register.IR_1_LED, on)
|
||||
Spi.write(Register.IR_1_LED, 1, on)
|
||||
elif sensor == 2:
|
||||
Spi.write(Register.IR_2_LED, on)
|
||||
Spi.write(Register.IR_2_LED, 1, on)
|
||||
elif sensor == 3:
|
||||
Spi.write(Register.IR_3_LED, on)
|
||||
Spi.write(Register.IR_3_LED, 1, on)
|
||||
elif sensor == 4:
|
||||
Spi.write(Register.IR_4_LED, on)
|
||||
Spi.write(Register.IR_4_LED, 1, on)
|
||||
elif sensor == 5:
|
||||
Spi.write(Register.IR_5_LED, on)
|
||||
Spi.write(Register.IR_5_LED, 1, on)
|
|
@ -2,8 +2,9 @@ import spidev
|
|||
from threading import Thread, Lock
|
||||
from enum import IntEnum
|
||||
import time
|
||||
import sys
|
||||
|
||||
from compLib.LogstashLogging import logstash_logger
|
||||
from compLib.LogstashLogging import Logging
|
||||
|
||||
SPI_BUS = 1
|
||||
SPI_DEVICE = 2
|
||||
|
@ -100,7 +101,7 @@ class Spi(object):
|
|||
rx_buffer = spi.xfer([0] * 32)
|
||||
|
||||
if rx_buffer[1] != write_reg:
|
||||
logstash_logger.error(f"SPI error during read/write of register {write_reg}!")
|
||||
Logging.get_logger().error(f"SPI error during read/write of register {write_reg}!")
|
||||
|
||||
return rx_buffer
|
||||
|
||||
|
@ -159,8 +160,9 @@ class Spi(object):
|
|||
@staticmethod
|
||||
def health_check():
|
||||
if Spi.read(Register.IDENTIFICATION_MODEL_ID, 1) != 3:
|
||||
logstash_logger.error(f"Unable to read Version! Make sure the mainboard is connected!")
|
||||
quit()
|
||||
Logging.get_logger().error(f"Unable to read Version! Make sure the mainboard is connected!")
|
||||
print("Unable to read Version! Make sure the mainboard is connected!")
|
||||
sys.exit()
|
||||
|
||||
@staticmethod
|
||||
def health_check_loop():
|
||||
|
|
Reference in a new issue