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())
backlightSetBrightness(100);
backlightSetBrightness(globalconfig.backlightvalue);
else
backlightSetBrightness(0);

View File

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

View File

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

View File

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

View File

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

View File

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