Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit f7ff411

Browse files
Merge pull request #1036 from dmazzella/patch-2
[Arduino H7 Video Librari] Get the status of the display
2 parents 9f0337f + fbc0773 commit f7ff411

File tree

7 files changed

+41
-0
lines changed

7 files changed

+41
-0
lines changed

‎libraries/Arduino_H7_Video/docs/api.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ The main class for managing the video controller and the display.
1414
| `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. |
1515
| `public int` [`begin`](#public-int-begin) | Initialize the video controller and display. |
1616
| `public void` [`end`](#public-void-end) | De-initialize the video controller and display. |
17+
| `public bool` [`detect`](#public-bool-detect) | Checks if the display is connected. |
1718
| `public int` [`width`](#public-int-width) | Get the width of the display. |
1819
| `public int` [`height`](#public-int-height) | Get the height of the display. |
1920
| `public bool` [`isRotated`](#public-bool-isrotated) | Check if the display is rotated. |
@@ -54,6 +55,15 @@ De-initialize the video controller and display.
5455

5556
---
5657

58+
### `public bool` [`detect`](#)`()`
59+
60+
Checks if the display is connected.
61+
62+
#### Returns
63+
`bool`: True if the display is connected, False otherwis.
64+
65+
---
66+
5767
### `public int` [`width`](#)`()`
5868

5969
Get the width of the display.

‎libraries/Arduino_H7_Video/src/Arduino_H7_Video.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,11 @@ bool Arduino_H7_Video::isRotated() {
179179
return _rotated;
180180
}
181181

182+
bool Arduino_H7_Video::detect()
183+
{
184+
return (_shield->getStatus() > 0);
185+
}
186+
182187
void Arduino_H7_Video::end() {
183188
#ifdef HAS_ARDUINOGRAPHICS
184189
ArduinoGraphics::end();

‎libraries/Arduino_H7_Video/src/Arduino_H7_Video.h‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,13 @@ class Arduino_H7_Video
106106
*/
107107
bool isRotated();
108108

109+
/**
110+
* @brief Checks if the display is connected.
111+
*
112+
* @return true if the display is connected, false otherwise.
113+
*/
114+
bool detect();
115+
109116
#ifdef HAS_ARDUINOGRAPHICS
110117
/**
111118
* @brief Clear the display.

‎libraries/Arduino_H7_Video/src/H7DisplayShield.cpp‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ int GigaDisplayShieldClass::getEdidMode(int h, int v) {
1818
return EDID_MODE_480x800_60Hz;
1919
}
2020

21+
int GigaDisplayShieldClass::getStatus() {
22+
return 1; // TODO: Not implemented;
23+
}
24+
2125
int USBCVideoClass::init(int edidmode) {
2226
struct edid recognized_edid;
2327
int err_code = 0;
@@ -57,5 +61,11 @@ int USBCVideoClass::getEdidMode(int h, int v) {
5761
return edidmode;
5862
}
5963

64+
int USBCVideoClass::getStatus() {
65+
int detected = anx7625_get_hpd_event(0);
66+
67+
return detected;
68+
}
69+
6070
GigaDisplayShieldClass GigaDisplayShield;
6171
USBCVideoClass USBCVideo;

‎libraries/Arduino_H7_Video/src/H7DisplayShield.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,21 @@ class H7DisplayShield {
55
public:
66
virtual int init(int edidmode) = 0;
77
virtual int getEdidMode(int h, int v);
8+
virtual int getStatus();
89
};
910

1011
class GigaDisplayShieldClass : public H7DisplayShield {
1112
public:
1213
int init(int edidmode);
1314
int getEdidMode(int h, int v);
15+
int getStatus();
1416
};
1517

1618
class USBCVideoClass : public H7DisplayShield {
1719
public:
1820
int init(int edidmode);
1921
int getEdidMode(int h, int v);
22+
int getStatus();
2023
};
2124

2225
extern GigaDisplayShieldClass GigaDisplayShield;

‎libraries/Arduino_H7_Video/src/anx7625.cpp‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,11 @@ bool anx7625_is_power_provider(uint8_t bus) {
630630
}
631631
}
632632

633+
int anx7625_get_hpd_event(uint8_t bus) {
634+
int ret = anx7625_hpd_change_detect(bus);
635+
return ret;
636+
}
637+
633638
int i2c_writeb(uint8_t bus, uint8_t saddr, uint8_t offset, uint8_t val) {
634639
char cmd[2];
635640
cmd[0] = offset;

‎libraries/Arduino_H7_Video/src/anx7625.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,6 @@ int anx7625_wait_hpd_event(uint8_t bus);
2424
int anx7625_get_cc_status(uint8_t bus, uint8_t *cc_status);
2525
int anx7625_read_system_status(uint8_t bus, uint8_t *sys_status);
2626
bool anx7625_is_power_provider(uint8_t bus);
27+
int anx7625_get_hpd_event(uint8_t bus);
2728

2829
#endif /* _ANX7625_H */

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /