Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added panel rotation switching based on switch state change, not switch position #12

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
34 changes: 25 additions & 9 deletions MinimOSD_Extra_Plane_Pre_release_Beta/OSD_Panels.ino
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ void startPanels(){
void panLogo(){
osd.setPanel(5, 5);
osd.openPanel();
osd.printf_P(PSTR("MinimOSD-Extra 2.4|Plane r805"));
osd.printf_P(PSTR("MinimOSD-Extra 2.4|Plane r807"));
osd.closePanel();
}

Expand Down Expand Up @@ -486,13 +486,29 @@ void panOff(){
panel = npanels; //off panel
}
}
//Rotation switch
else{
if (ch_raw > 1200)
if (osd_switch_time + 1000 < millis()){
rotatePanel = 1;
osd_switch_time = millis();
}
// Rotation switch
else {
// Switch changed from its last position
if (abs (ch_raw - ch_raw_prev1) > 100) {
// but is the same than 2 positions ago
if (abs (ch_raw - ch_raw_prev2) < 100) {
osd.closePanel();
// and it's been less than 1 sec since the position switch and back
if (osd_switch_time + 1000 > millis()) {
// then rotate
rotatePanel = 1;
}
// stop continuous rotation, forcing a switch flip to restart the process
// or if the flip didn't happen because it happened too slowly, reset too.
ch_raw_prev2 = 0;
} else {
osd_switch_time = millis();
// If position changed and is different from what it was 2 positions ago
// record the new state
ch_raw_prev2 = ch_raw_prev1;
ch_raw_prev1 = ch_raw;
}
}
}
}
if(rotatePanel == 1){
Expand Down Expand Up @@ -703,7 +719,7 @@ void panWarn(int first_col, int first_line){
// }
rotation++;

// Auto switch decesion
// Auto switch decision
if (warning[0] == 1 && panel_auto_switch < 3){
canswitch = 0;
}else if (ch_raw < 1200) {
Expand Down
3 changes: 3 additions & 0 deletions MinimOSD_Extra_Plane_Pre_release_Beta/OSD_Vars.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ static uint8_t panel_auto_switch=0;
static bool ma = 0;
static bool osd_clear = 0;
static uint16_t ch_raw = 0;
// keep track of whether the channel rotation switch moved from its last position and back
static uint16_t ch_raw_prev1 = 0;
static uint16_t ch_raw_prev2 = 0;
//static uint16_t chan1_raw = 0;
//static uint16_t chan2_raw = 0;
//static uint16_t chan3_raw = 0;
Expand Down
37 changes: 37 additions & 0 deletions MinimOSD_Extra_Plane_Pre_release_Beta/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Build
-----
1) copy librariesOK/AP_Common AP_Math FastSerial GCS_MAVLink to your
arduino library directory
2) get an old version of the arduino IDE (1.0.2 and 1.0.6 worked ok,
1.5.8 did not), and run it _after_ you've copied the libraries in the
right place (arduino doesn't rescan after startup)
3) Select board Arduino Nano/ATmega328
4) build and upload

For this to work well (it can still work ok-ish without), it's better to set SR1_RC_CHAN 5
(although it can work with the default of 2, it's just more picky about timing).
If your OSD board is plugged into serial2 instead of serial2, then change SR2 instead.

Changelog
---------
R807 - 2015/12/19 - Marc MERLIN <[email protected]>
--------------------------------------------------------------------------------
Previous rotation switch didn't quite work as well as I was hoping. This new
one will rotate OSD if you flip to any other position more than 200ms away from
the current one, and come back within less than 1 second.
This should work with all switches and positions and allows you to use
another switch and activate a function you don't want, but only for
a fraction for a second, come back, and generate an OSD flip in the
process.

Binary sketch size: 30,718 bytes (of a 30,720 byte maximum) (pfew :) )


R806 - 2015/12/13 - Marc MERLIN <[email protected]>
--------------------------------------------------------------------------------
Rotation switching only rotates when switch changes states between low/mid/high.
This allows reusing a switch that has another function for OSD rotation.
You can rotate the OSD by flipping the switch to any other state and leaving it
there or coming back to the original location within 2 seconds.

Binary sketch size: 30,656 bytes (of a 30,720 byte maximum)
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# MinimOSD-Extra

MinimOSD_Extra_Plane_Pre_release_Beta was improved, please see
MinimOSD_Extra_Plane_Pre_release_Beta/README.txt
for changelog and build instructions

Prebuilt binary for plane: Released/FW & Char/MinimOSD_Extra_Plane_R8??.hex

For this to work well (it can still work ok-ish without), it's better to set SR1_RC_CHAN 5
(although it can work with the default of 2, it's just more picky about timing).
If your OSD board is plugged into serial2 instead of serial2, then change SR2 instead.
Loading