Merge pull request #11 from justfalter/fix-options
Update rpi-rgb-led-matrix, fix column calculation, add several missing configuration options
This commit is contained in:
@@ -11,18 +11,28 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rows = flag.Int("led-rows", 32, "number of rows supported")
|
rows = flag.Int("led-rows", 32, "number of rows supported")
|
||||||
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
cols = flag.Int("led-cols", 32, "number of columns supported")
|
||||||
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
||||||
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
||||||
|
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
||||||
|
hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.")
|
||||||
|
show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.")
|
||||||
|
inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.")
|
||||||
|
disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config := &rgbmatrix.DefaultConfig
|
config := &rgbmatrix.DefaultConfig
|
||||||
config.Rows = *rows
|
config.Rows = *rows
|
||||||
|
config.Cols = *cols
|
||||||
config.Parallel = *parallel
|
config.Parallel = *parallel
|
||||||
config.ChainLength = *chain
|
config.ChainLength = *chain
|
||||||
config.Brightness = *brightness
|
config.Brightness = *brightness
|
||||||
|
config.HardwareMapping = *hardware_mapping
|
||||||
|
config.ShowRefreshRate = *show_refresh
|
||||||
|
config.InverseColors = *inverse_colors
|
||||||
|
config.DisableHardwarePulsing = *disable_hardware_pulsing
|
||||||
|
|
||||||
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
|||||||
@@ -9,18 +9,28 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rows = flag.Int("led-rows", 32, "number of rows supported")
|
rows = flag.Int("led-rows", 32, "number of rows supported")
|
||||||
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
cols = flag.Int("led-cols", 32, "number of columns supported")
|
||||||
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
||||||
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
||||||
|
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
||||||
|
hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.")
|
||||||
|
show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.")
|
||||||
|
inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.")
|
||||||
|
disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config := &rgbmatrix.DefaultConfig
|
config := &rgbmatrix.DefaultConfig
|
||||||
config.Rows = *rows
|
config.Rows = *rows
|
||||||
|
config.Cols = *cols
|
||||||
config.Parallel = *parallel
|
config.Parallel = *parallel
|
||||||
config.ChainLength = *chain
|
config.ChainLength = *chain
|
||||||
config.Brightness = *brightness
|
config.Brightness = *brightness
|
||||||
|
config.HardwareMapping = *hardware_mapping
|
||||||
|
config.ShowRefreshRate = *show_refresh
|
||||||
|
config.InverseColors = *inverse_colors
|
||||||
|
config.DisableHardwarePulsing = *disable_hardware_pulsing
|
||||||
|
|
||||||
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
|||||||
@@ -10,11 +10,16 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rows = flag.Int("led-rows", 32, "number of rows supported")
|
rows = flag.Int("led-rows", 32, "number of rows supported")
|
||||||
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
cols = flag.Int("led-cols", 32, "number of columns supported")
|
||||||
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
||||||
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
||||||
img = flag.String("image", "", "image path")
|
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
||||||
|
hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.")
|
||||||
|
show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.")
|
||||||
|
inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.")
|
||||||
|
disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.")
|
||||||
|
img = flag.String("image", "", "image path")
|
||||||
|
|
||||||
rotate = flag.Int("rotate", 0, "rotate angle, 90, 180, 270")
|
rotate = flag.Int("rotate", 0, "rotate angle, 90, 180, 270")
|
||||||
)
|
)
|
||||||
@@ -25,9 +30,14 @@ func main() {
|
|||||||
|
|
||||||
config := &rgbmatrix.DefaultConfig
|
config := &rgbmatrix.DefaultConfig
|
||||||
config.Rows = *rows
|
config.Rows = *rows
|
||||||
|
config.Cols = *cols
|
||||||
config.Parallel = *parallel
|
config.Parallel = *parallel
|
||||||
config.ChainLength = *chain
|
config.ChainLength = *chain
|
||||||
config.Brightness = *brightness
|
config.Brightness = *brightness
|
||||||
|
config.HardwareMapping = *hardware_mapping
|
||||||
|
config.ShowRefreshRate = *show_refresh
|
||||||
|
config.InverseColors = *inverse_colors
|
||||||
|
config.DisableHardwarePulsing = *disable_hardware_pulsing
|
||||||
|
|
||||||
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
|||||||
@@ -8,18 +8,28 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
rows = flag.Int("led-rows", 32, "number of rows supported")
|
rows = flag.Int("led-rows", 32, "number of rows supported")
|
||||||
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
cols = flag.Int("led-cols", 32, "number of columns supported")
|
||||||
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
parallel = flag.Int("led-parallel", 1, "number of daisy-chained panels")
|
||||||
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
chain = flag.Int("led-chain", 2, "number of displays daisy-chained")
|
||||||
|
brightness = flag.Int("brightness", 100, "brightness (0-100)")
|
||||||
|
hardware_mapping = flag.String("led-gpio-mapping", "regular", "Name of GPIO mapping used.")
|
||||||
|
show_refresh = flag.Bool("led-show-refresh", false, "Show refresh rate.")
|
||||||
|
inverse_colors = flag.Bool("led-inverse", false, "Switch if your matrix has inverse colors on.")
|
||||||
|
disable_hardware_pulsing = flag.Bool("led-no-hardware-pulse", false, "Don't use hardware pin-pulse generation.")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
config := &rgbmatrix.DefaultConfig
|
config := &rgbmatrix.DefaultConfig
|
||||||
config.Rows = *rows
|
config.Rows = *rows
|
||||||
|
config.Cols = *cols
|
||||||
|
config.Parallel = *parallel
|
||||||
config.ChainLength = *chain
|
config.ChainLength = *chain
|
||||||
config.Brightness = *brightness
|
config.Brightness = *brightness
|
||||||
config.Parallel = *parallel
|
config.HardwareMapping = *hardware_mapping
|
||||||
|
config.ShowRefreshRate = *show_refresh
|
||||||
|
config.InverseColors = *inverse_colors
|
||||||
|
config.DisableHardwarePulsing = *disable_hardware_pulsing
|
||||||
|
|
||||||
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
m, err := rgbmatrix.NewRGBLedMatrix(config)
|
||||||
fatal(err)
|
fatal(err)
|
||||||
|
|||||||
45
matrix.go
45
matrix.go
@@ -23,6 +23,18 @@ void led_matrix_swap(struct RGBLedMatrix *matrix, struct LedCanvas *offscreen_ca
|
|||||||
|
|
||||||
offscreen_canvas = led_matrix_swap_on_vsync(matrix, offscreen_canvas);
|
offscreen_canvas = led_matrix_swap_on_vsync(matrix, offscreen_canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void set_show_refresh_rate(struct RGBLedMatrixOptions *o, int show_refresh_rate) {
|
||||||
|
o->show_refresh_rate = show_refresh_rate != 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_disable_hardware_pulsing(struct RGBLedMatrixOptions *o, int disable_hardware_pulsing) {
|
||||||
|
o->disable_hardware_pulsing = disable_hardware_pulsing != 0 ? 1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void set_inverse_colors(struct RGBLedMatrixOptions *o, int inverse_colors) {
|
||||||
|
o->inverse_colors = inverse_colors != 0 ? 1 : 0;
|
||||||
|
}
|
||||||
*/
|
*/
|
||||||
import "C"
|
import "C"
|
||||||
import (
|
import (
|
||||||
@@ -37,6 +49,7 @@ import (
|
|||||||
// DefaultConfig default WS281x configuration
|
// DefaultConfig default WS281x configuration
|
||||||
var DefaultConfig = HardwareConfig{
|
var DefaultConfig = HardwareConfig{
|
||||||
Rows: 32,
|
Rows: 32,
|
||||||
|
Cols: 32,
|
||||||
ChainLength: 1,
|
ChainLength: 1,
|
||||||
Parallel: 1,
|
Parallel: 1,
|
||||||
PWMBits: 11,
|
PWMBits: 11,
|
||||||
@@ -49,6 +62,8 @@ var DefaultConfig = HardwareConfig{
|
|||||||
type HardwareConfig struct {
|
type HardwareConfig struct {
|
||||||
// Rows the number of rows supported by the display, so 32 or 16.
|
// Rows the number of rows supported by the display, so 32 or 16.
|
||||||
Rows int
|
Rows int
|
||||||
|
// Cols the number of columns supported by the display, so 32 or 64 .
|
||||||
|
Cols int
|
||||||
// ChainLengthis the number of displays daisy-chained together
|
// ChainLengthis the number of displays daisy-chained together
|
||||||
// (output of one connected to input of next).
|
// (output of one connected to input of next).
|
||||||
ChainLength int
|
ChainLength int
|
||||||
@@ -79,24 +94,44 @@ type HardwareConfig struct {
|
|||||||
|
|
||||||
ShowRefreshRate bool
|
ShowRefreshRate bool
|
||||||
InverseColors bool
|
InverseColors bool
|
||||||
|
|
||||||
|
// Name of GPIO mapping used
|
||||||
|
HardwareMapping string
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HardwareConfig) geometry() (width, height int) {
|
func (c *HardwareConfig) geometry() (width, height int) {
|
||||||
return c.Rows * c.ChainLength, c.Rows * c.Parallel
|
return c.Cols * c.ChainLength, c.Rows * c.Parallel
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *HardwareConfig) toC() *C.struct_RGBLedMatrixOptions {
|
func (c *HardwareConfig) toC() *C.struct_RGBLedMatrixOptions {
|
||||||
o := &C.struct_RGBLedMatrixOptions{}
|
o := &C.struct_RGBLedMatrixOptions{}
|
||||||
o.rows = C.int(c.Rows)
|
o.rows = C.int(c.Rows)
|
||||||
|
o.cols = C.int(c.Cols)
|
||||||
o.chain_length = C.int(c.ChainLength)
|
o.chain_length = C.int(c.ChainLength)
|
||||||
o.parallel = C.int(c.Parallel)
|
o.parallel = C.int(c.Parallel)
|
||||||
o.pwm_bits = C.int(c.PWMBits)
|
o.pwm_bits = C.int(c.PWMBits)
|
||||||
o.pwm_lsb_nanoseconds = C.int(c.PWMLSBNanoseconds)
|
o.pwm_lsb_nanoseconds = C.int(c.PWMLSBNanoseconds)
|
||||||
o.brightness = C.int(c.Brightness)
|
o.brightness = C.int(c.Brightness)
|
||||||
o.scan_mode = C.int(c.ScanMode)
|
o.scan_mode = C.int(c.ScanMode)
|
||||||
// o.disable_hardware_pulsing = c.DisableHardwarePulsing
|
o.hardware_mapping = C.CString(c.HardwareMapping)
|
||||||
// o.show_refresh_rate = c.ShowRefreshRate
|
|
||||||
// o.inverse_colors = c.InverseColors
|
if c.ShowRefreshRate == true {
|
||||||
|
C.set_show_refresh_rate(o, C.int(1))
|
||||||
|
} else {
|
||||||
|
C.set_show_refresh_rate(o, C.int(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.DisableHardwarePulsing == true {
|
||||||
|
C.set_disable_hardware_pulsing(o, C.int(1))
|
||||||
|
} else {
|
||||||
|
C.set_disable_hardware_pulsing(o, C.int(0))
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.InverseColors == true {
|
||||||
|
C.set_inverse_colors(o, C.int(1))
|
||||||
|
} else {
|
||||||
|
C.set_inverse_colors(o, C.int(0))
|
||||||
|
}
|
||||||
|
|
||||||
return o
|
return o
|
||||||
}
|
}
|
||||||
@@ -132,7 +167,7 @@ func NewRGBLedMatrix(config *HardwareConfig) (c Matrix, err error) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
if isMatrixEmulator() {
|
if isMatrixEmulator() {
|
||||||
return buildMatrixEmulator(config), nil
|
return buildMatrixEmulator(config), nil
|
||||||
}
|
}
|
||||||
|
|||||||
2
vendor/rpi-rgb-led-matrix
vendored
2
vendor/rpi-rgb-led-matrix
vendored
Submodule vendor/rpi-rgb-led-matrix updated: 24ecf1d839...0a4f8f9a9e
Reference in New Issue
Block a user