Skip to content

Commit be556a9

Browse files
jakebaileydeadprogram
authored andcommitted
uc8151: fix LUT timing calculations
1 parent e082054 commit be556a9

1 file changed

Lines changed: 9 additions & 4 deletions

File tree

uc8151/uc8151.go

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -412,21 +412,26 @@ func (d *Device) Invert(invert bool) {
412412
func (d *Device) SetLUT(speed Speed, flickerFree bool) error {
413413
var lut LUTSet
414414

415+
if speed == DEFAULT {
416+
return nil
417+
}
418+
415419
// Num. of frames for single direction change.
416420
period := 64
417-
p := uint8(period / (2 ^ (int(speed) - 1)))
421+
scale := 1 << (int(speed) - 1)
422+
p := uint8(period / scale)
418423
if p < 1 {
419424
p = 1
420425
}
421426

422427
// Num. of frames for back-and-forth change.
423-
hperiod := period % 2
424-
hp := uint8(hperiod / (2 ^ (int(speed) - 1)))
428+
hperiod := period / 2
429+
hp := uint8(hperiod / scale)
425430
if hp < 1 {
426431
hp = 1
427432
}
428433

429-
if speed < FAST && !flickerFree {
434+
if speed <= FAST && !flickerFree {
430435
// For low speed everything is charge-neutral, even WB/BW.
431436

432437
// Phase 1: long go-inverted-color.

0 commit comments

Comments
 (0)