Skip to content

Commit 5ae56fb

Browse files
authored
Merge pull request #41 from TheNitek/master
Add (rudimentary) offset support and cleanup
2 parents b611e88 + 058ada8 commit 5ae56fb

File tree

4 files changed

+15
-17
lines changed

4 files changed

+15
-17
lines changed

src/VNC.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,6 @@
2727

2828
#include <Arduino.h>
2929

30-
#include <stdio.h>
31-
#include <unistd.h>
32-
#include <inttypes.h>
33-
#include <stdint.h>
3430
#include <math.h>
3531

3632
#include "VNC.h"
@@ -238,15 +234,16 @@ void arduinoVNC::loop(void) {
238234
// reset dict
239235
memset(zout, 0, ZRLE_OUTPUT_BUFFER);
240236
zout_next = zout;
241-
#endif
242237

243238
#ifdef VNC_ZRLE
244239
zout_read = zout;
245240
#endif // #ifdef VNC_ZRLE
246241

242+
#endif
243+
247244
} else {
248245
if(!rfb_handle_server_message()) {
249-
//DEBUG_VNC("rfb_handle_server_message faild.\n");
246+
//DEBUG_VNC("rfb_handle_server_message failed.\n");
250247
return;
251248
}
252249

@@ -268,7 +265,12 @@ void arduinoVNC::loop(void) {
268265
}
269266

270267
int arduinoVNC::forceFullUpdate(void) {
271-
return rfb_send_update_request(1);
268+
return rfb_send_update_request(0);
269+
}
270+
271+
void arduinoVNC::setOffset(uint16_t x, uint16_t y) {
272+
opt.h_offset = x;
273+
opt.v_offset = y;
272274
}
273275

274276
void arduinoVNC::setMaxFPS(uint16_t fps) {

src/VNC.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,8 @@ class arduinoVNC {
195195
void mouseEvent(uint16_t x, uint16_t y, uint8_t buttonMask);
196196
void keyEvent(int key, int keyMask);
197197

198+
void setOffset(uint16_t x, uint16_t y);
199+
198200
private:
199201
bool onlyFullUpdate;
200202
int port;

src/frameBuffer.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,8 @@
2424
*
2525
*/
2626

27-
#include <Arduino.h>
28-
#include <stdlib.h>
29-
#include <stdint.h>
3027
#include "frameBuffer.h"
3128

32-
#ifndef HEXDUMP_COLS
33-
#define HEXDUMP_COLS 32
34-
#endif
35-
3629
/// debugging
3730
#ifdef ESP32
3831
#define DEBUG_VNC(...) Serial.printf( __VA_ARGS__ )
@@ -64,7 +57,7 @@ bool FrameBuffer::begin(uint32_t _w, uint32_t _h) {
6457
if(buffer) {
6558
if((size < newSize)) {
6659
//DEBUG_VNC("[FrameBuffer::begin] (size < newSize) realloc... <--------------------------------------\n");
67-
delay(10);
60+
//delay(10);
6861
uint8_t * newbuffer = (uint8_t *) realloc(buffer, newSize);
6962
//DEBUG_VNC("[FrameBuffer::begin] newbuffer: 0x%08X\n", newbuffer);
7063
if(!newbuffer) {
@@ -130,8 +123,7 @@ void FrameBuffer::draw_rect(uint32_t x, uint32_t y, uint32_t rw, uint32_t rh, ui
130123
while(rh--) {
131124
xc = rw;
132125
while(xc--) {
133-
*ptr = color;
134-
ptr++;
126+
*ptr++ = color;
135127
}
136128
ptr += offset;
137129
}

src/frameBuffer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#ifndef ARDUINOVNC_SRC_FB_H_
2828
#define ARDUINOVNC_SRC_FB_H_
2929

30+
#include <Arduino.h>
31+
3032
#ifdef WORDS_BIGENDIAN
3133
#define Swap16IfLE(s) (s)
3234
#else

0 commit comments

Comments
 (0)