Skip to content
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

Add (rudimentary) offset support and cleanup #41

Merged
merged 1 commit into from
Jun 2, 2024
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
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
Loading