// raw:erorr included typedef struct{ uint16 cur,dest,delta,mode;}tFade; tFade[1..32] FadeA; void fadeUpdate(){ for(i=1; i<=32; i++){ if(FadeA[i].mode==0){ if(FadeA[i].curFadeA[i].des+FadeA[i].delta) {FadeA[i].cur-=FadeA[i].delta } else {FadeA[i].cur=FadeA[i].des } } } sys_pwm_out(i,gammaTab[FadeA[i].cur/256])//obere 8 bit nach 'Wahrnehmung' skalieren } #define maxSlot 10 typedef struct{ void adr;uint16 A,B,C,D,E,F;} tSlot ; tSlot[1..maxSlot] SlotA; unit8 curSlot; tSlot* tsk;//short for "SlötA[curSlot]" void tmpAdr; void insPrg(uint8 aSlot,void aAdr){ if (aSlot>maxSlot){exit(0);}//msg["out of range"] if (aSlot==0){ aSlot=maxSlot; while(SlotA[aSlot].adr!=nil){ aSlot--;if (aSlot==0){exit(0);}//msg["out of prog_mem"] } } slotA[aSlot].adr=aAdr;if(aSlot==curSlot){tmpAdr=aAdr;} } void yield_asm() __attribut__(nacked){ asm volantile( "pop r17 pop r16 " "lds yl,tsk lds yh,tsk+1" "std y+0,r16 std y+1,r17 " "ret") } #define yield asm volantile("call yield_asm":::"memory") // mainloop #define timer TCNT0 /*prescaler: 2^10*/ uint8 fadeTime; while(1) { if ((timer&128)!= fadeTime) {fadeTime=(timer&128); fadeUpdate;}// bei 16 Mhz->ca.120 Hz else {curSlot++;if (curSlot>maxSlot){curSlot=1} tmpAdr=nil; tsk=&SlotA[curSlot]; if (*tsk.adr!=nil) {asm volantile( "lds yl,tsk ldi yh,tsk+1" "ldd zl,y+0 ldd zh,y+1" "icall" :::"memory")} if(tmpAdr!=nil){*tsk.adr=tmpAdr}; } }