فهرست منبع

Add softserial

Per Mårtensson 4 سال پیش
والد
کامیت
a48d7d349e

+ 1 - 1
sw/key800/include/abc800_webcontent.h

@@ -68,7 +68,7 @@ const char index_html[] PROGMEM = R"rawliteral(
      font-weight: bold;
    }
   </style>
-<title>ABC80 Keyboard controller</title>
+<title>ABC800 Keyboard controller</title>
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <link rel="icon" href="data:,">
 </head>

+ 3 - 2
sw/key800/platformio.ini

@@ -23,10 +23,11 @@ lib_deps =
     https://github.com/bblanchon/ArduinoJson.git#5.x
     https://git.sweproj.com/pm/LITTLEFS.git#master
     https://git.sweproj.com/pm/ElegantOTAKEY80.git#master
+    https://github.com/plerup/espsoftwareserial.git#master
 
 
-upload_port = /dev/ttyUSB0
-monitor_port = /dev/ttyUSB0
+upload_port = com6
+monitor_port = com6
 monitor_speed = 115200
 
 build_type = debug

+ 5 - 3
sw/key800/src/abc800_keyboard.cpp

@@ -4,6 +4,7 @@
 #include "abc800_gpio.h"
 #include "abc800_config.h"
 #include "WiFi.h"
+#include <SoftwareSerial.h>
 static const char TAG[] = __FILE__;
 extern QueueHandle_t abc800_key_queue_out;
 extern QueueHandle_t abc800_key_queue_in;
@@ -78,6 +79,7 @@ namespace abc800
                 }
                 if (keyboard_action == ABC800_KEY_RESET)
                 {
+                    ESP_LOGI(TAG,"RESET");
                     digitalWrite(A800_RST,HIGH);
                     delay(1000);
                     digitalWrite(A800_RST,LOW);
@@ -169,13 +171,13 @@ namespace abc800
             return(0x08);
         }
         //F1-F8
-        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41)
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && keyqueue.modifier == 0x00)
         {
 
             return (keyqueue.special+0x86);
         }
         //F1-F8 Shift
-        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && (keyqueue.modifier == 0x02 ||  keyqueue.modifier == 0x20))
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && (keyqueue.modifier == 0x02 ||  keyqueue.modifier == 0x22))
         {
 
             return (keyqueue.special+0x96);
@@ -523,7 +525,7 @@ namespace abc800
         if (keyqueue.special == 0x2a )
             return(0x08);
         // Delete
-        if (keyqueue.special == 0x4c )
+        if (keyqueue.special == 0x4c && keyqueue.modifier!=0x05 )
             return(0x18);
         
         return (0xFF);

+ 4 - 2
sw/key800/src/abc800_usb.cpp

@@ -90,13 +90,15 @@ static void hid_datain_cb(ext_pipe_event_msg_t event, usb_irp_t *irp)
             if (old_key!=key)
             {
               // RESET
-              if (key800queue.modifier==0x05 || key ==0x4c) 
+              if (key800queue.modifier==0x05 && key ==0x4c) 
               {
                 if (!xTaskNotifyFromISR(Keyboard_ABC800_Task_In, ABC800_KEY_RESET, eSetValueWithoutOverwrite,NULL))
                 {
                     ESP_LOGE(TAG,"Could not notify task");
                 }
-              }else{
+              }
+              else
+              {
                 if (xQueueSend(abc800_key_queue_out, (void *)&key800queue, 0) != pdTRUE) {
                   ESP_LOGE(TAG,"Queue full");
                 }

+ 3 - 1
sw/key800/src/main.cpp

@@ -16,6 +16,7 @@
 #define LOG_LOCAL_LEVEL ESP_LOG_INFO
 #include "esp_log.h"
 #include <AsyncElegantOTA.h>
+#include <SoftwareSerial.h>
 #define DEVICE_ADDRESS 2
 static const char TAG[] = __FILE__;
 
@@ -46,7 +47,7 @@ TimerHandle_t repeat_timer_out = NULL;
 TimerHandle_t abc800_repeat_delay_timer = NULL;
 TimerHandle_t abc800_repeat_timer = NULL;
 TimerHandle_t abc800_check_timer = NULL;
-
+SoftwareSerial abc800_serial_keyboard;
 
 String macaddr;
 
@@ -59,6 +60,7 @@ void setup()
 {
   Serial.begin(KEY800_SERIAL_BAUD_RATE);
   Serial1.begin(650,SERIAL_8N2,A800_RXD,A800_TXD);
+  abc800_serial_keyboard.begin(650,SWSERIAL_8N2,K800_RXD,K800_TXD,false);
   abc800_littlefs.setup();
   abc800_littlefs.loadconfig();
   abc800_gpio.init();