Animation support added.

This commit is contained in:
Kai Lauterbach 2011-12-18 19:35:47 +01:00
parent 9d6eb9dfc5
commit ff56b090fd
5 changed files with 40 additions and 21 deletions

View file

@ -18,10 +18,7 @@ main()
init(); init();
init_usb(); init_usb();
//cube_t c;
//cube = &c;
frame = 0x07ffffff; frame = 0x07ffffff;
//cube->level = 0x00;
// Hauptschleife // Hauptschleife
for (;;) for (;;)
@ -65,6 +62,21 @@ void init()
ISR (TIMER1_COMPA_vect) ISR (TIMER1_COMPA_vect)
{ {
delay--;
if ( !delay )
{
if (frmnum == 32)
{
if (mode > 0)
frmnum = 0;
if (mode == 1)
mode = 0;
} else
setFrame(frmnum);
if (mode)
frmnum++;
}
// 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
PORTD |= (1 << 6) | ((1 << level) << 3); // level setzen (Ebene A=0, B=1, C=2) PORTD |= (1 << 6) | ((1 << level) << 3); // level setzen (Ebene A=0, B=1, C=2)
@ -83,3 +95,8 @@ ISR (TIMER1_COMPA_vect)
} }
void setFrame(uint8_t f)
{
frame = eeprom_read_dword( &eep_anim[f] );
}

View file

@ -18,13 +18,18 @@
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <avr/io.h> #include <avr/io.h>
#include <avr/eeprom.h>
// Cube-Data // Cube-Data
uint32_t frame = 0xffffffff; uint32_t frame = 0xffffffff;
// Bit Offset in Cube-Data // Bit Offset in Cube-Data
uint8_t level; // Aktive Ebene uint8_t level; // Aktive Ebene
uint8_t mode;
uint8_t frmnum;
uint8_t delay;
//cube_t *cube; //cube_t *cube;
uint32_t eep_anim[32] EEMEM;
// Prototypen // Prototypen
void init(void); void init(void);
@ -32,5 +37,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);
#endif // __main_h__ #endif // __main_h__

View file

@ -19,8 +19,6 @@
#define CUSTOM_RQ_SET_FRAME 1 #define CUSTOM_RQ_SET_FRAME 1
#define CUSTOM_RQ_EEPROM_STORE_FRAME 2 #define CUSTOM_RQ_EEPROM_STORE_FRAME 2
#define CUSTOM_RQ_EEPROM_SET_FRAME 3 #define CUSTOM_RQ_EEPROM_SET_FRAME 3
#define CUSTOM_RQ_LOOP_ANIMATION 4 #define CUSTOM_RQ_SET_MODE 4
#define CUSTOM_RQ_START_ANIMATION 5
#define CUSTOM_RQ_STOP_ANIMATION 6
#endif /* __REQUESTS_H_INCLUDED__ */ #endif /* __REQUESTS_H_INCLUDED__ */

View file

@ -16,19 +16,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR ) if ( (rq->bmRequestType & USBRQ_TYPE_MASK) == USBRQ_TYPE_VENDOR )
{ {
/*if ( rq->bRequest == CUSTOM_RQ_SET_LED ) if ( rq->bRequest == CUSTOM_RQ_SET_FRAME )
{
if ( rq->wValue.bytes[0] == 1 )
cube |= ((uint32_t)1 << rq->wIndex.bytes[0]);
else
cube &= ~((uint32_t)1 << rq->wIndex.bytes[0]);
} else*/ if ( rq->bRequest == CUSTOM_RQ_SET_FRAME )
{ {
/* requires more flash space
cube = (cube & (uint32_t)0xffff0000) |
( rq->wValue.bytes[0] + (rq->wValue.bytes[1] << 8) ) |
( (uint32_t)(rq->wIndex.bytes[0] + (rq->wIndex.bytes[1] << 8)) << 16 );*/
if ( rq->wIndex.bytes[0] == 0 ) if ( rq->wIndex.bytes[0] == 0 )
{ {
frame = (frame & (uint32_t)0xffff0000) | frame = (frame & (uint32_t)0xffff0000) |
@ -42,10 +32,15 @@ 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[0], 0x07007007); 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_EEPROM_SET_FRAME )
{ {
frame = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] ); //frame = eeprom_read_dword( &eep_anim[rq->wIndex.bytes[0]] );
setFrame( &eep_anim[rq->wIndex.bytes[0]] );*/
} else if ( rq->bRequest == CUSTOM_RQ_SET_MODE )
{
mode = rq->wValue.bytes[0]; // 0 = stop; 1 = single; 2 = loop
} }
} }

View file

@ -57,12 +57,14 @@ PROGMEM char usbHidReportDescriptor[22] = { /* USB report descriptor */
void init_usb(void); void init_usb(void);
uint32_t eep_anim[32] EEMEM; extern uint32_t eep_anim[32] EEMEM;
// usb buffer // usb buffer
extern uint32_t frame; // Framebuffer extern uint32_t frame; // Framebuffer
extern uint8_t mode; // FW mode
//extern cube_t *cube; //extern cube_t *cube;
extern void setFrame(uint8_t f);
#endif // __usb_h__ #endif // __usb_h__