Skip to content

Commit

Permalink
Remove extra buffer copy from old variant. Change global txPin var fr…
Browse files Browse the repository at this point in the history
…om pointer to global var. Added custom toolchain used personally to gitignore.
  • Loading branch information
N-Storm committed May 30, 2024
1 parent 250ec71 commit de0ff45
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions firmware/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.vscode/c_cpp_properties.json
.vscode/launch.json
.vscode/ipch
packages/toolchain-atmelavr
12 changes: 4 additions & 8 deletions firmware/lib/DLTransmitter/DLTransmitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "DLTransmitter.h"

volatile dl_buffer_u dl_buf = { 0 };
uint8_t *txPin_p;
uint8_t txPin_g;

#ifndef __AVR_ATtinyX5__
static bool state_buf = false;
Expand All @@ -31,14 +31,14 @@ DLTransmitter::DLTransmitter(uint8_t pin) : Livolo(pin)
{
pinMode(pin, OUTPUT);
txPin = pin;
txPin_p = &txPin;
}

// Sequence remoteID, 16 bits followed by keycode, 7 bits
// seq = (remoteID << 7) + (keycode & 0x7F)

void DLTransmitter::sendButton(uint16_t remoteID, uint8_t keycode, bool use_timer, void (*idleCallback_ptr)(void)) {
if (use_timer == true) {
txPin_g = txPin;
memset((void *)&dl_buf, 0, sizeof(dl_buf));

// Set MSB to 1 (it's not transmitted as keycode are 7-bit, but we use it as a end-of-transmit mark)
Expand All @@ -61,10 +61,6 @@ void DLTransmitter::sendButton(uint16_t remoteID, uint8_t keycode, bool use_time
#endif

for (uint8_t z = 0; z <= 128; z++) {
dl_buf.bytes[2] = tempbuf[2];
dl_buf.bytes[1] = tempbuf[1];
dl_buf.bytes[0] = tempbuf[0];

memcpy((void *)dl_buf.bytes, tempbuf, 3);

#ifdef __AVR_ATtinyX5__
Expand Down Expand Up @@ -184,7 +180,7 @@ inline void timer1_update(uint8_t ocr, uint8_t ocr_aux = 0) {

ISR(TIMER1_COMPA_vect) {
#ifdef __AVR_ATtinyX5__
PINB = 1 << *txPin_p;
PINB = 1 << txPin_g;
#else
state_buf = !state_buf;
digitalWrite(*txPin_p, state_buf ? HIGH : LOW);
Expand All @@ -205,7 +201,7 @@ ISR(TIMER1_COMPA_vect) {

ISR(TIMER1_COMPB_vect) {
#ifdef __AVR_ATtinyX5__
PINB = 1 << *txPin_p;
PINB = 1 << txPin_g;
#else
state_buf = !state_buf;
digitalWrite(*txPin_p, state_buf ? HIGH : LOW);
Expand Down

0 comments on commit de0ff45

Please sign in to comment.