Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #
- include < avr / sfr_defs.h > #include < avr / iom128.h > #include < avr / io.h > #include < string.h > #define CELL_OFF 0x00# define SEGMENT_A# define SEGMENT_B# define SEGMENT_C# define SEGMENT_D# define SEGMENT_E# define SEGMENT_F# define SEGMENT_G# define SEGMENT_H# define SYMBOL_Br(SEGMENT_A | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F | SEGMENT_G)# define SYMBOL_Gr(SEGMENT_A | SEGMENT_E | SEGMENT_F)# define SYMBOL_Ur(SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_F | SEGMENT_G)# define SYMBOL_Ir(SEGMENT_B | SEGMENT_C | SEGMENT_D | SEGMENT_E | SEGMENT_F)# define SYMBOL_Rr(SEGMENT_A | SEGMENT_B | SEGMENT_E | SEGMENT_F | SEGMENT_G)# define TOGGLE_CLK()(PORTC |= _BV(PC3), \
- PORTC &= ~_BV(PC3))# define STRING_RUN_PERIOD 3000
- static uint8_t aunVideoMemory[] = {
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0
- };
- static uint8_t aunRunningString[] = {
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- SYMBOL_Rr,
- SYMBOL_Ir,
- SYMBOL_Ur,
- SYMBOL_Gr,
- SYMBOL_Br,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- };
- const uint8_t unVMSize = sizeof(aunVideoMemory) / sizeof(uint8_t);
- const uint8_t unRSSize = sizeof(aunRunningString) / sizeof(uint8_t);
- int main(void) {
- uint8_t unDispCell = 0;
- int32_t nDelayIn, nDelayOut;
- int16_t nSymbol = 0;
- DDRA = _BV(DDA0) | _BV(DDA1) | \
- _BV(DDA2) | _BV(DDA3) | \
- _BV(DDA4) | _BV(DDA5) | \
- _BV(DDA6) | _BV(DDA7);
- DDRC = _BV(DDC0) | _BV(DDC1) | \
- _BV(DDC2) | _BV(DDC3);
- while (1) {
- nDelayOut = STRING_RUN_PERIOD;
- memcpy(aunVideoMemory, aunRunningString + nSymbol, unVMSize);
- while (--nDelayOut > 0) {
- PORTC = unDispCell;
- PORTA = ~(aunVideoMemory[unDispCell++]);
- unDispCell %= unVMSize;
- TOGGLE_CLK();
- for (nDelayIn = 0; nDelayIn < 5; nDelayIn++);
- PORTA = ~CELL_OFF;
- TOGGLE_CLK();
- }
- if (--nSymbol < 0) {
- nSymbol = (unRSSize - unVMSize);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement