components/vnc_server/vnc-server.h

changeset 0
b74b0e4902c3
child 30
3cc32f97410c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/components/vnc_server/vnc-server.h	Sat Oct 20 13:23:15 2018 +0200
@@ -0,0 +1,143 @@
+/**
+ * @file vnc-server.h
+ * @brief VNC server original written for eCos.
+ *
+ * The VNC server runs on the target platform and waits for a client 
+ * (vncviewer program running on a PC) to connect via an ethernet connection
+ * (port 5900). Once a client has connected, the target platform has a 
+ * virtual screen, keyboard and mouse.
+ *
+ * This port of the VNC server has been designed with some limitations in 
+ * order to keep memory and processor power requirements to a minimum.
+ *
+ * The VNC client must accept the settings that the VNC server suggests (bits-per-pixel, 
+ * number-of-colours and so on as specified at build time with the eCos configuration 
+ * tool) or the VNC server will just disconnect.
+ *
+ * The VNC server only supports CoRRE encoding and RAW encoding for sending 
+ * display data to the client.
+ *
+ * The VNC server does not support password authentication, the client is able 
+ * to connect without the user typing in a password.
+ *
+ * Only one VNC client may connect to the VNC server at a time.
+ *
+ * In reality these limitations are not a problem.
+ *
+ * @author Chris Garry <cgarry@sweeneydesign.co.uk>
+ * @author Michiel Broek.
+ */
+
+
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <string.h>
+#include <stdbool.h>
+#include <errno.h>
+#include <sys/unistd.h>
+#include "lwip/sockets.h"
+#include "lwip/netdb.h"
+#include "esp_log.h"
+#include "freertos/FreeRTOS.h"
+#include "freertos/task.h"
+#include "freertos/semphr.h"
+#include "freertos/event_groups.h"
+
+
+
+/**
+ * @brief Type to hold the frame format details
+ */
+typedef struct
+{
+    uint16_t	frame_width;			///< Frame width
+    uint16_t	frame_height;			///< Frame height
+    void	*frame_buffer;			///< Frame buffer data
+    bool	rgb332;				///< 8 bits RGB format (only one is set).
+    bool	rgb555;				///< 15 bits RGB
+    bool	rgb565;				///< 16 bits RGB
+    bool	bgr233;				///< 8 bits BGR format
+    bool	truecolor0888;			///< 24 bits truecolor.
+} vnc_frame_format_t;
+
+
+
+typedef uint8_t vnc_color_t;
+
+
+
+/**
+ * @brief Start the VNC server. Two tasks are started, one to handle the
+ *        clients and one that serves the updates of the framebuffer.
+ */
+void VncStartup(void);
+
+/**
+ * @brief Clear the display and set a background color.
+ * @param color Then RGB color for the background.
+ */
+void  VncCls(vnc_color_t color);
+
+/**
+ * @brief Draw a pixel on the display.
+ * @param x The horizontal position of the pixel.
+ * @param y The vertical position of the pixel.
+ * @param color The RGB value of the pixel.
+ */
+void VncDrawPixel(uint16_t x, uint16_t y, vnc_color_t color);
+
+/**
+ * @brief Draw a horizontal line on the display.
+ * @param x1 Start horizontal position.
+ * @param x2 End of the horizontal position.
+ * @param y The vertical position of the line.
+ * @param colour The RGB color of the line.
+ */
+void VncDrawHorzLine(uint16_t x1, uint16_t x2, uint16_t y, vnc_color_t color);
+
+/**
+ * @brief Draw a vertical line on the display.
+ * @param x The jprizontal position of the line.
+ * @param y1 The vertical top position of the line.
+ * @param y2 The vertical bottom position of the line.
+ * @param color The RGB color of the line.
+ */
+void VncDrawVertLine(uint16_t x, uint16_t y1, uint16_t y2, vnc_color_t color);
+
+/**
+ * @brief Fill a rectangle with the given color.
+ * @param x1 The top-left horizontal start position.
+ * @param y1 The top-left vertical start position.
+ * @param x2 The bottom-right horizontal end position.
+ * @param y2 The bottom-right vertical end position.
+ * @param color The RGB color of the line.
+ */
+void VncFillRect(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, vnc_color_t color);
+
+/**
+ * @brief Sound the bell on the client computer.
+ */
+void VncSoundBell(void);
+
+
+/* Macro to convert from RGB to colour values */
+#define VNC_RGB2COL(r,g,b) (vnc_color_t)(((((uint8_t)r)&0xE0) >> 0) | ((((uint8_t)g)&0xE0) >> 3) | ((((uint8_t)b)&0xC0) >> 6))
+
+
+/**
+ * @brief Start task for a websocket client.
+ */
+int VncStartWS(int num);
+
+/**
+ * @brief Stop task for a websocket client.
+ */
+void VncStopWS(int num);
+
+/**
+ * @brief Remote websocket message to the VNC server.
+ */
+void VncGetWSmessage(char *msg, uint16_t len);
+

mercurial