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
|
//button
|
||||||
volatile bool buttonPushed = false;
|
volatile bool buttonPushed = false;
|
||||||
volatile int screenBrightness = 15;
|
volatile int screenBrightnessButton = 15;
|
||||||
|
volatile int screenBrightnessCurrent = screenBrightnessButton;
|
||||||
volatile unsigned long lastButtonPush = 0UL;
|
volatile unsigned long lastButtonPush = 0UL;
|
||||||
|
|
||||||
void chageBrightness() {
|
void chageBrightness() {
|
||||||
|
|
@ -67,7 +68,7 @@ void setup() {
|
||||||
Wire.setSDA(16);
|
Wire.setSDA(16);
|
||||||
//Wire.setClock(100000);
|
//Wire.setClock(100000);
|
||||||
disp.begin(DISPLAY_ADDRESS);
|
disp.begin(DISPLAY_ADDRESS);
|
||||||
disp.setBrightness(screenBrightness);
|
disp.setBrightness(screenBrightnessButton);
|
||||||
disp.clear();
|
disp.clear();
|
||||||
disp.writeDigitAscii(0, 71); //"G"
|
disp.writeDigitAscii(0, 71); //"G"
|
||||||
disp.writeDigitAscii(1, 80); //"P"
|
disp.writeDigitAscii(1, 80); //"P"
|
||||||
|
|
@ -92,19 +93,24 @@ void loop() {
|
||||||
|
|
||||||
//change brightness
|
//change brightness
|
||||||
if (buttonPushed == true) {
|
if (buttonPushed == true) {
|
||||||
if (screenBrightness == 15) {
|
if (screenBrightnessButton == 15) {
|
||||||
screenBrightness = MIDDLE_SCREEN_BRIGHTNESS;
|
screenBrightnessButton = MIDDLE_SCREEN_BRIGHTNESS;
|
||||||
} else if (screenBrightness == MIDDLE_SCREEN_BRIGHTNESS) {
|
} else if (screenBrightnessButton == MIDDLE_SCREEN_BRIGHTNESS) {
|
||||||
screenBrightness = 0;
|
screenBrightnessButton = 0;
|
||||||
} else {
|
} else {
|
||||||
screenBrightness = 15;
|
screenBrightnessButton = 15;
|
||||||
}
|
}
|
||||||
disp.setBrightness(screenBrightness);
|
disp.setBrightness(screenBrightnessButton);
|
||||||
|
screenBrightnessCurrent=screenBrightnessButton;
|
||||||
buttonPushed = false;
|
buttonPushed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
disp.clear();
|
disp.clear();
|
||||||
if (gpsFixType.load() > 0) {
|
if (gpsFixType.load() > 0) {
|
||||||
|
if (screenBrightnessCurrent != screenBrightnessButton){
|
||||||
|
disp.setBrightness(screenBrightnessButton);
|
||||||
|
screenBrightnessCurrent=screenBrightnessButton;
|
||||||
|
}
|
||||||
timeOfLastFix = millis(); //reset no gps screen display
|
timeOfLastFix = millis(); //reset no gps screen display
|
||||||
int temp = speed.load() * 10;
|
int temp = speed.load() * 10;
|
||||||
//int temp = rand();
|
//int temp = rand();
|
||||||
|
|
@ -122,6 +128,10 @@ void loop() {
|
||||||
disp.writeDigitAscii(2, 48 + digit2, true);
|
disp.writeDigitAscii(2, 48 + digit2, true);
|
||||||
disp.writeDigitAscii(3, 48 + digit3);
|
disp.writeDigitAscii(3, 48 + digit3);
|
||||||
} else {
|
} else {
|
||||||
|
if (screenBrightnessCurrent!=0){
|
||||||
|
disp.setBrightness(0);
|
||||||
|
screenBrightnessCurrent=0;
|
||||||
|
}
|
||||||
unsigned long currentTime = millis();
|
unsigned long currentTime = millis();
|
||||||
unsigned long timeSinceLastFIx = timeOfLastFix - currentTime;
|
unsigned long timeSinceLastFIx = timeOfLastFix - currentTime;
|
||||||
int flashStage = timeSinceLastFIx % 3000;
|
int flashStage = timeSinceLastFIx % 3000;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue