Code optimized, delay changing via USB added and animation viewing
routine fixed.
This commit is contained in:
parent
5d944fac4b
commit
73ad4d9fd9
4 changed files with 24 additions and 20 deletions
|
@ -18,7 +18,8 @@ main()
|
|||
init();
|
||||
init_usb();
|
||||
|
||||
frame = 0x07ffffff;
|
||||
//frame = 0x07ffffff;
|
||||
mode = 2;
|
||||
|
||||
// Hauptschleife
|
||||
for (;;)
|
||||
|
@ -31,11 +32,11 @@ main()
|
|||
void init()
|
||||
{
|
||||
// Ports vorbereiten
|
||||
DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden)
|
||||
PORTB = 0b11111111; // HIGH
|
||||
DDRB = 0b11111111; // PB0-PB7: LED 1-8 (Kathoden)
|
||||
PORTB = 0b11111111; // HIGH
|
||||
|
||||
DDRD = 0b01111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden)
|
||||
PORTD = 0b01000000;
|
||||
DDRD = 0b01111000; // PD6: LED 9 (Kathode); PD5-PD3: A-C (Anoden)
|
||||
PORTD = 0b01000000;
|
||||
|
||||
// Timer-Interrupt "TIMER1" vorbereiten
|
||||
|
||||
|
@ -67,14 +68,17 @@ ISR (TIMER1_COMPA_vect)
|
|||
{
|
||||
if (frmnum == 32)
|
||||
{
|
||||
if (mode > 0)
|
||||
frmnum = 0;
|
||||
if (mode == 1)
|
||||
mode = 0;
|
||||
} else
|
||||
setFrame(frmnum);
|
||||
if (mode)
|
||||
frmnum++;
|
||||
frmnum = 0;
|
||||
} else {
|
||||
if (mode)
|
||||
{
|
||||
loadEEPROMFrame(frmnum);
|
||||
frmnum++;
|
||||
}
|
||||
}
|
||||
delay = delay_max;
|
||||
}
|
||||
|
||||
// PORTD = __, 9, C, B, A,D+,D-,__
|
||||
|
@ -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] );
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ uint8_t level; // Aktive Ebene
|
|||
uint8_t mode;
|
||||
uint8_t frmnum;
|
||||
uint8_t delay;
|
||||
uint8_t delay_max;
|
||||
|
||||
//cube_t *cube;
|
||||
uint32_t eep_anim[32] EEMEM;
|
||||
|
@ -37,7 +38,7 @@ void init(void);
|
|||
extern void init_usb(void);
|
||||
extern void usbPoll(void);
|
||||
|
||||
void setFrame(uint8_t);
|
||||
void loadEEPROMFrame(uint8_t);
|
||||
|
||||
#endif // __main_h__
|
||||
|
||||
|
|
|
@ -33,11 +33,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
|
|||
} else if ( rq->bRequest == CUSTOM_RQ_EEPROM_STORE_FRAME )
|
||||
{
|
||||
eeprom_write_dword( &eep_anim[ rq->wIndex.bytes[0] ], frame );
|
||||
|
||||
/*} else if ( rq->bRequest == CUSTOM_RQ_EEPROM_SET_FRAME )
|
||||
} else if ( rq->bRequest == CUSTOM_RQ_SET_DELAY )
|
||||
{
|
||||
//frame = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] );
|
||||
setFrame( &eep_anim[rq->wIndex.bytes[0]] );*/
|
||||
delay_max = rq->wValue.bytes[0];
|
||||
} else if ( rq->bRequest == CUSTOM_RQ_SET_MODE )
|
||||
{
|
||||
mode = rq->wValue.bytes[0]; // 0 = stop; 1 = single; 2 = loop
|
||||
|
|
|
@ -60,11 +60,12 @@ void init_usb(void);
|
|||
extern uint32_t eep_anim[32] EEMEM;
|
||||
|
||||
// usb buffer
|
||||
extern uint32_t frame; // Framebuffer
|
||||
extern uint8_t mode; // FW mode
|
||||
extern uint32_t frame; // Framebuffer
|
||||
extern uint8_t delay_max; // delay in ISR aufrufen
|
||||
extern uint8_t mode; // FW mode
|
||||
|
||||
//extern cube_t *cube;
|
||||
extern void setFrame(uint8_t f);
|
||||
extern void loadEEPROMFrame(uint8_t f);
|
||||
|
||||
#endif // __usb_h__
|
||||
|
||||
|
|
Loading…
Reference in a new issue