Interrupts.c


1
#include <avr/io.h>
2
#include <avr/interrupt.h>
3
#include "GlobalVar.h"
4
5
uint8_t PWM_G = 255;
6
uint8_t Buffer;
7
uint8_t ArrPos;
8
uint8_t CurFra;
9
10
//Timer0 Overflow Interrupt
11
ISR(TIMER0_OVF_vect)
12
{
13
}  
14
15
//Pin Change Interrupts 3 (Port D)
16
ISR(PCINT3_vect)
17
{
18
  if(PIND & (1<<PD0))        //PCINT24 - Down
19
  {
20
    ArrPos = ArrowPosition(Get, Get);
21
    if (ArrPos < 2)
22
      ArrPos++;
23
    else if (ArrPos >= 2)
24
      ArrPos = 0;
25
    Buffer = ArrowPosition(Set, ArrPos);
26
    FrameHome();
27
  }
28
  else if(PIND & (1<<PD1))    //PCINT25 -  Up
29
  {
30
    ArrPos = ArrowPosition(Get, Get);
31
    if (ArrPos > 0)
32
      ArrPos--;
33
    else if (ArrPos == 0)
34
      ArrPos = 2;
35
    Buffer = ArrowPosition(Set, ArrPos);
36
    FrameHome();
37
  }
38
  else if(PIND & (1<<PD2))    //PCINT26 - Home
39
  {
40
    CurFra = CurrentFrame(Get, Get);
41
    if (CurFra == 1)
42
    {}
43
    else if (CurFra != 1)
44
    {
45
      FrameHome();
46
    }
47
  }
48
  else if(PIND & (1<<PD3))        //PCINT27 - Makes the Display darker
49
  {
50
    if (PWM_G == 255)
51
    {
52
      OCR1A = 127;
53
      PWM_G = 127;
54
    }
55
    else if (PWM_G == 127)
56
    {
57
      OCR1A = 63;
58
      PWM_G = 63;
59
    }
60
    else if (PWM_G == 63)
61
    {
62
      OCR1A = 0;
63
      PWM_G = 0;
64
    }
65
  }
66
  
67
  else if(PIND & (1<<PD4))    //PCINT28 - Makes the Display brighter
68
  {
69
    if(PWM_G == 0)
70
    {
71
      OCR1A = 63;
72
      PWM_G = 63;
73
    }
74
    else if(PWM_G == 63)
75
    {
76
      OCR1A = 127;
77
      PWM_G = 127;
78
    }
79
    else if(PWM_G == 127)
80
    {
81
      OCR1A = 255;
82
      PWM_G = 255;
83
    }
84
  }
85
}