brunh Posted January 27, 2017 Posted January 27, 2017 Please tell me what to write in the program, so that it was connected by SPI1? import spidev ... """ An APA102 LED is addressed with SPI. The bits are shifted in one by one, starting with the least significant bit. ... void show() Sends the content of the pixel buffer to the strip. Todo: More than 1024 LEDs requires more than one xfer operation. """ def show(self): self.clockStartFrame() self.spi.xfer2(self.leds) # SPI takes up to 4096 Integers. So we are fine for up to 1024 LEDs. self.clockEndFrame() """ void cleanup() This method should be called at the end of a program in order to release the SPI device """ def cleanup(self): self.spi.close() # ... SPI Port schliessen
martinayotte Posted January 27, 2017 Posted January 27, 2017 You don't show the whole code, usually there is a spidev.open() where arguments describe port number.
brunh Posted January 28, 2017 Author Posted January 28, 2017 if not spidev.open (), then simply paste, how it should look like? for example in the upper or this code: def __init__(self,spd=1000000): spi.openSPI(speed=spd) # GPIO.setmode(GPIO.BOARD) # GPIO.setup(22, GPIO.OUT) # GPIO.output(self.NRSTPD, 1) self.MFRC522_Init() I see!)) I try. class APA102: def __init__(self, numLEDs, globalBrightness = 31, order='rgb'): # The number of LEDs in the Strip self.numLEDs = numLEDs order = order.lower() self.rgb = rgb_map.get(order, rgb_map['rgb']) # LED startframe is three "1" bits, followed by 5 brightness bits self.ledstart = (globalBrightness & 0b00011111) | 0b11100000 # Don't validate, just slash of extra bits self.leds = [self.ledstart,0,0,0] * self.numLEDs # Pixel buffer self.spi = spidev.SpiDev() # Init the SPI device self.spi.open(1, 0) # Open SPI port 1, slave device (CS) 1 self.spi.max_speed_hz=16000000 # Up the speed a bit, so that the LEDs are painted faster 8 000 000 is default
martinayotte Posted January 28, 2017 Posted January 28, 2017 Yes, this is the line to tweak : self.spi.open(1, 0) # Open SPI port 1, slave device (CS) 1 Of couse, your DT or FEX also need to be tweak accordingly.
brunh Posted January 28, 2017 Author Posted January 28, 2017 im redacted fex and change script.bin but ansver: self.spi.open(1, 0) # Open SPI port 1, slave device (CS) 1 IOError: [Errno 2] No such file or directory and: root@orangepipcplus:~# ls /dev/spidev0.0 /dev/spidev0.0 root@orangepipcplus:~# ls /dev/spidev1.0 ls: cannot access /dev/spidev1.0: No such file or directory from FEX: [spi0] spi_used = 1 spi_cs_bitmap = 1 spi_mosi = port:PC00<3><default><default><default> spi_miso = port:PC01<3><default><default><default> spi_sclk = port:PC02<3><default><default><default> spi_cs0 = port:PC03<3><1><default><default> [spi1] spi_used = 1 spi_cs_bitmap = 1 spi_cs0 = port:PA07<2><1><default><default> spi_sclk = port:PA08<2><default><default><default> spi_mosi = port:PA09<2><default><default><default> spi_miso = port:PA10<2><default><default><default> [spi_devices] spi_dev_num = 1 [spi_board0] modalias = "spidev" max_speed_hz = 33000000 bus_num = 0 chip_select = 0 mode = 0 full_duplex = 1 manual_cs = 0
martinayotte Posted January 28, 2017 Posted January 28, 2017 I'm not really fluent with FEX since I'm using Mainline since more than 2 years. But from H3 Datasheet, the SPI1 is using PA13 to PA16 (not PA7 to PA10). Also, the spi_dev_num = 2, since you have now 2 spidev.
brunh Posted January 28, 2017 Author Posted January 28, 2017 I manually changed the ports, because the PA15 is not available. spi_dev_num = 2 the answer is the same: root @ orangepipcplus: ~ # python /root/Software/main2.py Traceback (most recent call last): File "/root/Software/main2.py", line 183, in <module> a = APA102 (ledNumber) #amount of led here File "/root/Software/apa102.py", line 65, in __init__ self.spi.open (1, 0) # Open SPI port 1, slave device (CS) 1 IOError: [Errno 2] No such file or directory
martinayotte Posted January 28, 2017 Posted January 28, 2017 If you look at the H3 datasheet, they can not be move around to any other GPIOs ... Which Orange do you have ? Did you look at the schematic ?
brunh Posted January 29, 2017 Author Posted January 29, 2017 Clear. I thought possible as I want to assign ports. I look for how to deal with GPIO PA15 I have Orangepi One, Lite, PC, PC +, and zero.
martinayotte Posted January 29, 2017 Posted January 29, 2017 Unfortunately, all those boards are not providing easy access to SPI1, they are provding SPI0 instead. Even if PA15 is used for LED_STATUS, it is could probably still be used as SPI1_MOSI, since MOSI is "Master-Out-Slave-In". Of course, this LED maybe will affect speed efficiency, but you can give it a try. Also, you need to make sure that UART3 is disabled, and finally MUTE is the more difficult to access, since it it the PA16 SPI1_MISO, and should not be used as MUTE output anymore.
brunh Posted January 30, 2017 Author Posted January 30, 2017 Thank you, it works! [spi0] spi_used = 1 spi_cs_bitmap = 1 spi_mosi = порт:PC00<3><по умолчанию><по умолчанию><по умолчанию> spi_miso = порт:PC01<3><по умолчанию><по умолчанию><по умолчанию> spi_sclk = порт:PC02<3><по умолчанию><по умолчанию><по умолчанию> spi_cs0 = порт:PC03<3><1><значение по умолчанию><по умолчанию> [spi1] spi_used = 1 spi_cs_bitmap = 1 spi_cs0 = порт:PA13<2><1><значение по умолчанию><по умолчанию> spi_sclk = порт:Почтовый Ð¸Ð½Ð´ÐµÐºÑ pa14<2><значение по умолчанию><по умолчанию><по умолчанию> spi_mosi = порт:PA15<2><значение по умолчанию><по умолчанию><по умолчанию> spi_miso = порт:PA16<2><значение по умолчанию><по умолчанию><по умолчанию> [spi_devices] spi_dev_num = 2 [spi_board0] modalias = "spidev" max_speed_hz = 33000000 bus_num = 0 chip_select = 0 режим = 0 full_duplex = 1 manual_cs = 0 [spi_board1] modalias = "spidev" max_speed_hz = 33000000 bus_num = 1 chip_select = 0 режим = 0 full_duplex = 1 manual_cs = 0 [leds_para] leds_used = 0 may be disable audio0 , there spi_miso [audio0] audio_used = 0
nedoskiv Posted April 17, 2017 Posted April 17, 2017 any success with use second spi, without detach the led and audio?
Recommended Posts