[英]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 ┌────┐ ┏━━━━┓
0 ──┘ └── ━━┛ ┗━━
▁▆▆▆▁▁▇▇▁▁
▁▆▆▆▁▁▇▇▁▁
⎺⎺⎺⎺⎺\⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽⎽/⎺⎺⎺⎺⎺\⎽⎽
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.