Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void refreshLCD(void){
- LCD_Clear();
- //write status
- if(isPlaying==1){
- LCD_GoTo(4,0);
- LCD_WriteText("Playing!");
- }
- else{
- LCD_GoTo(5,0);
- LCD_WriteText("Paused");
- }
- //write bpm
- LCD_GoTo(0,1);
- LCD_WriteText("BPM:");
- LCD_WriteInteger(bpm);
- //write "currentbeat / beat"
- LCD_GoTo(8,1);
- LCD_WriteText("Beat:");
- LCD_WriteInteger(currentBeat);
- LCD_WriteText("/");
- LCD_WriteInteger(beat);
- }
- ISR(TIMER2_OVF_vect) {
- ++currentOverflowCount;
- if(currentOverflowCount>=expectedOverflowCount){
- TIMSK|=(1<<OCIE2);
- TIMSK&=~(1<<TOIE2);
- }
- }
- ISR(TIMER2_COMP_vect){
- TCNT2 = 0;
- TIMSK&=~(1<<OCIE2);
- TIMSK|=(1<<TOIE2);
- ++currentBeat;
- if ((currentBeat % beat == 1) || (currentBeat > beat)){
- tick(1);
- currentBeat = 1;
- }
- else {
- tick(0);
- }
- currentOverflowCount=0;
- refreshLCD();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement