get args passed in

This commit is contained in:
2023-12-21 11:08:35 -05:00
parent 4dcea50309
commit b3e8a617a7
+15 -1
View File
@@ -156,6 +156,18 @@ type RGBLedMatrix struct {
const MatrixEmulatorENV = "MATRIX_EMULATOR" const MatrixEmulatorENV = "MATRIX_EMULATOR"
func stringsToC(s []string) **C.char {
cArray := C.malloc(C.size_t(len(s)) * C.size_t(unsafe.Sizeof(uintptr(0))))
a := (*[2000]*C.char)(cArray)
for idx, substring := range s {
a[idx] = C.CString(substring)
}
return (**C.char)(cArray)
}
// NewRGBLedMatrix returns a new matrix using the given size and config // NewRGBLedMatrix returns a new matrix using the given size and config
func NewRGBLedMatrix(config *HardwareConfig) (c Matrix, err error) { func NewRGBLedMatrix(config *HardwareConfig) (c Matrix, err error) {
defer func() { defer func() {
@@ -173,7 +185,9 @@ func NewRGBLedMatrix(config *HardwareConfig) (c Matrix, err error) {
} }
w, h := config.geometry() w, h := config.geometry()
m := C.led_matrix_create_from_options(config.toC(), nil, nil) cargc := C.int(len(os.Args))
cargv := stringsToC(os.Args)
m := C.led_matrix_create_from_options(config.toC(), &cargc, &cargv)
b := C.led_matrix_create_offscreen_canvas(m) b := C.led_matrix_create_offscreen_canvas(m)
c = &RGBLedMatrix{ c = &RGBLedMatrix{
Config: config, Config: config,