mothercup/mcm-ddc-ble/inc/app_display.h
evan.liu ed2cf2a29d 新增 apptest 全字符显示自检 (0-9/A-F) (APP V1.00.39)
- display_set_raw(digits[5], type) + 裸码模式: 绕过温度解码直接渲染段位字符
- apptest: 循环 0-15, 四数字位同显一字符, DIG4 固定 C
- 仅 APP 改动, Boot 不动 (仍 V1.00.07)
- docs/开发日志.md: 新增 §67
2026-09-13 09:55:51 +08:00

81 lines
2.7 KiB
C

/**
* @file app_display.h
* @brief YF30137 7-segment display driver.
*
* The YF30137 is a 7-pin Charlieplexed temperature display:
* - DIG1 = hundreds, DIG2 = tens, DIG3 = ones,
* DIG4 = unit letter ("F" Fahrenheit / "C" Celsius), DIG5 = tenths
* - DIG6 holds two single indicators: A6 = "deg F", B6 = decimal point
*
* A dedicated FreeRTOS task (display_task) scans the module continuously.
* Every other task updates the display simply by calling display_set();
* the scan task only reads the global state and never blocks callers.
*/
#ifndef __APP_DISPLAY_H__
#define __APP_DISPLAY_H__
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include "n32wb03x.h"
/* Display type / unit (controls the DIG6 "deg F" indicator A6) */
#define DISP_TYPE_CELSIUS 0u /* degree C: A6 off */
#define DISP_TYPE_FAHRENHEIT 1u /* degree F: A6 on */
/* Number base for the displayed value */
#define DISP_BASE_DECIMAL 10u
#define DISP_BASE_HEX 16u
/**
* @brief Update what the display should show (read by the scan task).
* @param value temperature to display, clamped to 0.0..999.9 (1 decimal)
* @param type DISP_TYPE_CELSIUS / DISP_TYPE_FAHRENHEIT (DIG6-A indicator)
* @param base unused (kept for API compatibility)
* @note Non-blocking; may be called from any task context.
*/
void display_set(float value, uint8_t type, uint8_t base);
/**
* @brief Show raw digit codes directly (bypasses the temperature decode).
* Used by the display self-test to render every segment character.
* @param digits 5 codes: 0..9, 0xA..0xF (A..F), CHAR_BLANK(0xFF),
* CHAR_MINUS(0x10); index 3 is the DIG4 unit letter
* @param type DISP_TYPE_CELSIUS / DISP_TYPE_FAHRENHEIT (DIG6-A indicator)
*/
void display_set_raw(const uint8_t digits[5], uint8_t type);
/**
* @brief Display driver FreeRTOS task: Charlieplexing scan loop, never returns.
*/
void display_task(void *pvParameters);
/**
* @brief Enable (1) / disable (0) the automatic Charlieplexing scan.
* When disabled the scan task releases all 7 pins to high-impedance
* so another task (e.g. the "dispset" CLI) can drive them manually.
*/
void display_auto_set(uint8_t on);
/**
* @brief @return 1 when the automatic scan is enabled.
*/
uint8_t display_auto_get(void);
/**
* @brief Map a display pin number (1..7) to its GPIO port + pin mask.
* @param pin_no display pin number 1..7 (pin1=PB0 ... pin7=PA6)
* @param port out: GPIO port
* @param pin out: GPIO pin mask
* @return 1 on success, 0 when pin_no is out of range.
*/
int display_pin_map(uint8_t pin_no, GPIO_Module** port, uint16_t* pin);
#ifdef __cplusplus
}
#endif
#endif /* __APP_DISPLAY_H__ */