繁体   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