Skip to content

Commit

Permalink
Merge pull request #41 from TheNitek/master
Browse files Browse the repository at this point in the history
Add (rudimentary) offset support and cleanup
  • Loading branch information
TheNitek authored Jun 2, 2024
2 parents b611e88 + 058ada8 commit 5ae56fb
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
16 changes: 9 additions & 7 deletions src/VNC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@

#include <Arduino.h>

#include <stdio.h>
#include <unistd.h>
#include <inttypes.h>
#include <stdint.h>
#include <math.h>

#include "VNC.h"
Expand Down Expand Up @@ -238,15 +234,16 @@ void arduinoVNC::loop(void) {
// reset dict
memset(zout, 0, ZRLE_OUTPUT_BUFFER);
zout_next = zout;
#endif

#ifdef VNC_ZRLE
zout_read = zout;
#endif // #ifdef VNC_ZRLE

#endif

} else {
if(!rfb_handle_server_message()) {
//DEBUG_VNC("rfb_handle_server_message faild.\n");
//DEBUG_VNC("rfb_handle_server_message failed.\n");
return;
}

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

int arduinoVNC::forceFullUpdate(void) {
return rfb_send_update_request(1);
return rfb_send_update_request(0);
}

void arduinoVNC::setOffset(uint16_t x, uint16_t y) {
opt.h_offset = x;
opt.v_offset = y;
}

void arduinoVNC::setMaxFPS(uint16_t fps) {
Expand Down
2 changes: 2 additions & 0 deletions src/VNC.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ class arduinoVNC {
void mouseEvent(uint16_t x, uint16_t y, uint8_t buttonMask);
void keyEvent(int key, int keyMask);

void setOffset(uint16_t x, uint16_t y);

private:
bool onlyFullUpdate;
int port;
Expand Down
12 changes: 2 additions & 10 deletions src/frameBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@
*
*/

#include <Arduino.h>
#include <stdlib.h>
#include <stdint.h>
#include "frameBuffer.h"

#ifndef HEXDUMP_COLS
#define HEXDUMP_COLS 32
#endif

/// debugging
#ifdef ESP32
#define DEBUG_VNC(...) Serial.printf( __VA_ARGS__ )
Expand Down Expand Up @@ -64,7 +57,7 @@ bool FrameBuffer::begin(uint32_t _w, uint32_t _h) {
if(buffer) {
if((size < newSize)) {
//DEBUG_VNC("[FrameBuffer::begin] (size < newSize) realloc... <--------------------------------------\n");
delay(10);
//delay(10);
uint8_t * newbuffer = (uint8_t *) realloc(buffer, newSize);
//DEBUG_VNC("[FrameBuffer::begin] newbuffer: 0x%08X\n", newbuffer);
if(!newbuffer) {
Expand Down Expand Up @@ -130,8 +123,7 @@ void FrameBuffer::draw_rect(uint32_t x, uint32_t y, uint32_t rw, uint32_t rh, ui
while(rh--) {
xc = rw;
while(xc--) {
*ptr = color;
ptr++;
*ptr++ = color;
}
ptr += offset;
}
Expand Down
2 changes: 2 additions & 0 deletions src/frameBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
#ifndef ARDUINOVNC_SRC_FB_H_
#define ARDUINOVNC_SRC_FB_H_

#include <Arduino.h>

#ifdef WORDS_BIGENDIAN
#define Swap16IfLE(s) (s)
#else
Expand Down

0 comments on commit 5ae56fb

Please sign in to comment.