mirror of
https://github.com/portapack-mayhem/mayhem-firmware.git
synced 2024-12-04 23:45:26 +00:00
fine tune waveform and ook again (#2322)
This commit is contained in:
parent
abd6177303
commit
bea9f444c6
@ -25,6 +25,9 @@
|
|||||||
#include "baseband_api.hpp"
|
#include "baseband_api.hpp"
|
||||||
#include "string_format.hpp"
|
#include "string_format.hpp"
|
||||||
|
|
||||||
|
#define PADDING_LEFT 1
|
||||||
|
#define PADDING_RIGHT 1
|
||||||
|
|
||||||
using namespace portapack;
|
using namespace portapack;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
@ -154,12 +157,34 @@ void EncodersConfigView::on_show() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void EncodersConfigView::draw_waveform() {
|
void EncodersConfigView::draw_waveform() {
|
||||||
|
// padding reason:
|
||||||
|
// in real world the signal would always start with low level and became low level again after yout turn off the radio;
|
||||||
|
// the waveform_buffer only controls drawing, the real send logic that been sent is controlled by frame_fragments
|
||||||
|
// so just for out of looking things
|
||||||
|
|
||||||
size_t length = frame_fragments.length();
|
size_t length = frame_fragments.length();
|
||||||
|
|
||||||
for (size_t n = 0; n < length; n++)
|
// currently not needed since all the supported OOK protocol wont exceed 550 yet
|
||||||
waveform_buffer[n] = (frame_fragments[n] == '0') ? 0 : 1;
|
if (length + (PADDING_LEFT + PADDING_RIGHT) >= WAVEFORM_BUFFER_SIZE) {
|
||||||
|
length = WAVEFORM_BUFFER_SIZE - (PADDING_LEFT + PADDING_RIGHT);
|
||||||
|
}
|
||||||
|
|
||||||
waveform.set_length(length);
|
// padding l
|
||||||
|
for (size_t i = 0; i < PADDING_LEFT; i++) {
|
||||||
|
waveform_buffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// real wf
|
||||||
|
for (size_t n = 0; n < length; n++) {
|
||||||
|
waveform_buffer[n + PADDING_LEFT] = (frame_fragments[n] == '0') ? 0 : 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// padding r
|
||||||
|
for (size_t i = length + PADDING_LEFT; i < WAVEFORM_BUFFER_SIZE; i++) {
|
||||||
|
waveform_buffer[i] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
waveform.set_length(length + PADDING_LEFT + PADDING_RIGHT);
|
||||||
waveform.set_dirty();
|
waveform.set_dirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,8 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#define WAVEFORM_BUFFER_SIZE 550
|
||||||
|
|
||||||
using namespace encoders;
|
using namespace encoders;
|
||||||
|
|
||||||
namespace ui {
|
namespace ui {
|
||||||
@ -56,7 +58,7 @@ class EncodersConfigView : public View {
|
|||||||
std::string frame_fragments = "0";
|
std::string frame_fragments = "0";
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int16_t waveform_buffer[550];
|
int16_t waveform_buffer[WAVEFORM_BUFFER_SIZE];
|
||||||
const encoder_def_t* encoder_def{};
|
const encoder_def_t* encoder_def{};
|
||||||
|
|
||||||
void draw_waveform();
|
void draw_waveform();
|
||||||
|
@ -2681,9 +2681,9 @@ void Waveform::paint(Painter& painter) {
|
|||||||
x = prev_x + x_inc;
|
x = prev_x + x_inc;
|
||||||
h /= 2;
|
h /= 2;
|
||||||
|
|
||||||
prev_y = y_offset + h + (*(data_start++) * y_scale);
|
prev_y = y_offset + h - (*(data_start++) * y_scale);
|
||||||
for (n = 1; n < length_; n++) {
|
for (n = 1; n < length_; n++) {
|
||||||
y = y_offset + h + (*(data_start++) * y_scale);
|
y = y_offset + h - (*(data_start++) * y_scale);
|
||||||
display.draw_line({prev_x, prev_y}, {(Coord)x, y}, color_);
|
display.draw_line({prev_x, prev_y}, {(Coord)x, y}, color_);
|
||||||
|
|
||||||
prev_x = x;
|
prev_x = x;
|
||||||
|
Loading…
Reference in New Issue
Block a user