82|0

25

帖子

0

TA的资源

一粒金砂(中级)

楼主
 

【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字样,新增命令成功。

点赞 关注
 
 

回复
举报
您需要登录后才可以回帖 登录 | 注册

随便看看
查找数据手册?

EEWorld Datasheet 技术支持

相关文章 更多>>
关闭
站长推荐上一条 1/10 下一条

 
EEWorld订阅号

 
EEWorld服务号

 
汽车开发圈

About Us 关于我们 客户服务 联系方式 器件索引 网站地图 最新更新 手机版

站点相关: 国产芯 安防电子 汽车电子 手机便携 工业控制 家用电子 医疗电子 测试测量 网络通信 物联网

北京市海淀区中关村大街18号B座15层1530室 电话:(010)82350740 邮编:100190

电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号 Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved
快速回复 返回顶部 返回列表