WouoUI/Third-party-design/platform-test/Gui/gui_main.h

185 lines
4.9 KiB
C
Raw Normal View History

#ifndef __GUI_MAIN_H
#define __GUI_MAIN_H
#include "main.h"
#include "stdbool.h"
#include "string.h"
#include "math.h"
//<2F><>Ŀ¼<C4BF><C2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾҳ<CABE><D2B3><EFBFBD>
enum
{
M_WINDOW,
M_CONFIRM_WINDOW,
M_SLEEP,
M_MAIN,
M_EDITOR,
M_KNOB,
M_KRF,
M_KPF,
M_VOLT,
M_COUNT,
M_COUNT_SHOW,
M_RANGING,
M_SETTING,
M_ABOUT,
};
//״̬<D7B4><CCAC><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>ǩ
enum
{
S_FADE, //ת<><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
S_WINDOW, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
S_CONFIRM_WINDOW, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><CABC>
S_LAYER_IN, //<2F><EFBFBD><E3BCB6>ʼ<EFBFBD><CABC>
S_LAYER_OUT, //<2F><EFBFBD><E3BCB6>ʼ<EFBFBD><CABC>
S_NONE, //ֱ<><D6B1>ѡ<EFBFBD><D1A1>ҳ<EFBFBD><D2B3>
};
// <20><><EFBFBD><EFBFBD>ID
enum
{
BTN_ID_CC = 0, // <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ת
BTN_ID_CW = 1, // ˳ʱ<CBB3><CAB1><EFBFBD><EFBFBD>ת
BTN_ID_SP = 2, // <20>̰<EFBFBD>
BTN_ID_LP = 3, // <20><><EFBFBD><EFBFBD>
};
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define BTN_PARAM_TIMES 2 // <20><><EFBFBD><EFBFBD>uint8_t<5F><74><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD>ܲ<EFBFBD><DCB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3A3AC><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
typedef struct
{
uint8_t id;
bool pressed;
}M_BTN_INFO;
//<2F>˵<EFBFBD><CBB5><EFBFBD><E1B9B9>
typedef struct MENU
{
char *m_select;
} M_SELECT;
/************************************* ҳ<><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD> *************************************/
//OLED<45><44><EFBFBD><EFBFBD>
#define DISP_H 64 //<2F><>Ļ<EFBFBD>߶<EFBFBD>
#define DISP_W 128 //<2F><>Ļ<EFBFBD><C4BB><EFBFBD><EFBFBD>
//UI<55><49><EFBFBD><EFBFBD>
#define UI_DEPTH 20 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E3BCB6>
#define UI_MNUMB 50 //<2F>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
// <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
// Ĭ<>ϲ<EFBFBD><CFB2><EFBFBD>
#define LIST_FONT u8g2_font_HelvetiPixel_tr // <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
#define LIST_TEXT_H 8 // <20>б<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߶<C4B8>
#define LIST_LINE_H 16 // <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD>и߶<D0B8>
#define LIST_TEXT_S 4 // <20>б<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ϱ߾࣬<DFBE><E0A3AC><EFBFBD>߾<EFBFBD><DFBE><EFBFBD><EFBFBD>ұ߾࣬<DFBE>±߾<C2B1><DFBE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶Ⱥ<DFB6><C8BA>и߶Ⱦ<DFB6><C8BE><EFBFBD>
#define LIST_BAR_W 5 // <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȣ<EFBFBD><C8A3><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD>м<EFBFBD><D0BC><EFBFBD>1<EFBFBD><31><EFBFBD>ؿ<EFBFBD><D8BF>ȵ<EFBFBD><C8B5><EFBFBD>
#define LIST_BOX_R 0.5 // <20>б<EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD>Բ<EFBFBD><D4B2>
// <20><>խ<EFBFBD>и߶Ȳ<DFB6><C8B2><EFBFBD>
/*
#define LIST_FONT u8g2_font_4x6_tr // <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD>
#define LIST_TEXT_H 5 // <20>б<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ĸ߶<C4B8>
#define LIST_LINE_H 7 // <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD>и߶<D0B8>
#define LIST_TEXT_S 1 // <20>б<EFBFBD>ÿ<EFBFBD><C3BF><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ϱ߾࣬<DFBE><E0A3AC><EFBFBD>߾<E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FBFBD>̰<EFBFBD>ʱ<EFBFBD><CAB1>
BTN_LPT, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
TILE_UFD, //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD>ͷչ<CDB7><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
LIST_UFD, //<2F>˵<EFBFBD><CBB5>б<EFBFBD><D0B1><EFBFBD>ͷչ<CDB7><D5B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
TILE_LOOP, //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>ѭ<EFBFBD><D1AD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
LIST_LOOP, //<2F>˵<EFBFBD><CBB5>б<EFBFBD>ѭ<EFBFBD><D1AD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
WIN_BOK, //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><E9BBAF><EFBFBD><EFBFBD>
KNOB_DIR, //<2F><>ť<EFBFBD><C5A5><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><D0BB><EFBFBD><EFBFBD><EFBFBD>
DARK_MODE, //<2F>ڰ<EFBFBD>ģʽ<C4A3><CABD><EFBFBD><EFBFBD>
UI_PARAM, //16//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
};
typedef struct
{
bool init;
uint8_t num[UI_MNUMB];
uint8_t select[UI_DEPTH];
uint8_t layer;
uint8_t index; // = M_SLEEP;
uint8_t state; // = S_NONE;
bool sleep; // = true;
uint8_t fade; // = 1;
uint8_t param[UI_PARAM];
} M_UI;
typedef struct
{
float title_y_calc; //= TILE_INDI_S + (TILE_INDI_H - TILE_B_TITLE_H) / 2 + TILE_B_TITLE_H * 2;
float title_y_trg_calc; //= TILE_INDI_S + (TILE_INDI_H - TILE_B_TITLE_H) / 2 + TILE_B_TITLE_H;
int16_t temp;
bool select_flag;
float icon_x;
float icon_x_trg;
float icon_y;
float icon_y_trg;
float indi_x;
float indi_x_trg;
float title_y;
float title_y_trg;
} M_TILE;
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
//<2F><><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ҳ<EFBFBD>ʹ<E6B6BC><CAB9>ͬһ<CDAC>ײ<EFBFBD><D7B2><EFBFBD>
#define TILE_B_FONT u8g2_font_helvB18_tr //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TILE_B_TITLE_H 18 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߶<EFBFBD>
#define TILE_ICON_H 30 //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD>߶<EFBFBD>
#define TILE_ICON_W 30 //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TILE_ICON_S 36 //<2F><><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TILE_INDI_H 27 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD>߶<EFBFBD>
#define TILE_INDI_W 7 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
#define TILE_INDI_S 36 //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD>ϱ߾<CFB1>
typedef void (*fun_callback_t)(int number);//<2F><><EFBFBD><EFBFBD><EFBFBD>ص<EFBFBD><D8B5><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8>
extern M_BTN_INFO btn;
extern M_UI ui;
char *itoa(uint32_t num);
char *ftoa(float num);
//֪ͨ<CDA8><D6AA>Ҫ<EFBFBD><EFBFBD><E6B4A2><EFBFBD><EFBFBD>
void eeprom_notify_change(void);
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void animation(float *a, float *a_trg, uint8_t n);
// <20><>ʾ<EFBFBD><CABE>ֵ<EFBFBD>ij<EFBFBD>ʼ<EFBFBD><CABC>
void check_box_v_init(uint8_t *param);
// <20>б<EFBFBD><D0B1><EFBFBD>ҳ<EFBFBD><D2B3>ͨ<EFBFBD><CDA8><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void list_show(M_SELECT arr[], uint8_t ui_index);
// <20>б<EFBFBD><D0B1><EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD>תʱ<D7AA>ж<EFBFBD>ͨ<EFBFBD>ú<EFBFBD><C3BA><EFBFBD>
void list_rotate_switch();
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʼ<EFBFBD><CABC>
void window_value_init(char title[], uint8_t select, uint8_t *value, uint8_t max, uint8_t min, uint8_t step, M_SELECT *bg, uint8_t index);
// ȷ<>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5>ʼ<EFBFBD><CABC>
void confirm_window_value_init(char title[], uint8_t _select_btn, fun_callback_t _cb, M_SELECT *bg, uint8_t index);
void gui_btn_send_signal(uint8_t btn_id,uint8_t event);
void gui_task(void);
void gui_init(void);
#endif /****** __GUI_MAIN_H ******/