Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add touch input values to an accessible FreeRTOS queue #136

Merged
merged 3 commits into from
Oct 27, 2021

Conversation

rashedtalukder
Copy link

@rashedtalukder rashedtalukder commented Oct 20, 2021

For applications that might want to read the touch values without creating another task that is also reading the FT6336U over the i2c bus. This is especially an issue for the M5Stack Core2 for AWS IoT EduKit or standard Core2 that has etched buttons and touch sensing capabilities that are past the bounds of the screen perimeter.

Queue was chosen due to their minimal overhead and non-blocking. Directly copied the values to the queue instead of a pointer since the struct size is fairly small.

Example Usage:

#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include <esp_log.h>
#include "ft6x36.h"

static const char* TAG = "MAIN";

void button_press_task( void *args )
{
***INITIALIZE EVERYTHING FIRST***

    ft6x36_touch_t touch_received;
    for ( ;; ){
        xQueueReceive( ft6x36_touch_queue_handle, &touch_received, 0 );

        ESP_LOGI( TAG, "X=%i Y=%i State=%u", touch_received.last_x, touch_received.last_y, touch_received.current_state );
        vTaskDelay(pdMS_TO_TICKS(20));
    }
    
}

void app_main( void )
{
    xTaskCreatePinnedToCore( button_press_task, "buttonPress", configMINIMAL_STACK_SIZE * 3, NULL, 0, ( TaskHandle_t * ) NULL, 1 );
}

@rashedtalukder
Copy link
Author

@tore-espressif @C47D, would love to have your inputs/review.

@C47D
Copy link
Collaborator

C47D commented Oct 22, 2021

Hi,

Sorry for the late reply, it looks good to me, do you think we could make it optional? We could add an option on the Kconfig interface to choose between the old and this approach.

@rashedtalukder
Copy link
Author

Couldn't get to this during the weekend. I've pushed a new commit with a kconfig symbol in the appropriate area.

Copy link
Collaborator

@C47D C47D left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've leaved a couple of minor comments, please let me know if they make sense to you, if so, please confirm they work as expected.

lvgl_touch/ft6x36.h Outdated Show resolved Hide resolved
lvgl_touch/ft6x36.h Show resolved Hide resolved
@rashedtalukder
Copy link
Author

Added changes based on latest feedback.

@rashedtalukder
Copy link
Author

rashedtalukder commented Oct 27, 2021

Awesome. Thank you, this is a big help!

@C47D C47D merged commit b674d2d into lvgl:master Oct 27, 2021
@C47D
Copy link
Collaborator

C47D commented Oct 28, 2021

Thanks for the improvement @rashedtalukder , I've also included it in the development branch of this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants