Skip to content

Get the status of the display. #1036

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

Merged
merged 3 commits into from
Mar 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions libraries/Arduino_H7_Video/docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ The main class for managing the video controller and the display.
| `public ` [`Arduino_H7_Video`](#public-arduino_h7_videoint-width-int-height-h7displayshield-shield) | Construct a new Arduino_H7_Video object with the specified width, height, and display shield. |
| `public int` [`begin`](#public-int-begin) | Initialize the video controller and display. |
| `public void` [`end`](#public-void-end) | De-initialize the video controller and display. |
| `public bool` [`detect`](#public-bool-detect) | Checks if the display is connected. |
| `public int` [`width`](#public-int-width) | Get the width of the display. |
| `public int` [`height`](#public-int-height) | Get the height of the display. |
| `public bool` [`isRotated`](#public-bool-isrotated) | Check if the display is rotated. |
Expand Down Expand Up @@ -54,6 +55,15 @@ De-initialize the video controller and display.

---

### `public bool` [`detect`](#)`()`

Checks if the display is connected.

#### Returns
`bool`: True if the display is connected, False otherwis.

---

### `public int` [`width`](#)`()`

Get the width of the display.
Expand Down
5 changes: 5 additions & 0 deletions libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,11 @@ bool Arduino_H7_Video::isRotated() {
return _rotated;
}

bool Arduino_H7_Video::detect()
{
return (_shield->getStatus() > 0);
}

void Arduino_H7_Video::end() {
#ifdef HAS_ARDUINOGRAPHICS
ArduinoGraphics::end();
Expand Down
7 changes: 7 additions & 0 deletions libraries/Arduino_H7_Video/src/Arduino_H7_Video.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ class Arduino_H7_Video
*/
bool isRotated();

/**
* @brief Checks if the display is connected.
*
* @return true if the display is connected, false otherwise.
*/
bool detect();

#ifdef HAS_ARDUINOGRAPHICS
/**
* @brief Clear the display.
Expand Down
10 changes: 10 additions & 0 deletions libraries/Arduino_H7_Video/src/H7DisplayShield.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ int GigaDisplayShieldClass::getEdidMode(int h, int v) {
return EDID_MODE_480x800_60Hz;
}

int GigaDisplayShieldClass::getStatus() {
return 1; // TODO: Not implemented;
}

int USBCVideoClass::init(int edidmode) {
struct edid recognized_edid;
int err_code = 0;
Expand Down Expand Up @@ -57,5 +61,11 @@ int USBCVideoClass::getEdidMode(int h, int v) {
return edidmode;
}

int USBCVideoClass::getStatus() {
int detected = anx7625_get_hpd_event(0);

return detected;
}

GigaDisplayShieldClass GigaDisplayShield;
USBCVideoClass USBCVideo;
3 changes: 3 additions & 0 deletions libraries/Arduino_H7_Video/src/H7DisplayShield.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,21 @@ class H7DisplayShield {
public:
virtual int init(int edidmode) = 0;
virtual int getEdidMode(int h, int v);
virtual int getStatus();
};

class GigaDisplayShieldClass : public H7DisplayShield {
public:
int init(int edidmode);
int getEdidMode(int h, int v);
int getStatus();
};

class USBCVideoClass : public H7DisplayShield {
public:
int init(int edidmode);
int getEdidMode(int h, int v);
int getStatus();
};

extern GigaDisplayShieldClass GigaDisplayShield;
Expand Down
5 changes: 5 additions & 0 deletions libraries/Arduino_H7_Video/src/anx7625.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -630,6 +630,11 @@ bool anx7625_is_power_provider(uint8_t bus) {
}
}

int anx7625_get_hpd_event(uint8_t bus) {
int ret = anx7625_hpd_change_detect(bus);
return ret;
}

int i2c_writeb(uint8_t bus, uint8_t saddr, uint8_t offset, uint8_t val) {
char cmd[2];
cmd[0] = offset;
Expand Down
1 change: 1 addition & 0 deletions libraries/Arduino_H7_Video/src/anx7625.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ int anx7625_wait_hpd_event(uint8_t bus);
int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status);
int anx7625_read_system_status(uint8_t bus, uint8_t *sys_status);
bool anx7625_is_power_provider(uint8_t bus);
int anx7625_get_hpd_event(uint8_t bus);

#endif /* _ANX7625_H */