screen dims when searching for gps signal
This commit is contained in:
parent
7d45508899
commit
50b724dabc
1 changed files with 18 additions and 8 deletions
|
|
@ -29,7 +29,8 @@ unsigned long timeOfLastFix = 0UL;
|
|||
|
||||
//button
|
||||
volatile bool buttonPushed = false;
|
||||
volatile int screenBrightness = 15;
|
||||
volatile int screenBrightnessButton = 15;
|
||||
volatile int screenBrightnessCurrent = screenBrightnessButton;
|
||||
volatile unsigned long lastButtonPush = 0UL;
|
||||
|
||||
void chageBrightness() {
|
||||
|
|
@ -67,7 +68,7 @@ void setup() {
|
|||
Wire.setSDA(16);
|
||||
//Wire.setClock(100000);
|
||||
disp.begin(DISPLAY_ADDRESS);
|
||||
disp.setBrightness(screenBrightness);
|
||||
disp.setBrightness(screenBrightnessButton);
|
||||
disp.clear();
|
||||
disp.writeDigitAscii(0, 71); //"G"
|
||||
disp.writeDigitAscii(1, 80); //"P"
|
||||
|
|
@ -92,19 +93,24 @@ void loop() {
|
|||
|
||||
//change brightness
|
||||
if (buttonPushed == true) {
|
||||
if (screenBrightness == 15) {
|
||||
screenBrightness = MIDDLE_SCREEN_BRIGHTNESS;
|
||||
} else if (screenBrightness == MIDDLE_SCREEN_BRIGHTNESS) {
|
||||
screenBrightness = 0;
|
||||
if (screenBrightnessButton == 15) {
|
||||
screenBrightnessButton = MIDDLE_SCREEN_BRIGHTNESS;
|
||||
} else if (screenBrightnessButton == MIDDLE_SCREEN_BRIGHTNESS) {
|
||||
screenBrightnessButton = 0;
|
||||
} else {
|
||||
screenBrightness = 15;
|
||||
screenBrightnessButton = 15;
|
||||
}
|
||||
disp.setBrightness(screenBrightness);
|
||||
disp.setBrightness(screenBrightnessButton);
|
||||
screenBrightnessCurrent=screenBrightnessButton;
|
||||
buttonPushed = false;
|
||||
}
|
||||
|
||||
disp.clear();
|
||||
if (gpsFixType.load() > 0) {
|
||||
if (screenBrightnessCurrent != screenBrightnessButton){
|
||||
disp.setBrightness(screenBrightnessButton);
|
||||
screenBrightnessCurrent=screenBrightnessButton;
|
||||
}
|
||||
timeOfLastFix = millis(); //reset no gps screen display
|
||||
int temp = speed.load() * 10;
|
||||
//int temp = rand();
|
||||
|
|
@ -122,6 +128,10 @@ void loop() {
|
|||
disp.writeDigitAscii(2, 48 + digit2, true);
|
||||
disp.writeDigitAscii(3, 48 + digit3);
|
||||
} else {
|
||||
if (screenBrightnessCurrent!=0){
|
||||
disp.setBrightness(0);
|
||||
screenBrightnessCurrent=0;
|
||||
}
|
||||
unsigned long currentTime = millis();
|
||||
unsigned long timeSinceLastFIx = timeOfLastFix - currentTime;
|
||||
int flashStage = timeSinceLastFIx % 3000;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue