Skip to content

Commit

Permalink
Merge branch 'main' into 20231116_EMUF_font_variant
Browse files Browse the repository at this point in the history
  • Loading branch information
nerdCopter committed Dec 6, 2023
2 parents f14b979 + 0f8cabf commit 633bc73
Show file tree
Hide file tree
Showing 122 changed files with 1,394 additions and 344 deletions.
8 changes: 8 additions & 0 deletions mkapp/app/setting.ini
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,14 @@ enable=false
[elrs]
enable=false

[inputs]
roller=0
left_click=0
left_press=1
right_click=2
right_press=6
right_double_click=3

[wifi]
enable=false
ap_ssid=HDZero
Expand Down
12 changes: 9 additions & 3 deletions src/bmi270/accel_gyro.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#ifndef _ACCEL_GYRO_H
#define _ACCEL_GYRO_H
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "bmi2_defs.h"

void init_bmi270();
Expand All @@ -16,4 +20,6 @@ float acc_to_g(int16_t val);

float gyr_to_dps(int16_t gyr);

#endif //_ACCEL_GYRO_H
#ifdef __cplusplus
}
#endif
5 changes: 1 addition & 4 deletions src/bmi270/bmi2.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
* @brief Sensor driver for BMI2 sensor
*/

#ifndef BMI2_H_
#define BMI2_H_
#pragma once

/*! CPP guard */
#ifdef __cplusplus
Expand Down Expand Up @@ -1481,5 +1480,3 @@ int8_t bmi2_get_feat_config(uint8_t sw_page, uint8_t *feat_config, struct bmi2_d
#ifdef __cplusplus
}
#endif /* End of CPP guard */

#endif /* BMI2_H_ */
5 changes: 1 addition & 4 deletions src/bmi270/bmi270.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@
* @brief Sensor driver for BMI270 sensor
*/

#ifndef BMI270_H_
#define BMI270_H_
#pragma once

/*! CPP guard */
#ifdef __cplusplus
Expand Down Expand Up @@ -416,5 +415,3 @@ int8_t bmi270_map_feat_int(const struct bmi2_sens_int_config *sens_int, uint8_t
#ifdef __cplusplus
}
#endif /* End of CPP guard */

#endif /* BMI270_H_ */
6 changes: 1 addition & 5 deletions src/bmi270/bmi2_defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@
*
*/

#ifndef BMI2_DEFS_H_
#define BMI2_DEFS_H_

#pragma once
/******************************************************************************/
/*! @name Header includes */
/******************************************************************************/
Expand Down Expand Up @@ -2654,5 +2652,3 @@ struct bmi2_hc_act_recg_sett
/*! Minimum segments belonging to a certain activity type */
uint16_t min_seg_conf;
};

#endif /* BMI2_DEFS_H_ */
11 changes: 8 additions & 3 deletions src/bmi270/common.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef _COMMON_H
#define _COMMON_H
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdio.h>
#include "bmi2.h"
Expand Down Expand Up @@ -103,4 +106,6 @@ void bmi2_error_codes_print_result(int8_t rslt);
* @return void.
*/

#endif /* _COMMON_H */
#ifdef __cplusplus
}
#endif
10 changes: 8 additions & 2 deletions src/core/MadgwickAHRS.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,11 @@
// 02/10/2011 SOH Madgwick Optimised for reduced CPU load
//
//=====================================================================================================
#ifndef MadgwickAHRS_h
#define MadgwickAHRS_h
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#define AHRS_UPDATE_FREQUENCY 100

Expand All @@ -23,7 +26,10 @@ float getRoll();
float getPitch();
float getYaw();

#ifdef __cplusplus
}
#endif

//=====================================================================================================
// End of file
//=====================================================================================================
10 changes: 9 additions & 1 deletion src/core/app_state.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>

typedef enum {
Expand Down Expand Up @@ -35,4 +39,8 @@ void app_switch_to_menu();
void app_exit_menu();
void app_switch_to_analog(bool is_bay);
void app_switch_to_hdmi_in();
void app_switch_to_hdzero(bool is_default);
void app_switch_to_hdzero(bool is_default);

#ifdef __cplusplus
}
#endif
10 changes: 9 additions & 1 deletion src/core/battery.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>

Expand All @@ -19,4 +23,8 @@ void battery_update();

bool battery_is_low();
int battery_get_millivolts(bool per_cell);
void battery_get_voltage_str(char* buf);
void battery_get_voltage_str(char* buf);

#ifdef __cplusplus
}
#endif
13 changes: 10 additions & 3 deletions src/core/common.hh
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef __COMMON_HH__
#define __COMMON_HH__
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <pthread.h>
#include <stdatomic.h>
Expand Down Expand Up @@ -27,8 +30,12 @@ hw_revision_t getHwRevision();
#define RIGHT_KEY_CLICK 5
#define RIGHT_KEY_PRESS 6

#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0]))

extern atomic_int g_key;
extern atomic_int g_init_done;
extern pthread_mutex_t lvgl_mutex;

#endif //__COMMON_HH__
#ifdef __cplusplus
}
#endif
4 changes: 4 additions & 0 deletions src/core/dvr.c
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ void dvr_update_vi_conf(video_resolution_t fmt) {
LOGI("update_record_vi_conf: fmt=%d", fmt);
}

void dvr_toggle() {
dvr_cmd(DVR_TOGGLE);
}

static void dvr_update_record_conf() {
LOGI("CAM_MODE=%d", CAM_MODE);
if (g_setting.record.format_ts)
Expand Down
11 changes: 10 additions & 1 deletion src/core/dvr.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>

Expand All @@ -17,4 +21,9 @@ void dvr_update_status();
void dvr_select_audio_source(uint8_t audio_source);
void dvr_enable_line_out(bool enable);
void dvr_cmd(osd_dvr_cmd_t cmd);
void dvr_update_vi_conf(video_resolution_t fmt);
void dvr_update_vi_conf(video_resolution_t fmt);
void dvr_toggle();

#ifdef __cplusplus
}
#endif
11 changes: 8 additions & 3 deletions src/core/elrs.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef __ELRS_H__
#define __ELRS_H__
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include <stdbool.h>
#include <stdint.h>
Expand Down Expand Up @@ -82,4 +85,6 @@ void msp_cancel_await();
void msp_ht_update(uint16_t pan, uint16_t tilt, uint16_t roll);
void msp_channel_update();

#endif //__ELRS_H__
#ifdef __cplusplus
}
#endif
11 changes: 8 additions & 3 deletions src/core/esp32_flash.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
#ifndef __ESP32_FLASH_H__
#define __ESP32_FLASH_H__
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "serial_io.h"
#include <stdint.h>

esp_loader_error_t loader_port_init();
void loader_port_close();

#endif //__ESP32_FLASH_H__
#ifdef __cplusplus
}
#endif
11 changes: 8 additions & 3 deletions src/core/ht.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#ifndef __HT_C__
#define __HT_C__
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#define DEG_TO_RAD 0.017453295199
#define RAD_TO_DEG 57.29577951308
Expand Down Expand Up @@ -55,4 +58,6 @@ void ht_set_maxangle(int angle);
void ht_set_center_position();
int16_t *ht_get_channels();

#endif //__HT_C__
#ifdef __cplusplus
}
#endif
49 changes: 28 additions & 21 deletions src/core/input_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,6 @@ void tune_channel(uint8_t action) {
tune_timer = TUNER_TIMER_LEN;
tune_state = 2;
channel = g_setting.scan.channel;
} else if (action == DIAL_KEY_CLICK) {
g_setting.osd.is_visible = !g_setting.osd.is_visible;
if (g_setting.osd.is_visible)
channel_osd_mode = CHANNEL_SHOWTIME;

settings_put_bool("osd", "is_visible", g_setting.osd.is_visible);
}
}

Expand Down Expand Up @@ -136,6 +130,12 @@ void tune_channel(uint8_t action) {
tune_timer = TUNER_TIMER_LEN;
}

void tune_channel_confirm() {
if (g_source_info.source == SOURCE_HDZERO) {
tune_channel(DIAL_KEY_CLICK);
}
}

void tune_channel_timer() {
if (tune_state == 2) {
if (!tune_timer)
Expand All @@ -157,6 +157,15 @@ void tune_channel_timer() {
static int roller_up_acc = 0;
static int roller_down_acc = 0;

void (*btn_click_callback)() = &osd_toggle;
void (*btn_press_callback)() = &app_switch_to_menu;

void (*rbtn_click_callback)() = &dvr_toggle;
void (*rbtn_press_callback)() = &step_topfan;
void (*rbtn_double_click_callback)() = &ht_set_center_position;

void (*roller_callback)(uint8_t key) = &tune_channel;

static void btn_press(void) // long press left key
{
LOGI("btn_press (%d)", g_app_state);
Expand All @@ -177,7 +186,7 @@ static void btn_press(void) // long press left key
if (tune_timer && g_source_info.source == SOURCE_HDZERO)
tune_channel(DIAL_KEY_PRESS);
else
app_switch_to_menu();
(*btn_press_callback)();
} else if (g_app_state == APP_STATE_OSD_ELEMENT_PREV) {
ui_osd_element_pos_cancel_and_hide();
app_switch_to_menu();
Expand All @@ -204,7 +213,11 @@ static void btn_click(void) // short press enter key

if (g_app_state == APP_STATE_VIDEO) {
pthread_mutex_lock(&lvgl_mutex);
tune_channel(DIAL_KEY_CLICK);
if (tune_state == 2) {
tune_channel_confirm();
} else {
(*btn_click_callback)();
}
pthread_mutex_unlock(&lvgl_mutex);
return;
} else if (g_app_state == APP_STATE_IMS) {
Expand Down Expand Up @@ -263,19 +276,15 @@ void rbtn_click(right_button_t click_type) {
pthread_mutex_unlock(&lvgl_mutex);
break;
case APP_STATE_VIDEO:
pthread_mutex_lock(&lvgl_mutex);
if (click_type == RIGHT_CLICK) {
dvr_cmd(DVR_TOGGLE);
(*rbtn_click_callback)();
} else if (click_type == RIGHT_LONG_PRESS) {
pthread_mutex_lock(&lvgl_mutex);
step_topfan();
pthread_mutex_unlock(&lvgl_mutex);
(*rbtn_press_callback)();
} else if (click_type == RIGHT_DOUBLE_CLICK) {
if (g_setting.ht.enable == true) {
ht_set_center_position();
} else {
go_sleep();
}
(*rbtn_double_click_callback)();
}
pthread_mutex_unlock(&lvgl_mutex);
break;
case APP_STATE_SLEEP:
wake_up();
Expand Down Expand Up @@ -307,8 +316,7 @@ static void roller_up(void) {
} else if ((g_app_state == APP_STATE_SUBMENU_ITEM_FOCUSED)) {
submenu_roller_no_selection_change(DIAL_KEY_UP);
} else if (g_app_state == APP_STATE_VIDEO) {
if (g_source_info.source == SOURCE_HDZERO)
tune_channel(DIAL_KEY_UP);
(*roller_callback)(DIAL_KEY_UP);
} else if (g_app_state == APP_STATE_IMS) {
ims_key(DIAL_KEY_UP);
} else if (g_app_state == APP_STATE_OSD_ELEMENT_PREV) {
Expand Down Expand Up @@ -342,8 +350,7 @@ static void roller_down(void) {
} else if ((g_app_state == APP_STATE_SUBMENU_ITEM_FOCUSED)) {
submenu_roller_no_selection_change(DIAL_KEY_DOWN);
} else if (g_app_state == APP_STATE_VIDEO) {
if (g_source_info.source == SOURCE_HDZERO)
tune_channel(DIAL_KEY_DOWN);
(*roller_callback)(DIAL_KEY_DOWN);
} else if (g_app_state == APP_STATE_IMS) {
ims_key(DIAL_KEY_DOWN);
} else if (g_app_state == APP_STATE_OSD_ELEMENT_PREV) {
Expand Down
Loading

0 comments on commit 633bc73

Please sign in to comment.