Просмотр исходного кода

fixed some typos and fixed a ui bug where it flipped the hex-chars of the mac

Anton Stadie 2 лет назад
Родитель
Сommit
dbdbb1efb3
5 измененных файлов с 21 добавлено и 24 удалено
  1. 5 5
      eth_save_process.c
  2. 3 3
      eth_save_process.h
  3. 9 10
      eth_view_process.c
  4. 4 4
      eth_worker.c
  5. 0 2
      eth_worker_ping.c

+ 5 - 5
eth_save_process.c

@@ -250,7 +250,7 @@ void ethernet_save_process_read(EthernetSaveConfig* config) {
     furi_record_close(RECORD_STORAGE);
 }
 
-EthernetSaveConfig* ehternet_save_process_malloc() {
+EthernetSaveConfig* ethernet_save_process_malloc() {
     EthernetSaveConfig* config = malloc(sizeof(EthernetSaveConfig));
 
     set_default_config(config);
@@ -259,7 +259,7 @@ EthernetSaveConfig* ehternet_save_process_malloc() {
 
     Storage* storage = furi_record_open(RECORD_STORAGE);
 
-    FURI_LOG_E(TAG, "ehternet_save_process_malloc");
+    FURI_LOG_E(TAG, "ethernet_save_process_malloc");
 
     File* file = storage_file_alloc(storage);
 
@@ -275,7 +275,7 @@ EthernetSaveConfig* ehternet_save_process_malloc() {
     return config;
 }
 
-void ehternet_save_process_print(EthernetSaveConfig* config, const char* str) {
+void ethernet_save_process_print(EthernetSaveConfig* config, const char* str) {
     furi_assert(config);
     FuriHalRtcDateTime datetime = {0};
     furi_hal_rtc_get_datetime(&datetime);
@@ -291,8 +291,8 @@ void ehternet_save_process_print(EthernetSaveConfig* config, const char* str) {
         str);
 }
 
-void ehternet_save_process_free(EthernetSaveConfig* config) {
-    FURI_LOG_E(TAG, "ehternet_save_process_free");
+void ethernet_save_process_free(EthernetSaveConfig* config) {
+    FURI_LOG_E(TAG, "ethernet_save_process_free");
     ethernet_save_process_write(config);
     storage_file_close(config->log_file);
     storage_file_free(config->log_file);

+ 3 - 3
eth_save_process.h

@@ -26,6 +26,6 @@ typedef struct EthernetSaveConfig {
 #define ETHERNET_SAVE_DEFAULT_PING_IP \
     { 8, 8, 8, 8 }
 
-EthernetSaveConfig* ehternet_save_process_malloc();
-void ehternet_save_process_free(EthernetSaveConfig* config);
-void ehternet_save_process_print(EthernetSaveConfig* config, const char* str);
+EthernetSaveConfig* ethernet_save_process_malloc();
+void ethernet_save_process_free(EthernetSaveConfig* config);
+void ethernet_save_process_print(EthernetSaveConfig* config, const char* str);

+ 9 - 10
eth_view_process.c

@@ -168,8 +168,8 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
         for(uint8_t i = 0; i < 6; ++i) {
             uint8_t x1 = 29 + i * 17;
             uint8_t x2 = x1 + 6;
-            draw_hex_digit(canvas, x1, 25, (mac[i] & 0x0F));
-            draw_hex_digit(canvas, x2, 25, (mac[i] & 0xF0) >> 4);
+            draw_hex_digit(canvas, x1, 25, (mac[i] & 0xF0) >> 4);
+            draw_hex_digit(canvas, x2, 25, (mac[i] & 0x0F));
             if(editing && (octet / 2 == i)) {
                 uint8_t x = octet & 1 ? x2 : x1;
                 canvas_draw_line(canvas, x, 26, x + 4, 26);
@@ -226,10 +226,13 @@ void ethernet_view_process_draw(EthViewProcess* process, Canvas* canvas) {
 }
 
 static void mac_change_hex_digit(uint8_t* mac, uint8_t octet, int8_t diff) {
-    uint8_t digit = (octet & 1) ? (mac[octet / 2] >> 4) : (mac[octet / 2]);
+    uint8_t digit = (octet & 1) ? (mac[octet / 2] & 0x0F) : (mac[octet / 2] >> 4);
     digit = (digit + diff) & 0xF;
-    mac[octet / 2] = (mac[octet / 2] & ((octet & 1) ? 0x0F : 0xF0)) |
-                     (digit << ((octet & 1) ? 4 : 0));
+    if(octet & 1) {
+        mac[octet / 2] = (mac[octet / 2] & 0xF0) | digit;
+    } else {
+        mac[octet / 2] = (digit << 4) | (mac[octet / 2] & 0x0F);
+    }
 }
 
 static void adress_change_dec_digit(uint8_t* ip, uint8_t digit, int8_t diff) {
@@ -254,11 +257,7 @@ void ethernet_view_process_keyevent(EthViewProcess* process, InputKey key) {
         uint8_t octet = ((EthViewDrawInit*)process->draw_struct)->current_octet;
         uint8_t* mac = ((EthViewDrawInit*)process->draw_struct)->mac;
         if(key == InputKeyLeft) {
-            if(octet > 0) {
-                octet -= 1;
-            } else {
-                process->editing = 0;
-            }
+            if(octet > 0) octet -= 1;
         } else if(key == InputKeyRight) {
             if(octet < 11) octet += 1;
         } else if(key == InputKeyUp) {

+ 4 - 4
eth_worker.c

@@ -14,7 +14,7 @@ static EthWorker* static_worker = NULL;
 EthWorker* eth_worker_alloc() {
     EthWorker* worker = malloc(sizeof(EthWorker));
 
-    worker->config = ehternet_save_process_malloc();
+    worker->config = ethernet_save_process_malloc();
     furi_assert(worker->config);
 
     worker->init_process = ethernet_view_process_malloc(EthWorkerProcessInit, worker->config);
@@ -49,7 +49,7 @@ void eth_worker_free(EthWorker* worker) {
     ethernet_view_process_free(worker->stat_process);
     ethernet_view_process_free(worker->ping_process);
     ethernet_view_process_free(worker->reset_process);
-    ehternet_save_process_free(worker->config);
+    ethernet_save_process_free(worker->config);
 
     furi_timer_stop(worker->timer);
     furi_timer_free(worker->timer);
@@ -87,7 +87,7 @@ void eth_worker_set_active_process(EthWorker* worker, EthWorkerProcess state) {
 
 void eth_worker_log(EthWorker* worker, const char* str) {
     furi_assert(worker);
-    ehternet_save_process_print(worker->config, str);
+    ethernet_save_process_print(worker->config, str);
 }
 
 static EthViewProcess* get_process(EthWorker* worker, EthWorkerProcess process) {
@@ -119,7 +119,7 @@ void eth_log(EthWorkerProcess process, const char* format, ...) {
     va_end(args);
 
     FURI_LOG_I(TAG, "%s", string);
-    ehternet_save_process_print(static_worker->config, string);
+    ethernet_save_process_print(static_worker->config, string);
     ethernet_view_process_print(get_process(static_worker, process), string);
     if(process != EthWorkerProcessReset) {
         ethernet_view_process_print(get_process(static_worker, EthWorkerProcessReset), string);

+ 0 - 2
eth_worker_ping.c

@@ -2,8 +2,6 @@
 #include <furi_hal.h>
 #include <ping.h>
 
-uint8_t ping_count(uint8_t s, uint16_t pCount, uint8_t* addr);
-
 void ping_wait_ms(int ms) {
     furi_delay_ms(ms);
 }