This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

I am using the NRF2840 and WaveShare's 2.9 epaper display to make a cutdown tool, but I am facing some problems.

I have realized the cutdown function with the examples. But now I want to reflesh the number I have published, which means that I first publish a number, then I want to publish a new number. But now, the new number i published can't preemptive the old number. I want to know how to replace the old number. Thanks for all of your effort.

yours sincerely,

Leo Li.

Parents
  • I don't know your setup Leo, but if the issue is that the numbers are stacked on top of each other, it sounds like you need to clear the screen first. How you do that, I don't know, but it is probably documented somewhere around the same place as you found out how to write to the epaper display.

  • Thank you for your reply. I am sorry that I don't describe my question very clearly. I have update my question in the previous answers by awneil. You can go to that answer to know further things. Thank you very much.

  • When you write a new number it will replace the old number in the service. If the counter isn't updated, then that is because of how you treat it in your application.

    The nus_data_handler() is called when you "refresh" the number by sending the number to your characteristic. How you use this number after that is up to the application. I don't know how you use this event, and how you start your countdown, but it sounds like you need to abort the current countdown, and start it again with the new number.

  • I am using the bluetooth uart module.

    You mean the Nordic UART Service (NUS) ?

    https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/group__ble__nus.html

    https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v15.3.0/ble_sdk_app_nus_eval.html

    As says, that gives you an Event when data is received.

    So it's up to your code to do whatever you want when that Event occurs.

  • Yes, this is exactly what I mean. I want to abort the current countdown and start it with the new number. But I don't know how to realize this function. I just rewrite the nus_data_handler() function with a very easy logic. I changed the receive data into int, and let it decrease. The code is like this:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    static void nus_data_handler(ble_nus_evt_t * p_evt)
    {
    if (p_evt->type == BLE_NUS_EVT_RX_DATA)
    {
    int time_now_s;
    time_now_s=atoi((char*)p_evt->params.rx_data.p_data);
    ...
    ...
    ...
    while(time_now_s>0)
    {
    time_now_s--;
    ...
    ...
    ...
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    And the service_init() function is like this:
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    static void services_init(void)
    {
    uint32_t err_code;
    ble_nus_init_t nus_init;
    nrf_ble_qwr_init_t qwr_init = {0};
    // ble_nus_evt_t *pp_evt;
    // Initialize Queued Write Module.
    qwr_init.error_handler = nrf_qwr_error_handler;
    err_code = nrf_ble_qwr_init(&m_qwr, &qwr_init);
    APP_ERROR_CHECK(err_code);
    // Initialize NUS.
    memset(&nus_init, 0, sizeof(nus_init));
    nus_init.data_handler = nus_data_handler;
    err_code = ble_nus_init(&m_nus, &nus_init);
    APP_ERROR_CHECK(err_code);
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    I don't know whether these code will help you to understand my meanings or not.
    Thank you for your continuous attention to my questions.
  • I have update some of my code in the reply to Edvin. Maybe that will help you to understand my thoughts. I just can't abort the countdown, maybe it's because of that the Nordic UART Service is FIFO?

    Thank you for your continuous attention to my questions.

  • I just can't abort the countdown

    Why not?

    What's the problem?

    maybe it's because of that the Nordic UART Service is FIFO

    Why would that be a problem?

    It's your code that does the countdown - so you should know how to abort it!

    Can you get this working on its own - without the added complication of BLE?

    It sounds like a problem with your system design ...

Reply
  • I just can't abort the countdown

    Why not?

    What's the problem?

    maybe it's because of that the Nordic UART Service is FIFO

    Why would that be a problem?

    It's your code that does the countdown - so you should know how to abort it!

    Can you get this working on its own - without the added complication of BLE?

    It sounds like a problem with your system design ...

Children