Skip to content

Commit

Permalink
RDS radiotext transmit (group 2A)
Browse files Browse the repository at this point in the history
Keyboard/Unistroke text input method selection
  • Loading branch information
furrtek committed May 29, 2016
1 parent ceced96 commit e15f659
Show file tree
Hide file tree
Showing 34 changed files with 573 additions and 168 deletions.
1 change: 1 addition & 0 deletions firmware/application/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ CPPSRC = main.cpp \
ui_soundboard.cpp \
ui_spectrum.cpp \
ui_text.cpp \
ui_textentry.cpp \
ui_widget.cpp \
ui_xylos.cpp \
recent_entries.cpp \
Expand Down
46 changes: 46 additions & 0 deletions firmware/application/bitmap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,52 @@

namespace ui {

static constexpr uint8_t bitmap_keyboard_data[] = {
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
0xF8, 0x0F,
0x88, 0x08,
0x88, 0x08,
0x88, 0x08,
0xFE, 0x3F,
0x22, 0x22,
0x22, 0x22,
0x22, 0x22,
0xFE, 0x3F,
0x00, 0x00,
0x00, 0x00,
0x00, 0x00,
};

static constexpr Bitmap bitmap_keyboard {
{ 16, 16 }, bitmap_keyboard_data
};

static constexpr uint8_t bitmap_unistroke_data[] = {
0x00, 0x00,
0x00, 0x00,
0x22, 0x00,
0x22, 0x00,
0x22, 0x00,
0x22, 0x00,
0x22, 0x00,
0x22, 0x00,
0xA2, 0x73,
0xA2, 0x24,
0xA2, 0x24,
0xA2, 0x24,
0xA2, 0x24,
0x9C, 0x74,
0x00, 0x00,
0x00, 0x00,
};

static constexpr Bitmap bitmap_unistroke {
{ 16, 16 }, bitmap_unistroke_data
};

static constexpr uint8_t bitmap_record_data[] = {
0x00, 0x00,
0x00, 0x00,
Expand Down
7 changes: 1 addition & 6 deletions firmware/application/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/

// Bitmaps generated with:
// Gimp :(, then "xxd -i *.bmp"
// Gimp :( > indexed colors, then "xxd -i *.bmp"

//BUG: No audio in about when shown second time
//BUG: Description doesn't show up first time going to system>module info (UI drawn on top)
Expand All @@ -35,26 +35,21 @@
//TODO: Morse coder
//TODO: Playdead amnesia and login
//TODO: Touch screen calibration
//TODO: Display module info (name, desc) somewhere
//TODO: Show MD5 mismatches for modules not found, etc...
//TODO: More gfx, cute icons :)
//TODO: Check jammer bandwidths
//TODO: GSM channel detector
//TODO: AFSK receiver
//TODO: SIGFOX RX/TX
//TODO: Reset baseband if module not found (instead of lockup in RAM loop)
//TODO: Module name/filename in modules.hpp to indicate requirement in case it's not found ui_loadmodule
//BUG: Crash after TX stop (unregister message !)
//TODO: Check bw setting in LCR TX
//TODO: BUG: Crash after PSN entry in RDS TX
//TODO: Bodet :)
//TODO: Whistler
//TODO: Setup: Play dead by default ? Enable/disable ?
//TODO: Hide statusview when playing dead
//TODO: Persistent playdead !
//TODO: LCR EC=A,J,N
//TODO: LCR full message former (see norm)
//TODO: LCR address scan
//TODO: AFSK NRZI
//TODO: TX power

Expand Down
5 changes: 3 additions & 2 deletions firmware/application/ui_alphanum.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ using namespace hackrf::one;
namespace ui {

void AlphanumView::paint(Painter& painter) {
(void)painter;
move_cursor();
}

Expand All @@ -51,13 +52,13 @@ AlphanumView::AlphanumView(
static constexpr Style style_alpha {
.font = font::fixed_8x16,
.background = Color::red(),
.foreground = Color::black(),
.foreground = Color::black()
};

static constexpr Style style_num {
.font = font::fixed_8x16,
.background = Color::yellow(),
.foreground = Color::black(),
.foreground = Color::black()
};

txtidx = strlen(txt);
Expand Down
5 changes: 5 additions & 0 deletions firmware/application/ui_alphanum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __ALPHANUM_H__
#define __ALPHANUM_H__

#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
Expand Down Expand Up @@ -81,3 +84,5 @@ class AlphanumView : public View {
};

} /* namespace ui */

#endif/*__ALPHANUM_H__*/
13 changes: 9 additions & 4 deletions firmware/application/ui_handwrite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ HandWriteView::HandWriteView(
// Handwriting alphabet definition here
handwriting = &handwriting_unistroke;

//memcpy(txtinput, txt, max_len+1);
txtidx = strlen(txt);
memcpy(txtinput, txt, max_len + 1);

add_children({ {
&text_input,
Expand Down Expand Up @@ -108,12 +109,12 @@ HandWriteView::HandWriteView(
};

button_ok.on_select = [this, &nav, txt, max_len](Button&) {
//memcpy(txt, txtinput, max_len+1);
//on_changed(this->value());
memcpy(txt, txtinput, max_len + 1);
on_changed(this->value());
nav.pop();
};

//update_text();
update_text();
}

bool HandWriteView::on_touch(const TouchEvent event) {
Expand Down Expand Up @@ -385,6 +386,10 @@ void HandWriteView::on_show() {
clear_zone(Color::black(), false);
}

void HandWriteView::on_hide() {
EventDispatcher::message_map().unregister_handler(Message::ID::DisplayFrameSync);
}

char * HandWriteView::value() {
return txtinput;
}
Expand Down
6 changes: 6 additions & 0 deletions firmware/application/ui_handwrite.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
* Boston, MA 02110-1301, USA.
*/

#ifndef __UNISTROKE_H__
#define __UNISTROKE_H__

#include "ui.hpp"
#include "ui_widget.hpp"
#include "ui_painter.hpp"
Expand All @@ -38,6 +41,7 @@ class HandWriteView : public View {

void paint(Painter& painter) override;
void on_show() override;
void on_hide() override;
bool on_touch(const TouchEvent event) override;

char * value();
Expand Down Expand Up @@ -88,3 +92,5 @@ class HandWriteView : public View {
};

} /* namespace ui */

#endif/*__UNISTROKE_H__*/
32 changes: 12 additions & 20 deletions firmware/application/ui_lcr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
* Boston, MA 02110-1301, USA.
*/

#include "ui_alphanum.hpp"
#include "ui_rds.hpp"
#include "ui_lcr.hpp"
#include "ui_receiver.hpp"
#include "ui_afsksetup.hpp"
Expand Down Expand Up @@ -180,6 +178,8 @@ void LCRView::paint(Painter& painter) {
);
offset.y += 32;
}

button_setrgsb.set_text(rgsb);
}

void LCRView::start_tx() {
Expand All @@ -200,8 +200,8 @@ void LCRView::start_tx() {

shared_memory.afsk_fmmod = portapack::persistent_memory::afsk_bw() * 8;

memset(shared_memory.lcrdata, 0, 256);
memcpy(shared_memory.lcrdata, lcrframe_f, 256);
memset(shared_memory.radio_data, 0, 256);
memcpy(shared_memory.radio_data, lcrframe_f, 256);

shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5; //(portapack::persistent_memory::afsk_config() >> 8) & 0xFF;
Expand Down Expand Up @@ -249,8 +249,8 @@ void LCRView::start_tx() {
strcpy(rgsb, RGSB_list[scan_index]);
make_frame();

memset(shared_memory.lcrdata, 0, 256);
memcpy(shared_memory.lcrdata, lcrframe_f, 256);
memset(shared_memory.radio_data, 0, 256);
memcpy(shared_memory.radio_data, lcrframe_f, 256);
shared_memory.afsk_transmit_done = false;
shared_memory.afsk_repeat = 5;

Expand Down Expand Up @@ -352,31 +352,23 @@ LCRView::LCRView(
button_scan.set_style(&style_val);

button_setrgsb.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(rgsb, 4);
an_view->on_changed = [this](char *rgsb) {
button_setrgsb.set_text(rgsb);
};
textentry(nav, rgsb, 4);
};

button_setam_a.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(litteral[0], 7);
an_view->on_changed = [this](char *) {};
textentry(nav, litteral[0], 7);
};
button_setam_b.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(litteral[1], 7);
an_view->on_changed = [this](char *) {};
textentry(nav, litteral[1], 7);
};
button_setam_c.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(litteral[2], 7);
an_view->on_changed = [this](char *) {};
textentry(nav, litteral[2], 7);
};
button_setam_d.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(litteral[3], 7);
an_view->on_changed = [this](char *) {};
textentry(nav, litteral[3], 7);
};
button_setam_e.on_select = [this,&nav](Button&) {
auto an_view = nav.push<AlphanumView>(litteral[4], 7);
an_view->on_changed = [this](char *) {};
textentry(nav, litteral[4], 7);
};

button_txsetup.on_select = [&nav](Button&) {
Expand Down
1 change: 1 addition & 0 deletions firmware/application/ui_lcr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "ui_painter.hpp"
#include "ui_menu.hpp"
#include "ui_navigation.hpp"
#include "ui_textentry.hpp"
#include "ui_font_fixed_8x16.hpp"
#include "clock_manager.hpp"
#include "message.hpp"
Expand Down
28 changes: 27 additions & 1 deletion firmware/application/ui_navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,19 +53,33 @@ namespace ui {
/* SystemStatusView ******************************************************/

SystemStatusView::SystemStatusView() {
uint8_t cfg;

add_children({ {
&button_back,
&title,
&button_textentry,
&button_camera,
&button_sleep,
&sd_card_status_view,
} });

cfg = portapack::persistent_memory::ui_config_textentry();

if (!cfg)
button_textentry.set_bitmap(&bitmap_keyboard);
else
button_textentry.set_bitmap(&bitmap_unistroke);

button_back.on_select = [this](Button&){
if( this->on_back ) {
this->on_back();
}
};

button_textentry.on_select = [this](ImageButton&) {
this->on_textentry();
};

button_camera.on_select = [this](ImageButton&) {
this->on_camera();
Expand All @@ -90,6 +104,18 @@ void SystemStatusView::set_title(const std::string new_value) {
}
}

void SystemStatusView::on_textentry() {
uint8_t cfg;

cfg = portapack::persistent_memory::ui_config_textentry();
portapack::persistent_memory::set_config_textentry(cfg ^ 1);

if (!cfg)
button_textentry.set_bitmap(&bitmap_unistroke);
else
button_textentry.set_bitmap(&bitmap_keyboard);
}

void SystemStatusView::on_camera() {
const auto filename_stem = next_filename_stem_matching_pattern("SCR_????");
if( filename_stem.empty() ) {
Expand Down Expand Up @@ -219,7 +245,7 @@ SystemMenuView::SystemMenuView(NavigationView& nav) {
static constexpr ui::Style style_default {
.font = ui::font::fixed_8x16,
.background = ui::Color::black(),
.foreground = ui::Color::white(),
.foreground = ui::Color::white()
};

SystemView::SystemView(
Expand Down
12 changes: 10 additions & 2 deletions firmware/application/ui_navigation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,23 @@ class SystemStatusView : public View {
{ 3 * 8, 0, 16 * 8, 1 * 16 },
default_title,
};

ImageButton button_textentry {
{ 164, 0, 2 * 8, 1 * 16 },
&bitmap_unistroke,
Color::white(),
Color::black()
};

ImageButton button_camera {
{ 22 * 8, 0, 2 * 8, 1 * 16 },
{ 184, 0, 2 * 8, 1 * 16 },
&bitmap_camera,
Color::white(),
Color::black()
};

ImageButton button_sleep {
{ 25 * 8, 0, 2 * 8, 1 * 16 },
{ 204, 0, 2 * 8, 1 * 16 },
&bitmap_sleep,
Color::white(),
Color::black()
Expand All @@ -82,6 +89,7 @@ class SystemStatusView : public View {
};

void on_camera();
void on_textentry();
};

class NavigationView : public View {
Expand Down
Loading

0 comments on commit e15f659

Please sign in to comment.