Rev 3021 Rev 3023
Line 3... Line 3...
3 #define LED1 PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 3 #define LED1 PIN_C6 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
4 #define LED2 PIN_C5 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 4 #define LED2 PIN_C5 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5
5 #define LED3 PIN_C4 //CHANGE PIN_XX TO YOUR LED PIN NUMBER 5 #define LED3 PIN_C4 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
6 #define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER 6 #define LED4 PIN_D3 //CHANGE PIN_XX TO YOUR LED PIN NUMBER
7   7  
8 #define S1 PIN_B0 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 8 #define S1 PIN_B0 //Raw up
9 #define S2 PIN_B1 //CHANGE PIN_XX TO YOUR LED PIN NUMBER, EX: PIN_A5 9 #define S2 PIN_B1 //Raw down
10 #define S3 PIN_D0 //CHANGE PIN_XX TO YOUR LED PIN NUMBER 10 #define S3 PIN_D0 //Fine up
11 #define S4 PIN_D1 //CHANGE PIN_XX TO YOUR LED PIN NUMBER 11 #define S4 PIN_D1 //Fine down
12   12  
13 #define BEEP PIN_D2 //piezo beeper 13 #define BEEP PIN_D2 //piezo beeper
14   14  
15 #define LCD_ENABLE_PIN PIN_E0 //// 15 #define LCD_ENABLE_PIN PIN_E0 ////
16 #define LCD_RS_PIN PIN_E1 //// 16 #define LCD_RS_PIN PIN_E1 ////
Line 19... Line 19...
19 #define LCD_DATA5 PIN_D5 //// 19 #define LCD_DATA5 PIN_D5 ////
20 #define LCD_DATA6 PIN_D6 //// 20 #define LCD_DATA6 PIN_D6 ////
21 #define LCD_DATA7 PIN_D7 21 #define LCD_DATA7 PIN_D7
22 #include <lcd.c> 22 #include <lcd.c>
23   23  
-   24 #define OUTPUT_ENABLE PIN_C1
-   25  
24 void sound_beep( unsigned int lenght, int16 frequency) 26 void sound_beep( unsigned int lenght, int16 frequency)
25 { 27 {
26 unsigned int i; 28 unsigned int i;
27 29
28 for(i=0;i<=lenght;i++) 30 for(i=0;i<=lenght;i++)
Line 73... Line 75...
73 { 75 {
74 76
75 set_adc_channel(1); 77 set_adc_channel(1);
76 delay_us(100); 78 delay_us(100);
77 napeti = (napeti+read_adc())/2; 79 napeti = (napeti+read_adc())/2;
78   -  
79 if (napeti <= setpoint) 80 if(input(OUTPUT_ENABLE))
80 { 81 {
-   82 if (napeti <= setpoint)
-   83 {
81 if (plneni < 300) plneni++; 84 if (plneni < 300) plneni++;
82 output_low(LED2); 85 output_low(LED2);
-   86 }
-   87 else
-   88 {
-   89 if (plneni > 0) plneni--;
-   90 output_high(LED2);
-   91 }
-   92 set_pwm1_duty(plneni);
-   93 set_pwm2_duty(1023-plneni);
83 } 94 }
84 else 95 else
85 { 96 {
86 if (plneni > 0) plneni--; 97 set_pwm1_duty(0);
87 output_high(LED2); 98 set_pwm2_duty(1023);
88 } 99 }
89 set_pwm1_duty(plneni); -  
90 set_pwm2_duty(1023-plneni); -  
91 100
92 lcd_gotoxy(1,1); 101 lcd_gotoxy(1,1);
93 printf(lcd_putc,"%lu",napeti); 102 printf(lcd_putc,"%4lu",napeti);
94 lcd_gotoxy(1,2); 103 lcd_gotoxy(1,2);
-   104  
95 printf(lcd_putc,"Set:%lu"setpoint); 105 if(input(OUTPUT_ENABLE))printf(lcd_putc,"Set:%lu "setpoint);
-   106 else printf(lcd_putc,"DISABLED");
96   107  
97 if(button_press==false ) // tlacitka se ctou znovu pouze pokud v redchozim cyklu nebyla zmacknuta. 108 if(button_press==false ) // tlacitka se ctou znovu pouze pokud v redchozim cyklu nebyla zmacknuta.
98 { 109 {
99 if(!input(S1)) 110 if(!input(S1))
100 { 111 {