Bläddra i källkod

Add reset and ph keys

Per Mårtensson 4 år sedan
förälder
incheckning
dd681fcb67
3 ändrade filer med 63 tillägg och 34 borttagningar
  1. 1 1
      sw/key800/src/abc800_gpio.cpp
  2. 46 27
      sw/key800/src/abc800_keyboard.cpp
  3. 16 6
      sw/key800/src/abc800_usb.cpp

+ 1 - 1
sw/key800/src/abc800_gpio.cpp

@@ -8,7 +8,7 @@ extern TaskHandle_t Keyboard_ABC800_Task_In;
 namespace abc800 {
     void IRAM_ATTR abc800keybord_rst_isr(){
         portENTER_CRITICAL(&sync_isr);
-        if (!xTaskNotifyFromISR(Keyboard_ABC800_Task_In, ABC800_KEY_IN_ABC800, eSetValueWithoutOverwrite,NULL))
+        if (!xTaskNotifyFromISR(Keyboard_ABC800_Task_In, ABC800_KEY_RESET, eSetValueWithoutOverwrite,NULL))
         {
             ESP_LOGE(TAG,"Could not notify task");
         }

+ 46 - 27
sw/key800/src/abc800_keyboard.cpp

@@ -56,22 +56,32 @@ namespace abc800
             uint32_t keyboard_action = 0;
             if (xTaskNotifyWait(0, ULONG_MAX, &keyboard_action , 5)  == pdPASS) {
 
-                if (abc800_gpio.abc800_getupdown()){
-                    uint8_t key = abc800_gpio.abc800_getkey();
-                    key800queue ascii = abc800_keyboard.getKeyboardKeycode(key);
-                    abc800_keyboard.abc800_old_key = key;
-                    if (xQueueSend(abc800_key_queue_out, (void *)&ascii, 0) != pdTRUE) {
-                        ESP_LOGE(TAG,"Queue full");
+                if (keyboard_action == ABC800_KEY_IN_ABC800)
+                {
+                    if (abc800_gpio.abc800_getupdown()){
+                        uint8_t key = abc800_gpio.abc800_getkey();
+                        key800queue ascii = abc800_keyboard.getKeyboardKeycode(key);
+                        abc800_keyboard.abc800_old_key = key;
+                        if (xQueueSend(abc800_key_queue_out, (void *)&ascii, 0) != pdTRUE) {
+                            ESP_LOGE(TAG,"Queue full");
+                        }
+                        xTimerStop(abc800_repeat_delay_timer, portMAX_DELAY);
+                        xTimerStop(abc800_repeat_timer, portMAX_DELAY);
+                        xTimerStop(abc800_check_timer, portMAX_DELAY);
+                        xTimerStart(abc800_repeat_delay_timer, portMAX_DELAY);
+                        xTimerStart(abc800_check_timer, portMAX_DELAY);
+                    }else{
+                        xTimerStop(abc800_repeat_delay_timer, portMAX_DELAY);
+                        xTimerStop(abc800_repeat_timer, portMAX_DELAY);
+                        xTimerStop(abc800_check_timer, portMAX_DELAY);
                     }
-                    xTimerStop(abc800_repeat_delay_timer, portMAX_DELAY);
-                    xTimerStop(abc800_repeat_timer, portMAX_DELAY);
-                    xTimerStop(abc800_check_timer, portMAX_DELAY);
-                    xTimerStart(abc800_repeat_delay_timer, portMAX_DELAY);
-                    xTimerStart(abc800_check_timer, portMAX_DELAY);
-                }else{
-                    xTimerStop(abc800_repeat_delay_timer, portMAX_DELAY);
-                    xTimerStop(abc800_repeat_timer, portMAX_DELAY);
-                    xTimerStop(abc800_check_timer, portMAX_DELAY);
+                }
+                if (keyboard_action == ABC800_KEY_RESET)
+                {
+                    digitalWrite(A800_RST,HIGH);
+                    delay(1000);
+                    digitalWrite(A800_RST,LOW);
+
                 }
 
             }       
@@ -158,20 +168,29 @@ namespace abc800
         if ( keyqueue.special == 0x50 ){
             return(0x08);
         }
-        if (keyqueue.special == 0x3a)
+        //F1-F8
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41)
         {
-            char x[15]={"10 print \"HEJ\""}; //F1
-            key800queue key800queue ;
-            key800queue.modifier=0x00;
-            key800queue.special=0x00;
 
-            for (uint8_t i=0;i<15;i++){
-                key800queue.ascii = x[i];
-                if (xQueueSend(abc800_key_queue_out, (void *)&key800queue, 0) != pdTRUE) {
-                    ESP_LOGE(TAG,"Queue full");
-                }
-            }
-            return (0x00);
+            return (keyqueue.special+0x86);
+        }
+        //F1-F8 Shift
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && (keyqueue.modifier == 0x02 ||  keyqueue.modifier == 0x20))
+        {
+
+            return (keyqueue.special+0x96);
+        }
+        //F1-F8 CTRL
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && (keyqueue.modifier == 0x01))
+        {
+
+            return (keyqueue.special+0xA6);
+        }
+        //F1-F8 CTRL+SHIFT
+        if (keyqueue.special >= 0x3a && keyqueue.special <= 0x41 && (keyqueue.modifier == 0x03 ||  keyqueue.modifier == 0x33))
+        {
+
+            return (keyqueue.special+0xB6);
         }
         if (keyqueue.special == 0x45) //F12
         {

+ 16 - 6
sw/key800/src/abc800_usb.cpp

@@ -4,12 +4,13 @@
 #include "keyboardpipe.h"
 #include "abc800_hidboot.h"
 #include "abc800_config.h"
-
+#include "abc800_gpio.h"
 extern USBHostKeyboard port;
 extern TimerHandle_t repeat_delay_timer_out;
 extern TimerHandle_t repeat_timer_out;
 extern KeyboardReportParser keyparse;
 extern TaskHandle_t Keyboard_Task_Out;
+extern TaskHandle_t Keyboard_ABC800_Task_In;
 extern QueueHandle_t abc800_key_queue_out;
 uint8_t old_key = 0x00;
 key800queue key800queueold; 
@@ -88,17 +89,26 @@ static void hid_datain_cb(ext_pipe_event_msg_t event, usb_irp_t *irp)
             
             if (old_key!=key)
             {
-              if (xQueueSend(abc800_key_queue_out, (void *)&key800queue, 0) != pdTRUE) {
-                ESP_LOGE(TAG,"Queue full");
+              // RESET
+              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{
+                if (xQueueSend(abc800_key_queue_out, (void *)&key800queue, 0) != pdTRUE) {
+                  ESP_LOGE(TAG,"Queue full");
+                }
+                key800queueold=key800queue;
+                xTimerStart(repeat_delay_timer_out, portMAX_DELAY);
               }
-              key800queueold=key800queue;
-              xTimerStart(repeat_delay_timer_out, portMAX_DELAY);
             }
             
           }
  
         }else{
-          digitalWrite(2,0);
+          digitalWrite(KEY800_LED,LOW);
         }
         old_key=key;