add pointer mode
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
#include <stdint.h>
|
||||
#include "global.h"
|
||||
#include "ui.h"
|
||||
#include "time.h"
|
||||
#include "st7735.h"
|
||||
#include "Images/digi18x32.h"
|
||||
#include "monoimg.h"
|
||||
@@ -74,51 +76,52 @@ void ui_com_title_bar(uint8_t clear, uint8_t *text, uint32_t bytes_len) {
|
||||
bmf_draw_text(font_unifont_16x16, text, bytes_len, off_x, 1, ST7735_WIDTH - 2, 16, ST7735_YELLOW);
|
||||
}
|
||||
|
||||
void ui_com_freq_digital(uint8_t clear) {
|
||||
void ui_com_freq_digital(uint8_t clear, uint8_t only_pointer) {
|
||||
// 5位数字, 即高32+2(小数点高度),宽90
|
||||
uint16_t off_x = (ST7735_WIDTH - 90) / 2;
|
||||
uint16_t off_y = (ST7735_HEIGHT - 34 - 34 - 18) / 2 + 17;
|
||||
uint16_t freq_num;
|
||||
if (global_data.rf_mode == G_RF_MODE_AM) {
|
||||
uint16_t scale = 10000;
|
||||
uint32_t tmp = 0;
|
||||
if (clear) {
|
||||
ST7735_FillRectangle(off_x, off_y+32, 90, 2, ST7735_BLACK); // 清除小数点
|
||||
}
|
||||
while (scale > 0) {
|
||||
if (clear) {
|
||||
ui_text_number18x32_with_bg(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0), ST7735_BLACK);
|
||||
} else {
|
||||
ui_text_number18x32(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0));
|
||||
}
|
||||
off_x += 18;
|
||||
scale /= 10;
|
||||
}
|
||||
freq_num = global_data.freq;
|
||||
} else {
|
||||
uint16_t fm_freq = global_data.freq / 20;
|
||||
uint8_t fm_freq_float = (global_data.freq % 20) * 5;
|
||||
uint16_t scale = 100;
|
||||
uint16_t tmp = 0;
|
||||
if (clear) {
|
||||
ST7735_FillRectangle(off_x, off_y + 32, 18 * 3 - 1, 2, ST7735_BLACK); // 清除小数点
|
||||
ST7735_FillRectangle(off_x + (18 * 3) + 1, off_y + 32, 18 * 2 - 1, 2, ST7735_BLACK); // 清除小数点
|
||||
freq_num = global_data.freq * 5;
|
||||
}
|
||||
uint16_t color_orange = ST7735_COLOR565(0xFF, 0x7F, 0);
|
||||
if (clear) {
|
||||
if (global_data.rf_mode == G_RF_MODE_AM) {
|
||||
ST7735_FillRectangle(off_x, off_y+32, 90, 3, ST7735_BLACK); // 清除小数点
|
||||
} else {
|
||||
ST7735_FillRectangle(off_x, off_y + 32, 18 * 3 - 1, 3, ST7735_BLACK); // 清除小数点
|
||||
ST7735_FillRectangle(off_x + (18 * 3) + 1, off_y + 32, 18 * 2 - 1, 3, ST7735_BLACK); // 清除小数点
|
||||
ST7735_FillRectangle(off_x + (18 * 3) - 1, off_y + 34, 2, 1, ST7735_BLACK);
|
||||
}
|
||||
while (scale > 0) {
|
||||
tmp = (fm_freq / scale) % 10;
|
||||
if (clear) {
|
||||
ui_text_number18x32_with_bg(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0), ST7735_BLACK);
|
||||
} else {
|
||||
ui_text_number18x32(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0));
|
||||
}
|
||||
off_x += 18;
|
||||
scale /= 10;
|
||||
}
|
||||
if (global_data.rf_mode == G_RF_MODE_FM) {
|
||||
// 绘制小数点
|
||||
ST7735_FillRectangle(off_x + (18 * 3) - 1, off_y + 32, 2, 2, color_orange);
|
||||
}
|
||||
if (global_data.point_mode & G_PMOD_MODE_MASK) {
|
||||
// 绘制光标
|
||||
uint8_t blink_state = (ticks_ms() / UI_BLINK_MS) % 2;
|
||||
uint8_t blink_state2 = !(global_data.point_mode & G_PMOD_PBLINK_MASK);
|
||||
if (!(global_data.point_mode & G_PMOD_PMOVE_MASK) || (blink_state ^ blink_state2)) {
|
||||
uint8_t p_pos = (global_data.point_mode & G_POMD_POS_MASK) >> G_POMD_POS_BOFF;
|
||||
uint16_t p_off = (4 - p_pos) * 18 + 2 + off_x;
|
||||
ST7735_FillRectangle(p_off, off_y + 33, 14, 2, color_orange);
|
||||
global_data.point_mode = global_data.point_mode | G_PMOD_PBLINK2_MASK;
|
||||
} else {
|
||||
global_data.point_mode = global_data.point_mode & (~G_PMOD_PBLINK2_MASK);
|
||||
}
|
||||
scale = 10;
|
||||
}
|
||||
uint16_t scale = 10000;
|
||||
uint32_t tmp = 0;
|
||||
if (!only_pointer) {
|
||||
while (scale > 0) {
|
||||
tmp = (fm_freq_float / scale) % 10;
|
||||
tmp = (freq_num / scale) % 10;
|
||||
if (clear) {
|
||||
ui_text_number18x32_with_bg(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0), ST7735_BLACK);
|
||||
ui_text_number18x32_with_bg(tmp, off_x, off_y, color_orange, ST7735_BLACK);
|
||||
} else {
|
||||
ui_text_number18x32(tmp, off_x, off_y, ST7735_COLOR565(0xFF, 0x7F, 0));
|
||||
ui_text_number18x32(tmp, off_x, off_y, color_orange);
|
||||
}
|
||||
off_x += 18;
|
||||
scale /= 10;
|
||||
@@ -200,7 +203,19 @@ void ui_screen_main() {
|
||||
ui_com_main_border();
|
||||
ui_com_title_bar(0, u8str("Radio"), 5);
|
||||
ui_com_fm_am(0);
|
||||
ui_com_freq_digital(0);
|
||||
ui_com_freq_digital(0, 0);
|
||||
ui_com_vol_bar(0);
|
||||
ui_com_sig_bar(0);
|
||||
}
|
||||
|
||||
void ui_screen_main_animation() {
|
||||
// 绘制闪烁效果
|
||||
if ((global_data.point_mode & G_PMOD_MODE_MASK) && (global_data.point_mode & G_PMOD_PMOVE_MASK)) {
|
||||
uint8_t blink_state = (ticks_ms() / UI_BLINK_MS) % 2;
|
||||
uint8_t blink_state2 = !(global_data.point_mode & G_PMOD_PBLINK_MASK);
|
||||
uint8_t blink_state3 = (global_data.point_mode & G_PMOD_PBLINK2_MASK) ? 1 : 0;
|
||||
if ((blink_state ^ blink_state2) ^ blink_state3) {
|
||||
ui_com_freq_digital(1, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,16 @@
|
||||
#pragma once
|
||||
#include <stdint.h>
|
||||
|
||||
#define UI_BLINK_MS 250
|
||||
|
||||
void ui_text_number18x32(uint32_t num, uint16_t x, uint16_t y, uint16_t color);
|
||||
|
||||
/* 绘制界面元素 */
|
||||
void ui_com_title_bar(uint8_t clear, uint8_t *text, uint32_t bytes_len);
|
||||
void ui_com_freq_digital(uint8_t clear);
|
||||
void ui_com_freq_digital(uint8_t clear, uint8_t only_pointer);
|
||||
void ui_com_fm_am(uint8_t clear);
|
||||
void ui_com_vol_bar(uint8_t clear);
|
||||
void ui_com_sig_bar(uint8_t clear);
|
||||
/* 绘制主界面 */
|
||||
void ui_screen_main();
|
||||
void ui_screen_main_animation();
|
||||
|
Reference in New Issue
Block a user