Roll display print loop
This commit is contained in:
parent
f165807ec5
commit
11a0f85c9f
1 changed files with 3 additions and 9 deletions
|
@ -28,16 +28,10 @@ func (c *Can) DisplayWrite(line int, a []byte) error {
|
|||
default:
|
||||
return errors.New("Invalid line")
|
||||
}
|
||||
// print in 3 chunks, as one frame is limited to 8 bytes
|
||||
// print in separate chunks, as one frame payload is limited to 7 bytes
|
||||
// the display has only 16 characters per line, so we truncate there
|
||||
if len(a) > 0 {
|
||||
return c.bus.Publish(DisplayCommand{addr, a[:7]}.Encode())
|
||||
}
|
||||
if len(a) > 7 {
|
||||
return c.bus.Publish(DisplayCommand{addr, a[7:14]}.Encode())
|
||||
}
|
||||
if len(a) > 14 {
|
||||
return c.bus.Publish(DisplayCommand{addr, a[14:16]}.Encode())
|
||||
for i := 0; i < len(a) && i < 16; i += 7 {
|
||||
return c.bus.Publish(DisplayCommand{addr, a[i:i+7]}.Encode())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue