Code optimized, delay changing via USB added and animation viewing

routine fixed.
This commit is contained in:
Kai Lauterbach 2011-12-18 22:16:32 +01:00
parent 5d944fac4b
commit 73ad4d9fd9
4 changed files with 24 additions and 20 deletions

View file

@ -18,7 +18,8 @@ main()
init(); init();
init_usb(); init_usb();
frame = 0x07ffffff; //frame = 0x07ffffff;
mode = 2;
// Hauptschleife // Hauptschleife
for (;;) for (;;)
@ -67,15 +68,18 @@ ISR (TIMER1_COMPA_vect)
{ {
if (frmnum == 32) if (frmnum == 32)
{ {
if (mode > 0)
frmnum = 0;
if (mode == 1) if (mode == 1)
mode = 0; mode = 0;
} else frmnum = 0;
setFrame(frmnum); } else {
if (mode) if (mode)
{
loadEEPROMFrame(frmnum);
frmnum++; frmnum++;
} }
}
delay = delay_max;
}
// PORTD = __, 9, C, B, A,D+,D-,__ // PORTD = __, 9, C, B, A,D+,D-,__
PORTD &= 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren PORTD &= 0b10000111; // 7tes Bit löschen (Leitung 9) und alle Ebenen deaktivieren
@ -95,7 +99,7 @@ ISR (TIMER1_COMPA_vect)
} }
void setFrame(uint8_t f) void loadEEPROMFrame(uint8_t f)
{ {
frame = eeprom_read_dword( &eep_anim[f] ); frame = eeprom_read_dword( &eep_anim[f] );
} }

View file

@ -27,6 +27,7 @@ uint8_t level; // Aktive Ebene
uint8_t mode; uint8_t mode;
uint8_t frmnum; uint8_t frmnum;
uint8_t delay; uint8_t delay;
uint8_t delay_max;
//cube_t *cube; //cube_t *cube;
uint32_t eep_anim[32] EEMEM; uint32_t eep_anim[32] EEMEM;
@ -37,7 +38,7 @@ void init(void);
extern void init_usb(void); extern void init_usb(void);
extern void usbPoll(void); extern void usbPoll(void);
void setFrame(uint8_t); void loadEEPROMFrame(uint8_t);
#endif // __main_h__ #endif // __main_h__

View file

@ -33,11 +33,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
} else if ( rq->bRequest == CUSTOM_RQ_EEPROM_STORE_FRAME ) } else if ( rq->bRequest == CUSTOM_RQ_EEPROM_STORE_FRAME )
{ {
eeprom_write_dword( &eep_anim[ rq->wIndex.bytes[0] ], frame ); eeprom_write_dword( &eep_anim[ rq->wIndex.bytes[0] ], frame );
} else if ( rq->bRequest == CUSTOM_RQ_SET_DELAY )
/*} else if ( rq->bRequest == CUSTOM_RQ_EEPROM_SET_FRAME )
{ {
//frame = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] ); delay_max = rq->wValue.bytes[0];
setFrame( &eep_anim[rq->wIndex.bytes[0]] );*/
} else if ( rq->bRequest == CUSTOM_RQ_SET_MODE ) } else if ( rq->bRequest == CUSTOM_RQ_SET_MODE )
{ {
mode = rq->wValue.bytes[0]; // 0 = stop; 1 = single; 2 = loop mode = rq->wValue.bytes[0]; // 0 = stop; 1 = single; 2 = loop

View file

@ -61,10 +61,11 @@ extern uint32_t eep_anim[32] EEMEM;
// usb buffer // usb buffer
extern uint32_t frame; // Framebuffer extern uint32_t frame; // Framebuffer
extern uint8_t delay_max; // delay in ISR aufrufen
extern uint8_t mode; // FW mode extern uint8_t mode; // FW mode
//extern cube_t *cube; //extern cube_t *cube;
extern void setFrame(uint8_t f); extern void loadEEPROMFrame(uint8_t f);
#endif // __usb_h__ #endif // __usb_h__