/* Reads what arrives from the modem/device that it is * connected in and shows in the terminal module */ void Terminal::update() { /* DO NOT CHANGE THER ORDER */ this->update_write (); this->update_buffer(); CLEAR_BUFFER(this->output); }
int8_t anim_movingDot( void ) { if( animation.currentFrame >= NUMBER_OF_LEDS ) { return -1; } CLEAR_BUFFER( buffer ); buffer[ animation.currentFrame / 8 ] |= _BV( animation.currentFrame % 8 ); buffer[ animation.currentFrame % 8 ] |= _BV( animation.currentFrame / 8 ); return 18; }
void animationTick( void ) { int8_t ticks; if( !animation.active ) { return; } if( animation.ticksForCurrentFrame == 0 ) { ticks = (*animation.currentAnimation)(); if( ticks < 0 ) { CLEAR_BUFFER( buffer ); CLEAR_BUFFER( frame ); if( animation.loop ) { animation.currentFrame = 0; ticks = 128; } else { animation.active = FALSE; } } else { animation.nextFrameReady = TRUE; animation.ticksForCurrentFrame = ticks; } } else { animation.ticksForCurrentFrame--; } }
int main(void) { static uint8_t oldPosition; static uint8_t divVal, modVal; cli(); wdt_disable(); set_sleep_mode( SLEEP_MODE_IDLE ); initDevice(); DDRD = 0b11111111; DDRB = 0b11111111; initTimer2(); initTimer0(); sei(); startTimer2(); startTimer0(); frame = buf1; buffer = buf2; CLEAR_BUFFER( frame ); CLEAR_BUFFER( buffer ); setAnimationFunction( anim_fillDot, TRUE, TRUE ); animation.loop = TRUE; while ( 1 ) { if( animation.tick ) { animationTick(); clearTick(); } if( currentScanPixel == 0 ) { if( animation.nextFrameReady ) { animationBufferSwap(); } } if( oldPosition != currentScanPixel ) { modVal = currentScanPixel % 8; //we need to change columns only so often if( modVal == 0 ) { divVal = currentScanPixel / 8; COL_PIXEL( divVal ); } if( frame[ divVal ] & _BV( modVal ) ) { ROW_PIXEL( modVal ); } else { ROW_OFF(); } oldPosition = currentScanPixel; } //if( TIME TO SLEEP ) { sleep_mode(); } } }