Hi,
Thanks for the reply
This is the class under the namespace (there are multiple classes)
///START of SPISettings
export class SPIsetting{
// SPI Function Ids
protected SPI_WRITE_id : number
protected SPI_READ_id : number
protected SPI_CONFIG_id : number
protected SPI_WRITEBULK_id : number
protected SPI_WRITEBULK_CS_id : number
protected SPI_READBULK_CS_id : number
protected SPI_BAUD_id : number
protected SPI_CONFIG_CS_id : number
constructor(){
this.SPI_WRITE_id = 1
this.SPI_READ_id = 2
this.SPI_CONFIG_id = 3
this.SPI_WRITEBULK_id = 4
this.SPI_WRITEBULK_CS_id = 5
this. SPI_READBULK_CS_id = 6
this.SPI_BAUD_id = 7
this.SPI_CONFIG_CS_id = 8
}
//%blockId=send_UART_Buffer
//%block=“Send buffer %Buf to click %BoardNum”
//% blockGap=7
//% weight=90 color=#9E4894 icon=“”
//% advanced=false
sendBuffer( Buf: Buffer,BoardNum?: BoardID){
let buffLength = Buf.length+4;
let UARTBuf = pins.createBuffer(buffLength);
UARTBuf.setNumber(NumberFormat.UInt8LE, 0, RX_TX_Settings.BBOARD_COMMAND_WRITE_RX_BUFFER_DATA)
UARTBuf.setNumber(NumberFormat.UInt8LE, 1, clickBoardNum)
UARTBuf.setNumber(NumberFormat.UInt8LE, 2, UART_module_id)
UARTBuf.setNumber(NumberFormat.UInt8LE, 3, 5)
for(let i=0; i<buffLength-4;i++){
UARTBuf.setNumber(NumberFormat.UInt8LE, i+4, Buf.getNumber(NumberFormat.UInt8LE,i));
}
pins.i2cWriteBuffer(BBOARD_I2C_ADDRESS, CLEAR_BBOARD_RX_BUFFER, false)
pins.i2cWriteBuffer(BBOARD_I2C_ADDRESS, UARTBuf, false)
pins.i2cWriteBuffer(BBOARD_I2C_ADDRESS, EXECUTE_BBOARD_COMMAND, false)
}
}
Right now,
Even if I keep the function outside the class and use export function sendBuffer, I get the error but it may be becuase buffer is not being recognized by makecode.
I have some other functions where a string/ number has to be paased, I put them outside the class and used export function, but for cases where I am using them or enums,
I’m now getting an error
cannot read property ‘vtable’ of undefined.
Can I pm you for some help if that is possible?, I needed to share the entire file and also to learn how to use classes in makecode.
Thanks