nikthefix / Lilygo_Support_T_Display_S3_Long_TFT_eSPI_Volos-nikthefix

16 stars 2 forks source link

[Suggestion] Commenting some lines in the code #2

Open d3mac123 opened 4 months ago

d3mac123 commented 4 months ago

I know I am asking too much already but, it would be nice to have some (at least the mandatory ones for a new app to work) lines of the code commented, explaining why something is required. For example (using the TRulerNick one as a learning app), I would like to understand what some lines do and if I need to bring them to a new app. Example:

uint8_t ALS_ADDRESS = 0x3B;
uint8_t read_touchpad_cmd[11] = {0xb5, 0xab, 0xa5, 0x5a, 0x0, 0x0, 0x0, 0x8}; 

Do I need to have them in any touchable app? What is the ALS_ADDRESS about? And the number in the read_touchpad_cmd array?

nikthefix commented 4 months ago

No that's not asking too much! Far from it. I will expand on the repos. They were rushed to get them out quickly. There is a lot left to add. I agree that commenting is vital - especially for me so I can remember what I meant when I look back :)

Much of the touch code is taken straight from the code supplied by lilygo and ALS refers to the touch hardware built in to the display. Since it communicates with the esp32 via i2c we need to set up i2c credentials like the unique address and provided a buffer to hold the touch data stream as it comes in when we poll it. The touch sensor alerts the esp32 that it has completed a full scan by pulling the touch_int pin low briefly. This happens 60 times per second. The esp responds to this pulse by requesting the touch data payload and placing it in the touch buffer(s). The esp then generates coordinates based on these data which are then passed to the conditionals which determine whether a touch coordinate coincides with one of Volos's GUI objects. Guards are in place to prevent a held button causing auto-repeat chaos.

But yes, for all future projects using this board you can simply copy and paste the getTouch() function as it is. If you rotate the display then you'll need to rotate the touch axes but I'll make that automatic with a revision.