Allow disabling the slider and fixing the brightness via the Makefile

Use make FIXED_BRIGHTNESS=x, whereas x is between 0...15
This commit is contained in:
d0k3 2017-10-20 17:36:30 +02:00
parent 39b76ef5fc
commit d9ae07bd2b
3 changed files with 6 additions and 4 deletions

View File

@ -64,8 +64,8 @@ ifeq ($(SWITCH_SCREENS),1)
CFLAGS += -DSWITCH_SCREENS CFLAGS += -DSWITCH_SCREENS
endif endif
ifeq ($(DISABLE_SLIDER),1) ifdef FIXED_BRIGHTNESS
CFLAGS += -DDISABLE_SLIDER CFLAGS += -DFIXED_BRIGHTNESS=$(FIXED_BRIGHTNESS)
endif endif
ifneq ("$(wildcard $(CURDIR)/../$(DATA)/README.md)","") ifneq ("$(wildcard $(CURDIR)/../$(DATA)/README.md)","")

View File

@ -24,9 +24,7 @@ u32 InputWait(u32 timeout_sec) {
return sd_state ? SD_INSERT : SD_EJECT; return sd_state ? SD_INSERT : SD_EJECT;
u8 special_key; u8 special_key;
if ((timer_msec(timer_mcu) >= 64) && (I2C_readRegBuf(I2C_DEV_MCU, 0x10, &special_key, 1))) { if ((timer_msec(timer_mcu) >= 64) && (I2C_readRegBuf(I2C_DEV_MCU, 0x10, &special_key, 1))) {
#ifndef DISABLE_SLIDER
CheckBrightness(); CheckBrightness();
#endif
if (special_key == 0x01) if (special_key == 0x01)
return pad_state | BUTTON_POWER; return pad_state | BUTTON_POWER;
else if (special_key == 0x04) else if (special_key == 0x04)

View File

@ -7,9 +7,13 @@ static const u8 br_settings[] = {0x10, 0x17, 0x1E, 0x25, 0x2C, 0x34, 0x3C, 0x44,
static int prev_brightness = -1; static int prev_brightness = -1;
void CheckBrightness() { void CheckBrightness() {
u8 curSlider; u8 curSlider;
#ifndef FIXED_BRIGHTNESS
I2C_readRegBuf(I2C_DEV_MCU, 0x09, &curSlider, 1); I2C_readRegBuf(I2C_DEV_MCU, 0x09, &curSlider, 1);
// Volume Slider value is always between 0x00 and 0x3F // Volume Slider value is always between 0x00 and 0x3F
curSlider >>= 2; curSlider >>= 2;
#else
curSlider = FIXED_BRIGHTNESS;
#endif
if (curSlider != prev_brightness) { if (curSlider != prev_brightness) {
PXI_DoCMD(PXI_BRIGHTNESS, (u32[]){br_settings[curSlider]}, 1); PXI_DoCMD(PXI_BRIGHTNESS, (u32[]){br_settings[curSlider]}, 1);
prev_brightness = curSlider; prev_brightness = curSlider;