Skip to content

Conversation

@meisZWFLZ
Copy link
Contributor

Overview

A friendlier, documented and safer API wrapper around the Vex SDK.

Motivation

Gives users a documented and safe api to interact with.

References (optional)

Implementation Details (optional)

on_pressed()/on_released() should not use vexTouchUserCallbackSet(), since then the callback would be called within the system_daemon task.
This would enable a user to mistakenly delay within the callback and prevent the program from receiving new device data, as vexTasksRun() would not be run.
NOTE: document the above in source

Test Plan:

TBD

@meisZWFLZ meisZWFLZ marked this pull request as ready for review June 15, 2025 04:53
@meisZWFLZ meisZWFLZ marked this pull request as draft June 15, 2025 04:53
@ion098 ion098 self-requested a review August 27, 2025 22:07
* @brief Subscribes the listener to be called when the screen touch state changes.
*
* Spawn a new task to check for events if it is not already running.
* All listeners are called from this task.
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO we should either use a separate task for every callback, or not have this functionality built-in.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Perhaps. My thinking is that if we have a good mechanism to warn the user at runtime that something bad is going on (via the brain screen), then one task should be good. There was also a large discussion about this in discord and about supporting event listeners for device updates.

std::optional<Screen::TouchEvent::State> filter;
};

static std::vector<Listener> listeners;
Copy link
Contributor

Choose a reason for hiding this comment

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

This needs a mutex.


// TODO: Determine when it starts counting
/** The number of times the screen has been pressed. */
int32_t pressCount;
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are the counts signed integers?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comes from this
May also have to do with vex sdk api, but I'm not sure.
Likely would be good to make unsigned

#pragma once

#include "pros/rtos.hpp"
#include "stdint.h"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
#include "stdint.h"
#include <cstdint>

#include <utility>
#include <vector>

#ifndef ZESTCODE_CONFIG_SCREEN_TOUCH_LISTENER_TASK_INTERVAL
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the point of this code? Users can't change the #define value without editing ZestCode's source code anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since the user compiles zest code themselves as part of the build process, they can define this macro when calling the compiler thru a cli option.

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.

3 participants