Make backlight and lcd-state config vars actually work

This commit is contained in:
Stefan `Sec` Zehl 2011-07-27 01:15:52 +02:00
parent 477dfcf98a
commit 250ea3213f
6 changed files with 13 additions and 15 deletions

View File

@ -39,7 +39,7 @@ void tick_default(void) {
}; };
if(isNight()) if(isNight())
backlightSetBrightness(100); backlightSetBrightness(globalconfig.backlightvalue);
else else
backlightSetBrightness(0); backlightSetBrightness(0);

View File

@ -3,6 +3,7 @@
#include "basic/basic.h" #include "basic/basic.h"
#include "lcd/print.h" #include "lcd/print.h"
#include "lcd/display.h"
#include "filesystem/ff.h" #include "filesystem/ff.h"
@ -33,5 +34,5 @@ void show(void){
}; };
void lcdmirror(void){ void lcdmirror(void){
globalconfig.lcdstate^=2; lcdToggleFlag(LCD_MIRRORX);
}; };

View File

@ -33,10 +33,11 @@ void adc_light(void) {
int dx=0; int dx=0;
int dy=8; int dy=8;
dx=DoString(0,dy,"Light:"); dx=DoString(0,dy,"Light:");
DoString(0,dy+8,"Night:"); DoString(0,dy+16,"Night:");
while ((getInputRaw())==BTN_NONE){ while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetLight()); DoInt(dx,dy,GetLight());
DoInt(dx,dy+8,isNight()); DoInt(dx,dy+16,isNight());
DoInt(dx,dy+8,globalconfig.backlighttrigger);
lcdDisplay(); lcdDisplay();
}; };
dy+=8; dy+=8;

View File

@ -77,9 +77,5 @@ int readConfig(void){
}; };
int applyConfig(){ int applyConfig(){
if(globalconfig.lcdstate & LCD_INVERTED)
lcdToggleFlag(LCD_INVERTED);
if(globalconfig.lcdstate & LCD_MIRRORX)
lcdToggleFlag(LCD_MIRRORX);
return 0; return 0;
}; };

View File

@ -7,6 +7,8 @@
uint32_t light=300*HYST; uint32_t light=300*HYST;
char _isnight=1; char _isnight=1;
#define threshold globalconfig.backlighttrigger
void LightCheck(void){ void LightCheck(void){
int iocon; int iocon;
char iodir; char iodir;
@ -25,16 +27,14 @@ void LightCheck(void){
gpioSetDir(RB_LED3, iodir); gpioSetDir(RB_LED3, iodir);
IOCON_PIO1_11=iocon; IOCON_PIO1_11=iocon;
static uint16_t threshold=0; if(threshold==0){ // uninitialized?
if(threshold==0){ threshold=320;
// read threshold from config
threshold=320 * HYST;
}; };
if(_isnight && light>(threshold+RANGE*HYST)) if(_isnight && light/HYST>(threshold+RANGE))
_isnight=0; _isnight=0;
if(!_isnight && light<threshold) if(!_isnight && light/HYST<threshold)
_isnight=1; _isnight=1;
}; };

View File

@ -13,7 +13,7 @@
/**************************************************************************/ /**************************************************************************/
uint8_t lcdBuffer[RESX*RESY_B]; uint8_t lcdBuffer[RESX*RESY_B];
int lcd_layout = 0; #define lcd_layout globalconfig.lcdstate
uint32_t intstatus; // Caches USB interrupt state uint32_t intstatus; // Caches USB interrupt state
// (need to disable MSC while displaying) // (need to disable MSC while displaying)