-
Notifications
You must be signed in to change notification settings - Fork 151
Initial vtx support (IRC Tramp) #164
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
Draft
bsvdoom
wants to merge
11
commits into
rtlopez:master
Choose a base branch
from
bsvdoom:vtx-tramp
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5d2598c
vtx tramp init commit
bsvdoom fcae2a8
remove obsolete
bsvdoom e2d5742
fix
bsvdoom b779846
revert
bsvdoom 86cb6e1
more fixes
bsvdoom e978b77
undemo
bsvdoom 1908504
some progress
bsvdoom cbdc07c
interval, constructor
bsvdoom fdd101d
rework protocol
bsvdoom a1c2ec7
update readme
bsvdoom 7385841
vtx channels, and pitmode init
bsvdoom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| #include "VtxSmartAudio.hpp" | ||
| #include "Utils/Crc.hpp" | ||
|
|
||
| static const uint8_t dummyByte[] = { 0x00 }; | ||
|
|
||
| namespace Espfc::Connect { | ||
|
|
||
| int VtxSmartAudio::begin(Device::SerialDevice * serial) | ||
| { | ||
| _serial = serial; | ||
| _timer.setRate(300); | ||
|
|
||
| _state = State::INIT; | ||
| return 1; | ||
| } | ||
|
|
||
| int VtxSmartAudio::update() | ||
| { | ||
| if (!_timer.check()) return 1; | ||
| switch (_state) | ||
| { | ||
| case State::INIT: | ||
| _state = State::SET_CHANNEL; | ||
| _model.state.vtx.active = true; | ||
| break; | ||
| case State::SET_POWER: | ||
| setPower(); | ||
| _state = State::IDLE; | ||
| break; | ||
| case State::SET_CHANNEL: | ||
| setChannel(); | ||
| _state = State::SET_POWER; | ||
| break; | ||
| case State::IDLE: | ||
| if (_model.isModeActive(MODE_ARMED) != _armed) | ||
| { | ||
| _armed = !_armed; | ||
| _state = State::SET_POWER; | ||
| } | ||
| break; | ||
| case State::INACTIVE: | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| int VtxSmartAudio::setChannel() | ||
| { | ||
| uint8_t vtxCommand[6] = { 0xAA, 0x55, 0x07, 0x01, (uint8_t)((_model.config.vtx.band -1)*8 + _model.config.vtx.channel - 1) }; | ||
| vtxCommand[5] = Utils::crc8_dvb_s2(vtxCommand[5], reinterpret_cast<uint8_t*>(&vtxCommand), 5); | ||
| _serial->write(dummyByte, 1); | ||
| _serial->write(vtxCommand, 6); | ||
| _serial->flush(); | ||
| return 1; | ||
| } | ||
|
|
||
| int VtxSmartAudio::setPower() | ||
| { | ||
| uint8_t vtxCommand[6] = { 0xAA, 0x55, 0x05, 0x01, (uint8_t)((!_model.config.vtx.lowPowerDisarm || _model.isModeActive(MODE_ARMED)) ? _model.config.vtx.power - 1 : 0) }; | ||
| vtxCommand[5] = Utils::crc8_dvb_s2(vtxCommand[5], reinterpret_cast<uint8_t*>(&vtxCommand), 5); | ||
| _serial->write(dummyByte, 1); | ||
| _serial->write(vtxCommand, 6); | ||
| _serial->flush(); | ||
| return 1; | ||
| } | ||
|
|
||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| #include "VtxTramp.hpp" | ||
| #include "Utils/Crc.hpp" | ||
|
|
||
| static const uint8_t dummyByte[] = { 0x00 }; | ||
|
|
||
| namespace Espfc::Connect { | ||
|
|
||
| int VtxTramp::begin(Device::SerialDevice * serial) | ||
| { | ||
| _serial = serial; | ||
| _timer.setRate(300); | ||
|
|
||
| _state = State::INIT; | ||
| return 1; | ||
| } | ||
|
|
||
| int VtxTramp::initTramp() | ||
| { | ||
| // Send initialization command | ||
| TrampCommand initCmd; | ||
|
bsvdoom marked this conversation as resolved.
Outdated
|
||
| initCmd.command = 'r'; // 'r' for reset/init | ||
| initCmd.crc = Utils::crc8_dvb_s2(0, reinterpret_cast<uint8_t*>(&initCmd), sizeof(initCmd) - 2); | ||
| _serial->write(reinterpret_cast<uint8_t*>(&initCmd), sizeof(initCmd)); | ||
| _serial->flush(); | ||
| return 1; | ||
| } | ||
|
|
||
| int VtxTramp::update() | ||
| { | ||
| if (!_timer.check()) return 1; | ||
| switch (_state) | ||
| { | ||
| case State::INIT: | ||
| initTramp(); | ||
| _state = State::SET_CHANNEL; | ||
| _model.state.vtx.active = true; | ||
| break; | ||
| case State::SET_POWER: | ||
| setPower(); | ||
| _state = State::IDLE; | ||
| break; | ||
| case State::SET_CHANNEL: | ||
| setChannel(); | ||
| _state = State::SET_POWER; | ||
| break; | ||
| case State::IDLE: | ||
| if (_model.isModeActive(MODE_ARMED) != _armed) | ||
| { | ||
| _armed = !_armed; | ||
| _state = State::SET_POWER; | ||
| } | ||
| break; | ||
| case State::INACTIVE: | ||
| default: | ||
| break; | ||
| } | ||
|
|
||
| return 1; | ||
| } | ||
|
|
||
| int VtxTramp::setChannel() | ||
| { | ||
| uint8_t vtxCommand[6]; | ||
| vtxCommand[0] = 0x0F; | ||
| vtxCommand[1] = 0x55; | ||
| vtxCommand[2] = 0x00; | ||
| vtxCommand[3] = 0x00; | ||
| vtxCommand[4] = (_model.config.vtx.band - 1) * 8 + (_model.config.vtx.channel - 1); | ||
| vtxCommand[5] = Utils::crc8_dvb_s2(0, reinterpret_cast<uint8_t*>(&vtxCommand), 5); | ||
| _serial->write(vtxCommand, 6); | ||
| _serial->flush(); | ||
| return 1; | ||
| } | ||
|
|
||
| int VtxTramp::setPower() | ||
| { | ||
| uint8_t vtxCommand[6]; | ||
| vtxCommand[0] = 0x0F; | ||
| vtxCommand[1] = 0x56; | ||
| vtxCommand[2] = 0x00; | ||
| vtxCommand[3] = 0x00; | ||
| vtxCommand[4] = (!_model.config.vtx.lowPowerDisarm || _model.isModeActive(MODE_ARMED)) ? _model.config.vtx.power : 0; | ||
| vtxCommand[5] = Utils::crc8_dvb_s2(0, reinterpret_cast<uint8_t*>(&vtxCommand), 5); | ||
| _serial->write(vtxCommand, 6); | ||
| _serial->flush(); | ||
| return 1; | ||
| } | ||
|
|
||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.