Error: in file macro line 44 column 35: M260: array too long
-
Is there a fixed maximum array size to send to M260? I think mine had 33 elements, which doesn't seem like a lot.
; Changes NeoPixel LED Color Values ; Manage parameters and defaults var I2CAddress = 0x60 var Red = 255 var Green = 255 var Blue = 255 var StartLEDNum = 0 var LEDCount = 10 if exists(param.A) set var.I2CAddress = param.A if exists(param.R) set var.Red = param.R if exists(param.U) set var.Green = param.U if exists(param.B) set var.Blue = param.B if exists(param.S) set var.StartLEDNum = param.S if exists(param.N) set var.LEDCount = param.N ; Set up bytes to send var Bytes = vector(3 + 3 * var.LEDCount, null) set var.Bytes[0] = 0x0E ; NeoPixels Base Address on seesaw set var.Bytes[1] = 0x04 ; BUF Function Register of seesaw NeoPixels feature set var.Bytes[2] = 3 * var.StartLEDNum ; Start Address Within seesaw NeoPixels Buffer var BlueIndex = 0 ; Data in BGR order while iterations < var.LEDCount set var.BlueIndex = 3 + 3 * iterations set var.Bytes[{var.BlueIndex}] = var.Blue set var.Bytes[{var.BlueIndex + 1}] = var.Green set var.Bytes[{var.BlueIndex + 2}] = var.Red ; Send the bytes M260 A{var.I2CAddress} B{var.Bytes}
-
@DonStauffer the maximum number of I2C bytes that can be sent and/or received by RRF in a single transaction is 32. I could increase this value somewhat - how much do you need?
-
@dc42 The NeoDriver can't handle more than 32 bytes anyway, I discovered. I really just wanted to gain knowledge rather than request a change. So I'm good now.
-
-
-
@dc42 I wish I had known at the time to say "Yes, I could use 34 bytes".
The NeoDriver lets you send blocks of 30 bytes of data, but with 4 bytes of overhead in the form of some address info internal to the NeoDriver. So I could really use 34 bytes on M260, if that's possible.
-
@DonStauffer I will look at increase it to to 34 in the 3.5.2 release.
-
@dc42 The new RRF version lets me send 31 bytes, but for some reason, sending 34 bytes gives "Error: I2C transmission error". What's interesting is this is usually a fatal error, in that to get the NeoDriver working again requires a power cycle. In this case, it does not seem to interfere with subsequent I2C communications. 31 bytes (9 LEDs) didn't used to work; the best I could do was 28, meaning 8 LEDs (the data being in 3-byte multiples). Now 9 works fine.
In the code below, running with the "var RunCount = 9" changed to "var RunCount = 10" will produce a transmission error, and doesn't update the LEDs, but it doesn't lock up future communications; you can then change it back to 9 and it runs successfully with the desired result. The first 4 bytes of the buffer are overhead information, and the rest are "GRB" triplets, each representing one LED.
var I2CAddr = 0x60 var LED_COUNT = 28 var NeoBufSize = 3 * var.LED_COUNT var RunCount = 9 var BufSize = 4 + 3 * var.RunCount var Buf = vector(var.BufSize, null) set var.Buf[0] = {0x0E} ; base address in NeoDriver set var.Buf[1] = 4 ; Specifies sending a buffer set var.Buf[2] = 0 set var.Buf[3] = 0 ; Offset in NeoDriver internal buffer while iterations < var.RunCount ; Put individual R, G, & B values into Buf array set var.Buf[4 + iterations * 3] = 0 ; Green set var.Buf[5 + iterations * 3] = 0 ; Red set var.Buf[6 + iterations * 3] = 24 ; Blue ;----------------------------------------------------------------------- ; Send the data ;----------------------------------------------------------------------- M260 A{var.I2CAddr} B{0x0E, 1, 0x0F} ; NeoDriver "pin #" G4 P50 M260 A{var.I2CAddr} B{0x0E, 2, 1} ; NeoDriver I2C speed G4 P50 M260 A{var.I2CAddr} B{0x0E, 3, var.NeoBufSize, 0} ; Internal NeoDriver buffer size ;------------------------------------------------------------------------------- M260 A{var.I2CAddr} B{var.Buf} ; Sending buffer data ;------------------------------------------------------------------------------- ; G4 delays seem to prevent NeoDriver locking up with "I2C transmission error" ;------------------------------------------------------------------------------- G4 P100 ;------------------------------------------------------------------------------- ; Show NeoPixels ;------------------------------------------------------------------------------- M260 A{var.I2CAddr} B{0x0E, 5}