Skip to content

Commit

Permalink
add option to adjust display clock +-2%
Browse files Browse the repository at this point in the history
  • Loading branch information
iltis42 committed Jun 12, 2024
1 parent e71c9b3 commit 0e30066
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 4 deletions.
3 changes: 2 additions & 1 deletion main/AdaptUGC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ void AdaptUGC::begin() {
ili9341_config.page_address = ILI9341_PAGE_ADDRESS_BOTTOM_TO_TOP;
ili9341_config.colum_address = ILI9341_COLUMN_ADDRESS_RIGHT_TO_LEFT;
}
ESP_LOGI(FNAME, "eglib_Send() &eglib:%x hal-driv:%x config:%x\n", (unsigned int)eglib, (unsigned int)&esp32_ili9341, (unsigned int)&esp32_ili9341_config );
esp32_ili9341_config.freq = rint( FREQ_BMP_SPI * 3 * ((100.0 + display_clock_adj.get())/100.0));
ESP_LOGI(FNAME, "eglib_Send() &eglib:%x hal-driv:%x config:%x clk:%.3f MHz\n", (unsigned int)eglib, (unsigned int)&esp32_ili9341, (unsigned int)&esp32_ili9341_config, (double)(esp32_ili9341_config.freq/1000000.0) );
eglib_Init( &myeglib, &esp32_ili9341, &esp32_ili9341_config, &ili9341, &ili9341_config );
setClipRange( 0,0, 240, 320 );
};
Expand Down
2 changes: 2 additions & 0 deletions main/AdaptUGC.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ extern "C" {

#pragma once

#define FREQ_BMP_SPI 13111111 // *3 for SPI display clock, /2 for BMP pressure sensor clock

// later we want to get rid of UGC, so lets add all needed API definitions here

typedef struct _ucg_color_t
Expand Down
5 changes: 5 additions & 0 deletions main/SetupMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1722,6 +1722,11 @@ void SetupMenu::system_menu_create_hardware_type( MenuEntry *top ){
dtest->setHelp( "Start display test screens, press rotary to cancel");
dtest->addEntry( "Cancel");
dtest->addEntry( "Start Test");

SetupMenuValFloat * dcadj= new SetupMenuValFloat( "Display Clk Adj", "%", -2, 2, 0.1, 0, true, &display_clock_adj, RST_IMMEDIATE );
dcadj->setHelp( "Modify display clock by given percentage (restarts on exit)", 100 );
top->addEntry( dcadj );

}


Expand Down
1 change: 1 addition & 0 deletions main/SetupNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ SetupNG<int> gear_warning("GEARWA", 0 );
SetupNG<t_wireless_id> custom_wireless_id("WLID", t_wireless_id("") );
SetupNG<int> drawing_prio("DRAWP", DP_NEEDLE );
SetupNG<int> logging("LOGGING", LOG_DISABLE );
SetupNG<float> display_clock_adj("DSCLADHJ", 0 );

static mpud::raw_axes_t zero_bias;
SetupNG<float> glider_ground_aa("GLD_GND_AA", 12.0, true, SYNC_FROM_MASTER);
Expand Down
1 change: 1 addition & 0 deletions main/SetupNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ extern SetupNG<int> drawing_prio;
extern uint8_t g_col_background;
extern uint8_t g_col_highlight;
extern SetupNG<int> logging;
extern SetupNG<float> display_clock_adj;


extern float last_volume; // is this used?
Expand Down
7 changes: 4 additions & 3 deletions main/sensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@

#define CS_bme280BA GPIO_NUM_26 // before CS pin 33
#define CS_bme280TE GPIO_NUM_33 // before CS pin 26
#define FREQ_BMP_SPI 13111111/2

#define SPL06_007_BARO 0x77
#define SPL06_007_TE 0x76

Expand Down Expand Up @@ -1224,8 +1224,9 @@ void system_startup(void *args){
ESP_LOGI(FNAME,"No SPL06_007 chip detected, now check BMP280");
BME280_ESP32_SPI *bmpBA = new BME280_ESP32_SPI();
BME280_ESP32_SPI *bmpTE= new BME280_ESP32_SPI();
bmpBA->setSPIBus(SPI_SCLK, SPI_MOSI, SPI_MISO, CS_bme280BA, FREQ_BMP_SPI);
bmpTE->setSPIBus(SPI_SCLK, SPI_MOSI, SPI_MISO, CS_bme280TE, FREQ_BMP_SPI);
int spi_freq=rint( FREQ_BMP_SPI / 2 * ((100.0 + display_clock_adj.get())/100.0));
bmpBA->setSPIBus(SPI_SCLK, SPI_MOSI, SPI_MISO, CS_bme280BA, spi_freq);
bmpTE->setSPIBus(SPI_SCLK, SPI_MOSI, SPI_MISO, CS_bme280TE, spi_freq);
bmpTE->begin();
bmpBA->begin();
baroSensor = bmpBA;
Expand Down

0 comments on commit 0e30066

Please sign in to comment.