【Follow me第二季第3期】进阶任务:示例程序中新增命令打印信息
[复制链接]
本次任务是进阶任务:示例程序中新增命令打印信息。
在memu_main.c中修改s_menu_items菜单数组。添加,Hello Information,对应函数为hello_display_menu。
/* Table of menu functions */
static st_menu_fn_tbl_t s_menu_items[] =
{
{"Hello Information" , hello_display_menu},
{"Kit Information" , kis_display_menu},
{"Web Server" , eth_emb_display_menu},
{"Network Name Lookup" , eth_www_display_menu},
{"Quad-SPI and Octo-SPI Speed Comparison" , ext_display_menu},
{"Cryptography and USB High speed (MSC)" , enc_display_menu},
{"Next Steps", ns_display_menu },
{"", NULL }
};
然后//memu_kis.c文件中新增以下代码
//memu_kis.c
#define HELLO_OPTIONS "\r\n\x1b[2m\x1b[37m a) FollowMe 2-3 " \
"\r\n\x1b[2m\x1b[37m a) Kit name: %s " \
"\r\n\x1b[2m\x1b[37m b) Kit ordering part number: %s " \
"\r\n\x1b[2m\x1b[37m c) RA Device part number: %s" \
"\r\n\x1b[2m\x1b[37m d) RA MCU 128-bit Unique ID (hex): " \
"\x1b[32m%08x\x1b[37m-\x1b[32m%08x\x1b[37m-\x1b[32m%08x\x1b[37m-\x1b[32m%08x\x1b[37m" \
"\r\n\x1b[2m\x1b[37m e) RA MCU Die temperature (F/C): \x1b[32m%d.%02d/%d.%02d\x1b[37m " \
"\r\n\x1b[2m\x1b[37m f) Blue LED blinking frequency (Hz): \x1b[32m%d\x1b[37m " \
"\r\n\x1b[2m\x1b[37m g) Blue LED blinking intensity (%%%%): \x1b[32m%d\x1b[37m "
//memu_kis.c
test_fn hello_display_menu(void)
{
int8_t c = -1;
uint16_t wn_mcu_temp_f = 0;
uint16_t fr_mcu_temp_f = 0;
uint16_t wn_mcu_temp_c = 0;
uint16_t fr_mcu_temp_c = 0;
bsp_unique_id_t const * p_uid = R_BSP_UniqueIdGet ();
sprintf (s_print_buffer, "%s%s", gp_clear_screen, gp_cursor_home);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
//sprintf (s_print_buffer, MODULE_NAME, g_selected_menu);
sprintf (s_print_buffer, "Eeworld and Dgikey is very good", g_selected_menu);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
wn_mcu_temp_f = g_board_status.temperature_f.whole_number;
fr_mcu_temp_f = g_board_status.temperature_f.mantissa;
wn_mcu_temp_c = g_board_status.temperature_c.whole_number;
fr_mcu_temp_c = g_board_status.temperature_c.mantissa;
sprintf (s_print_buffer, HELLO_OPTIONS, FULL_NAME, PART_NUMBER, DEVICE_NUMBER,
(int_t)p_uid->unique_id_words[0], (int_t)p_uid->unique_id_words[1], // typedef uint_t in stdint.h
(int_t)p_uid->unique_id_words[2], (int_t)p_uid->unique_id_words[3], // as signed long long int64_t;
wn_mcu_temp_f, fr_mcu_temp_f, wn_mcu_temp_c, fr_mcu_temp_c,
g_pwm_rates_data[g_board_status.led_frequency], g_pwm_dcs_data[g_board_status.led_intensity]);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
sprintf (s_print_buffer, MENU_RETURN_INFO);
/* ignoring -Wpointer-sign is OK when treating signed char_t array as as unsigned */
print_to_console((void*)s_print_buffer);
/* provide small delay so board_status should be up to date */
vTaskDelay (s_ticks_to_wait);
xEventGroupSetBits (g_update_console_event, STATUS_DISPLAY_MENU_KIS);
while (CONNECTION_ABORT_CRTL != c)
{
c = input_from_console ();
if ((MENU_EXIT_CRTL == c) || (CONNECTION_ABORT_CRTL == c))
{
break;
}
}
xEventGroupClearBits (g_update_console_event, STATUS_DISPLAY_MENU_KIS);
return (0);
}
编译,下载运行。
可以看到,新增的Eeworld and Dgikey is very good和fellow Me 2-3字样,新增命令成功。
|