mirror of
https://github.com/eried/portapack-mayhem.git
synced 2024-12-24 06:49:24 -05:00
Unistroke in dirty code
This commit is contained in:
parent
c8d37e215b
commit
4511090eae
@ -23,6 +23,7 @@
|
||||
|
||||
#include "portapack.hpp"
|
||||
#include "portapack_shared_memory.hpp"
|
||||
#include "portapack_persistent_memory.hpp"
|
||||
|
||||
#include "sd_card.hpp"
|
||||
#include "time.hpp"
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "ch.h"
|
||||
|
||||
#include "ff.h"
|
||||
#include "unistroke.hpp"
|
||||
#include "portapack.hpp"
|
||||
#include "event_m0.hpp"
|
||||
#include "string_format.hpp"
|
||||
@ -36,10 +37,6 @@
|
||||
using namespace portapack;
|
||||
|
||||
namespace ui {
|
||||
|
||||
HandWriteView::~HandWriteView() {
|
||||
time::signal_tick_second -= signal_token_tick_second;
|
||||
}
|
||||
|
||||
HandWriteView::HandWriteView(
|
||||
NavigationView& nav,
|
||||
@ -68,7 +65,7 @@ HandWriteView::HandWriteView(
|
||||
24, 20
|
||||
});
|
||||
const std::string label {
|
||||
n + 0x30
|
||||
(char)(n + 0x30)
|
||||
};
|
||||
button.set_text(label);
|
||||
button.id = n;
|
||||
@ -91,17 +88,12 @@ HandWriteView::HandWriteView(
|
||||
|
||||
add_child(&text_debug_x);
|
||||
add_child(&text_debug_y);
|
||||
add_child(&text_debug_write);
|
||||
add_child(&button_done);
|
||||
button_done.on_select = [this, &nav, txt, max_len](Button&) {
|
||||
//memcpy(txt, txtinput, max_len+1);
|
||||
//on_changed(this->value());
|
||||
nav.pop();
|
||||
};
|
||||
|
||||
signal_token_tick_second = time::signal_tick_second += [this]() {
|
||||
this->on_tick_second();
|
||||
};
|
||||
|
||||
//update_text();
|
||||
}
|
||||
@ -161,7 +153,7 @@ bool HandWriteView::on_touch(const TouchEvent event) {
|
||||
);
|
||||
|
||||
// Letter guessing
|
||||
guess = '?';
|
||||
guess = ' ';
|
||||
|
||||
if (MM(0, 'U')) {
|
||||
if (MM(0, 'U', '?')) {
|
||||
@ -174,7 +166,10 @@ bool HandWriteView::on_touch(const TouchEvent event) {
|
||||
guess = 'K';
|
||||
} else {
|
||||
if (MM(1, 'L')) {
|
||||
if (txt_idx > 0) txtinput[txt_idx--] = 0; // Erase
|
||||
if (txtidx > 0) {
|
||||
txtinput[--txtidx] = 0; // Erase
|
||||
guess = '!';
|
||||
}
|
||||
} else {
|
||||
guess = 'N';
|
||||
}
|
||||
@ -218,7 +213,7 @@ bool HandWriteView::on_touch(const TouchEvent event) {
|
||||
if (MI(1))
|
||||
guess = 'E';
|
||||
else
|
||||
guess = 'S';
|
||||
if (MM(1, 'R')) guess = 'S';
|
||||
}
|
||||
} else if (MM(0, 'R')) {
|
||||
if (!MI(2) && (MLAST('U') || MLAST('R'))) guess = 'X';
|
||||
@ -234,9 +229,8 @@ bool HandWriteView::on_touch(const TouchEvent event) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (guess = '?') guess = ' ';
|
||||
if (guess != '!') txtinput[txt_idx++] = guess;
|
||||
|
||||
if (guess != '!') txtinput[txtidx++] = guess;
|
||||
update_text();
|
||||
}
|
||||
if (event.type == ui::TouchEvent::Type::Move) {
|
||||
@ -249,7 +243,28 @@ bool HandWriteView::on_touch(const TouchEvent event) {
|
||||
|
||||
void HandWriteView::sample_pen() {
|
||||
int16_t diff_x, diff_y;
|
||||
uint8_t dir, i;
|
||||
uint8_t dir;
|
||||
|
||||
// Blink cursor
|
||||
if (!(sample_skip & 15)) {
|
||||
Point cursor_pos;
|
||||
|
||||
cursor_pos.x = text_input.screen_rect().pos.x + (txtidx * 8);
|
||||
cursor_pos.y = text_input.screen_rect().pos.y + 17;
|
||||
|
||||
if (cursor) {
|
||||
display.fill_rectangle(
|
||||
{{text_input.screen_rect().pos.x, cursor_pos.y}, {text_input.screen_rect().size.w, 4}},
|
||||
Color::black()
|
||||
);
|
||||
} else {
|
||||
display.fill_rectangle(
|
||||
{cursor_pos, {8, 4}},
|
||||
Color::white()
|
||||
);
|
||||
}
|
||||
cursor = !cursor;
|
||||
}
|
||||
|
||||
if (!(sample_skip & 1)) {
|
||||
if (tracing) {
|
||||
|
@ -36,7 +36,6 @@ public:
|
||||
std::function<void(char *)> on_changed;
|
||||
|
||||
HandWriteView(NavigationView& nav, char txt[], uint8_t max_len);
|
||||
~HandWriteView();
|
||||
|
||||
void on_show() override;
|
||||
bool on_touch(const TouchEvent event) override;
|
||||
@ -49,11 +48,10 @@ public:
|
||||
void char_delete();
|
||||
|
||||
private:
|
||||
SignalToken signal_token_tick_second;
|
||||
|
||||
uint8_t _max_len, txt_idx = 0;
|
||||
uint8_t _max_len;
|
||||
uint8_t dir_cnt = 0;
|
||||
uint8_t dir_prev;
|
||||
bool cursor = false;
|
||||
bool tracing = false;
|
||||
uint8_t move_index;
|
||||
uint8_t sample_skip, move_wait;
|
||||
@ -72,7 +70,7 @@ private:
|
||||
void sample_pen();
|
||||
|
||||
Text text_input {
|
||||
{ 0, 0, 240, 16 }
|
||||
{ 8, 0, 224, 16 }
|
||||
};
|
||||
|
||||
Text text_debug_x {
|
||||
@ -81,10 +79,6 @@ private:
|
||||
Text text_debug_y {
|
||||
{ 0, 32, 32, 16 }
|
||||
};
|
||||
Text text_debug_write {
|
||||
{ 80, 24, 150, 16 }
|
||||
};
|
||||
|
||||
std::array<Button, 10> num_buttons;
|
||||
|
||||
Button button_lowercase {
|
||||
|
87
firmware/application/unistroke.hpp
Normal file
87
firmware/application/unistroke.hpp
Normal file
@ -0,0 +1,87 @@
|
||||
/*
|
||||
* Copyright (C) 2015 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#define HWDIR_TWO 0x40
|
||||
#define HWDIR_ONLY 0x80
|
||||
|
||||
enum Condition {
|
||||
cond_empty = -1,
|
||||
stroke_a = 0,
|
||||
stroke_b = 1,
|
||||
stroke_c = 2,
|
||||
stroke_d = 3,
|
||||
last = 8
|
||||
};
|
||||
|
||||
enum Direction {
|
||||
dir_empty = -1,
|
||||
Uw = 0x00,
|
||||
Dw = 0x10,
|
||||
Lw = 0x00,
|
||||
Rw = 0x01,
|
||||
U = 0x00 | HWDIR_ONLY,
|
||||
D = 0x10 | HWDIR_ONLY,
|
||||
L = 0x00 | HWDIR_ONLY,
|
||||
R = 0x01 | HWDIR_ONLY,
|
||||
UL = 0x00 | HWDIR_TWO,
|
||||
DL = 0x10 | HWDIR_TWO,
|
||||
UR = 0x01 | HWDIR_TWO,
|
||||
DR = 0x11 | HWDIR_TWO
|
||||
};
|
||||
|
||||
struct HandWriting {
|
||||
struct HandWritingLetter {
|
||||
Condition cond;
|
||||
Direction dir;
|
||||
} letter[3];
|
||||
int8_t count;
|
||||
};
|
||||
|
||||
const HandWriting handwriting_unistroke[32] = {
|
||||
{{{stroke_a, U}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // A 0=U MI=1
|
||||
{{{stroke_a, DR}, {stroke_b, DL}, {cond_empty, dir_empty}}, 0}, // B 0=DR 1=DL
|
||||
{{{stroke_a, UL}, {stroke_b, UR}, {cond_empty, dir_empty}}, 0}, // C 0=UL 1=UR
|
||||
{{{stroke_a, DL}, {stroke_b, DR}, {cond_empty, dir_empty}}, 0}, // D 0=DL 1=DR
|
||||
{{{stroke_a, L}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // E 0=L MI=1
|
||||
{{{stroke_a, U}, {stroke_b, R}, {cond_empty, dir_empty}}, 0}, // F 0=U 1=R
|
||||
{{{stroke_a, R}, {stroke_b, U}, {cond_empty, dir_empty}}, 0}, // G 0=R 1=U
|
||||
{{{stroke_a, R}, {stroke_b, D}, {cond_empty, dir_empty}}, 0}, // H 0=R 1=D
|
||||
{{{stroke_a, D}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // I 0=D MI=1
|
||||
{{{stroke_a, D}, {stroke_b, L}, {cond_empty, dir_empty}}, 0}, // J 0=D 1=L
|
||||
{{{stroke_a, UR}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // K 0=UR MI=1
|
||||
{{{stroke_a, D}, {stroke_b, R}, {cond_empty, dir_empty}}, 0}, // L 0=D 1=R
|
||||
{{{stroke_a, UL}, {stroke_b, DL}, {cond_empty, dir_empty}}, 0}, // M 0=UL 1=DL
|
||||
{{{stroke_a, UR}, {stroke_b, DR}, {cond_empty, dir_empty}}, 0}, // N 0=UR 1=DR
|
||||
{{{stroke_a, Lw}, {last, Lw}, {cond_empty, dir_empty}}, 2}, // O 0=Lw MI>2 -=Lw !!!
|
||||
{{{stroke_a, Dw}, {last, Dw}, {cond_empty, dir_empty}}, 2}, // P 0=Dw MI>2 -=Dw !!!
|
||||
{{{stroke_a, Dw}, {stroke_b, Lw}, {cond_empty, dir_empty}}, 2}, // Q 0=Dw MI>2 1=Lw
|
||||
{{{stroke_a, DR}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // R 0=DR MI=1
|
||||
{{{stroke_a, Lw}, {stroke_b, Rw}, {cond_empty, dir_empty}}, 0}, // S 0=Lw 1=Rw
|
||||
{{{stroke_a, R}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // T 0=R MI=1
|
||||
{{{stroke_a, DL}, {stroke_b, UL}, {cond_empty, dir_empty}}, 2}, // U 0=DL 1=UL MI=2
|
||||
{{{stroke_a, DR}, {stroke_b, UR}, {cond_empty, dir_empty}}, 2}, // V 0=DR 1=UR MI=2
|
||||
{{{stroke_a, D}, {stroke_b, UR}, {stroke_c, D}}, 0}, // W 0=D 1=UR 2=D
|
||||
{{{stroke_a, Rw}, {last, Rw}, {cond_empty, dir_empty}}, 0}, // X 0=Rw MI>2 -=Rw
|
||||
{{{stroke_a, DL}, {cond_empty, dir_empty}, {cond_empty, dir_empty}}, 1}, // Y 0=DL MI=1
|
||||
{{{stroke_a, Rw}, {stroke_b, DL}, {cond_empty, dir_empty}}, 0}, // Z 0=Rw 1=DL
|
||||
|
||||
// Erase 0=UR MI!1 1=L
|
||||
};
|
Binary file not shown.
@ -96,8 +96,8 @@ void AudioOutput::fill_audio_buffer(const buffer_f32_t& audio, const bool send_t
|
||||
audio_buffer.p[i].left = audio_buffer.p[i].right = sample_saturated;
|
||||
audio_int[i] = sample_saturated;
|
||||
}
|
||||
if( send_to_fifo ) {
|
||||
stream.write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
|
||||
if( stream && send_to_fifo ) {
|
||||
stream->write(audio_int.data(), audio_buffer.count * sizeof(audio_int[0]));
|
||||
}
|
||||
|
||||
feed_audio_stats(audio);
|
||||
|
@ -32,6 +32,7 @@
|
||||
#include "audio_stats_collector.hpp"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
class AudioOutput {
|
||||
public:
|
||||
@ -44,6 +45,10 @@ public:
|
||||
void write(const buffer_s16_t& audio);
|
||||
void write(const buffer_f32_t& audio);
|
||||
|
||||
void set_stream(std::unique_ptr<StreamInput> new_stream) {
|
||||
stream = std::move(new_stream);
|
||||
}
|
||||
|
||||
private:
|
||||
static constexpr float k = 32768.0f;
|
||||
static constexpr float ki = 1.0f / k;
|
||||
@ -54,7 +59,7 @@ private:
|
||||
IIRBiquadFilter deemph;
|
||||
FMSquelch squelch;
|
||||
|
||||
StreamInput stream { 14 };
|
||||
std::unique_ptr<StreamInput> stream;
|
||||
|
||||
AudioStatsCollector audio_stats;
|
||||
|
||||
|
@ -28,14 +28,14 @@
|
||||
#include "baseband_sgpio.hpp"
|
||||
#include "baseband_dma.hpp"
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "i2s.hpp"
|
||||
|
||||
#include "proc_playaudio.hpp"
|
||||
#include "proc_audiotx.hpp"
|
||||
#include "proc_xylos.hpp"
|
||||
#include "proc_fsk_lcr.hpp"
|
||||
|
||||
#include "rssi.hpp"
|
||||
#include "i2s.hpp"
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include <array>
|
||||
@ -98,7 +98,7 @@ void BasebandThread::run() {
|
||||
|
||||
while(true) {
|
||||
// TODO: Place correct sampling rate into buffer returned here:
|
||||
const auto buffer_tmp = baseband::dma::wait_for_tx_buffer();
|
||||
const auto buffer_tmp = baseband::dma::wait_for_rx_buffer();
|
||||
if( buffer_tmp ) {
|
||||
buffer_c8_t buffer {
|
||||
buffer_tmp.p, buffer_tmp.count, baseband_configuration.sampling_rate
|
||||
|
22
firmware/baseband-tx/clock_recovery.cpp
Normal file
22
firmware/baseband-tx/clock_recovery.cpp
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright (C) 2014 Jared Boone, ShareBrained Technology, Inc.
|
||||
*
|
||||
* This file is part of PortaPack.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 51 Franklin Street,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include "clock_recovery.hpp"
|
@ -22,22 +22,26 @@
|
||||
#ifndef __STREAM_INPUT_H__
|
||||
#define __STREAM_INPUT_H__
|
||||
|
||||
#include "portapack_shared_memory.hpp"
|
||||
|
||||
#include "message.hpp"
|
||||
#include "fifo.hpp"
|
||||
|
||||
#include "lpc43xx_cpp.hpp"
|
||||
using namespace lpc43xx;
|
||||
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
#include <memory>
|
||||
|
||||
class StreamInput {
|
||||
public:
|
||||
StreamInput(const size_t K, CaptureConfig& config) :
|
||||
K { K },
|
||||
StreamInput(CaptureConfig* const config) :
|
||||
config { config },
|
||||
K { config->write_size_log2 + config->buffer_count_log2 },
|
||||
event_bytes_mask { (1UL << config->write_size_log2) - 1 },
|
||||
data { std::make_unique<uint8_t[]>(1UL << K) },
|
||||
fifo { data.get(), K }
|
||||
{
|
||||
config.fifo = &fifo;
|
||||
config->fifo = &fifo;
|
||||
}
|
||||
|
||||
size_t write(const void* const data, const size_t length) {
|
||||
@ -48,17 +52,16 @@ public:
|
||||
if( (bytes_written & event_bytes_mask) < (last_bytes_written & event_bytes_mask) ) {
|
||||
creg::m4txevent::assert();
|
||||
}
|
||||
config->baseband_bytes_received += length;
|
||||
config->baseband_bytes_dropped = config->baseband_bytes_received - bytes_written;
|
||||
|
||||
return written;
|
||||
}
|
||||
|
||||
uint64_t written() const {
|
||||
return bytes_written;
|
||||
}
|
||||
|
||||
private:
|
||||
CaptureConfig* const config;
|
||||
const size_t K;
|
||||
const uint64_t event_bytes_mask = (1ULL << (K - 2)) - 1;
|
||||
const uint64_t event_bytes_mask;
|
||||
uint64_t bytes_written = 0;
|
||||
std::unique_ptr<uint8_t[]> data;
|
||||
FIFO<uint8_t> fifo;
|
||||
|
Binary file not shown.
@ -1,2 +1,2 @@
|
||||
const char md5_baseband[16] = {0xf2,0x01,0x2e,0xbf,0xc2,0xee,0x9f,0x0e,0x36,0x75,0x0e,0xb7,0x87,0x28,0x49,0xbd,};
|
||||
const char md5_baseband_tx[16] = {0xb1,0xe1,0xca,0x79,0x83,0x86,0x2f,0x20,0xba,0x94,0xd3,0x0c,0xc7,0x9d,0x43,0xe2,};
|
||||
const char md5_baseband[16] = {0x44,0xbd,0x72,0x34,0x68,0xd8,0xf1,0x97,0xd8,0xc0,0xd0,0x7a,0xfd,0x6a,0xc1,0xc5,};
|
||||
const char md5_baseband_tx[16] = {0x6c,0xfd,0x05,0x4c,0x96,0xdd,0xca,0x39,0xf9,0xab,0x57,0xfe,0x1a,0x49,0x36,0x15,};
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user