Skip to content

Commit ae9ef1e

Browse files
committed
update
1 parent ab54e0f commit ae9ef1e

File tree

2 files changed

+60
-62
lines changed

2 files changed

+60
-62
lines changed

src/GigaDisplay.cpp

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232

3333
/* Private function prototypes -----------------------------------------------*/
3434
#if __has_include ("lvgl.h")
35-
#if defined(__MBED__)
35+
#if __MBED__
3636
#include "mbed.h"
3737
#endif
3838
#if (LVGL_VERSION_MAJOR == 9)
3939
void lvgl_displayFlushing(lv_display_t * display, const lv_area_t * area, unsigned char * px_map);
40-
#if defined(__MBED__)
40+
#if __MBED__
4141
static void inc_thd() {
4242
while (1) {
4343
lv_tick_inc(16);
@@ -49,7 +49,7 @@ static rtos::Thread lvgl_inc_thd;
4949
#else
5050
void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p);
5151
#endif
52-
52+
#endif
5353

5454
#ifdef HAS_ARDUINOGRAPHICS
5555
Display::Display(int width, int height) : ArduinoGraphics(width, height), gdev(NULL)
@@ -212,9 +212,9 @@ bool Display::begin(DisplayPixelFormat pixformat) {
212212
}
213213
lv_display_set_buffers(display, buf1, NULL, width() * height() / 10, LV_DISPLAY_RENDER_MODE_PARTIAL); /*Initialize the display buffer.*/
214214
lv_display_set_flush_cb(display, lvgl_displayFlushing);
215-
215+
#if __MBED__
216216
lvgl_inc_thd.start(inc_thd);
217-
217+
#endif
218218
printk("LVGL Initialized\n");
219219

220220
#else //LVGL_VERSION_MAJOR
@@ -414,13 +414,14 @@ void lvgl_displayFlushing(lv_display_t * disp, const lv_area_t * area, unsigned
414414
uint32_t offsetPos = (area_in_use->x1 + (dsi_getDisplayXSize() * area_in_use->y1)) * sizeof(uint16_t);
415415
dsi_lcdDrawImage((void *) px_map, (void *)(dsi_getActiveFrameBuffer() + offsetPos), w, h, DMA2D_INPUT_RGB565);
416416
#else
417-
uint32_t offsetPos = (area_in_use->x1 + (getDisplayXSize() * area_in_use->y1)) * sizeof(uint16_t);
417+
uint32_t offsetPos = (area_in_use->x1 + (lcd_x_size * area_in_use->y1)) * sizeof(uint16_t);
418418
//dsi_lcdDrawImage((void *) px_map, (void *)(dsi_getActiveFrameBuffer() + offsetPos), w, h, DMA2D_INPUT_RGB565);
419-
memcpy(px_map, buffer + offest, w * h);
420-
write8(0, 0, buffer);
419+
//--- cant do this memcpy(px_map, buffer + offsetPos, w * h);
420+
Display::write8(0, 0, buffer);
421421
#endif
422422
lv_display_flush_ready(disp); /* Indicate you are ready with the flushing*/
423423
}
424+
424425
#else
425426
void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color_t * color_p) {
426427
uint32_t width = lv_area_get_width(area);
@@ -429,8 +430,9 @@ void lvgl_displayFlushing(lv_disp_drv_t * disp, const lv_area_t * area, lv_color
429430
#if defined(__MBED__)
430431
dsi_lcdDrawImage((void *) color_p, (void *)(dsi_getActiveFrameBuffer() + offsetPos), width, height, DMA2D_INPUT_RGB565);
431432
#else
432-
memcpy(color_p, buffer + offest, w * h);
433-
write8(0, 0, buffer);
433+
//--- cant do this memcpy(px_map, buffer + offsetPos, w * h);
434+
Display::write8(0, 0, buffer);
435+
434436
#endif
435437
lv_disp_flush_ready(disp); /* Indicate you are ready with the flushing*/
436438
}

src/GigaDisplay.h

Lines changed: 48 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,10 @@
2626
#include "SDRAM.h"
2727
#include "ArduinoGraphics.h"
2828
#define HAS_ARDUINOGRAPHICS
29+
#endif
2930

3031
static uint32_t lcd_x_size = 480;
3132
static uint32_t lcd_y_size = 800;
32-
#endif
33-
3433

3534
/**
3635
* @enum DisplayPixelFormat
@@ -77,46 +76,54 @@ class Display
7776
#endif
7877
{
7978
public:
80-
/**
81-
* @brief Construct a new Camera object.
82-
*/
83-
Display(int width = 800, int height = 480);
84-
85-
/**
86-
* @brief Initialize the display
87-
*/
88-
bool begin(DisplayPixelFormat pixformat = DISPLAY_RGB565);
89-
90-
/**
91-
* @brief a frame.
92-
*
93-
* @param fb Reference to a FrameBuffer object to store the frame data.
94-
* @param timeout Time in milliseconds to wait for a frame (default: 5000).
95-
* @return true if the frame is successfully captured, otherwise false.
96-
*/
97-
//bool grabFrame(FrameBuffer &fb, uint32_t timeout = 5000);
98-
99-
100-
/**
101-
*
102-
*
103-
*
104-
*
105-
*/
106-
int write8(const uint16_t x,
107-
const uint16_t y,
108-
const void *buf);
109-
110-
void setFrameDesc(uint16_t w, uint16_t h, uint16_t pitch, uint32_t buf_size);
111-
void startFrameBuffering();
112-
void endFrameBuffering();
113-
114-
int setBlanking(bool on);
79+
/**
80+
* @brief Construct a new Camera object.
81+
*/
82+
Display(int width = 800, int height = 480);
11583

116-
void* getFrameBuffer();
84+
/**
85+
* @brief Initialize the display
86+
*/
87+
bool begin(DisplayPixelFormat pixformat = DISPLAY_RGB565);
88+
89+
/**
90+
* @brief a frame.
91+
*
92+
* @param fb Reference to a FrameBuffer object to store the frame data.
93+
* @param timeout Time in milliseconds to wait for a frame (default: 5000).
94+
* @return true if the frame is successfully captured, otherwise false.
95+
*/
96+
//bool grabFrame(FrameBuffer &fb, uint32_t timeout = 5000);
97+
98+
99+
/**
100+
*
101+
*
102+
*
103+
*
104+
*/
105+
int write8(const uint16_t x,
106+
const uint16_t y,
107+
const void *buf);
108+
109+
void setFrameDesc(uint16_t w, uint16_t h, uint16_t pitch, uint32_t buf_size);
110+
void startFrameBuffering();
111+
void endFrameBuffering();
112+
113+
int setBlanking(bool on);
114+
115+
void* getFrameBuffer();
116+
117+
int16_t width(void) { return _width; }
118+
int16_t height(void) { return _height; }
119+
120+
uint32_t getDisplayXSize(){
121+
return lcd_x_size;
122+
}
117123

118-
int16_t width(void) { return _width; }
119-
int16_t height(void) { return _height; }
124+
uint32_t getDisplayYSize(){
125+
return lcd_y_size;
126+
}
120127

121128

122129
#ifdef HAS_ARDUINOGRAPHICS
@@ -146,14 +153,6 @@ class Display
146153
*/
147154
virtual void set(int x, int y, uint8_t r, uint8_t g, uint8_t b);
148155

149-
uint32_t getDisplayXSize(){
150-
return lcd_x_size;
151-
}
152-
153-
uint32_t getDisplayYSize(){
154-
return lcd_y_size;
155-
}
156-
157156
void lcdClear(uint16_t Color);
158157

159158
#endif
@@ -162,16 +161,13 @@ class Display
162161
private:
163162
const struct device *gdev;
164163
struct display_buffer_descriptor *buf_desc;
165-
#if defined(HAS_ARDUINOGRAPHICS) || __has_include ("lvgl.h")
166164
uint16_t *buffer = nullptr;
167165
uint32_t sizeof_framebuffer;
168-
#endif
169166
protected:
170167
int16_t _height, _width;
171168
bool _rotated = false;
172169

173170
};
174171

172+
#endif // __ZEPHYR__
175173
#endif // __GIGA_DISPLAY_H__
176-
177-
#endif // __ZEPHYR__

0 commit comments

Comments
 (0)