Skip to content

Commit

Permalink
Merge branch 'hd-zero:main' into low-band
Browse files Browse the repository at this point in the history
  • Loading branch information
ligenxxxx authored Jul 31, 2023
2 parents a23798e + ab9d7c1 commit a9e8a1a
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 9 deletions.
6 changes: 4 additions & 2 deletions src/core/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ static void device_init(void) {
TP2825_Config(0, 0);
DM5680_req_ver();
fans_top_setspeed(g_setting.fans.top_speed);
DM5680_Power_AnalogModule(g_setting.power.power_ana);
}

void lvgl_init() {
Expand Down Expand Up @@ -188,7 +187,10 @@ int main(int argc, char *argv[]) {

// 8. Synthetic counter for gif refresh
gif_cnt = 0;


// 8.1 set initial analog module power state
Analog_Module_Power(0);

// 10. Execute main loop
g_init_done = 1;
for (;;) {
Expand Down
24 changes: 24 additions & 0 deletions src/driver/hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@

#include <log/log.h>

#include "../core/app_state.h"
#include "../core/common.hh"
#include "../core/osd.h"
#include "../core/settings.h"
#include "../ui/page_common.h"
#include "TP2825.h"
#include "beep.h"
#include "defines.h"
#include "dm5680.h"
#include "dm6302.h"
Expand Down Expand Up @@ -593,6 +595,28 @@ void Set_HT_dat(uint16_t ch0, uint16_t ch1, uint16_t ch2) {
I2C_Write(ADDR_FPGA, 0x77, (ch2 >> 8) & 0xff);
}

void Analog_Module_Power(bool ForceSet) {
// Batch 2 goggles only
if (getHwRevision() >= HW_REV_2) {
static bool Analog_Module_Power_State = 0;
static bool Analog_Module_Power_State_Last = 0;
if (g_setting.power.power_ana == 0) {
Analog_Module_Power_State = 0;
} else {
if (g_source_info.source != SOURCE_EXPANSION) {
Analog_Module_Power_State = 1;
} else {
Analog_Module_Power_State = 0;
}
}
if ((Analog_Module_Power_State_Last != Analog_Module_Power_State) || (ForceSet == 1)) {
beep();
Analog_Module_Power_State_Last = Analog_Module_Power_State;
DM5680_Power_AnalogModule(Analog_Module_Power_State);
}
}
}

int Get_VideoLatancy_status() // ret: 0=unlocked, 1=locked
{
uint8_t rdat = 0;
Expand Down
2 changes: 2 additions & 0 deletions src/driver/hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void Set_Saturation(uint8_t sat);
void Set_HT_status(uint8_t is_open, uint8_t frame_period, uint8_t sync_len);
void Set_HT_dat(uint16_t ch0, uint16_t ch1, uint16_t ch2);

void Analog_Module_Power(bool Force);

int HDZERO_detect();
int AV_in_detect();
void HDMI_in_detect();
Expand Down
7 changes: 4 additions & 3 deletions src/ui/page_power.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "core/common.hh"
#include "core/settings.h"
#include "driver/dm5680.h"
#include "driver/hardware.h"
#include "driver/mcp3021.h"
#include "page_common.h"
#include "ui/ui_style.h"
Expand Down Expand Up @@ -98,7 +99,7 @@ static lv_obj_t *page_power_create(lv_obj_t *parent, panel_arr_t *arr) {

// Batch 2 goggles only
if (getHwRevision() >= HW_REV_2) {
create_btn_group_item(&btn_group_power_ana, cont, 2, "AnalogRX Power", "On", "Off", "", "", ROW_POWER_ANA);
create_btn_group_item(&btn_group_power_ana, cont, 2, "AnalogRX Power", "On", "Auto", "", "", ROW_POWER_ANA);
}

// Back entry
Expand Down Expand Up @@ -248,7 +249,7 @@ static void page_power_on_click(uint8_t key, int sel) {
btn_group_toggle_sel(&btn_group_power_ana);
g_setting.power.power_ana = btn_group_get_sel(&btn_group_power_ana);
ini_putl("power", "power_ana_rx", g_setting.power.power_ana, SETTING_INI);
DM5680_Power_AnalogModule(g_setting.power.power_ana);
Analog_Module_Power(1);
}
break;

Expand All @@ -269,4 +270,4 @@ page_pack_t pp_power = {
.on_roller = NULL,
.on_click = page_power_on_click,
.on_right_button = NULL,
};
};
6 changes: 2 additions & 4 deletions src/ui/page_sleep.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,8 @@ static void page_sleep_enter() {
static void page_sleep_exit() {
LOGI("page_sleep_exit");
OLED_ON(1); // Turn on OLED
if (getHwRevision() >= HW_REV_2) {
DM5680_Power_AnalogModule(g_setting.power.power_ana);
}

Analog_Module_Power(1);

g_setting.fans.top_speed = fan_speed_save.top;
g_setting.fans.left_speed = fan_speed_save.left;
g_setting.fans.right_speed = fan_speed_save.right;
Expand Down
1 change: 1 addition & 0 deletions src/ui/page_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ static void page_source_on_click(uint8_t key, int sel) {
break;
}
}
Analog_Module_Power(0);
}

static void page_source_enter() {
Expand Down

0 comments on commit a9e8a1a

Please sign in to comment.