Skip to content

Commit

Permalink
update last changes of kaleidoscope
Browse files Browse the repository at this point in the history
Signed-off-by: noteolvides <[email protected]>
  • Loading branch information
Noteolvides committed Oct 3, 2023
1 parent 332c39b commit 23c03f8
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 45 deletions.
5 changes: 2 additions & 3 deletions src/kaleidoscope/device/dygma/Defy_wireless.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifdef ARDUINO_ARCH_NRF52

#include "kaleidoscope/Runtime.h"
#include <Kaleidoscope-EEPROM-Settings.h>
#include <Kaleidoscope-LEDControl.h>
Expand All @@ -36,7 +35,7 @@
#include "Defy_wireless.h"
#include "LED-Palette-Theme-Defy.h"
#include "Radio_manager.h"
#include "Wire_nrf52.h"
#include "Wire.h" // Arduino Wire wrapper for the NRF52 chips
#include "defy_wireless/Focus.h"
#include "nrf_gpio.h"

Expand Down Expand Up @@ -728,7 +727,7 @@ void DefyNrf::side::reset_sides()

void DefyNrf::side::prepareForFlash()
{
Wire_nrf52::init(100);
Wire::begin(100);
}

uint16_t DefyNrf::settings::keyscanInterval()
Expand Down
84 changes: 42 additions & 42 deletions src/kaleidoscope/device/dygma/defy_wireless/Hand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,54 +43,54 @@ bool inline filterHand(Communications_protocol::Devices incomingDevice,Hand::Han

void Hand::init()
{
auto keyScanFunction = [this](Packet const &packet)
auto keyScanFunction = [this](Packet const &packet)
{
if (filterHand(packet.header.device, this_device_))
{
if (filterHand(packet.header.device, this_device_))
{
if (memcmp(key_data_.rows, packet.data, sizeof(key_data)) == 0) return;
new_key_ = true;
memcpy(key_data_.rows, packet.data, sizeof(key_data));
NRF_LOG_DEBUG("New key %lu",key_data_.all);
}
};
Communications.callbacks.bind(HAS_KEYS, keyScanFunction);
auto keyScanFunctionIsAlive = [this](Packet const &packet)
if (memcmp(key_data_.rows, packet.data, sizeof(key_data)) == 0) return;
new_key_ = true;
memcpy(key_data_.rows, packet.data, sizeof(key_data));
// NRF_LOG_DEBUG("New key %lu",key_data_.all);
}
};
Communications.callbacks.bind(HAS_KEYS, keyScanFunction);
auto keyScanFunctionIsAlive = [this](Packet const &packet)
{
if(packet.data[0] != HAS_KEYS) return;
if (filterHand(packet.header.device, this_device_))
{
if(packet.data[0] != HAS_KEYS) return;
if (filterHand(packet.header.device, this_device_))
{
if (memcmp(key_data_.rows, &packet.data[1], sizeof(key_data)) == 0) return;
new_key_ = true;
memcpy(key_data_.rows, &packet.data[1], sizeof(key_data));
NRF_LOG_DEBUG("New key is alive %lu",key_data_.all);
}
};
Communications.callbacks.bind(IS_ALIVE, keyScanFunctionIsAlive);
auto checkConnected = [this](Packet const &packet)
if (memcmp(key_data_.rows, &packet.data[1], sizeof(key_data)) == 0) return;
new_key_ = true;
memcpy(key_data_.rows, &packet.data[1], sizeof(key_data));
NRF_LOG_DEBUG("New key is alive %lu",key_data_.all);
}
};
Communications.callbacks.bind(IS_ALIVE, keyScanFunctionIsAlive);
auto checkConnected = [this](Packet const &packet)
{
if (filterHand(packet.header.device, this_device_))
{
if (filterHand(packet.header.device, this_device_))
{
NRF_LOG_DEBUG("Connected device %i",packet.header.device);
connected_ = packet.header.device;
if(ble_innited()){
if(this_device_==RIGHT){
connected_ = BLE_DEFY_RIGHT;
}else{
connected_ = BLE_DEFY_LEFT;
}
NRF_LOG_DEBUG("Connected device %i",packet.header.device);
connected_ = packet.header.device;
if(ble_innited()){
if(this_device_==RIGHT){
connected_ = BLE_DEFY_RIGHT;
}else{
connected_ = BLE_DEFY_LEFT;
}
}
};
Communications.callbacks.bind(CONNECTED, checkConnected);
auto checkDisconnected = [this](Packet const &packet)
}
};
Communications.callbacks.bind(CONNECTED, checkConnected);
auto checkDisconnected = [this](Packet const &packet)
{
if (filterHand(packet.header.device, this_device_))
{
if (filterHand(packet.header.device, this_device_))
{
NRF_LOG_DEBUG("Disconnected device %i",packet.header.device);
connected_ = packet.header.device;
}
};
Communications.callbacks.bind(DISCONNECTED, checkDisconnected);
NRF_LOG_DEBUG("Disconnected device %i",packet.header.device);
connected_ = UNKNOWN;
}
};
Communications.callbacks.bind(DISCONNECTED, checkDisconnected);
}

Devices Hand::getConnectedDevice() const
Expand Down

0 comments on commit 23c03f8

Please sign in to comment.