eth_view_process.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. #pragma once
  2. #include "eth_worker.h"
  3. #include "eth_save_process.h"
  4. #include <gui/gui.h>
  5. #define SCREEN_SYMBOLS_WIDTH 30
  6. EthViewProcess* ethernet_view_process_malloc(EthWorkerProcess type, EthernetSaveConfig* config);
  7. void ethernet_view_process_free(EthViewProcess* evp);
  8. void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas);
  9. void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key);
  10. void ethernet_view_process_print(EthViewProcess* process, const char* str);
  11. void ethernet_view_process_move(EthViewProcess* process, int8_t shift);
  12. void evp_printf(EthViewProcess* process, const char* format, ...);
  13. typedef struct u8x8_struct u8x8_t;
  14. typedef struct u8x8_display_info_struct u8x8_display_info_t;
  15. typedef struct u8x8_tile_struct u8x8_tile_t;
  16. typedef uint8_t (*u8x8_msg_cb)(u8x8_t* u8x8, uint8_t msg, uint8_t arg_int, void* arg_ptr);
  17. typedef uint16_t (*u8x8_char_cb)(u8x8_t* u8x8, uint8_t b);
  18. struct u8x8_struct {
  19. const u8x8_display_info_t* display_info;
  20. u8x8_char_cb next_cb; /* procedure, which will be used to get the next char from the string */
  21. u8x8_msg_cb display_cb;
  22. u8x8_msg_cb cad_cb;
  23. u8x8_msg_cb byte_cb;
  24. u8x8_msg_cb gpio_and_delay_cb;
  25. uint32_t bus_clock; /* can be used by the byte function to store the clock speed of the bus */
  26. const uint8_t* font;
  27. uint16_t encoding; /* encoding result for utf8 decoder in next_cb */
  28. uint8_t x_offset; /* copied from info struct, can be modified in flip mode */
  29. uint8_t is_font_inverse_mode; /* 0: normal, 1: font glyphs are inverted */
  30. uint8_t
  31. i2c_address; /* a valid i2c adr. Initially this is 255, but this is set to something useful during DISPLAY_INIT */
  32. /* i2c_address is the address for writing data to the display */
  33. /* usually, the lowest bit must be zero for a valid address */
  34. uint8_t i2c_started; /* for i2c interface */
  35. //uint8_t device_address; /* OBSOLETE???? - this is the device address, replacement for U8X8_MSG_CAD_SET_DEVICE */
  36. uint8_t utf8_state; /* number of chars which are still to scan */
  37. uint8_t gpio_result; /* return value from the gpio call (only for MENU keys at the moment) */
  38. uint8_t debounce_default_pin_state;
  39. uint8_t debounce_last_pin_state;
  40. uint8_t debounce_state;
  41. uint8_t debounce_result_msg; /* result msg or event after debounce */
  42. #ifdef U8X8_WITH_USER_PTR
  43. void* user_ptr;
  44. #endif
  45. #ifdef U8X8_USE_PINS
  46. uint8_t pins
  47. [U8X8_PIN_CNT]; /* defines a pinlist: Mainly a list of pins for the Arduino Environment, use U8X8_PIN_xxx to access */
  48. #endif
  49. };
  50. typedef uint8_t u8g2_uint_t; /* for pixel position only */
  51. typedef int8_t u8g2_int_t; /* introduced for circle calculation */
  52. typedef int16_t u8g2_long_t; /* introduced for ellipse calculation */
  53. typedef struct u8g2_struct u8g2_t;
  54. typedef struct u8g2_cb_struct u8g2_cb_t;
  55. typedef void (*u8g2_update_dimension_cb)(u8g2_t* u8g2);
  56. typedef void (*u8g2_update_page_win_cb)(u8g2_t* u8g2);
  57. typedef void (
  58. *u8g2_draw_l90_cb)(u8g2_t* u8g2, u8g2_uint_t x, u8g2_uint_t y, u8g2_uint_t len, uint8_t dir);
  59. typedef void (*u8g2_draw_ll_hvline_cb)(
  60. u8g2_t* u8g2,
  61. u8g2_uint_t x,
  62. u8g2_uint_t y,
  63. u8g2_uint_t len,
  64. uint8_t dir);
  65. typedef uint8_t (*u8g2_get_kerning_cb)(u8g2_t* u8g2, uint16_t e1, uint16_t e2);
  66. /* from ucglib... */
  67. struct _u8g2_font_info_t {
  68. /* offset 0 */
  69. uint8_t glyph_cnt;
  70. uint8_t bbx_mode;
  71. uint8_t bits_per_0;
  72. uint8_t bits_per_1;
  73. /* offset 4 */
  74. uint8_t bits_per_char_width;
  75. uint8_t bits_per_char_height;
  76. uint8_t bits_per_char_x;
  77. uint8_t bits_per_char_y;
  78. uint8_t bits_per_delta_x;
  79. /* offset 9 */
  80. int8_t max_char_width;
  81. int8_t
  82. max_char_height; /* overall height, NOT ascent. Instead ascent = max_char_height + y_offset */
  83. int8_t x_offset;
  84. int8_t y_offset;
  85. /* offset 13 */
  86. int8_t ascent_A;
  87. int8_t descent_g; /* usually a negative value */
  88. int8_t ascent_para;
  89. int8_t descent_para;
  90. /* offset 17 */
  91. uint16_t start_pos_upper_A;
  92. uint16_t start_pos_lower_a;
  93. /* offset 21 */
  94. #ifdef U8G2_WITH_UNICODE
  95. uint16_t start_pos_unicode;
  96. #endif
  97. };
  98. typedef struct _u8g2_font_info_t u8g2_font_info_t;
  99. /* from ucglib... */
  100. struct _u8g2_font_decode_t {
  101. const uint8_t* decode_ptr; /* pointer to the compressed data */
  102. u8g2_uint_t target_x;
  103. u8g2_uint_t target_y;
  104. int8_t x; /* local coordinates, (0,0) is upper left */
  105. int8_t y;
  106. int8_t glyph_width;
  107. int8_t glyph_height;
  108. uint8_t decode_bit_pos; /* bitpos inside a byte of the compressed data */
  109. uint8_t is_transparent;
  110. uint8_t fg_color;
  111. uint8_t bg_color;
  112. #ifdef U8G2_WITH_FONT_ROTATION
  113. uint8_t dir; /* direction */
  114. #endif
  115. };
  116. typedef struct _u8g2_font_decode_t u8g2_font_decode_t;
  117. struct _u8g2_kerning_t {
  118. uint16_t first_table_cnt;
  119. uint16_t second_table_cnt;
  120. const uint16_t* first_encoding_table;
  121. const uint16_t* index_to_second_table;
  122. const uint16_t* second_encoding_table;
  123. const uint8_t* kerning_values;
  124. };
  125. typedef struct _u8g2_kerning_t u8g2_kerning_t;
  126. struct u8g2_cb_struct {
  127. u8g2_update_dimension_cb update_dimension;
  128. u8g2_update_page_win_cb update_page_win;
  129. u8g2_draw_l90_cb draw_l90;
  130. };
  131. typedef u8g2_uint_t (*u8g2_font_calc_vref_fnptr)(u8g2_t* u8g2);
  132. struct u8g2_struct {
  133. u8x8_t u8x8;
  134. u8g2_draw_ll_hvline_cb ll_hvline; /* low level hvline procedure */
  135. const u8g2_cb_t* cb; /* callback drawprocedures, can be replaced for rotation */
  136. /* the following variables must be assigned during u8g2 setup */
  137. uint8_t*
  138. tile_buf_ptr; /* ptr to memory area with u8x8.display_info->tile_width * 8 * tile_buf_height bytes */
  139. uint8_t tile_buf_height; /* height of the tile memory area in tile rows */
  140. uint8_t tile_curr_row; /* current row for picture loop */
  141. /* dimension of the buffer in pixel */
  142. u8g2_uint_t pixel_buf_width; /* equal to tile_buf_width*8 */
  143. u8g2_uint_t pixel_buf_height; /* tile_buf_height*8 */
  144. u8g2_uint_t pixel_curr_row; /* u8g2.tile_curr_row*8 */
  145. /* the following variables are set by the update dimension callback */
  146. /* this is the clipbox after rotation for the hvline procedures */
  147. //u8g2_uint_t buf_x0; /* left corner of the buffer */
  148. //u8g2_uint_t buf_x1; /* right corner of the buffer (excluded) */
  149. u8g2_uint_t buf_y0;
  150. u8g2_uint_t buf_y1;
  151. /* display dimensions in pixel for the user, calculated in u8g2_update_dimension_common() */
  152. u8g2_uint_t width;
  153. u8g2_uint_t height;
  154. /* this is the clip box for the user to check if a specific box has an intersection */
  155. /* use u8g2_IsIntersection from u8g2_intersection.c to test against this intersection */
  156. /* actually, this window describes the position of the current page */
  157. u8g2_uint_t user_x0; /* left corner of the buffer */
  158. u8g2_uint_t user_x1; /* right corner of the buffer (excluded) */
  159. u8g2_uint_t user_y0; /* upper edge of the buffer */
  160. u8g2_uint_t user_y1; /* lower edge of the buffer (excluded) */
  161. #ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
  162. /* clip window */
  163. u8g2_uint_t clip_x0; /* left corner of the clip window */
  164. u8g2_uint_t clip_x1; /* right corner of the clip window (excluded) */
  165. u8g2_uint_t clip_y0; /* upper edge of the clip window */
  166. u8g2_uint_t clip_y1; /* lower edge of the clip window (excluded) */
  167. #endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
  168. /* information about the current font */
  169. const uint8_t* font; /* current font for all text procedures */
  170. // removed: const u8g2_kerning_t *kerning; /* can be NULL */
  171. // removed: u8g2_get_kerning_cb get_kerning_cb;
  172. u8g2_font_calc_vref_fnptr font_calc_vref;
  173. u8g2_font_decode_t font_decode; /* new font decode structure */
  174. u8g2_font_info_t font_info; /* new font info structure */
  175. #ifdef U8G2_WITH_CLIP_WINDOW_SUPPORT
  176. /* 1 of there is an intersection between user_?? and clip_?? box */
  177. uint8_t is_page_clip_window_intersection;
  178. #endif /* U8G2_WITH_CLIP_WINDOW_SUPPORT */
  179. uint8_t font_height_mode;
  180. int8_t font_ref_ascent;
  181. int8_t font_ref_descent;
  182. int8_t glyph_x_offset; /* set by u8g2_GetGlyphWidth as a side effect */
  183. uint8_t bitmap_transparency; /* black pixels will be treated as transparent (not drawn) */
  184. uint8_t draw_color; /* 0: clear pixel, 1: set pixel, modified and restored by font procedures */
  185. /* draw_color can be used also directly by the user API */
  186. // the following variable should be renamed to is_buffer_auto_clear
  187. uint8_t
  188. is_auto_page_clear; /* set to 0 to disable automatic clear of the buffer in firstPage() and nextPage() */
  189. };
  190. typedef struct EthViewProcessLine {
  191. char data[SCREEN_SYMBOLS_WIDTH];
  192. } EthViewProcessLine;
  193. struct EthViewProcess {
  194. EthViewProcessLine* fifo;
  195. EthWorkerProcess type;
  196. uint8_t strings_cnt;
  197. uint8_t carriage;
  198. uint8_t position;
  199. uint8_t autofill;
  200. uint8_t editing;
  201. uint8_t x;
  202. uint8_t y;
  203. void* draw_struct;
  204. };
  205. typedef struct EthViewDrawInit {
  206. uint8_t* mac;
  207. uint8_t current_octet;
  208. } EthViewDrawInit;
  209. typedef enum {
  210. EthViewDrawStaticModeIp,
  211. EthViewDrawStaticModeMask,
  212. EthViewDrawStaticModeGateway,
  213. EthViewDrawStaticModeDNS
  214. } EthViewDrawStaticMode;
  215. typedef struct EthViewDrawStatic {
  216. EthViewDrawStaticMode current_mode;
  217. uint8_t* ip;
  218. uint8_t* mask;
  219. uint8_t* gateway;
  220. uint8_t* dns;
  221. uint8_t current_digit;
  222. uint8_t editing;
  223. } EthViewDrawStatic;
  224. typedef struct EthViewDrawPing {
  225. uint8_t current_digit;
  226. uint8_t* ip;
  227. } EthViewDrawPing;