Skip to content

Commit

Permalink
add support for serial polarity invert, and minor improvements in men…
Browse files Browse the repository at this point in the history
…u texts
  • Loading branch information
iltis42 committed Dec 26, 2024
1 parent e76e074 commit 96c61c2
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 9 deletions.
14 changes: 8 additions & 6 deletions main/Serial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "Flarm.h"
#include "driver/uart.h"
#include "DataMonitor.h"
#include "SetupMenu.h"

/* Note that the standard NMEA 0183 baud rate is only 4.8 kBaud.
Nevertheless, a lot of NMEA-compatible devices can properly work with
Expand Down Expand Up @@ -268,10 +269,11 @@ void Serial::huntBaudrate(){
baudrate=1; // 4800
}
uart_set_baudrate(uart_num, baud[baudrate]);
egl->setColor(COLOR_WHITE);
egl->setPrintPos( 10, 40 );
egl->printf("Autobaud: %d ", baud[baudrate] );

if( !SetupMenu::isActive() ){
egl->setColor(COLOR_WHITE);
egl->setPrintPos( 10, 40 );
egl->printf("Autobaud: %d ", baud[baudrate] );
}
ESP_LOGI(FNAME,"Serial Interface ttyS1 next baudrate: %d", baud[baudrate] );
}
}
Expand Down Expand Up @@ -299,10 +301,10 @@ void Serial::begin(){
uart_set_baudrate(uart_num, br);

int umask = UART_SIGNAL_INV_DISABLE;
if( serial1_tx_inverted.get() )
if( rs232_polarity.get() == RS232_INVERTED ){
umask |= UART_SIGNAL_TXD_INV;
if( serial1_rx_inverted.get() )
umask |= UART_SIGNAL_RXD_INV;
}
if( umask ){
ESP_ERROR_CHECK( uart_set_line_inverse( uart_num, umask ) );
ESP_LOGI(FNAME,"Serial param line inverse" );
Expand Down
11 changes: 9 additions & 2 deletions main/SetupMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ void SetupMenu::begin(){
ESP_LOGI(FNAME,"SetupMenu() begin");
setup();
if( inch2dot4 )
hpos = 240;
hpos = 200;
else
hpos = 120;
}
Expand Down Expand Up @@ -343,13 +343,19 @@ void SetupMenu::options_menu_create_settings( MenuEntry *top ){
nmove->addEntry( "Show");
top->addEntry( nmove );
nmove->setHelp("Select if targets on ground that do not move shall be displayed", hpos );

SetupMenuSelect * pol = new SetupMenuSelect( "Serial Polarity", RST_NONE, 0, true, &rs232_polarity );
pol->addEntry( "Normal");
pol->addEntry( "Inverted");
top->addEntry( pol );
pol->setHelp("Select for Normal for normal RS232 polarity or Inverted for RS232 TTL signals", hpos );
}

void SetupMenu::setup_create_root(MenuEntry *top ){
ESP_LOGI(FNAME,"setup_create_root()");
SetupMenu * set = new SetupMenu( "Settings" );
top->addEntry( set );
set->setHelp( "Setup volume and other modes", 160);
set->setHelp( "Setup buzzer, display, RS232 and more", hpos);
set->addCreator(options_menu_create_settings);

SetupMenu * un = new SetupMenu( "Units" );
Expand All @@ -366,6 +372,7 @@ void SetupMenu::setup_create_root(MenuEntry *top ){
SetupMenuSelect * demo = new SetupMenuSelect( "Traffic Demo", RST_IMMEDIATE, 0, true, &traffic_demo );
demo->addEntry( "Cancel");
demo->addEntry( "Start");
demo->setHelp( "Starts a short traffic demo with some other gliders (reboots)", hpos );
top->addEntry( demo );

// Orientation _display_orientation
Expand Down
2 changes: 1 addition & 1 deletion main/SetupMenuSelect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ void SetupMenuSelect::display( int mode ){
showhelp( y );
if(mode == 1 && bits._save == true ){
egl->setColor( COLOR_BLACK );
egl->drawBox( 1,130,DISPLAY_W,40 );
egl->drawBox( 1,DISPLAY_H-40,DISPLAY_W,40 );
egl->setPrintPos( 1, DISPLAY_H-30 );
egl->setColor( COLOR_WHITE );
egl->print(PROGMEM"Saved " );
Expand Down
2 changes: 2 additions & 0 deletions main/SetupNG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,5 @@ SetupNG<int> display_orientation("DISPLAY_ORIENT" , DISPLAY_NORMAL );
SetupNG<int> display_mode("DISPLAY_MODE" , DISPLAY_MULTI );
SetupNG<int> display_non_moving_target("NON_MOVE" , NON_MOVE_HIDE );
SetupNG<int> notify_near( "NOTFNEAR", BUZZ_2KM );
SetupNG<int> rs232_polarity( "RS232POL", RS232_INVERTED );

1 change: 1 addition & 0 deletions main/SetupNG.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,6 @@ extern SetupNG<int> display_orientation;
extern SetupNG<int> display_mode;
extern SetupNG<int> display_non_moving_target;
extern SetupNG<int> notify_near;
extern SetupNG<int> rs232_polarity;


0 comments on commit 96c61c2

Please sign in to comment.