LoginSignup
0
0

More than 5 years have passed since last update.

MWOSDでスロットルグラフ表示した備忘録

Last updated at Posted at 2017-10-18

OSDとは

On Screen Displayの略でビデオ映像に任意の情報をオーバーレイ表示させる機能。

MWOSD

フライトコントローラーから情報を受け取り、飛行時間、バッテリー残量、ジャイロの状態などをリアルタイムに表示させることができる。BetaFlight組み込みOSDはこちら

フォント

OSD専用のフォントフォーマット。
白、黒、透明の情報をビットマップとして列挙したテキストファイル。

MCMフォントファイル

  • テキストファイル
  • 1行目ヘッダー
  • 2行目以降はデータ
  • 1行分のデータ=2進数8ビットの値
  • 16x16 = 256文字分のビットマップデータ。
  • 16384行のデータがあるので、1文字あたりのデータは64行
  • 1文字は縦18ドット、横12ドット、必要データは上記の行数として54行。次の10行は利用しない。
  • 1文字のデータは64行、使用するのは上位54行。
  • 1行の8ビットデータのうち、1ドットを2ビットで構成。
01 = 透明
00 = 黒
10 = 白
11 = 未使用

1文字分のデータ

010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010101
010101010101010101010100
010101010101010101010010
010101010100010101010010
010101010010010101010010
010101010010010101010010
000000000010000000000010
101010101010101010101010
000000000000000000000000
010101010101010101010101
01010101
01010101
01010101
01010101
01010101
01010101
01010101
01010101
01010101
01010101

コード

フォントマップ0xF0から12文字分をアニメーションできるフォントとして定義し4文字分を表示領域にする。

void displayCurrentThrottle(void)
{
  if(!fieldIsVisible(CurrentThrottlePosition))
    return;

  #ifndef NOTHROTTLESPACE
    #define THROTTLESPACE 1
  #else
    #define THROTTLESPACE 0
  #endif  
  screenBuffer[1]=' ';
  #ifdef AUTOTHROTTLE
    if (MwRcData[THROTTLESTICK] > HighT) HighT = MwRcData[THROTTLESTICK];
    if (MwRcData[THROTTLESTICK] < LowT) LowT = MwRcData[THROTTLESTICK];      // Calibrate high and low throttle settings  --defaults set in GlobalVariables.h 1100-1900
    if (HighT>2050) HighT=2050;
    if (LowT<950) LowT=950;
  #else
    HighT=HIGHTHROTTLE;
    LowT=LOWTHROTTLE;
  #endif


  uint32_t Vthrottle = constrain(MwRcData[THROTTLESTICK],1000,2000);

#ifndef FIXEDWING   
  if(!armed) {
    screenBuffer[0+THROTTLESPACE]=' ';
    screenBuffer[1+THROTTLESPACE]=' ';
    screenBuffer[2+THROTTLESPACE]='-';
    screenBuffer[3+THROTTLESPACE]='-';
    screenBuffer[4+THROTTLESPACE]=' ';

  }
  else
#endif // FIXEDWING    

  #ifdef THROTTLE_GRAPH
  {
    int CurThrottle = map(MwRcData[THROTTLESTICK],LowT,HighT,0,48);//スロットルの値を0-48の数値に算出
    int cur1 = CurThrottle<12 ? CurThrottle : 12; CurThrottle = CurThrottle<12 ? 0 : CurThrottle-12;
    int cur2 = CurThrottle<12 ? CurThrottle : 12; CurThrottle = CurThrottle<12 ? 0 : CurThrottle-12;
    int cur3 = CurThrottle<12 ? CurThrottle : 12; CurThrottle = CurThrottle<12 ? 0 : CurThrottle-12;
    int cur4 = CurThrottle<12 ? CurThrottle : 12; 
    screenBuffer[1+THROTTLESPACE] = 0xF0 + cur1;
    screenBuffer[2+THROTTLESPACE] = 0xF0 + cur2;
    screenBuffer[3+THROTTLESPACE] = 0xF0 + cur3;
    screenBuffer[4+THROTTLESPACE] = 0xF0 + cur4;    
  }
  #else
  {
    int CurThrottle = map(MwRcData[THROTTLESTICK],LowT,HighT,0,100);//スロットルの値を100-0の数値に算出
    ItoaPadded(CurThrottle,screenBuffer+1+THROTTLESPACE,3,0);//数値を文字に変換して書き込み3文字。"100" - "  0"
    screenBuffer[4+THROTTLESPACE]='%';
  }
  #endif
    screenBuffer[0]=SYM_THR;          //スロットルのマーク
    screenBuffer[5+THROTTLESPACE]=0;  //NULL終端
    MAX7456_WriteString(screenBuffer,getPosition(CurrentThrottlePosition));
}

ダウンロード

111.png
MWOSD R1.6(改)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0