Subversion Repositories Projects

Rev

Rev 297 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 297 Rev 303
Line 15... Line 15...
15
#include "ubx.h"
15
#include "ubx.h"
16
#include "button.h"
16
#include "button.h"
Line 17... Line 17...
17
 
17
 
18
#ifdef USE_FOLLOWME
18
#ifdef USE_FOLLOWME
-
 
19
int16_t UBat = 120;
-
 
20
int16_t Zellenzahl = 0;
-
 
21
int16_t PowerOn = 0;
-
 
22
int16_t i = 0;
19
int16_t UBat = 120;
23
int16_t delay = 0;
Line 20... Line 24...
20
#endif
24
#endif
Line 65... Line 69...
65
        printf("\r\n------------------------------");
69
        printf("\r\n------------------------------");
66
        printf("\r\n");
70
        printf("\r\n");
Line 67... Line 71...
67
 
71
 
68
 
72
 
69
        #ifdef USE_FOLLOWME
73
        #ifdef USE_FOLLOWME
Line 70... Line 74...
70
        BeepTime = 2000;
74
        //BeepTime = 2000;
Line 71... Line 75...
71
        #endif
75
        #endif
72
 
76
 
73
    LCD_Clear();
77
    LCD_Clear();
74
 
78
 
75
        GPS_Timer = SetDelay(1000);
79
        GPS_Timer = SetDelay(1000);
76
        while (1)
80
        while (1)
77
        {
81
        {
78
                // check for button action
82
                // check for button action
Line 79... Line 83...
79
                if(GetButton())
83
                if(GetButton())
Line 80... Line 84...
80
                {
84
                {
Line 101... Line 105...
101
                        // because of the silicon diode inbetween.
105
                        // because of the silicon diode inbetween.
102
                        // voltage divider R2=10K, R3=3K9
106
                        // voltage divider R2=10K, R3=3K9
103
                        // UAdc4 = R3/(R3+R2)*UBat= 3.9/(3.9+10)*UBat = UBat/3.564
107
                        // UAdc4 = R3/(R3+R2)*UBat= 3.9/(3.9+10)*UBat = UBat/3.564
104
                        UBat = (3 * UBat + (64 * Adc4) / 368) / 4;
108
                        UBat = (3 * UBat + (64 * Adc4) / 368) / 4;
105
                        DebugOut.Analog[8] = UBat;
109
                        DebugOut.Analog[8] = UBat;
-
 
110
                       
-
 
111
                        // check for zellenzahl
-
 
112
                        if(PowerOn < 100)
-
 
113
                        {
-
 
114
                                if(UBat<=84) Zellenzahl = 2;
-
 
115
                                else Zellenzahl = 3;
-
 
116
                                PowerOn++;
-
 
117
                        }
-
 
118
                        DebugOut.Analog[16] = Zellenzahl;
-
 
119
                        DebugOut.Analog[17] = PowerOn;
-
 
120
                       
-
 
121
                        //show recognised Zellenzahl to user
-
 
122
                        if(i < Zellenzahl && PowerOn >= 100 && BeepTime == 0 && delay > 1000)
-
 
123
                        {
-
 
124
                                BeepTime = 100;
-
 
125
                                i++;
-
 
126
                                delay = 0;
-
 
127
                        }
-
 
128
                        if(delay < 1500) delay++;
-
 
129
                       
-
 
130
                        // monitor battery undervoltage
-
 
131
                        if(UBat < Zellenzahl * 31 && PowerOn >= 100) BeepTime = 200;
106
                        #endif
132
                        #endif
107
                        ADReady = 0;
133
                        ADReady = 0;
108
                        ADC_Enable(); // restart ad conversion sequence
134
                        ADC_Enable(); // restart ad conversion sequence
109
                }
135
                }