簡體   English   中英

什么unicode字符最適合在字符串中繪制方波

[英]What unicode characters are best for drawing a squarewave in a string

我試圖從存儲的 GPIO 事件和時序數組中用字符串表示方波脈沖序列。 該代碼正在運行,但我需要更好的 Unicode 個字符來進行轉換。

這是我目前的方法

    public String waveform()
    {
    String s = "";
    int pulses;
    int pulseWidth;

    pulseWidth = events.get(1).duration; //mostly right!
    for (RF433Event e: events)
    {
        pulses = e.duration/pulseWidth;
        if (e.gpioEvent.getEdge() == PinEdge.RISING)
        {
            // rising edge so for the duration it was low
            for (int i = 0; i<pulses; i++) s = s+'_';
            s = s+"\u02E9";
        } else
        {
            // falling edge so for the duration it was high
            for (int i = 0; i<pulses; i++) s = s+"\u0305";
            s = s+"\u02E5";
        }

    }
    return s;
    }

output 在 Intellij 控制台中看起來像這樣 window 在此處輸入圖像描述

但奇怪的是沒有出現在樹莓派上,我需要在樹莓派上安裝其他東西嗎?

經過大量的實驗,這對我有用

public String waveform()
{
    String s = "";
    int pulses;
    int pulseWidth;
    // Characters tried for drawing the pulse train
    // Low line - "_", "\u0332" Combining Low Line, "\uFF3F"; FULLWIDTH LOW LINE
    // High line - "\u0305" COMBINING OVERLINE, "\u203E" over line 
    // Vertical -  "\u20D2" COMBINING LONG VERTICAL LINE OVERLAY, "\u007C" Vertical line, "\u02E9" MODIFIER LETTER EXTRA-LOW TONE BAR
    if (events.get(0).duration > 50000) {return "Excessive duration in pluse 0 "+events.get(0).duration;}
    pulseWidth = 100; //gives a reasonable pulse train
    for (RF433Event e: events)
    {
        pulses = e.duration/pulseWidth;
        if (e.gpioEvent.getEdge() == PinEdge.RISING)
        {
            // rising edge so for the duration it was low
            for (int i = 0; i<pulses; i++) s = s+ "_";
            s = s+"\u20D2";
        } else
        {
            // falling edge so for the duration it was high
            for (int i = 0; i<pulses; i++) s = s+"\u0305";
            s = s+"\u20D2";
        }
    }
    return s;
}

這些是結果 脈沖列

我喜歡使用“組合字符”的想法,但發現它們更難編輯。 這是我使用或嘗試過的其他 unicode 選項。

  1. 方框圖紙(輕型或重型),(如前所述)需要 2 行:
1   ┌────┐      ┏━━━━┓
0 ──┘    └──  ━━┛    ┗━━
  1. “下八分之一塊”(2581) 與“下四分之三塊”(2586) 或“全塊”(2588)。 (根據字體和行間距,“整塊”可以到達上一行。)
▁▆▆▆▁▁▇▇▁▁
▁▆▆▆▁▁▇▇▁▁
  1. “solidus”(斜線)、“reverses solidus”(反斜線)、“水平掃描線 1”(23BA) 和“水平掃描線 9”(23BD) - 用於非垂直過渡。
⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺\⎽⎽

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM