View previous topic :: View next topic |
Author |
Message |
andro
Joined: 12 Mar 2007 Posts: 94 Location: Ljubljana
|
Posted: Wed Dec 06, 2017 10:09 pm Post subject: RB_SETTABLECOLOR isue |
|
|
Hi!
If I use RB_LOOKUPCOLOR command, the colors (on WS2812b LED ring or strip) are ok.
If I use RB_SETTABLECOLOR command, It looks like R and G are swapped (R is G and G is R).
Is it possible that there is an error in RB_SETTABLECOLOR procedure when reading from table?
Belowe there is my basic 12 colors + white Rainbov_colors DATA table, that works fine with RB_LOOKUPCOLOR, but if using RB_SETTABLECOLOR I have toexchange R and G colors.
Best regards
Andrej
Code: |
Rainbow_colors_:
Data 255 , 255 , 255 'white
Data 255 , 0 , 0 'red
Data 255 , 80 , 0 'orange
Data 255 , 255 , 0 'yellow
Data 128 , 255 , 0 'olive
Data 0 , 255 , 0 'green
Data 0 , 255 , 80 'lime
Data 0 , 255 , 255 'cyan
Data 0 , 128 , 255 'light blue
Data 0 , 0 , 255 'blue
Data 128 , 0 , 255 'purple
Data 255 , 0 , 255 'magenta
Data 255 , 0 , 128 'pink-red
|
(BASCOM-AVR version : 2.0.8.0 , Latest : 2.0.7.8 ) |
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Thu Dec 07, 2017 11:10 am Post subject: |
|
|
yes that can be the case. while adding support for rgbW leds i noticed some errors in color manipulation.
you can correct it as following :
RB_Color0:
LSR R16
BRCC RB_Color1
ST X+, R18 ; red
ST X+, R19 ; green
ST X+, R20 ; blue
and
RB_Color1:
BRTC RB_Color2
ST X+,R21 ; red
ST X+,R22 ; G
ST X+,R23 ; B _________________ Mark |
|
Back to top |
|
|
gallahat
Joined: 22 Dec 2005 Posts: 1
|
Posted: Fri Dec 08, 2017 7:35 am Post subject: |
|
|
Hi Mark, hi Andro
I think the cause of this problem is that when mixing the code parts RB_setTableColor and RB_LookUpColor in the Lib, it was not considered that the data order needs to be a different one.
Each Rainbow is an image of a strip itself. The data arrangement is GRB and not RGB. Ask the manufacturer why. To this byte order to be able to send simply and quickly, without having to exchange the bytes before sending, the colors are already stored accordingly.
In the table, the data is in RGB format. LookUp reads the data so that the data is in RGB sequence in the variable. SetColor, on the other hand, should write the RGB data in GRB sequence into the image.
Other functions such as RB_SetColor, take into account that the parameter has RGB format and save it in the GRB format. RB_SetTableColor must also take this into account
My suggestion for now:
Code: | [RB_SETTABLECOLOR]
$external BOW_POINT_ARRAY, RB_LOOKUPCOLOR
;DESCRIPTION loads color from datatable
;PARAMETER LED Index (R20|R21), coloridx(R24)
RB_SetTableColor:
RCALL BOW_Point_Array ; point Array
mov r24,r20 ; color
;RJMP RB_LookUpColorZ ; handle the rest
RCALL Calc_Offset8 ; build colortable address in r24,r25
ADD Zl , R24
ADC ZH , R25
#IF _ROMSIZE>65536
* call _LPM_INC_CHECK ; check for page crossing
#ENDIF
call _lpmbyte
mov r16,r0
call _lpmbyte
mov r17,r0
call _lpmbyte
ST x+ , R17 ; store color in needed order
ST x+ , R16
ST x , R0
RET
[END] |
|
|
Back to top |
|
|
albertsm
Joined: 09 Apr 2004 Posts: 5913 Location: Holland
|
Posted: Fri Dec 08, 2017 1:21 pm Post subject: |
|
|
yes i understand how it became that way. for 2081 i rewrote a part of the lib. now all data in RAM is in RGB format.
Only the sending routine either send in GRB or RGBW for rgbw leds.
this makes it simpler IMO _________________ Mark |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum
|
|