Skip to content

Commit

Permalink
feat: Increase dithering to 11-bit
Browse files Browse the repository at this point in the history
  • Loading branch information
mathiasvr committed Jan 23, 2021
1 parent 823a41f commit 054d1d9
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Bluejay.asm
Original file line number Diff line number Diff line change
Expand Up @@ -884,12 +884,11 @@ ELSEIF PWM_BITS_H == 0 ; 8-bit pwm
mov Temp3, #0
ENDIF

; 10-bit effective dithering of 8/9-bit pwm
IF PWM_BITS_H < 2
; 11-bit effective dithering of 8/9/10-bit pwm
IF PWM_BITS_H < 3
mov A, Temp4 ; 11-bit low byte
cpl A
rr A
anl A, #((1 SHL (2-PWM_BITS_H))-1); Get index into dithering pattern table
anl A, #((1 SHL (3 - PWM_BITS_H)) - 1); Get index into dithering pattern table

add A, #Dithering_Patterns
mov Temp1, A ; Reuse DShot pwm pointer since it is not currently in use.
Expand Down Expand Up @@ -3460,16 +3459,26 @@ decode_temp_done:
mov Temp_Prot_Limit, A

; Initialize pwm dithering bit patterns
IF PWM_BITS_H == 1
IF PWM_BITS_H == 2
mov Temp1, #Dithering_Patterns
Push_Mem Temp1, #00h
Push_Mem Temp1, #55h
ELSEIF PWM_BITS_H == 1
mov Temp1, #Dithering_Patterns
Push_Mem Temp1, #00h
Push_Mem Temp1, #11h
Push_Mem Temp1, #55h
Push_Mem Temp1, #77h
ELSEIF PWM_BITS_H == 0
mov Temp1, #Dithering_Patterns
Push_Mem Temp1, #00h
Push_Mem Temp1, #01h
Push_Mem Temp1, #11h
Push_Mem Temp1, #25h
Push_Mem Temp1, #55h
Push_Mem Temp1, #5Bh
Push_Mem Temp1, #77h
Push_Mem Temp1, #7fh
ENDIF
ret

Expand Down

0 comments on commit 054d1d9

Please sign in to comment.