--- /dev/null
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+
+int main(int argc,char **argv) {
+
+ int i;
+
+ double c,a,o,f;
+
+ a=atof(argv[1]);
+ c=(1.0-sqrt(1+4*a))/2.0; // -!
+ o=a/(1-c);
+
+ printf("; f(x) = a / (x+o) + c (a:%f o:%f c:%f)\n",a,o,c);
+
+ for(i=255;i>=0;i--) {
+ f=a/(1.0*i/255+o)+c;
+ printf("; %d - %d\n",255-i,255-i+1);
+ printf(".db 0x%0x, ",(int)(f*255));
+ i-=1;
+ f=a/(1.0*i/255+o)+c;
+ printf("0x%0x\n",(int)(f*255));
+ }
+
+ return 0;
+}
+
.def rgb_level = r21
.def rgb_dir = r22
.def rgb_upd_cnt = r23
+.def r_map = r24
+.def g_map = r25
+.def b_map = r26
.equ pin_red = 0x01
.equ pin_green = 0x02
.equ pin_blue = 0x04
ldi tmp,mid
mov blue,tmp
+; initial mapping intensities of intensities
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,red
+adc ZH,zero
+lpm r_map,Z
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,green
+adc ZH,zero
+lpm g_map,Z
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,blue
+adc ZH,zero
+lpm b_map,Z
+
; rgb propagation init
ldi rgb_dir,0x04
sub blue,two
add blue,one
+; update mapping
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,red
+adc ZH,zero
+lpm r_map,Z
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,green
+adc ZH,zero
+lpm g_map,Z
+ldi ZL,low(INTENSITIES*2)
+ldi ZH,high(INTENSITIES*2)
+add ZL,blue
+adc ZH,zero
+lpm b_map,Z
+
; power on the leds
POWER_LEDS:
mov rgb_level,zero
CHECK_RED:
-cp count,red
+cp count,r_map
brne CHECK_GREEN
ori rgb_level,pin_red
CHECK_GREEN:
-cp count,green
+cp count,g_map
brne CHECK_BLUE
ori rgb_level,pin_green
CHECK_BLUE:
-cp count,blue
+cp count,b_map
brne SET_PORTS
ori rgb_level,pin_blue
reti
+; intensities
+INTENSITIES:
+.include "rgb_moritz_intensities.asm"
+