Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
electronick-co committed Dec 8, 2022
2 parents 4b11fba + a170cba commit ba694a0
Show file tree
Hide file tree
Showing 43 changed files with 4,320 additions and 854 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
cmake_minimum_required(VERSION 3.5)

include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(MK32)
project(DeepDeck)
8 changes: 0 additions & 8 deletions components/battery/include/battery_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@
#ifndef BATTERY_MONITOR_BATTERY_MONITOR_H_
#define BATTERY_MONITOR_BATTERY_MONITOR_H_

#ifdef __cplusplus
extern "C" {
#endif

/*
*Please make sure you understand what is a voltage divider before modifying
* */
Expand All @@ -34,8 +30,4 @@ uint32_t get_battery_level(void);
//initialize battery monitor pin
void init_batt_monitor(void);

#ifdef __cplusplus
}
#endif

#endif /* BATTERY_MONITOR_BATTERY_MONITOR_H_ */
33 changes: 16 additions & 17 deletions components/ble/hal_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ void halBLETask_mouse(void * params) {
//check if queue is initialized
if (mouse_q != NULL) {
{
while (1) {
while (1)
{

//pend on MQ, if timeout triggers, just wait again.
if (xQueueReceive(mouse_q, &mouse_report, portMAX_DELAY)) {
Expand Down Expand Up @@ -261,7 +262,8 @@ void halBLETask_joystick(void * params) {
//check if queue is initialized
if (joystick_q != NULL) {
{
while (1) {
while (1)
{
//pend on MQ, if timeout triggers, just wait again.
if (xQueueReceive(joystick_q, &joystick_report,
portMAX_DELAY)) {
Expand Down Expand Up @@ -291,8 +293,8 @@ void halBLETask_media(void * params) {
//check if queue is initialized
if (media_q != NULL) {
{
while (1) {

while (1)
{
//pend on MQ, if timeout triggers, just wait again.
if (xQueueReceive(media_q, &media_report, portMAX_DELAY)) {

Expand Down Expand Up @@ -433,19 +435,16 @@ esp_err_t halBLEInit(uint8_t enableKeyboard, uint8_t enableMedia,
TaskHandle_t xBLETask_media;
TaskHandle_t xBLETask_joystick;

xTaskCreatePinnedToCore(halBLETask_battery, "ble_task_battery",
TASK_BLE_STACKSIZE, NULL, configMAX_PRIORITIES, &xBLETask_battery,
0);
xTaskCreatePinnedToCore(halBLETask_keyboard, "ble_task_keyboard",
TASK_BLE_STACKSIZE, NULL, configMAX_PRIORITIES, &xBLETask_keyboard,
0);
xTaskCreatePinnedToCore(halBLETask_mouse, "ble_task_mouse",
TASK_BLE_STACKSIZE, NULL, configMAX_PRIORITIES, &xBLETask_mouse, 0);
xTaskCreatePinnedToCore(halBLETask_media, "ble_task_media",
TASK_BLE_STACKSIZE, NULL, configMAX_PRIORITIES, &xBLETask_media, 0);
xTaskCreatePinnedToCore(halBLETask_joystick, "ble_task_joystick",
TASK_BLE_STACKSIZE, NULL, configMAX_PRIORITIES, &xBLETask_joystick,
0);
xTaskCreate(halBLETask_battery, "ble_task_battery",
TASK_BLE_STACKSIZE, NULL, 6, &xBLETask_battery);
xTaskCreate(halBLETask_keyboard, "ble_task_keyboard",
TASK_BLE_STACKSIZE, NULL, 6, &xBLETask_keyboard);
xTaskCreate(halBLETask_mouse, "ble_task_mouse",
TASK_BLE_STACKSIZE, NULL, 6, &xBLETask_mouse);
xTaskCreate(halBLETask_media, "ble_task_media",
TASK_BLE_STACKSIZE, NULL, 6, &xBLETask_media);
xTaskCreate(halBLETask_joystick, "ble_task_joystick",
TASK_BLE_STACKSIZE, NULL, 6, &xBLETask_joystick);

//set log level according to define
esp_log_level_set(HID_LE_PRF_TAG, LOG_LEVEL_BLE);
Expand Down
3 changes: 0 additions & 3 deletions components/ble/include/hid_dev.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@

#include "hidd_le_prf_int.h"

#ifdef __cplusplus
extern "C" {
#endif
#include "keyboard_config.h"

/* HID Report type */
Expand Down
8 changes: 0 additions & 8 deletions components/ble/include/keylayouts.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

//#define LAYOUT_US_ENGLISH
//#define LAYOUT_CANADIAN_FRENCH
//#define LAYOUT_CANADIAN_MULTILINGUAL
Expand Down Expand Up @@ -5718,8 +5714,4 @@ extern "C" {

#endif // LAYOUT_SERBIAN_LATIN_ONLY

#ifdef __cplusplus
} // extern "C"
#endif

#endif
7 changes: 0 additions & 7 deletions components/espnowmk32/include/espnow_receive.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,12 @@

#include <freertos/queue.h>

#ifdef __cplusplus
extern "C" {
#endif

//Queue for receiving report from slave
extern QueueHandle_t espnow_receive_q;

/** @Setup the function for receiving data via espnow
* */
void espnow_receive(void);

#ifdef __cplusplus
}
#endif

#endif /* ESPNOW_SPLIT_H_ */
8 changes: 0 additions & 8 deletions components/espnowmk32/include/espnow_send.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@

#include <freertos/queue.h>

#ifdef __cplusplus
extern "C" {
#endif

//Queue for sending report from matrix scan
extern QueueHandle_t espnow_matrix_send_q;
extern QueueHandle_t espnow_encoder_send_q;
Expand All @@ -23,8 +19,4 @@ extern QueueHandle_t espnow_encoder_send_q;
void espnow_send(void);


#ifdef __cplusplus
}
#endif

#endif /* ESPNOW_SPLIT_H_ */
9 changes: 0 additions & 9 deletions components/hidkeycodeconv/include/keycode_conv.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@
#include <freertos/queue.h>
#include "keyboard_config.h"

#ifdef __cplusplus
extern "C" {
#endif

//Flag to enable or disable sending reports via BLE
int BLE_EN;

Expand Down Expand Up @@ -54,9 +50,4 @@ uint8_t char_to_keycode(char ascii_key);
*/
char* input_string(void);

#ifdef __cplusplus
}
#endif


#endif /* KEYCODE_CONV_KEYCODE_CONV_H_ */
2 changes: 1 addition & 1 deletion components/menu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ idf_component_register(SRCS "${component_srcs}"
INCLUDE_DIRS "include" "${CMAKE_SOURCE_DIR}/main"
PRIV_INCLUDE_DIRS ""
PRIV_REQUIRES "driver"
REQUIRES "ble" "rotary_encoder")
REQUIRES "ble" "rotary_encoder" "rgb_led")
21 changes: 11 additions & 10 deletions components/menu/include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#ifndef MENU_H
#define MENU_H

#include "esp_err.h"
#include "u8g2.h"
#include "oled_tasks.h"
#include "rotary_encoder.h"
#include "rgb_led.h"

/**
* @brief DeepDeck Status
Expand Down Expand Up @@ -98,16 +98,17 @@ menu_ret menu_goto_sleep(void);
menu_ret menu_exit(void);

uint8_t menu_get_goto_sleep(void);
uint8_t menu_send_rgb_mode(uint8_t mode);
uint8_t menu_rgb_mode_0(void);
uint8_t menu_rgb_mode_1(void);
uint8_t menu_rgb_mode_2(void);
uint8_t menu_rgb_mode_3(void);
uint8_t menu_rgb_mode_4(void);

menu_t menu_main;
extern menu_item_t m_main_array[];

extern menu_t menu_bluetooth;
extern menu_item_t m_bluetooth_array[];




#ifdef __cplusplus
}
#endif
#endif
71 changes: 65 additions & 6 deletions components/menu/src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@
#include "esp_log.h"
#include "menu.h"

#define true 1
#define false 0

#define MY_BORDER_SIZE 1
//#define U8G2_REF_MAN_PIC
static const char *TAG = "menu";
//static const char *TAG = "menu";

volatile menu_event_t menu_event;

Expand All @@ -30,7 +32,6 @@ volatile menu_event_t menu_event;




// typedef struct menu_item_str_t{
// char * description; //String of the menu item
// menu_item_action action; //Action if the item. It can take to a new menu or run a function
Expand All @@ -51,6 +52,7 @@ enum {
NONE = -1,
MAIN_MENU = 0,
BLUETOOTH_MENU,
LED_MODE_MENU,
menu_num

} menu_list;
Expand All @@ -60,12 +62,14 @@ enum {
char menu_titles[menu_num][MENU_CHAR_NUM] =
{
"Main Menu",
"Bluetooth"
"Bluetooth",
"LED modes"
};

char menu_subtitles[menu_num][MENU_CHAR_NUM] =
{
"DeepSea",
"DeepDeck",
"DeepDeck"
};

Expand All @@ -82,13 +86,13 @@ menu_item_t m_main_array[] =
{
//Descripción //Acción //Siguiente menu ó //Función
{menu_main_description[0], MA_MENU, BLUETOOTH_MENU, 0},
{menu_main_description[1], MA_FUNCTION, NONE, &splashScreen},
{menu_main_description[1], MA_MENU, LED_MODE_MENU, 0},
{menu_main_description[2], MA_FUNCTION, NONE, &splashScreen},
{menu_main_description[3], MA_FUNCTION, NONE, &menu_goto_sleep},
{menu_main_description[4], MA_FUNCTION, NONE, &menu_exit},
{0, MA_END, 0, 0}
};
// ------------------Bluetooth Menu-------------------------------
// ------------------Bluetooth Menu-------------------------------
char menu_bt_description[2][MENU_CHAR_NUM] =
{
"Bluetooth 1",
Expand All @@ -102,13 +106,34 @@ menu_item_t m_bluetooth_array[] =
{0, MA_END, 0, 0}
};

// ------------------LED modes -------------------------------
char menu_led_mode[5][MENU_CHAR_NUM] =
{
"Off",
"Pulsating",
"Progressive",
"Rainbow",
"Solid"
};
menu_item_t m_led_array[] =
{
//Descripción //Acción //Siguiente menu ó //Función
{menu_led_mode[0], MA_FUNCTION, NONE, &menu_rgb_mode_0},
{menu_led_mode[1], MA_FUNCTION, NONE, &menu_rgb_mode_1},
{menu_led_mode[2], MA_FUNCTION, NONE, &menu_rgb_mode_2},
{menu_led_mode[3], MA_FUNCTION, NONE, &menu_rgb_mode_3},
{menu_led_mode[4], MA_FUNCTION, NONE, &menu_rgb_mode_4},
{0, MA_END, 0, 0}
};

// ----------------------------------- Menu Array ------------------------------------------

menu_t menu_array[menu_num] =
{
// Title //Subtitle //Item array
{menu_titles[MAIN_MENU], menu_subtitles[MAIN_MENU], &m_main_array},
{menu_titles[BLUETOOTH_MENU], menu_subtitles[BLUETOOTH_MENU], &m_bluetooth_array},
{menu_titles[LED_MODE_MENU], menu_subtitles[LED_MODE_MENU], &m_led_array},
};


Expand Down Expand Up @@ -480,4 +505,38 @@ uint8_t menu_get_goto_sleep(void)
return true;
}
return goto_sleep;
}
}

uint8_t menu_send_rgb_mode(uint8_t mode)
{
int mode_t = mode;
xQueueSend(keyled_q, &mode_t, 0);

return mret_none;
}

// ToDo: Optimize this
uint8_t menu_rgb_mode_0(void)
{
return menu_send_rgb_mode(0);
}

uint8_t menu_rgb_mode_1(void)
{
return menu_send_rgb_mode(1);
}

uint8_t menu_rgb_mode_2(void)
{
return menu_send_rgb_mode(2);
}

uint8_t menu_rgb_mode_3(void)
{
return menu_send_rgb_mode(3);
}

uint8_t menu_rgb_mode_4(void)
{
return menu_send_rgb_mode(4);
}
5 changes: 5 additions & 0 deletions components/mqtt_dd/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
set(component_srcs "src/mqtt.c")

idf_component_register(SRCS "${component_srcs}"
INCLUDE_DIRS "include" "${CMAKE_SOURCE_DIR}/main"
REQUIRES "mqtt")
16 changes: 16 additions & 0 deletions components/mqtt_dd/include/mqtt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

#ifndef MQTT_H
#define MQTT_H

void mqtt_app_start(void);

/**
* @brief Publish a message to a given topic
*
* @param topic topic to be sent
* @param message message to send
* @return int -1 if failed, id of message otherwise
*/
int mqtt_pub(char * topic, char * message);

#endif
Loading

0 comments on commit ba694a0

Please sign in to comment.