|
@@ -1,11 +1,16 @@
|
|
|
#include "eth_view_process.h"
|
|
#include "eth_view_process.h"
|
|
|
#include "eth_worker.h"
|
|
#include "eth_worker.h"
|
|
|
#include "eth_worker_i.h"
|
|
#include "eth_worker_i.h"
|
|
|
|
|
+
|
|
|
|
|
+#include <furi_hal.h>
|
|
|
#include <gui/gui.h>
|
|
#include <gui/gui.h>
|
|
|
#include <gui/canvas.h>
|
|
#include <gui/canvas.h>
|
|
|
#include <string.h>
|
|
#include <string.h>
|
|
|
|
|
+
|
|
|
#include "u8g2.h"
|
|
#include "u8g2.h"
|
|
|
|
|
|
|
|
|
|
+#define TAG "EthView"
|
|
|
|
|
+
|
|
|
void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
|
|
void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
|
|
|
furi_assert(canvas);
|
|
furi_assert(canvas);
|
|
|
furi_assert(process);
|
|
furi_assert(process);
|
|
@@ -15,38 +20,31 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
|
|
|
const uint8_t y = process->y;
|
|
const uint8_t y = process->y;
|
|
|
const uint8_t str_height = 11;
|
|
const uint8_t str_height = 11;
|
|
|
const uint8_t str_count = (64 - y) / str_height;
|
|
const uint8_t str_count = (64 - y) / str_height;
|
|
|
-
|
|
|
|
|
- int8_t position = process->position;
|
|
|
|
|
uint8_t carriage = process->carriage;
|
|
uint8_t carriage = process->carriage;
|
|
|
|
|
+ uint8_t position = process->position;
|
|
|
|
|
|
|
|
if(process->autofill) {
|
|
if(process->autofill) {
|
|
|
- if(carriage > str_count) {
|
|
|
|
|
- position = carriage - str_count;
|
|
|
|
|
- } else {
|
|
|
|
|
- position = 0;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ position = (carriage + SCREEN_STRINGS_COUNT - str_count) % SCREEN_STRINGS_COUNT;
|
|
|
|
|
+ process->position = position;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
for(uint8_t i = 0; i < str_count; ++i) {
|
|
for(uint8_t i = 0; i < str_count; ++i) {
|
|
|
- canvas_draw_str(
|
|
|
|
|
- canvas,
|
|
|
|
|
- x,
|
|
|
|
|
- y + (i + 1) * str_height,
|
|
|
|
|
- process->fifo[(position + i) % SCREEN_STRINGS_COUNT]);
|
|
|
|
|
|
|
+ uint8_t y1 = y + (i + 1) * str_height;
|
|
|
|
|
+ canvas_draw_str(canvas, x, y1, process->fifo[(position + i) % SCREEN_STRINGS_COUNT]);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
void ethernet_view_process_move(EthViewProcess* process, int8_t shift) {
|
|
void ethernet_view_process_move(EthViewProcess* process, int8_t shift) {
|
|
|
furi_assert(process);
|
|
furi_assert(process);
|
|
|
|
|
+ uint8_t position = process->position;
|
|
|
if(shift <= -SCREEN_STRINGS_COUNT) {
|
|
if(shift <= -SCREEN_STRINGS_COUNT) {
|
|
|
- process->position = 0;
|
|
|
|
|
|
|
+ position = 0;
|
|
|
} else if(shift >= SCREEN_STRINGS_COUNT) {
|
|
} else if(shift >= SCREEN_STRINGS_COUNT) {
|
|
|
- process->position = process->carriage - 1;
|
|
|
|
|
|
|
+ position = process->carriage - 1;
|
|
|
} else {
|
|
} else {
|
|
|
- process->position =
|
|
|
|
|
- (process->position + (SCREEN_STRINGS_COUNT + shift)) % SCREEN_STRINGS_COUNT;
|
|
|
|
|
|
|
+ position = (position + (SCREEN_STRINGS_COUNT + shift)) % SCREEN_STRINGS_COUNT;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ process->position = position;
|
|
|
process->autofill = !shift;
|
|
process->autofill = !shift;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -56,7 +54,7 @@ void ethernet_view_process_autofill(EthViewProcess* process, uint8_t state) {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
static uint16_t get_string_with_width(const char* str, uint16_t width) {
|
|
static uint16_t get_string_with_width(const char* str, uint16_t width) {
|
|
|
- u8g2_t canvas_memory[3];
|
|
|
|
|
|
|
+ u8g2_t canvas_memory;
|
|
|
Canvas* canvas = &canvas_memory; // grazniy hack
|
|
Canvas* canvas = &canvas_memory; // grazniy hack
|
|
|
canvas_set_font(canvas, FontSecondary);
|
|
canvas_set_font(canvas, FontSecondary);
|
|
|
|
|
|
|
@@ -91,11 +89,13 @@ void ethernet_view_process_print(EthViewProcess* process, const char* str) {
|
|
|
while(ptr < len) {
|
|
while(ptr < len) {
|
|
|
uint16_t start = ptr;
|
|
uint16_t start = ptr;
|
|
|
ptr += get_string_with_width(str + ptr, max_width);
|
|
ptr += get_string_with_width(str + ptr, max_width);
|
|
|
- memset(process->fifo[process->carriage % SCREEN_STRINGS_COUNT], 0, SCREEN_SYMBOLS_WIDTH);
|
|
|
|
|
- memcpy(process->fifo[process->carriage % SCREEN_STRINGS_COUNT], str + start, ptr - start);
|
|
|
|
|
- process->carriage += 1;
|
|
|
|
|
- if(process->carriage > SCREEN_STRINGS_COUNT * 2) {
|
|
|
|
|
- process->carriage -= SCREEN_STRINGS_COUNT;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ uint8_t carriage = process->carriage;
|
|
|
|
|
+ uint8_t carriage1 = (carriage + 1) % SCREEN_STRINGS_COUNT;
|
|
|
|
|
+ uint8_t carriage2 = (carriage + 2) % SCREEN_STRINGS_COUNT;
|
|
|
|
|
+ memset(process->fifo[carriage], 0, SCREEN_SYMBOLS_WIDTH);
|
|
|
|
|
+ memset(process->fifo[carriage1], 0, SCREEN_SYMBOLS_WIDTH);
|
|
|
|
|
+ memset(process->fifo[carriage2], 0, SCREEN_SYMBOLS_WIDTH);
|
|
|
|
|
+ memcpy(process->fifo[carriage], str + start, ptr - start);
|
|
|
|
|
+ process->carriage = carriage1;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|